servergroundmovementtree collidable work
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2025-05-31 15:31:17 -04:00
parent b2e93da04e
commit 6723031154
2 changed files with 38 additions and 31 deletions

View File

@ -2098,6 +2098,7 @@ TownLayout test
Macro pathing test Macro pathing test
Actually fix pathing spinlock Actually fix pathing spinlock
Support for observing ai entities Support for observing ai entities
ServerGroundMovementTree supports collidable entities

View File

@ -14,6 +14,7 @@ import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.EntityDataStrings; import electrosphere.entity.EntityDataStrings;
import electrosphere.entity.EntityUtils; import electrosphere.entity.EntityUtils;
import electrosphere.entity.ServerEntityUtils;
import electrosphere.entity.btree.BehaviorTree; import electrosphere.entity.btree.BehaviorTree;
import electrosphere.entity.state.AnimationPriorities; import electrosphere.entity.state.AnimationPriorities;
import electrosphere.entity.state.attack.ServerAttackTree; import electrosphere.entity.state.attack.ServerAttackTree;
@ -182,10 +183,10 @@ public class ServerGroundMovementTree implements BehaviorTree {
} }
DBody body = PhysicsEntityUtils.getDBody(parent); DBody body = PhysicsEntityUtils.getDBody(parent);
//TODO: eventually handle non-rigid-body entities //TODO: eventually handle non-rigid-body entities
if(body == null){ DVector3C linearVelocity = null;
return; if(body != null){
linearVelocity = body.getLinearVel();
} }
DVector3C linearVelocity = body.getLinearVel();
// //
//rotation update //rotation update
@ -288,14 +289,17 @@ public class ServerGroundMovementTree implements BehaviorTree {
state = MovementTreeState.MOVE; state = MovementTreeState.MOVE;
CreatureUtils.setVelocity(parent, velocity); CreatureUtils.setVelocity(parent, velocity);
} }
PhysicsEntityUtils.getDBody(parent).enable(); if(body == null){
PhysicsEntityUtils.getDBody(parent).setLinearVel( ServerEntityUtils.repositionEntity(parent, new Vector3d(position).add(velocity,velocity,velocity));
} else {
body.enable();
body.setLinearVel(
movementVector.x * velocity * Globals.engineState.timekeeper.getSimFrameTime(), movementVector.x * velocity * Globals.engineState.timekeeper.getSimFrameTime(),
linearVelocity.get1(), linearVelocity.get1(),
movementVector.z * velocity * Globals.engineState.timekeeper.getSimFrameTime() movementVector.z * velocity * Globals.engineState.timekeeper.getSimFrameTime()
); );
body.setAngularVel(0, 0, 0); body.setAngularVel(0, 0, 0);
// position.set(newPosition); }
GravityUtils.serverAttemptActivateGravity(parent); GravityUtils.serverAttemptActivateGravity(parent);
@ -334,13 +338,17 @@ public class ServerGroundMovementTree implements BehaviorTree {
} }
this.updateVelocity(); this.updateVelocity();
float velocity = this.getModifiedVelocity(); float velocity = this.getModifiedVelocity();
PhysicsEntityUtils.getDBody(parent).enable(); if(body == null){
PhysicsEntityUtils.getDBody(parent).setLinearVel( ServerEntityUtils.repositionEntity(parent, new Vector3d(position).add(velocity,velocity,velocity));
} else {
body.enable();
body.setLinearVel(
movementVector.x * velocity * Globals.engineState.timekeeper.getSimFrameTime(), movementVector.x * velocity * Globals.engineState.timekeeper.getSimFrameTime(),
linearVelocity.get1(), linearVelocity.get1(),
movementVector.z * velocity * Globals.engineState.timekeeper.getSimFrameTime() movementVector.z * velocity * Globals.engineState.timekeeper.getSimFrameTime()
); );
body.setAngularVel(0, 0, 0); body.setAngularVel(0, 0, 0);
}
GravityUtils.serverAttemptActivateGravity(parent); GravityUtils.serverAttemptActivateGravity(parent);
@ -398,19 +406,17 @@ public class ServerGroundMovementTree implements BehaviorTree {
} else { } else {
GravityUtils.serverAttemptActivateGravity(parent); GravityUtils.serverAttemptActivateGravity(parent);
} }
// PhysicsEntityUtils.getDBody(parent).addForce( if(body == null){
// movementVector.x * velocity * Globals.timekeeper.getSimFrameTime(), ServerEntityUtils.repositionEntity(parent, new Vector3d(position).add(velocity,velocity,velocity));
// linearVelocity.get1(), } else {
// movementVector.z * velocity * Globals.timekeeper.getSimFrameTime() body.enable();
// ); body.setLinearVel(
PhysicsEntityUtils.getDBody(parent).enable();
PhysicsEntityUtils.getDBody(parent).setLinearVel(
movementVector.x * velocity * Globals.engineState.timekeeper.getSimFrameTime(), movementVector.x * velocity * Globals.engineState.timekeeper.getSimFrameTime(),
linearVelocity.get1(), linearVelocity.get1(),
movementVector.z * velocity * Globals.engineState.timekeeper.getSimFrameTime() movementVector.z * velocity * Globals.engineState.timekeeper.getSimFrameTime()
); );
body.setAngularVel(0, 0, 0); body.setAngularVel(0, 0, 0);
// position.set(newPosition); }
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage( DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
EntityMessage.constructmoveUpdateMessage( EntityMessage.constructmoveUpdateMessage(