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 Physics work
Debug rendering for facing vectors Debug rendering for facing vectors
Fix progressive pathfinding iteration Fix progressive pathfinding iteration
Non-body ground movement animation work

View File

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

View File

@ -1,19 +1,20 @@
package electrosphere.entity.state.gravity; package electrosphere.entity.state.gravity;
import electrosphere.collision.PhysicsEntityUtils;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.EntityDataStrings; import electrosphere.entity.EntityDataStrings;
public class GravityUtils { public class GravityUtils {
public static void clientAttemptActivateGravity(Entity target){ 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); ClientGravityTree tree = ClientGravityTree.getClientGravityTree(target);
tree.start(); tree.start();
} }
} }
public static void serverAttemptActivateGravity(Entity target){ 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); ServerGravityTree tree = ServerGravityTree.getServerGravityTree(target);
tree.start(); tree.start();
} }

View File

@ -155,7 +155,7 @@ public class ServerGravityTree implements BehaviorTree {
*/ */
private boolean bodyIsActive(){ private boolean bodyIsActive(){
if(PhysicsEntityUtils.getDBody(parent) == null){ if(PhysicsEntityUtils.getDBody(parent) == null){
return true; return false;
} }
DBody body = PhysicsEntityUtils.getDBody(parent); DBody body = PhysicsEntityUtils.getDBody(parent);
return body.isEnabled(); 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 //body can be null if the behavior tree wasn't detatched for some reason
if(body != null){ if(body != null){
linearVelocity = body.getLinearVel(); linearVelocity = body.getLinearVel();
} else {
return;
} }
// //
@ -330,13 +328,15 @@ public class ClientGroundMovementTree implements BehaviorTree {
} }
CreatureUtils.setVelocity(parent, velocity); CreatureUtils.setVelocity(parent, velocity);
//actually update //actually update
PhysicsEntityUtils.getDBody(parent).enable(); if(body != null){
body.setLinearVel( PhysicsEntityUtils.getDBody(parent).enable();
movementVector.x * velocity * Globals.engineState.timekeeper.getSimFrameTime(), body.setLinearVel(
linearVelocity.get1(), movementVector.x * velocity * Globals.engineState.timekeeper.getSimFrameTime(),
movementVector.z * velocity * Globals.engineState.timekeeper.getSimFrameTime() linearVelocity.get1(),
); movementVector.z * velocity * Globals.engineState.timekeeper.getSimFrameTime()
body.setAngularVel(0, 0, 0); );
body.setAngularVel(0, 0, 0);
}
rotation.set(movementQuaternion); rotation.set(movementQuaternion);
GravityUtils.clientAttemptActivateGravity(parent); GravityUtils.clientAttemptActivateGravity(parent);
@ -362,13 +362,15 @@ public class ClientGroundMovementTree implements BehaviorTree {
this.updateVelocity(); this.updateVelocity();
float velocity = this.getModifiedVelocity(); float velocity = this.getModifiedVelocity();
PhysicsEntityUtils.getDBody(parent).enable(); if(body != null){
body.setLinearVel( PhysicsEntityUtils.getDBody(parent).enable();
movementVector.x * velocity * Globals.engineState.timekeeper.getSimFrameTime(), body.setLinearVel(
linearVelocity.get1(), movementVector.x * velocity * Globals.engineState.timekeeper.getSimFrameTime(),
movementVector.z * velocity * Globals.engineState.timekeeper.getSimFrameTime() linearVelocity.get1(),
); movementVector.z * velocity * Globals.engineState.timekeeper.getSimFrameTime()
body.setAngularVel(0, 0, 0); );
body.setAngularVel(0, 0, 0);
}
rotation.set(movementQuaternion); rotation.set(movementQuaternion);
GravityUtils.clientAttemptActivateGravity(parent); GravityUtils.clientAttemptActivateGravity(parent);
@ -412,13 +414,15 @@ public class ClientGroundMovementTree implements BehaviorTree {
} else { } else {
GravityUtils.clientAttemptActivateGravity(parent); GravityUtils.clientAttemptActivateGravity(parent);
} }
PhysicsEntityUtils.getDBody(parent).enable(); if(body != null){
body.setLinearVel( PhysicsEntityUtils.getDBody(parent).enable();
movementVector.x * velocity * Globals.engineState.timekeeper.getSimFrameTime(), body.setLinearVel(
linearVelocity.get1(), movementVector.x * velocity * Globals.engineState.timekeeper.getSimFrameTime(),
movementVector.z * velocity * Globals.engineState.timekeeper.getSimFrameTime() linearVelocity.get1(),
); movementVector.z * velocity * Globals.engineState.timekeeper.getSimFrameTime()
body.setAngularVel(0, 0, 0); );
body.setAngularVel(0, 0, 0);
}
rotation.set(movementQuaternion); rotation.set(movementQuaternion);
} break; } break;

View File

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