add always upright tree
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
This commit is contained in:
parent
a7b12c280a
commit
ea3518300f
@ -543,6 +543,7 @@ Block override concept for hitboxes
|
|||||||
Block sfx
|
Block sfx
|
||||||
Fix server hitboxes freaking out at animation end
|
Fix server hitboxes freaking out at animation end
|
||||||
Fix hitcapsule misalignment
|
Fix hitcapsule misalignment
|
||||||
|
Always upright tree
|
||||||
|
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
@ -572,6 +573,7 @@ Transvoxel implementation
|
|||||||
Terrain Interface Positional Access Interface
|
Terrain Interface Positional Access Interface
|
||||||
- Ability to get terrain at point for interactions with game world eg placing grass/water collision
|
- Ability to get terrain at point for interactions with game world eg placing grass/water collision
|
||||||
|
|
||||||
|
Fix hitbox placement does not scale with entity scale on server
|
||||||
|
|
||||||
Fix not all grass tiles update when updating a nearby voxel (ie it doesn't go into negative coordinates to scan for foliage updates)
|
Fix not all grass tiles update when updating a nearby voxel (ie it doesn't go into negative coordinates to scan for foliage updates)
|
||||||
|
|
||||||
|
|||||||
@ -305,6 +305,12 @@ public class EntityDataStrings {
|
|||||||
*/
|
*/
|
||||||
public static final String TREE_SERVERPHYSICSSYNCTREE = "treeServerPhysicsSyncTree";
|
public static final String TREE_SERVERPHYSICSSYNCTREE = "treeServerPhysicsSyncTree";
|
||||||
public static final String TREE_CLIENTPHYSICSSYNCTREE = "treeClientPhysicsSyncTree";
|
public static final String TREE_CLIENTPHYSICSSYNCTREE = "treeClientPhysicsSyncTree";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Always upright tree
|
||||||
|
*/
|
||||||
|
public static final String TREE_CLIENTALWAYSUPRIGHTTREE = "treeClientAlwaysUprightTree";
|
||||||
|
public static final String TREE_SERVERALWAYSUPRIGHTTREE = "treeServerAlwaysUprightTree";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Entity categories
|
Entity categories
|
||||||
|
|||||||
@ -11,7 +11,6 @@ import electrosphere.server.datacell.ServerDataCell;
|
|||||||
import electrosphere.server.datacell.utils.DataCellSearchUtils;
|
import electrosphere.server.datacell.utils.DataCellSearchUtils;
|
||||||
import electrosphere.server.datacell.utils.EntityLookupUtils;
|
import electrosphere.server.datacell.utils.EntityLookupUtils;
|
||||||
import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils;
|
import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils;
|
||||||
import electrosphere.server.datacell.utils.ServerEntityTagUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entity utilities specifically for the server side
|
* Entity utilities specifically for the server side
|
||||||
|
|||||||
@ -0,0 +1,97 @@
|
|||||||
|
package electrosphere.entity.state.physicssync.upright;
|
||||||
|
|
||||||
|
import org.joml.Quaterniond;
|
||||||
|
import org.joml.Vector3d;
|
||||||
|
import org.ode4j.ode.DBody;
|
||||||
|
|
||||||
|
import electrosphere.collision.PhysicsEntityUtils;
|
||||||
|
import electrosphere.collision.PhysicsUtils;
|
||||||
|
import electrosphere.engine.Globals;
|
||||||
|
import electrosphere.entity.Entity;
|
||||||
|
import electrosphere.entity.EntityDataStrings;
|
||||||
|
import electrosphere.entity.EntityUtils;
|
||||||
|
import electrosphere.entity.btree.BehaviorTree;
|
||||||
|
import electrosphere.entity.state.physicssync.ClientPhysicsSyncTree;
|
||||||
|
|
||||||
|
public class ClientAlwaysUprightTree implements BehaviorTree {
|
||||||
|
|
||||||
|
//The parent entity for the tree
|
||||||
|
Entity parent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* @param parent
|
||||||
|
* @param params
|
||||||
|
*/
|
||||||
|
private ClientAlwaysUprightTree(Entity parent, Object ... params){
|
||||||
|
this.parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void simulate(float deltaTime) {
|
||||||
|
DBody body = PhysicsEntityUtils.getDBody(parent);
|
||||||
|
if(body != null){
|
||||||
|
Vector3d position = EntityUtils.getPosition(parent);
|
||||||
|
Quaterniond sourceRotation = new Quaterniond(EntityUtils.getRotation(parent));
|
||||||
|
Vector3d linearVelocity = new Vector3d();
|
||||||
|
Vector3d angularVelocity = new Vector3d();
|
||||||
|
Vector3d linearForce = new Vector3d();
|
||||||
|
Vector3d angularForce = new Vector3d();
|
||||||
|
|
||||||
|
//make sure rotation is vertical
|
||||||
|
// sourceRotation = sourceRotation.mul(0.001, 1, 0.001, 1).normalize();
|
||||||
|
|
||||||
|
EntityUtils.getPosition(parent).set(position);
|
||||||
|
EntityUtils.getRotation(parent).set(sourceRotation);
|
||||||
|
PhysicsUtils.synchronizeData(Globals.clientSceneWrapper.getCollisionEngine(), body, position, sourceRotation, linearVelocity, angularVelocity, linearForce, angularForce);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p> (initially) Automatically generated </p>
|
||||||
|
* <p>
|
||||||
|
* Attaches this tree to the entity.
|
||||||
|
* </p>
|
||||||
|
* @param entity The entity to attach to
|
||||||
|
* @param tree The behavior tree to attach
|
||||||
|
* @param params Optional parameters that will be provided to the constructor
|
||||||
|
*/
|
||||||
|
public static ClientAlwaysUprightTree attachTree(Entity parent, Object ... params){
|
||||||
|
ClientAlwaysUprightTree rVal = new ClientAlwaysUprightTree(parent,params);
|
||||||
|
//!!WARNING!! from here below should not be touched
|
||||||
|
//This was generated automatically to properly alert various systems that the btree exists and should be tracked
|
||||||
|
parent.putData(EntityDataStrings.TREE_CLIENTALWAYSUPRIGHTTREE, rVal);
|
||||||
|
Globals.clientSceneWrapper.getScene().registerBehaviorTree(rVal);
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p> Automatically generated </p>
|
||||||
|
* <p>
|
||||||
|
* Detatches this tree from the entity.
|
||||||
|
* </p>
|
||||||
|
* @param entity The entity to detach to
|
||||||
|
* @param tree The behavior tree to detach
|
||||||
|
*/
|
||||||
|
public static void detachTree(Entity entity, BehaviorTree tree){
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the entity has a physics sync tree
|
||||||
|
* @param entity The entity to check
|
||||||
|
* @return True if the entity contains a physics sync tree, false otherwise
|
||||||
|
*/
|
||||||
|
public static boolean hasTree(Entity entity){
|
||||||
|
return entity.containsKey(EntityDataStrings.TREE_CLIENTALWAYSUPRIGHTTREE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the client physics sync tree on the entity
|
||||||
|
* @param entity The entity
|
||||||
|
* @return The tree if it exists, null otherwise
|
||||||
|
*/
|
||||||
|
public static ClientPhysicsSyncTree getTree(Entity entity){
|
||||||
|
return (ClientPhysicsSyncTree)entity.getData(EntityDataStrings.TREE_CLIENTALWAYSUPRIGHTTREE);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,98 @@
|
|||||||
|
package electrosphere.entity.state.physicssync.upright;
|
||||||
|
|
||||||
|
import org.joml.Quaterniond;
|
||||||
|
import org.joml.Vector3d;
|
||||||
|
import org.ode4j.ode.DBody;
|
||||||
|
|
||||||
|
import electrosphere.collision.PhysicsEntityUtils;
|
||||||
|
import electrosphere.collision.PhysicsUtils;
|
||||||
|
import electrosphere.engine.Globals;
|
||||||
|
import electrosphere.entity.Entity;
|
||||||
|
import electrosphere.entity.EntityDataStrings;
|
||||||
|
import electrosphere.entity.EntityUtils;
|
||||||
|
import electrosphere.entity.btree.BehaviorTree;
|
||||||
|
import electrosphere.entity.state.physicssync.ServerPhysicsSyncTree;
|
||||||
|
import electrosphere.server.datacell.Realm;
|
||||||
|
import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils;
|
||||||
|
|
||||||
|
public class ServerAlwaysUprightTree implements BehaviorTree {
|
||||||
|
|
||||||
|
//The parent entity for the tree
|
||||||
|
Entity parent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* @param parent
|
||||||
|
* @param params
|
||||||
|
*/
|
||||||
|
private ServerAlwaysUprightTree(Entity parent, Object ... params){
|
||||||
|
this.parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void simulate(float deltaTime) {
|
||||||
|
DBody body = PhysicsEntityUtils.getDBody(parent);
|
||||||
|
if(body != null){
|
||||||
|
Realm realm = Globals.realmManager.getEntityRealm(parent);
|
||||||
|
Vector3d position = EntityUtils.getPosition(parent);
|
||||||
|
Quaterniond sourceRotation = new Quaterniond(EntityUtils.getRotation(parent));
|
||||||
|
Vector3d linearVelocity = new Vector3d();
|
||||||
|
Vector3d angularVelocity = new Vector3d();
|
||||||
|
Vector3d linearForce = new Vector3d();
|
||||||
|
Vector3d angularForce = new Vector3d();
|
||||||
|
|
||||||
|
//make sure rotation is vertical
|
||||||
|
// sourceRotation = sourceRotation.mul(0.001, 1, 0.001, 1).normalize();
|
||||||
|
|
||||||
|
EntityUtils.getPosition(parent).set(position);
|
||||||
|
EntityUtils.getRotation(parent).set(sourceRotation);
|
||||||
|
PhysicsUtils.synchronizeData(realm.getCollisionEngine(), body, position, sourceRotation, linearVelocity, angularVelocity, linearForce, angularForce);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* Attaches this tree to the entity.
|
||||||
|
* </p>
|
||||||
|
* @param entity The entity to attach to
|
||||||
|
* @param tree The behavior tree to attach
|
||||||
|
* @param params Optional parameters that will be provided to the constructor
|
||||||
|
*/
|
||||||
|
public static ServerAlwaysUprightTree attachTree(Entity parent, Object ... params){
|
||||||
|
ServerAlwaysUprightTree rVal = new ServerAlwaysUprightTree(parent,params);
|
||||||
|
//!!WARNING!! from here below should not be touched
|
||||||
|
//This was generated automatically to properly alert various systems that the btree exists and should be tracked
|
||||||
|
ServerBehaviorTreeUtils.attachBTreeToEntity(parent, rVal);
|
||||||
|
parent.putData(EntityDataStrings.TREE_SERVERALWAYSUPRIGHTTREE, rVal);
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* Detatches this tree from the entity.
|
||||||
|
* </p>
|
||||||
|
* @param entity The entity to detach to
|
||||||
|
* @param tree The behavior tree to detach
|
||||||
|
*/
|
||||||
|
public static void detachTree(Entity entity, BehaviorTree tree){
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the entity has a physics sync tree
|
||||||
|
* @param entity The entity to check
|
||||||
|
* @return True if the entity contains a physics sync tree, false otherwise
|
||||||
|
*/
|
||||||
|
public static boolean hasTree(Entity entity){
|
||||||
|
return entity.containsKey(EntityDataStrings.TREE_SERVERALWAYSUPRIGHTTREE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the server physics sync tree on the entity
|
||||||
|
* @param entity The entity
|
||||||
|
* @return The tree if it exists, null otherwise
|
||||||
|
*/
|
||||||
|
public static ServerPhysicsSyncTree getTree(Entity entity){
|
||||||
|
return (ServerPhysicsSyncTree)entity.getData(EntityDataStrings.TREE_SERVERALWAYSUPRIGHTTREE);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -41,6 +41,8 @@ import electrosphere.entity.state.movement.groundmove.ClientGroundMovementTree;
|
|||||||
import electrosphere.entity.state.movement.groundmove.ServerGroundMovementTree;
|
import electrosphere.entity.state.movement.groundmove.ServerGroundMovementTree;
|
||||||
import electrosphere.entity.state.movement.jump.ClientJumpTree;
|
import electrosphere.entity.state.movement.jump.ClientJumpTree;
|
||||||
import electrosphere.entity.state.movement.jump.ServerJumpTree;
|
import electrosphere.entity.state.movement.jump.ServerJumpTree;
|
||||||
|
import electrosphere.entity.state.physicssync.upright.ClientAlwaysUprightTree;
|
||||||
|
import electrosphere.entity.state.physicssync.upright.ServerAlwaysUprightTree;
|
||||||
import electrosphere.entity.state.rotator.RotatorHierarchyNode;
|
import electrosphere.entity.state.rotator.RotatorHierarchyNode;
|
||||||
import electrosphere.entity.state.rotator.RotatorTree;
|
import electrosphere.entity.state.rotator.RotatorTree;
|
||||||
import electrosphere.entity.state.rotator.ServerRotatorTree;
|
import electrosphere.entity.state.rotator.ServerRotatorTree;
|
||||||
@ -115,6 +117,7 @@ public class CreatureUtils {
|
|||||||
if(rawType.getCollidable() != null){
|
if(rawType.getCollidable() != null){
|
||||||
CollidableTemplate physicsTemplate = rawType.getCollidable();
|
CollidableTemplate physicsTemplate = rawType.getCollidable();
|
||||||
PhysicsEntityUtils.clientAttachCollidableTemplate(rVal, physicsTemplate);
|
PhysicsEntityUtils.clientAttachCollidableTemplate(rVal, physicsTemplate);
|
||||||
|
ClientAlwaysUprightTree.attachTree(rVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -384,6 +387,7 @@ public class CreatureUtils {
|
|||||||
if(rawType.getCollidable() != null){
|
if(rawType.getCollidable() != null){
|
||||||
CollidableTemplate physicsTemplate = rawType.getCollidable();
|
CollidableTemplate physicsTemplate = rawType.getCollidable();
|
||||||
PhysicsEntityUtils.serverAttachCollidableTemplate(realm, rVal, physicsTemplate);
|
PhysicsEntityUtils.serverAttachCollidableTemplate(realm, rVal, physicsTemplate);
|
||||||
|
ServerAlwaysUprightTree.attachTree(rVal);
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user