floating world origin work
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
47e0ee824c
commit
90031765a9
@ -1934,6 +1934,8 @@ Geom-only collidables on server
|
||||
Block colliders leveraging spaces
|
||||
Scene view debug window
|
||||
Debug view of entity colliders
|
||||
Fix lookup bug in debug physics ui
|
||||
Floating point starting to play nice with engine
|
||||
|
||||
|
||||
|
||||
|
||||
@ -122,6 +122,10 @@ public class ClientSimulation {
|
||||
Globals.clientState.clientSceneWrapper.getChemistryEngine().clearCollidableImpulseLists();
|
||||
Globals.profiler.endCpuSample();
|
||||
|
||||
//
|
||||
//Rebase world origin
|
||||
Globals.clientState.clientSceneWrapper.getCollisionEngine().rebaseWorldOrigin();
|
||||
|
||||
//
|
||||
//wrap up functions
|
||||
this.runClientFunctions();
|
||||
|
||||
@ -64,6 +64,7 @@ public class ImGuiEntityMacros {
|
||||
private static boolean filterToCreatures = false; //filters the entity list to just creatures
|
||||
private static boolean filterToFoliage = false; //filters the entity list to just foliage
|
||||
private static boolean filterToTerrain = false; //filters the entity list to just terrain
|
||||
private static boolean filterHasCollidable = false; //filters the entity list to just entities that have collidables
|
||||
|
||||
//window for viewing details about an entity
|
||||
protected static ImGuiWindow clientEntityDetailWindow;
|
||||
@ -118,6 +119,9 @@ public class ImGuiEntityMacros {
|
||||
if(ImGui.checkbox("Filter to Terrain", filterToTerrain)){
|
||||
filterToTerrain = !filterToTerrain;
|
||||
}
|
||||
if(ImGui.checkbox("Filter has Collidable", filterHasCollidable)){
|
||||
filterHasCollidable = !filterHasCollidable;
|
||||
}
|
||||
for(Entity entity : Globals.clientState.clientSceneWrapper.getScene().getEntityList()){
|
||||
//filters
|
||||
if(filterToCreatures && !CreatureUtils.isCreature(entity)){
|
||||
@ -129,6 +133,9 @@ public class ImGuiEntityMacros {
|
||||
if(filterToTerrain && !TerrainChunk.isTerrainEntity(entity)){
|
||||
continue;
|
||||
}
|
||||
if(filterHasCollidable && PhysicsEntityUtils.getCollidable(entity) == null){
|
||||
continue;
|
||||
}
|
||||
if(filterBasic &&
|
||||
(
|
||||
AmbientFoliage.getAmbientFoliageTree(entity) != null ||
|
||||
|
||||
@ -10,7 +10,6 @@ import electrosphere.data.entity.collidable.CollidableTemplate;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.server.datacell.utils.EntityLookupUtils;
|
||||
import imgui.ImGui;
|
||||
@ -29,8 +28,8 @@ public class ImGuiEntityPhysicsTab {
|
||||
if(PhysicsEntityUtils.getDBody(detailViewEntity) != null){
|
||||
DBody physicsBody = PhysicsEntityUtils.getDBody(detailViewEntity);
|
||||
if(physicsBody != null){
|
||||
ImGui.text("Position: " + EntityUtils.getPosition(detailViewEntity));
|
||||
ImGui.text("Rotation: " + EntityUtils.getRotation(detailViewEntity));
|
||||
ImGui.text("Position: " + physicsBody.getPosition());
|
||||
ImGui.text("Rotation: " + physicsBody.getQuaternion());
|
||||
ImGui.text("Velocity: " + physicsBody.getLinearVel());
|
||||
ImGui.text("Force: " + physicsBody.getForce());
|
||||
ImGui.text("Angular Velocity: " + physicsBody.getAngularVel());
|
||||
@ -53,8 +52,8 @@ public class ImGuiEntityPhysicsTab {
|
||||
if(serverPhysicsBody != null){
|
||||
ImGui.newLine();
|
||||
ImGui.text("Linked server entity:");
|
||||
ImGui.text("Position (Server): " + EntityUtils.getPosition(serverEntity));
|
||||
ImGui.text("Rotation (Server): " + EntityUtils.getRotation(serverEntity));
|
||||
ImGui.text("Position (Server): " + physicsBody.getPosition());
|
||||
ImGui.text("Rotation (Server): " + physicsBody.getQuaternion());
|
||||
ImGui.text("Velocity (Server): " + serverPhysicsBody.getLinearVel());
|
||||
ImGui.text("Force (Server): " + serverPhysicsBody.getForce());
|
||||
ImGui.text("Angular Velocity: " + serverPhysicsBody.getAngularVel());
|
||||
@ -73,8 +72,8 @@ public class ImGuiEntityPhysicsTab {
|
||||
if(clientPhysicsBody != null){
|
||||
ImGui.newLine();
|
||||
ImGui.text("Linked client entity:");
|
||||
ImGui.text("Position (Client): " + EntityUtils.getPosition(clientEntity));
|
||||
ImGui.text("Rotation (Client): " + EntityUtils.getRotation(clientEntity));
|
||||
ImGui.text("Position (Client): " + physicsBody.getPosition());
|
||||
ImGui.text("Rotation (Client): " + physicsBody.getQuaternion());
|
||||
ImGui.text("Velocity (Client): " + clientPhysicsBody.getLinearVel());
|
||||
ImGui.text("Force (Client): " + clientPhysicsBody.getForce());
|
||||
ImGui.text("Angular Velocity: " + clientPhysicsBody.getAngularVel());
|
||||
|
||||
@ -94,6 +94,11 @@ public class CollisionEngine {
|
||||
* Default distance to interact with collidables at (ie picking where to place things)
|
||||
*/
|
||||
public static final double DEFAULT_INTERACT_DISTANCE = 5.0;
|
||||
|
||||
/**
|
||||
* Distance from current floating point origin to trigger a rebase
|
||||
*/
|
||||
private static final double REBASE_TRIGGER_DISTANCE = 500;
|
||||
|
||||
/**
|
||||
* world data that the collision engine leverages for position correction and the like
|
||||
@ -698,7 +703,7 @@ public class CollisionEngine {
|
||||
if(geom != null){
|
||||
if(geom instanceof DSpace space){
|
||||
for(DGeom child : space.getGeoms()){
|
||||
Vector3d currentBodyOffset = PhysicsUtils.odeVecToJomlVec(child.getPosition());
|
||||
Vector3d currentBodyOffset = PhysicsUtils.odeVecToJomlVec(child.getPosition()).add(this.floatingOrigin);
|
||||
if(collected == 0){
|
||||
newOrigin.set(currentBodyOffset);
|
||||
} else {
|
||||
@ -709,7 +714,7 @@ public class CollisionEngine {
|
||||
collected++;
|
||||
}
|
||||
} else {
|
||||
Vector3d currentBodyOffset = PhysicsUtils.odeVecToJomlVec(geom.getPosition());
|
||||
Vector3d currentBodyOffset = PhysicsUtils.odeVecToJomlVec(geom.getPosition()).add(this.floatingOrigin);
|
||||
if(collected == 0){
|
||||
newOrigin.set(currentBodyOffset);
|
||||
} else {
|
||||
@ -721,27 +726,32 @@ public class CollisionEngine {
|
||||
}
|
||||
}
|
||||
}
|
||||
Vector3d delta = new Vector3d(this.floatingOrigin).sub(newOrigin);
|
||||
this.floatingOrigin = this.floatingOrigin.set(newOrigin);
|
||||
//apply new origin to all geoms
|
||||
//calculate new origin
|
||||
for(Collidable collidable : collidableList){
|
||||
Entity physicsEntity = collidable.getParent();
|
||||
DBody rigidBody = PhysicsEntityUtils.getDBody(physicsEntity);
|
||||
if(rigidBody != null){
|
||||
Vector3d existingPosition = PhysicsUtils.odeVecToJomlVec(rigidBody.getPosition());
|
||||
rigidBody.setPosition(PhysicsUtils.jomlVecToOdeVec(existingPosition.add(delta)));
|
||||
}
|
||||
DGeom geom = PhysicsEntityUtils.getDGeom(physicsEntity);
|
||||
if(geom != null){
|
||||
if(geom instanceof DSpace space){
|
||||
for(DGeom child : space.getGeoms()){
|
||||
Vector3d existingPosition = PhysicsUtils.odeVecToJomlVec(child.getPosition());
|
||||
child.setPosition(PhysicsUtils.jomlVecToOdeVec(existingPosition.add(delta)));
|
||||
Vector3d delta = new Vector3d(this.floatingOrigin);
|
||||
delta = delta.sub(newOrigin);
|
||||
|
||||
//only perform rebase if sufficiently far away
|
||||
if(delta.length() > REBASE_TRIGGER_DISTANCE){
|
||||
this.floatingOrigin = newOrigin;
|
||||
//apply new origin to all geoms
|
||||
//calculate new origin
|
||||
for(Collidable collidable : collidableList){
|
||||
Entity physicsEntity = collidable.getParent();
|
||||
DBody rigidBody = PhysicsEntityUtils.getDBody(physicsEntity);
|
||||
if(rigidBody != null){
|
||||
Vector3d existingPosition = PhysicsUtils.odeVecToJomlVec(rigidBody.getPosition());
|
||||
rigidBody.setPosition(PhysicsUtils.jomlVecToOdeVec(existingPosition.add(delta)));
|
||||
}
|
||||
DGeom geom = PhysicsEntityUtils.getDGeom(physicsEntity);
|
||||
if(geom != null){
|
||||
if(geom instanceof DSpace space){
|
||||
for(DGeom child : space.getGeoms()){
|
||||
Vector3d existingPosition = PhysicsUtils.odeVecToJomlVec(child.getPosition());
|
||||
child.setPosition(PhysicsUtils.jomlVecToOdeVec(existingPosition.add(delta)));
|
||||
}
|
||||
} else {
|
||||
Vector3d existingPosition = PhysicsUtils.odeVecToJomlVec(geom.getPosition());
|
||||
geom.setPosition(PhysicsUtils.jomlVecToOdeVec(existingPosition.add(delta)));
|
||||
}
|
||||
} else {
|
||||
Vector3d existingPosition = PhysicsUtils.odeVecToJomlVec(geom.getPosition());
|
||||
geom.setPosition(PhysicsUtils.jomlVecToOdeVec(existingPosition.add(delta)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1483,6 +1493,7 @@ public class CollisionEngine {
|
||||
"Geom Ptrs: " + this.geomPointerMap.size() + "\n" +
|
||||
"Collidables: " + this.collidableList.size() + "\n" +
|
||||
"Space geom count: " + this.space.getNumGeoms() + "\n" +
|
||||
"Floating origin: " + this.floatingOrigin.x + "," + this.floatingOrigin.y + "," + this.floatingOrigin.z + "\n" +
|
||||
""
|
||||
;
|
||||
return message;
|
||||
|
||||
@ -63,8 +63,12 @@ public class ClientPhysicsSyncTree implements BehaviorTree {
|
||||
//bust distance caches if this is the player's entity and we've traveled a long distance suddenly
|
||||
if(parent == Globals.clientState.playerEntity){
|
||||
if(position.distance(EntityUtils.getPosition(parent)) > FoliageCellManager.TELEPORT_DISTANCE){
|
||||
Globals.clientState.clientDrawCellManager.bustDistanceCache();
|
||||
Globals.clientState.foliageCellManager.bustDistanceCache();
|
||||
if(Globals.clientState.clientDrawCellManager != null){
|
||||
Globals.clientState.clientDrawCellManager.bustDistanceCache();
|
||||
}
|
||||
if(Globals.clientState.foliageCellManager != null){
|
||||
Globals.clientState.foliageCellManager.bustDistanceCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -90,9 +90,7 @@ public class TerrainChunk {
|
||||
}
|
||||
LoggerInterface.loggerEngine.DEBUG("Finished generating terrain polygons; however, entity has already been deleted.");
|
||||
}
|
||||
} catch (Error e){
|
||||
LoggerInterface.loggerEngine.ERROR(e);
|
||||
} catch(Exception e){
|
||||
} catch (Throwable e){
|
||||
LoggerInterface.loggerEngine.ERROR(e);
|
||||
}
|
||||
});
|
||||
|
||||
@ -843,9 +843,7 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
|
||||
|
||||
//set ready
|
||||
dataCell.setReady(true);
|
||||
} catch(Exception ex){
|
||||
LoggerInterface.loggerEngine.ERROR(ex);
|
||||
} catch (Error ex){
|
||||
} catch(Throwable ex){
|
||||
LoggerInterface.loggerEngine.ERROR(ex);
|
||||
}
|
||||
});
|
||||
|
||||
@ -3,6 +3,7 @@ package electrosphere.server.macro.character;
|
||||
import org.joml.Vector3d;
|
||||
import org.joml.Vector3i;
|
||||
|
||||
import electrosphere.collision.PhysicsEntityUtils;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.state.server.ServerCharacterData;
|
||||
@ -59,6 +60,8 @@ public class PlayerCharacterCreation {
|
||||
//must come after the player is assigned, otherwise the player will not get the item attachment messages
|
||||
CreatureUtils.serverApplyTemplate(realm, newPlayerEntity, template);
|
||||
|
||||
PhysicsEntityUtils.disableBody(realm.getCollisionEngine(), newPlayerEntity);
|
||||
|
||||
//if macro data hasn't been generated in this area, generate it
|
||||
//but only if it's a player's entity
|
||||
realm.updateMacroData(spawnPoint);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user