Docs + fixes
This commit is contained in:
parent
b4426c413b
commit
e43ce32d70
@ -73,8 +73,8 @@
|
||||
"physicsCutoff": 3,
|
||||
"physicsBody": {
|
||||
"type" : "CYLINDER",
|
||||
"dimension1" : 3,
|
||||
"dimension2" : 1,
|
||||
"dimension1" : 1,
|
||||
"dimension2" : 3,
|
||||
"dimension3" : 1,
|
||||
"offsetX" : 0,
|
||||
"offsetY" : 1.5,
|
||||
|
||||
BIN
docs/src/images/CollisionEngineEntityFlow.png
Normal file
BIN
docs/src/images/CollisionEngineEntityFlow.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 59 KiB |
@ -12,6 +12,8 @@ The big case for this engine is the main physics system. The goal is to provide
|
||||
|
||||
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ import org.lwjgl.assimp.AIFace;
|
||||
import org.lwjgl.assimp.AIMesh;
|
||||
import org.lwjgl.assimp.AIScene;
|
||||
import org.lwjgl.assimp.AIVector3D;
|
||||
import org.ode4j.math.DMatrix3;
|
||||
import org.ode4j.ode.DBody;
|
||||
import org.ode4j.ode.DBox;
|
||||
import org.ode4j.ode.DCylinder;
|
||||
@ -21,6 +22,13 @@ import electrosphere.entity.types.terrain.TerrainChunkData;
|
||||
*/
|
||||
public class CollisionBodyCreation {
|
||||
|
||||
//Matrix for correcting initial axis of eg cylinders or capsules
|
||||
static final DMatrix3 AXIS_CORRECTION_MATRIX = new DMatrix3(
|
||||
1.0000000, 0.0000000, 0.0000000,
|
||||
0.0000000, 0.0000000, -1.0000000,
|
||||
0.0000000, 1.0000000, 0.0000000
|
||||
);
|
||||
|
||||
|
||||
|
||||
//The width of a plane rigid body
|
||||
@ -56,7 +64,9 @@ public class CollisionBodyCreation {
|
||||
*/
|
||||
public static DBody createCylinderBody(CollisionEngine collisionEngine, double radius, double length){
|
||||
DCylinder geom = collisionEngine.createCylinderGeom(radius,length);
|
||||
return collisionEngine.createDBody(geom);
|
||||
DBody returnBody = collisionEngine.createDBody(geom);
|
||||
geom.setOffsetRotation(AXIS_CORRECTION_MATRIX);
|
||||
return returnBody;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -11,8 +11,7 @@ import org.joml.Vector3f;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author satellite
|
||||
* Stores the type of the collidable object as well as the impulses currently applied to it
|
||||
*/
|
||||
public class Collidable {
|
||||
|
||||
|
||||
@ -229,11 +229,11 @@ public class GroundMovementTree implements BehaviorTree {
|
||||
// System.out.println(EntityUtils.getEntityPosition(parent));
|
||||
// System.out.println(message.getpositionX() + " " + message.getpositionY() + " " + message.getpositionZ());
|
||||
//this should only fire on the client, we don't want the server snap updating due to client position reporting
|
||||
if(position.distance(message.getpositionX(),message.getpositionY(),message.getpositionZ()) > STATE_DIFFERENCE_HARD_UPDATE_THRESHOLD){
|
||||
EntityUtils.getPosition(parent).set(message.getpositionX(),message.getpositionY(),message.getpositionZ());
|
||||
} else if(position.distance(message.getpositionX(),message.getpositionY(),message.getpositionZ()) > STATE_DIFFERENCE_SOFT_UPDATE_THRESHOLD){
|
||||
EntityUtils.getPosition(parent).add(new Vector3d(message.getpositionX(),message.getpositionY(),message.getpositionZ()).mul(SOFT_UPDATE_MULTIPLIER));
|
||||
}
|
||||
// if(position.distance(message.getpositionX(),message.getpositionY(),message.getpositionZ()) > STATE_DIFFERENCE_HARD_UPDATE_THRESHOLD){
|
||||
// EntityUtils.getPosition(parent).set(message.getpositionX(),message.getpositionY(),message.getpositionZ());
|
||||
// } else if(position.distance(message.getpositionX(),message.getpositionY(),message.getpositionZ()) > STATE_DIFFERENCE_SOFT_UPDATE_THRESHOLD){
|
||||
// EntityUtils.getPosition(parent).add(new Vector3d(message.getpositionX(),message.getpositionY(),message.getpositionZ()).mul(SOFT_UPDATE_MULTIPLIER));
|
||||
// }
|
||||
//we want to always update the server facing vector with where the client says they're facing
|
||||
EntityUtils.getRotation(parent).set(message.getrotationX(),message.getrotationY(),message.getrotationZ(),message.getrotationW());
|
||||
// CreatureUtils.setFacingVector(parent, new Vector3d(message.getrotationX(),message.getrotationY(),message.getrotationZ()));
|
||||
|
||||
@ -930,7 +930,7 @@ public class RenderingEngine {
|
||||
Model physicsGraphicsModel;
|
||||
for(Collidable collidable : Globals.clientSceneWrapper.getCollisionEngine().getCollidables()){
|
||||
Entity physicsEntity = collidable.getParent();
|
||||
if((boolean)physicsEntity.getData(EntityDataStrings.DATA_STRING_DRAW)){
|
||||
if((boolean)physicsEntity.getData(EntityDataStrings.DATA_STRING_DRAW) && physicsEntity.getData(EntityDataStrings.PHYSICS_MODEL_TEMPLATE) != null){
|
||||
CollidableTemplate template = (CollidableTemplate)physicsEntity.getData(EntityDataStrings.PHYSICS_MODEL_TEMPLATE);
|
||||
switch(template.getType()){
|
||||
case "CYLINDER":
|
||||
@ -942,7 +942,7 @@ public class RenderingEngine {
|
||||
modelTransformMatrix.translate(cameraModifiedPosition);
|
||||
modelTransformMatrix.rotate(EntityUtils.getRotation(physicsEntity));
|
||||
// modelTransformMatrix.translate(template.getOffsetX(),template.getOffsetY(),template.getOffsetZ()); //center sphere
|
||||
modelTransformMatrix.scale(template.getDimension1() * 0.5,template.getDimension2() * 0.5,template.getDimension3() * 0.5);
|
||||
modelTransformMatrix.scale(template.getDimension1(),template.getDimension2(),template.getDimension3());
|
||||
physicsGraphicsModel.modelMatrix = modelTransformMatrix;
|
||||
physicsGraphicsModel.draw(renderPipelineState);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user