fix gravity tree not deactivating
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2024-12-03 13:19:17 -05:00
parent acfd28a0fc
commit e21bcbbe3f
5 changed files with 34 additions and 14 deletions

View File

@ -1226,6 +1226,8 @@ Add native testing step to jenkins pipeline
(12/03/2024)
Native code building correctly in jenkins pipeline
Refactoring native code
Fix gravity tree not deactivating when body is disabled

View File

@ -3,6 +3,7 @@ package electrosphere.entity.state.gravity;
import org.ode4j.ode.DBody;
import electrosphere.collision.PhysicsEntityUtils;
import electrosphere.collision.collidable.Collidable;
import electrosphere.engine.Globals;
import electrosphere.entity.Entity;
@ -65,11 +66,6 @@ public class ClientGravityTree implements BehaviorTree {
state = GravityTreeState.ACTIVE;
}
public void interrupt(){
state = GravityTreeState.NOT_ACTIVE;
}
public void stop(){
state = GravityTreeState.NOT_ACTIVE;
}
@ -93,7 +89,7 @@ public class ClientGravityTree implements BehaviorTree {
//state machine
switch(state){
case ACTIVE:
if(hadGroundCollision()){
if(this.hadGroundCollision() || !this.bodyIsActive()){
ClientJumpTree jumpTree;
if((jumpTree = ClientJumpTree.getClientJumpTree(parent))!=null){
jumpTree.land();
@ -132,6 +128,18 @@ public class ClientGravityTree implements BehaviorTree {
}
return rVal;
}
/**
* Checks if the physics body is active
* @return true if it is active (or not present), false otherwise
*/
private boolean bodyIsActive(){
if(PhysicsEntityUtils.getDBody(parent) == null){
return true;
}
DBody body = PhysicsEntityUtils.getDBody(parent);
return body.isEnabled();
}
public boolean hadEntityCollision(){
boolean rVal = false;

View File

@ -8,6 +8,7 @@ import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils;
import org.ode4j.ode.DBody;
import electrosphere.collision.PhysicsEntityUtils;
import electrosphere.collision.collidable.Collidable;
import electrosphere.engine.Globals;
import electrosphere.entity.Entity;
@ -67,10 +68,6 @@ public class ServerGravityTree implements BehaviorTree {
}
}
public void interrupt(){
setState(GravityTreeState.NOT_ACTIVE);
}
public void stop(){
setState(GravityTreeState.NOT_ACTIVE);
}
@ -97,7 +94,7 @@ public class ServerGravityTree implements BehaviorTree {
//state machine
switch(state){
case ACTIVE:
if(hadGroundCollision()){
if(this.hadGroundCollision() || !this.bodyIsActive()){
setState(GravityTreeState.NOT_ACTIVE);
ServerJumpTree jumpTree;
if((jumpTree = ServerJumpTree.getServerJumpTree(parent))!=null){
@ -143,6 +140,18 @@ public class ServerGravityTree implements BehaviorTree {
}
return rVal;
}
/**
* Checks if the physics body is active
* @return true if it is active (or not present), false otherwise
*/
private boolean bodyIsActive(){
if(PhysicsEntityUtils.getDBody(parent) == null){
return true;
}
DBody body = PhysicsEntityUtils.getDBody(parent);
return body.isEnabled();
}
/**
* Checks if the gravity tree had a collision with an entity

View File

@ -408,6 +408,8 @@ public class ClientGroundMovementTree implements BehaviorTree {
}
}
CreatureUtils.setVelocity(parent, velocity);
} else {
GravityUtils.clientAttemptActivateGravity(parent);
}
PhysicsEntityUtils.getDBody(parent).enable();
body.setLinearVel(
@ -418,7 +420,6 @@ public class ClientGroundMovementTree implements BehaviorTree {
body.setAngularVel(0, 0, 0);
rotation.set(movementQuaternion);
GravityUtils.clientAttemptActivateGravity(parent);
} break;
case IDLE: {
Vector3d playerPos = EntityUtils.getPosition(parent);

View File

@ -381,6 +381,8 @@ public class ServerGroundMovementTree implements BehaviorTree {
poseActor.stopAnimation(animationToPlay);
}
}
} else {
GravityUtils.serverAttemptActivateGravity(parent);
}
// PhysicsEntityUtils.getDBody(parent).addForce(
// movementVector.x * velocity * Globals.timekeeper.getSimFrameTime(),
@ -396,8 +398,6 @@ public class ServerGroundMovementTree implements BehaviorTree {
body.setAngularVel(0, 0, 0);
// position.set(newPosition);
GravityUtils.serverAttemptActivateGravity(parent);
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
EntityMessage.constructmoveUpdateMessage(
parent.getId(),