ground movement work + text fixes
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2025-06-05 12:52:54 -04:00
parent 25d2dcd943
commit d650d223a8
6 changed files with 35 additions and 29 deletions

View File

@ -2122,6 +2122,7 @@ voxel tests
Physics work
Debug rendering for facing vectors
Fix progressive pathfinding iteration
Non-body ground movement animation work

View File

@ -136,7 +136,7 @@ public class ClientGravityTree implements BehaviorTree {
*/
private boolean bodyIsActive(){
if(PhysicsEntityUtils.getDBody(parent) == null){
return true;
return false;
}
DBody body = PhysicsEntityUtils.getDBody(parent);
return body.isEnabled();

View File

@ -1,19 +1,20 @@
package electrosphere.entity.state.gravity;
import electrosphere.collision.PhysicsEntityUtils;
import electrosphere.entity.Entity;
import electrosphere.entity.EntityDataStrings;
public class GravityUtils {
public static void clientAttemptActivateGravity(Entity target){
if(target.containsKey(EntityDataStrings.GRAVITY_ENTITY)){
if(target.containsKey(EntityDataStrings.GRAVITY_ENTITY) && PhysicsEntityUtils.containsDBody(target)){
ClientGravityTree tree = ClientGravityTree.getClientGravityTree(target);
tree.start();
}
}
public static void serverAttemptActivateGravity(Entity target){
if(target.containsKey(EntityDataStrings.GRAVITY_ENTITY)){
if(target.containsKey(EntityDataStrings.GRAVITY_ENTITY) && PhysicsEntityUtils.containsDBody(target)){
ServerGravityTree tree = ServerGravityTree.getServerGravityTree(target);
tree.start();
}

View File

@ -155,7 +155,7 @@ public class ServerGravityTree implements BehaviorTree {
*/
private boolean bodyIsActive(){
if(PhysicsEntityUtils.getDBody(parent) == null){
return true;
return false;
}
DBody body = PhysicsEntityUtils.getDBody(parent);
return body.isEnabled();

View File

@ -209,8 +209,6 @@ public class ClientGroundMovementTree implements BehaviorTree {
//body can be null if the behavior tree wasn't detatched for some reason
if(body != null){
linearVelocity = body.getLinearVel();
} else {
return;
}
//
@ -330,13 +328,15 @@ public class ClientGroundMovementTree implements BehaviorTree {
}
CreatureUtils.setVelocity(parent, velocity);
//actually update
PhysicsEntityUtils.getDBody(parent).enable();
body.setLinearVel(
movementVector.x * velocity * Globals.engineState.timekeeper.getSimFrameTime(),
linearVelocity.get1(),
movementVector.z * velocity * Globals.engineState.timekeeper.getSimFrameTime()
);
body.setAngularVel(0, 0, 0);
if(body != null){
PhysicsEntityUtils.getDBody(parent).enable();
body.setLinearVel(
movementVector.x * velocity * Globals.engineState.timekeeper.getSimFrameTime(),
linearVelocity.get1(),
movementVector.z * velocity * Globals.engineState.timekeeper.getSimFrameTime()
);
body.setAngularVel(0, 0, 0);
}
rotation.set(movementQuaternion);
GravityUtils.clientAttemptActivateGravity(parent);
@ -362,13 +362,15 @@ public class ClientGroundMovementTree implements BehaviorTree {
this.updateVelocity();
float velocity = this.getModifiedVelocity();
PhysicsEntityUtils.getDBody(parent).enable();
body.setLinearVel(
movementVector.x * velocity * Globals.engineState.timekeeper.getSimFrameTime(),
linearVelocity.get1(),
movementVector.z * velocity * Globals.engineState.timekeeper.getSimFrameTime()
);
body.setAngularVel(0, 0, 0);
if(body != null){
PhysicsEntityUtils.getDBody(parent).enable();
body.setLinearVel(
movementVector.x * velocity * Globals.engineState.timekeeper.getSimFrameTime(),
linearVelocity.get1(),
movementVector.z * velocity * Globals.engineState.timekeeper.getSimFrameTime()
);
body.setAngularVel(0, 0, 0);
}
rotation.set(movementQuaternion);
GravityUtils.clientAttemptActivateGravity(parent);
@ -412,13 +414,15 @@ public class ClientGroundMovementTree implements BehaviorTree {
} else {
GravityUtils.clientAttemptActivateGravity(parent);
}
PhysicsEntityUtils.getDBody(parent).enable();
body.setLinearVel(
movementVector.x * velocity * Globals.engineState.timekeeper.getSimFrameTime(),
linearVelocity.get1(),
movementVector.z * velocity * Globals.engineState.timekeeper.getSimFrameTime()
);
body.setAngularVel(0, 0, 0);
if(body != null){
PhysicsEntityUtils.getDBody(parent).enable();
body.setLinearVel(
movementVector.x * velocity * Globals.engineState.timekeeper.getSimFrameTime(),
linearVelocity.get1(),
movementVector.z * velocity * Globals.engineState.timekeeper.getSimFrameTime()
);
body.setAngularVel(0, 0, 0);
}
rotation.set(movementQuaternion);
} break;

View File

@ -23,7 +23,7 @@ public class CollisionEngineStaticSpaceTests extends EntityTestTemplate {
CollisionEngine collisionEngine = realm.getCollisionEngine();
//base plane + static space
assertEquals(2, collisionEngine.getSpace().getNumGeoms());
assertEquals(0, collisionEngine.getSpace().getNumGeoms());
}
@IntegrationTest
@ -62,7 +62,7 @@ public class CollisionEngineStaticSpaceTests extends EntityTestTemplate {
PhysicsEntityUtils.serverAttachCollidableTemplate(realm, ent1, CollidableTemplate.getBoxTemplate(new Vector3d(1,1,1)), new Vector3d(0));
int expectedBoxBoxCollisions = 4;
int expectedBoxBoxCollisions = 3;
int expectedTotalCollisions = expectedBoxBoxCollisions * CollisionEngine.PHYSICS_SIMULATION_RESOLUTION;