From d8a9d660aa19be11d3290849c0965c46bb09736f Mon Sep 17 00:00:00 2001 From: austin Date: Fri, 29 Nov 2024 12:13:53 -0500 Subject: [PATCH] variable collision bits from collidable defns --- docs/src/progress/renderertodo.md | 1 + .../collision/PhysicsEntityUtils.java | 20 +++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index bbab0de7..f5eba19a 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -1169,6 +1169,7 @@ Fix block not firing Fix reentrant locking bug Convert server physics cell generation to executor service Simplifying physics cases +Allow variable collision bits for collidable entities # TODO diff --git a/src/main/java/electrosphere/collision/PhysicsEntityUtils.java b/src/main/java/electrosphere/collision/PhysicsEntityUtils.java index 7bfab700..b85fed71 100644 --- a/src/main/java/electrosphere/collision/PhysicsEntityUtils.java +++ b/src/main/java/electrosphere/collision/PhysicsEntityUtils.java @@ -63,6 +63,10 @@ public class PhysicsEntityUtils { if(physicsTemplate.getMass() != null){ mass = physicsTemplate.getMass(); } + long categoryBit = Collidable.TYPE_CREATURE_BIT; + if(physicsTemplate.getKinematic()){ + categoryBit = Collidable.TYPE_STATIC_BIT; + } switch(physicsTemplate.getType()){ case "CYLINDER": { @@ -72,7 +76,7 @@ public class PhysicsEntityUtils { Globals.clientSceneWrapper.getCollisionEngine(), physicsTemplate.getDimension1(), physicsTemplate.getDimension2(), - Collidable.TYPE_CREATURE_BIT + categoryBit ); if(physicsTemplate.getMass() != null){ CollisionBodyCreation.setCylinderMass( @@ -135,7 +139,7 @@ public class PhysicsEntityUtils { rigidBody = CollisionBodyCreation.createCubeBody( Globals.clientSceneWrapper.getCollisionEngine(), new Vector3d(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3()), - Collidable.TYPE_CREATURE_BIT + categoryBit ); if(physicsTemplate.getMass() != null){ CollisionBodyCreation.setBoxMass( @@ -199,7 +203,7 @@ public class PhysicsEntityUtils { Globals.clientSceneWrapper.getCollisionEngine(), physicsTemplate.getDimension2(), physicsTemplate.getDimension2() - physicsTemplate.getDimension1() - physicsTemplate.getDimension1(), - Collidable.TYPE_CREATURE_BIT + categoryBit ); if(physicsTemplate.getMass() != null){ CollisionBodyCreation.setCapsuleMass( @@ -278,6 +282,10 @@ public class PhysicsEntityUtils { if(physicsTemplate.getMass() != null){ mass = physicsTemplate.getMass(); } + long categoryBit = Collidable.TYPE_CREATURE_BIT; + if(physicsTemplate.getKinematic()){ + categoryBit = Collidable.TYPE_STATIC_BIT; + } switch(physicsTemplate.getType()){ case "CYLINDER": { @@ -287,7 +295,7 @@ public class PhysicsEntityUtils { realm.getCollisionEngine(), physicsTemplate.getDimension1(), physicsTemplate.getDimension2(), - Collidable.TYPE_CREATURE_BIT + categoryBit ); if(physicsTemplate.getMass() != null){ CollisionBodyCreation.setCylinderMass( @@ -351,7 +359,7 @@ public class PhysicsEntityUtils { rigidBody = CollisionBodyCreation.createCubeBody( realm.getCollisionEngine(), new Vector3d(physicsTemplate.getDimension1(),physicsTemplate.getDimension2(),physicsTemplate.getDimension3()), - Collidable.TYPE_CREATURE_BIT + categoryBit ); if(physicsTemplate.getMass() != null){ CollisionBodyCreation.setBoxMass( @@ -415,7 +423,7 @@ public class PhysicsEntityUtils { realm.getCollisionEngine(), physicsTemplate.getDimension2(), physicsTemplate.getDimension2() - physicsTemplate.getDimension1() - physicsTemplate.getDimension1(), - Collidable.TYPE_CREATURE_BIT + categoryBit ); if(physicsTemplate.getMass() != null){ CollisionBodyCreation.setCapsuleMass(