fix entity position updates

This commit is contained in:
austin 2025-06-08 18:41:32 -04:00
parent 96de6ad8e8
commit ab1c1c36bf
8 changed files with 13 additions and 10 deletions

View File

@ -2132,6 +2132,9 @@ Fix scene re-adding tree that was previously removed
Fix client toolbar update deleting entity that shouldn't be deleted Fix client toolbar update deleting entity that shouldn't be deleted
Fix attachment bug Fix attachment bug
Fix cursor position setting Fix cursor position setting
Fix many places where entity position being set on vector fetched from getPosition
- Fixed first person model placement update
- Fixed skybox placement update

View File

@ -29,7 +29,7 @@ public class DebugVisualizerUtils {
Entity rVal = EntityCreationUtils.createClientSpatialEntity(); Entity rVal = EntityCreationUtils.createClientSpatialEntity();
EntityCreationUtils.makeEntityDrawable(rVal, "Models/basic/geometry/unitvector.glb"); EntityCreationUtils.makeEntityDrawable(rVal, "Models/basic/geometry/unitvector.glb");
Vector3d pos = new Vector3d(position); Vector3d pos = new Vector3d(position);
EntityUtils.getPosition(rVal).set(pos); EntityUtils.setPosition(rVal, pos);
EntityUtils.getScale(rVal).set(scale); EntityUtils.getScale(rVal).set(scale);
EntityUtils.getRotation(rVal).set(rotation); EntityUtils.getRotation(rVal).set(rotation);
return rVal; return rVal;

View File

@ -149,7 +149,7 @@ public class ParticleService extends SignalServiceImpl {
Entity rVal = EntityCreationUtils.createClientSpatialEntity(); Entity rVal = EntityCreationUtils.createClientSpatialEntity();
InstancedEntityUtils.makeEntityInstancedWithModelTransform(rVal, instanceTemplate, modelAttrib); InstancedEntityUtils.makeEntityInstancedWithModelTransform(rVal, instanceTemplate, modelAttrib);
DrawableUtils.makeEntityTransparent(rVal); DrawableUtils.makeEntityTransparent(rVal);
EntityUtils.getPosition(rVal).set(position); EntityUtils.setPosition(rVal, position);
EntityUtils.getRotation(rVal).set(rotation); EntityUtils.getRotation(rVal).set(rotation);
EntityUtils.getScale(rVal).set(data.getSize()); EntityUtils.getScale(rVal).set(data.getSize());
ClientParticleTree.attachTree(rVal, data); ClientParticleTree.attachTree(rVal, data);

View File

@ -173,7 +173,7 @@ public class ClientSimulation {
private void updateSkyboxPos(){ private void updateSkyboxPos(){
Globals.profiler.beginCpuSample("updateSkyboxPos"); Globals.profiler.beginCpuSample("updateSkyboxPos");
if(Globals.clientState.skybox != null && Globals.clientState.playerEntity != null){ if(Globals.clientState.skybox != null && Globals.clientState.playerEntity != null){
EntityUtils.getPosition(Globals.clientState.skybox).set(EntityUtils.getPosition(Globals.clientState.playerEntity)); EntityUtils.setPosition(Globals.clientState.skybox, EntityUtils.getPosition(Globals.clientState.playerEntity));
} }
Globals.profiler.endCpuSample(); Globals.profiler.endCpuSample();
} }

View File

@ -300,7 +300,7 @@ public class CursorState {
EntityCreationUtils.makeEntityDrawable(Globals.cursorState.playerAreaCursor, AssetDataStrings.UNITCUBE); EntityCreationUtils.makeEntityDrawable(Globals.cursorState.playerAreaCursor, AssetDataStrings.UNITCUBE);
Actor areaCursorActor = EntityUtils.getActor(Globals.cursorState.playerAreaCursor); Actor areaCursorActor = EntityUtils.getActor(Globals.cursorState.playerAreaCursor);
areaCursorActor.addTextureMask(new ActorTextureMask("cube", Arrays.asList(new String[]{"Textures/transparent_red.png"}))); areaCursorActor.addTextureMask(new ActorTextureMask("cube", Arrays.asList(new String[]{"Textures/transparent_red.png"})));
EntityUtils.getPosition(Globals.cursorState.playerAreaCursor).set(center); EntityUtils.setPosition(Globals.cursorState.playerAreaCursor, center);
EntityUtils.getScale(Globals.cursorState.playerAreaCursor).set(scale); EntityUtils.getScale(Globals.cursorState.playerAreaCursor).set(scale);
} }

View File

@ -84,7 +84,7 @@ public class AttachUtils {
} else if(currentEntity.getData(EntityDataStrings.ATTACH_TARGET_BASE)!=null){ } else if(currentEntity.getData(EntityDataStrings.ATTACH_TARGET_BASE)!=null){
Vector3d positionOffset = getVectorOffset(currentEntity); Vector3d positionOffset = getVectorOffset(currentEntity);
Vector3d parentPosition = EntityUtils.getPosition(parent); Vector3d parentPosition = EntityUtils.getPosition(parent);
EntityUtils.getPosition(currentEntity).set(new Vector3d(parentPosition).add(positionOffset)); EntityUtils.setPosition(currentEntity, new Vector3d(parentPosition).add(positionOffset));
} }
} }
} }
@ -124,7 +124,7 @@ public class AttachUtils {
//transform worldspace //transform worldspace
// position.add(new Vector3d(EntityUtils.getPosition(parent))); // position.add(new Vector3d(EntityUtils.getPosition(parent)));
//set //set
EntityUtils.getPosition(currentEntity).set(position); EntityUtils.setPosition(currentEntity, position);
EntityUtils.getRotation(currentEntity).set(rotation); EntityUtils.getRotation(currentEntity).set(rotation);
EntityUtils.getScale(currentEntity).set(scale); EntityUtils.getScale(currentEntity).set(scale);
} }
@ -182,7 +182,7 @@ public class AttachUtils {
} else if(currentEntity.getData(EntityDataStrings.ATTACH_TARGET_BASE)!=null){ } else if(currentEntity.getData(EntityDataStrings.ATTACH_TARGET_BASE)!=null){
Vector3d positionOffset = getVectorOffset(currentEntity); Vector3d positionOffset = getVectorOffset(currentEntity);
Vector3d parentPosition = EntityUtils.getPosition(parent); Vector3d parentPosition = EntityUtils.getPosition(parent);
EntityUtils.getPosition(currentEntity).set(new Vector3d(parentPosition).add(positionOffset)); EntityUtils.setPosition(currentEntity, new Vector3d(parentPosition).add(positionOffset));
} }
} }
Globals.profiler.endCpuSample(); Globals.profiler.endCpuSample();
@ -251,7 +251,7 @@ public class AttachUtils {
//transform worldspace //transform worldspace
// position.add(new Vector3d(EntityUtils.getPosition(parent))); // position.add(new Vector3d(EntityUtils.getPosition(parent)));
//set //set
EntityUtils.getPosition(currentEntity).set(position); EntityUtils.setPosition(currentEntity, position);
EntityUtils.getRotation(currentEntity).set(rotation); EntityUtils.getRotation(currentEntity).set(rotation);
EntityUtils.getScale(currentEntity).set(scale); EntityUtils.getScale(currentEntity).set(scale);
} }

View File

@ -104,7 +104,7 @@ public class ClientParticleTree implements BehaviorTree {
//update position //update position
position.add(velocity); position.add(velocity);
EntityUtils.getPosition(parent).set(position); EntityUtils.setPosition(parent, position);
//update velocity //update velocity
Vector3d accelerationVec = new Vector3d(velocity).normalize().mul(acceleration); Vector3d accelerationVec = new Vector3d(velocity).normalize().mul(acceleration);

View File

@ -102,7 +102,7 @@ public class FirstPersonItemsPipeline implements RenderPipeline {
Vector3d playerPos = EntityUtils.getPosition(Globals.clientState.playerEntity); Vector3d playerPos = EntityUtils.getPosition(Globals.clientState.playerEntity);
Vector4d behindCameraOffsetRaw = rotationMat.transform(new Vector4d(0,tree.getCameraViewDirOffsetY(),tree.getCameraViewDirOffsetZ(),1)); //pushes the model behind the camera Vector4d behindCameraOffsetRaw = rotationMat.transform(new Vector4d(0,tree.getCameraViewDirOffsetY(),tree.getCameraViewDirOffsetZ(),1)); //pushes the model behind the camera
Vector3d behindCameraOffset = new Vector3d(behindCameraOffsetRaw.x,behindCameraOffsetRaw.y,behindCameraOffsetRaw.z); Vector3d behindCameraOffset = new Vector3d(behindCameraOffsetRaw.x,behindCameraOffsetRaw.y,behindCameraOffsetRaw.z);
EntityUtils.getPosition(Globals.clientState.firstPersonEntity).set(playerPos).add(0.0f,tree.getHeightFromOrigin(),0.0f).add(behindCameraOffset); EntityUtils.setPosition(Globals.clientState.firstPersonEntity, new Vector3d(playerPos).add(0.0f,tree.getHeightFromOrigin(),0.0f).add(behindCameraOffset));
if(ClientEquipState.hasEquipState(Globals.clientState.playerEntity)){ if(ClientEquipState.hasEquipState(Globals.clientState.playerEntity)){
ClientEquipState clientEquipState = ClientEquipState.getClientEquipState(Globals.clientState.playerEntity); ClientEquipState clientEquipState = ClientEquipState.getClientEquipState(Globals.clientState.playerEntity);