This commit is contained in:
austin 2024-08-16 15:52:02 -04:00
parent e7851508fd
commit 51e028d9bb
15 changed files with 58 additions and 34 deletions

View File

@ -1,3 +1,3 @@
#maven.buildNumber.plugin properties file #maven.buildNumber.plugin properties file
#Fri Aug 16 10:14:05 EDT 2024 #Fri Aug 16 15:43:29 EDT 2024
buildNumber=249 buildNumber=252

View File

@ -21,8 +21,7 @@
+ bug fixes + bug fixes
Fix physics freakout for vertically aligned entities Fix physics freakout for vertically aligned entities
Fix entities running to edge of map causing audio engine to break Fix entities running to edge of map causing audio engine to break
Fix placing terrain
Fix spawning item from non-local client
Fix attack animation mayyybe caching on non-local clients ?? Fix attack animation mayyybe caching on non-local clients ??
Fix sword double-swing Fix sword double-swing
Fix broken rendering pipeline when creating new level Fix broken rendering pipeline when creating new level
@ -31,4 +30,5 @@
Fix being unable to jump sometimes (usually when pick up sword) Fix being unable to jump sometimes (usually when pick up sword)
Fix server ground movement tree playing animation over falling animation Fix server ground movement tree playing animation over falling animation
Fix F2 menu not regaining controls when Xing menu instead of hitting F2 to close Fix F2 menu not regaining controls when Xing menu instead of hitting F2 to close
Fix rotation not sending correctly on initialization of creatures on client
Fix grass rendering distance Fix grass rendering distance

View File

@ -591,6 +591,7 @@ Fix build tooling, scripts, etc
Launcher fixes Launcher fixes
Fix inventory control state suggestions not working correctly Fix inventory control state suggestions not working correctly
Fix unequipping item hard crashing engine Fix unequipping item hard crashing engine
Fix terrain editing hard crashing engine
# TODO # TODO

View File

@ -458,7 +458,7 @@ public class CollisionEngine {
for(Collidable collidable : collidableList){ for(Collidable collidable : collidableList){
if(collidable.getParentTracksCollidable()){ if(collidable.getParentTracksCollidable()){
Entity physicsEntity = collidable.getParent(); Entity physicsEntity = collidable.getParent();
DBody rigidBody = (DBody)physicsEntity.getData(EntityDataStrings.PHYSICS_COLLISION_BODY); DBody rigidBody = PhysicsEntityUtils.getDBody(physicsEntity);
Matrix4d inverseTransform = new Matrix4d(); Matrix4d inverseTransform = new Matrix4d();
Vector4d rawPos = inverseTransform.transform(new Vector4d(PhysicsUtils.getRigidBodyPosition(rigidBody),1)); Vector4d rawPos = inverseTransform.transform(new Vector4d(PhysicsUtils.getRigidBodyPosition(rigidBody),1));
Vector3d newPosition = new Vector3d(rawPos.x,rawPos.y,rawPos.z); Vector3d newPosition = new Vector3d(rawPos.x,rawPos.y,rawPos.z);

View File

@ -49,7 +49,7 @@ public class PhysicsEntityUtils {
rigidBody, rigidBody,
new Vector3d(physicsTemplate.getOffsetX(), physicsTemplate.getOffsetY(), physicsTemplate.getOffsetZ()) new Vector3d(physicsTemplate.getOffsetX(), physicsTemplate.getOffsetY(), physicsTemplate.getOffsetZ())
); );
collidable = new Collidable(rVal, Collidable.TYPE_CREATURE); collidable = new Collidable(rVal, Collidable.TYPE_CREATURE, true);
ClientCollidableTree tree = new ClientCollidableTree(rVal,collidable,rigidBody); ClientCollidableTree tree = new ClientCollidableTree(rVal,collidable,rigidBody);
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody); rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody);
Matrix4d offsetTransform = new Matrix4d().translationRotate( Matrix4d offsetTransform = new Matrix4d().translationRotate(
@ -72,7 +72,7 @@ public class PhysicsEntityUtils {
new Vector3d(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3()), new Vector3d(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3()),
Collidable.TYPE_CREATURE_BIT Collidable.TYPE_CREATURE_BIT
); );
collidable = new Collidable(rVal, Collidable.TYPE_CREATURE); collidable = new Collidable(rVal, Collidable.TYPE_CREATURE, true);
ClientCollidableTree tree = new ClientCollidableTree(rVal,collidable,rigidBody); ClientCollidableTree tree = new ClientCollidableTree(rVal,collidable,rigidBody);
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody); rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody);
Matrix4d offsetTransform = new Matrix4d().translationRotateScale( Matrix4d offsetTransform = new Matrix4d().translationRotateScale(
@ -121,7 +121,7 @@ public class PhysicsEntityUtils {
rigidBody, rigidBody,
new Vector3d(physicsTemplate.getOffsetX(), physicsTemplate.getOffsetY(), physicsTemplate.getOffsetZ()) new Vector3d(physicsTemplate.getOffsetX(), physicsTemplate.getOffsetY(), physicsTemplate.getOffsetZ())
); );
collidable = new Collidable(rVal, Collidable.TYPE_CREATURE); collidable = new Collidable(rVal, Collidable.TYPE_CREATURE, true);
ServerCollidableTree tree = new ServerCollidableTree(rVal,collidable,rigidBody); ServerCollidableTree tree = new ServerCollidableTree(rVal,collidable,rigidBody);
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody); rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody);
Matrix4d offsetTransform = new Matrix4d().translationRotateScale( Matrix4d offsetTransform = new Matrix4d().translationRotateScale(
@ -141,7 +141,7 @@ public class PhysicsEntityUtils {
} break; } break;
case "CUBE": { case "CUBE": {
rigidBody = CollisionBodyCreation.createCubeBody(realm.getCollisionEngine(),new Vector3d(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3()),Collidable.TYPE_CREATURE_BIT); rigidBody = CollisionBodyCreation.createCubeBody(realm.getCollisionEngine(),new Vector3d(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3()),Collidable.TYPE_CREATURE_BIT);
collidable = new Collidable(rVal, Collidable.TYPE_CREATURE); collidable = new Collidable(rVal, Collidable.TYPE_CREATURE, true);
ServerCollidableTree tree = new ServerCollidableTree(rVal,collidable,rigidBody); ServerCollidableTree tree = new ServerCollidableTree(rVal,collidable,rigidBody);
rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody); rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody);
Matrix4d offsetTransform = new Matrix4d().translationRotateScale( Matrix4d offsetTransform = new Matrix4d().translationRotateScale(
@ -239,7 +239,7 @@ public class PhysicsEntityUtils {
DTriMesh triMesh = collisionEngine.createTrimeshGeom(vertices,indices,Collidable.TYPE_STATIC_BIT); DTriMesh triMesh = collisionEngine.createTrimeshGeom(vertices,indices,Collidable.TYPE_STATIC_BIT);
DBody body = collisionEngine.createDBody(triMesh); DBody body = collisionEngine.createDBody(triMesh);
Globals.clientSceneWrapper.getCollisionEngine().registerCollisionObject(body, new Collidable(terrain,Collidable.TYPE_TERRAIN)); Globals.clientSceneWrapper.getCollisionEngine().registerCollisionObject(body, new Collidable(terrain,Collidable.TYPE_TERRAIN, false));
terrain.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, body); terrain.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, body);
return body; return body;
@ -259,7 +259,7 @@ public class PhysicsEntityUtils {
CollisionBodyCreation.setGravityMode(Globals.clientSceneWrapper.getCollisionEngine(), terrainBody, false); CollisionBodyCreation.setGravityMode(Globals.clientSceneWrapper.getCollisionEngine(), terrainBody, false);
Globals.clientSceneWrapper.getCollisionEngine().registerCollisionObject(terrainBody, new Collidable(terrain,Collidable.TYPE_TERRAIN)); Globals.clientSceneWrapper.getCollisionEngine().registerCollisionObject(terrainBody, new Collidable(terrain,Collidable.TYPE_TERRAIN, false));
terrain.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, terrainBody); terrain.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, terrainBody);
return terrainBody; return terrainBody;
@ -279,7 +279,7 @@ public class PhysicsEntityUtils {
CollisionBodyCreation.setKinematic(terrainRealm.getCollisionEngine(), terrainBody); CollisionBodyCreation.setKinematic(terrainRealm.getCollisionEngine(), terrainBody);
CollisionBodyCreation.setGravityMode(terrainRealm.getCollisionEngine(), terrainBody, false); CollisionBodyCreation.setGravityMode(terrainRealm.getCollisionEngine(), terrainBody, false);
terrainRealm.getCollisionEngine().registerCollisionObject(terrainBody, new Collidable(terrain,Collidable.TYPE_TERRAIN)); terrainRealm.getCollisionEngine().registerCollisionObject(terrainBody, new Collidable(terrain,Collidable.TYPE_TERRAIN, false));
terrain.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, terrainBody); terrain.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, terrainBody);
return terrainBody; return terrainBody;

View File

@ -48,10 +48,16 @@ public class Collidable {
public static final long TYPE_FOLIAGE_BIT = 0x80; public static final long TYPE_FOLIAGE_BIT = 0x80;
/**
public Collidable(Entity parent, String type){ * Constructor
* @param parent The parent entity
* @param type The type of collidable
* @param parentTracksCollidable true if the parent should have the same position as the collidable, false otherwise
*/
public Collidable(Entity parent, String type, boolean parentTracksCollidable){
this.parent = parent; this.parent = parent;
this.type = type; this.type = type;
this.parentTracksCollidable = parentTracksCollidable;
} }
public List<Impulse> getImpulses() { public List<Impulse> getImpulses() {

View File

@ -140,7 +140,7 @@ public class CameraHandler {
if(Globals.controlHandler.cameraIsThirdPerson()){ if(Globals.controlHandler.cameraIsThirdPerson()){
perspectiveVal = CameraHandler.CAMERA_PERSPECTIVE_THIRD; perspectiveVal = CameraHandler.CAMERA_PERSPECTIVE_THIRD;
} }
if(Globals.cameraHandler.getTrackPlayerEntity()){ if(Globals.cameraHandler.getTrackPlayerEntity() && Globals.playerEntity != null){
Globals.clientConnection.queueOutgoingMessage( Globals.clientConnection.queueOutgoingMessage(
EntityMessage.constructupdateEntityViewDirMessage( EntityMessage.constructupdateEntityViewDirMessage(
Globals.clientSceneWrapper.mapClientToServerId(Globals.playerEntity.getId()), Globals.clientSceneWrapper.mapClientToServerId(Globals.playerEntity.getId()),

View File

@ -206,7 +206,9 @@ public class ClientAttackTree implements BehaviorTree {
return state.getAudioData(); return state.getAudioData();
} }
}, },
false () -> {
this.setState(AttackTreeState.IDLE);
}
), ),
}); });
} }
@ -438,7 +440,7 @@ public class ClientAttackTree implements BehaviorTree {
//checks if we have a next move and if we're in the specified range of frames when we're allowed to chain into it //checks if we have a next move and if we're in the specified range of frames when we're allowed to chain into it
if( if(
currentMove == null || currentMove == null ||
currentMove.getNextMoveId() == null || currentMove.getNextMoveId() == null ||
currentMove.getNextMoveId().equals("") || currentMove.getNextMoveId().equals("") ||
frameCurrent < currentMove.getMoveChainWindowStart() || frameCurrent < currentMove.getMoveChainWindowStart() ||
frameCurrent > currentMove.getMoveChainWindowEnd() frameCurrent > currentMove.getMoveChainWindowEnd()

View File

@ -155,8 +155,8 @@ public class ServerAttackTree implements BehaviorTree {
}, },
null, null,
() -> { () -> {
this.setState(AttackTreeState.COOLDOWN);
this.stateTransitionUtil.interrupt(AttackTreeState.ATTACK); this.stateTransitionUtil.interrupt(AttackTreeState.ATTACK);
this.setState(AttackTreeState.COOLDOWN);
} }
), ),
StateTransitionUtilItem.create( StateTransitionUtilItem.create(
@ -170,7 +170,10 @@ public class ServerAttackTree implements BehaviorTree {
} }
}, },
null, null,
null () -> {
this.setState(AttackTreeState.IDLE);
this.stateTransitionUtil.interrupt(AttackTreeState.COOLDOWN);
}
), ),
}); });
} }

View File

@ -173,7 +173,7 @@ public class HitboxCollectionState {
rVal.body = CollisionBodyCreation.createBodyWithShapes(manager.getCollisionEngine(), geomArray); rVal.body = CollisionBodyCreation.createBodyWithShapes(manager.getCollisionEngine(), geomArray);
//register collidable with collision engine //register collidable with collision engine
Collidable collidable = new Collidable(entity, Collidable.TYPE_OBJECT); Collidable collidable = new Collidable(entity, Collidable.TYPE_OBJECT, true);
manager.getCollisionEngine().registerCollisionObject(rVal.body, collidable); manager.getCollisionEngine().registerCollisionObject(rVal.body, collidable);
//attach //attach

View File

@ -39,6 +39,7 @@ public class ClientAlwaysUprightTree implements BehaviorTree {
Vector3d angularForce = new Vector3d(); Vector3d angularForce = new Vector3d();
//make sure rotation is vertical //make sure rotation is vertical
body.setMaxAngularSpeed(0);
// sourceRotation = sourceRotation.mul(0.001, 1, 0.001, 1).normalize(); // sourceRotation = sourceRotation.mul(0.001, 1, 0.001, 1).normalize();
EntityUtils.getPosition(parent).set(position); EntityUtils.getPosition(parent).set(position);

View File

@ -42,7 +42,8 @@ public class ServerAlwaysUprightTree implements BehaviorTree {
Vector3d angularForce = new Vector3d(); Vector3d angularForce = new Vector3d();
//make sure rotation is vertical //make sure rotation is vertical
// sourceRotation = sourceRotation.mul(0.001, 1, 0.001, 1).normalize(); body.setMaxAngularSpeed(0);
// sourceRotation = sourceRotation.mul(0.001, 0.001, 0.001, 1).normalize();
EntityUtils.getPosition(parent).set(position); EntityUtils.getPosition(parent).set(position);
EntityUtils.getRotation(parent).set(sourceRotation); EntityUtils.getRotation(parent).set(sourceRotation);

View File

@ -29,7 +29,7 @@ public class CollisionObjUtils {
DBody planeObject = CollisionBodyCreation.createPlaneBody(Globals.clientSceneWrapper.getCollisionEngine(),new Vector3d(scale),Collidable.TYPE_STATIC_BIT); DBody planeObject = CollisionBodyCreation.createPlaneBody(Globals.clientSceneWrapper.getCollisionEngine(),new Vector3d(scale),Collidable.TYPE_STATIC_BIT);
PhysicsUtils.setRigidBodyTransform(Globals.clientSceneWrapper.getCollisionEngine(), position, rotation, planeObject); PhysicsUtils.setRigidBodyTransform(Globals.clientSceneWrapper.getCollisionEngine(), position, rotation, planeObject);
Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE); Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE, true);
Globals.clientSceneWrapper.getCollisionEngine().registerCollisionObject(planeObject, collidable); Globals.clientSceneWrapper.getCollisionEngine().registerCollisionObject(planeObject, collidable);
rVal.putData(EntityDataStrings.COLLISION_ENTITY_TYPE_PLANE, true); rVal.putData(EntityDataStrings.COLLISION_ENTITY_TYPE_PLANE, true);
@ -51,7 +51,7 @@ public class CollisionObjUtils {
DBody planeObject = CollisionBodyCreation.createPlaneBody(realm.getCollisionEngine(),new Vector3d(scale),Collidable.TYPE_STATIC_BIT); DBody planeObject = CollisionBodyCreation.createPlaneBody(realm.getCollisionEngine(),new Vector3d(scale),Collidable.TYPE_STATIC_BIT);
PhysicsUtils.setRigidBodyTransform(realm.getCollisionEngine(), position, rotation, planeObject); PhysicsUtils.setRigidBodyTransform(realm.getCollisionEngine(), position, rotation, planeObject);
Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE); Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE, true);
realm.getCollisionEngine().registerCollisionObject(planeObject, collidable); realm.getCollisionEngine().registerCollisionObject(planeObject, collidable);
rVal.putData(EntityDataStrings.COLLISION_ENTITY_TYPE_PLANE, true); rVal.putData(EntityDataStrings.COLLISION_ENTITY_TYPE_PLANE, true);
@ -74,7 +74,7 @@ public class CollisionObjUtils {
DBody cubeObject = CollisionBodyCreation.createCubeBody(Globals.clientSceneWrapper.getCollisionEngine(),new Vector3d(scale),Collidable.TYPE_STATIC_BIT); DBody cubeObject = CollisionBodyCreation.createCubeBody(Globals.clientSceneWrapper.getCollisionEngine(),new Vector3d(scale),Collidable.TYPE_STATIC_BIT);
PhysicsUtils.setRigidBodyTransform(Globals.clientSceneWrapper.getCollisionEngine(), position, rotation, cubeObject); PhysicsUtils.setRigidBodyTransform(Globals.clientSceneWrapper.getCollisionEngine(), position, rotation, cubeObject);
Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE); Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE, true);
Globals.clientSceneWrapper.getCollisionEngine().registerCollisionObject(cubeObject, collidable); Globals.clientSceneWrapper.getCollisionEngine().registerCollisionObject(cubeObject, collidable);
rVal.putData(EntityDataStrings.COLLISION_ENTITY_TYPE_CUBE, true); rVal.putData(EntityDataStrings.COLLISION_ENTITY_TYPE_CUBE, true);
@ -96,7 +96,7 @@ public class CollisionObjUtils {
DBody cubeObject = CollisionBodyCreation.createCubeBody(realm.getCollisionEngine(),new Vector3d(scale),Collidable.TYPE_STATIC_BIT); DBody cubeObject = CollisionBodyCreation.createCubeBody(realm.getCollisionEngine(),new Vector3d(scale),Collidable.TYPE_STATIC_BIT);
PhysicsUtils.setRigidBodyTransform(realm.getCollisionEngine(), position, rotation, cubeObject); PhysicsUtils.setRigidBodyTransform(realm.getCollisionEngine(), position, rotation, cubeObject);
Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE); Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE, true);
realm.getCollisionEngine().registerCollisionObject(cubeObject, collidable); realm.getCollisionEngine().registerCollisionObject(cubeObject, collidable);
rVal.putData(EntityDataStrings.COLLISION_ENTITY_TYPE_CUBE, true); rVal.putData(EntityDataStrings.COLLISION_ENTITY_TYPE_CUBE, true);
@ -117,7 +117,7 @@ public class CollisionObjUtils {
float mass = 1.0f; float mass = 1.0f;
DBody cubeObject = CollisionBodyCreation.createCylinderBody(Globals.clientSceneWrapper.getCollisionEngine(),scale.x,scale.y,Collidable.TYPE_STATIC_BIT); DBody cubeObject = CollisionBodyCreation.createCylinderBody(Globals.clientSceneWrapper.getCollisionEngine(),scale.x,scale.y,Collidable.TYPE_STATIC_BIT);
PhysicsUtils.setRigidBodyTransform(Globals.clientSceneWrapper.getCollisionEngine(), position, rotation, cubeObject); PhysicsUtils.setRigidBodyTransform(Globals.clientSceneWrapper.getCollisionEngine(), position, rotation, cubeObject);
Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE); Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE, true);
Globals.clientSceneWrapper.getCollisionEngine().registerCollisionObject(cubeObject, collidable); Globals.clientSceneWrapper.getCollisionEngine().registerCollisionObject(cubeObject, collidable);
rVal.putData(EntityDataStrings.COLLISION_ENTITY_TYPE_CYLINDER, true); rVal.putData(EntityDataStrings.COLLISION_ENTITY_TYPE_CYLINDER, true);
@ -138,7 +138,7 @@ public class CollisionObjUtils {
float mass = 1.0f; float mass = 1.0f;
DBody cubeObject = CollisionBodyCreation.createCylinderBody(realm.getCollisionEngine(),scale.x,scale.y,Collidable.TYPE_STATIC_BIT); DBody cubeObject = CollisionBodyCreation.createCylinderBody(realm.getCollisionEngine(),scale.x,scale.y,Collidable.TYPE_STATIC_BIT);
PhysicsUtils.setRigidBodyTransform(realm.getCollisionEngine(), position, rotation, cubeObject); PhysicsUtils.setRigidBodyTransform(realm.getCollisionEngine(), position, rotation, cubeObject);
Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE); Collidable collidable = new Collidable(rVal, Collidable.TYPE_STRUCTURE, true);
realm.getCollisionEngine().registerCollisionObject(cubeObject, collidable); realm.getCollisionEngine().registerCollisionObject(cubeObject, collidable);
rVal.putData(EntityDataStrings.COLLISION_ENTITY_TYPE_CYLINDER, true); rVal.putData(EntityDataStrings.COLLISION_ENTITY_TYPE_CYLINDER, true);
@ -233,7 +233,7 @@ public class CollisionObjUtils {
public static void clientAttachCollisionObjectToEntity(Entity entity, DBody collisionObject, float mass, String collidableType){ public static void clientAttachCollisionObjectToEntity(Entity entity, DBody collisionObject, float mass, String collidableType){
Vector3d position = EntityUtils.getPosition(entity); Vector3d position = EntityUtils.getPosition(entity);
Vector3f scale = EntityUtils.getScale(entity); Vector3f scale = EntityUtils.getScale(entity);
Collidable collidable = new Collidable(entity, collidableType); Collidable collidable = new Collidable(entity, collidableType, true);
Globals.clientSceneWrapper.getCollisionEngine().registerCollisionObject(collisionObject, collidable); Globals.clientSceneWrapper.getCollisionEngine().registerCollisionObject(collisionObject, collidable);
entity.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, collisionObject); entity.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, collisionObject);
@ -256,7 +256,7 @@ public class CollisionObjUtils {
public static void serverAttachCollisionObjectToEntity(Entity entity, DBody collisionObject, float mass, String collidableType){ public static void serverAttachCollisionObjectToEntity(Entity entity, DBody collisionObject, float mass, String collidableType){
Vector3d position = EntityUtils.getPosition(entity); Vector3d position = EntityUtils.getPosition(entity);
Vector3f scale = EntityUtils.getScale(entity); Vector3f scale = EntityUtils.getScale(entity);
Collidable collidable = new Collidable(entity, collidableType); Collidable collidable = new Collidable(entity, collidableType, true);
Realm realm = Globals.realmManager.getEntityRealm(entity); Realm realm = Globals.realmManager.getEntityRealm(entity);
realm.getCollisionEngine().registerCollisionObject(collisionObject, collidable); realm.getCollisionEngine().registerCollisionObject(collisionObject, collidable);

View File

@ -118,7 +118,7 @@ public class ProceduralTree {
); );
CollisionBodyCreation.setOffsetPosition(Globals.clientSceneWrapper.getCollisionEngine(), rigidBody, new Vector3d(0,treeModel.getPhysicsBody().getOffsetY(),0)); CollisionBodyCreation.setOffsetPosition(Globals.clientSceneWrapper.getCollisionEngine(), rigidBody, new Vector3d(0,treeModel.getPhysicsBody().getOffsetY(),0));
CollisionBodyCreation.setKinematic(Globals.clientSceneWrapper.getCollisionEngine(), rigidBody); CollisionBodyCreation.setKinematic(Globals.clientSceneWrapper.getCollisionEngine(), rigidBody);
Collidable collidable = new Collidable(trunkChild, Collidable.TYPE_OBJECT); Collidable collidable = new Collidable(trunkChild, Collidable.TYPE_FOLIAGE_STATIC, true);
trunkChild.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody); trunkChild.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody);
Matrix4d offsetTransform = new Matrix4d().translationRotateScale( Matrix4d offsetTransform = new Matrix4d().translationRotateScale(
0,treeModel.getPhysicsBody().getOffsetY(),0, //translate 0,treeModel.getPhysicsBody().getOffsetY(),0, //translate
@ -384,7 +384,7 @@ public class ProceduralTree {
); );
CollisionBodyCreation.setOffsetPosition(realm.getCollisionEngine(), rigidBody, new Vector3d(0,treeModel.getPhysicsBody().getOffsetY(),0)); CollisionBodyCreation.setOffsetPosition(realm.getCollisionEngine(), rigidBody, new Vector3d(0,treeModel.getPhysicsBody().getOffsetY(),0));
CollisionBodyCreation.setKinematic(realm.getCollisionEngine(), rigidBody); CollisionBodyCreation.setKinematic(realm.getCollisionEngine(), rigidBody);
Collidable collidable = new Collidable(trunkChild, Collidable.TYPE_FOLIAGE_STATIC); Collidable collidable = new Collidable(trunkChild, Collidable.TYPE_FOLIAGE_STATIC, true);
trunkChild.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody); trunkChild.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, rigidBody);
Matrix4d offsetTransform = new Matrix4d().translationRotateScale( Matrix4d offsetTransform = new Matrix4d().translationRotateScale(
0,treeModel.getPhysicsBody().getOffsetY(),0, //translate 0,treeModel.getPhysicsBody().getOffsetY(),0, //translate

View File

@ -122,9 +122,11 @@ public class MenuGeneratorsInGame {
}}); }});
// } // }
div.addChild(Button.createButton("Open Level Editor Tools", () -> { if(MenuGeneratorsInGame.shouldShowLevelEditor()){
WindowUtils.replaceWindow(WindowStrings.LEVEL_EDTIOR_SIDE_PANEL,MenuGeneratorsLevelEditor.createLevelEditorSidePanel()); div.addChild(Button.createButton("Open Level Editor Tools", () -> {
})); WindowUtils.replaceWindow(WindowStrings.LEVEL_EDTIOR_SIDE_PANEL,MenuGeneratorsLevelEditor.createLevelEditorSidePanel());
}));
}
rVal.applyYoga(0,0); rVal.applyYoga(0,0);
@ -401,4 +403,12 @@ public class MenuGeneratorsInGame {
return rVal; return rVal;
} }
/**
* Checks if should show the level editor button
* @return True if should show button, false otherwise
*/
private static boolean shouldShowLevelEditor(){
return Globals.server != null;
}
} }