cursor object pooling
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
0bb66aa0b4
commit
f6f6bfa15c
@ -2143,6 +2143,9 @@ Frametime reporting work
|
||||
Raycast allocation fix
|
||||
Fix single block shader
|
||||
|
||||
(06/09/2025)
|
||||
Cursor object pooling
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -22,6 +22,7 @@ import electrosphere.entity.EntityCreationUtils;
|
||||
import electrosphere.entity.EntityTags;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.state.equip.ClientToolbarState;
|
||||
import electrosphere.mem.JomlPool;
|
||||
import electrosphere.renderer.actor.Actor;
|
||||
import electrosphere.renderer.actor.mask.ActorTextureMask;
|
||||
import electrosphere.renderer.meshgen.BlockMeshgen;
|
||||
@ -205,17 +206,19 @@ public class CursorState {
|
||||
camera != null &&
|
||||
Globals.cursorState.playerCursor != null
|
||||
){
|
||||
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(camera));
|
||||
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(camera));
|
||||
Vector3d cursorPos = collisionEngine.rayCastPosition(centerPos, new Vector3d(eyePos).mul(-1.0), CollisionEngine.DEFAULT_INTERACT_DISTANCE);
|
||||
Vector3d eyePos = JomlPool.getD();
|
||||
eyePos.set(CameraEntityUtils.getCameraEye(camera)).mul(-1.0);
|
||||
Vector3d centerPos = JomlPool.getD();
|
||||
centerPos.set(CameraEntityUtils.getCameraCenter(camera));
|
||||
Vector3d cursorPos = collisionEngine.rayCastPosition(centerPos, eyePos, CollisionEngine.DEFAULT_INTERACT_DISTANCE);
|
||||
if(cursorPos == null){
|
||||
cursorPos = new Vector3d(centerPos).add(new Vector3d(eyePos).normalize().mul(-CollisionEngine.DEFAULT_INTERACT_DISTANCE));
|
||||
cursorPos = centerPos.add(eyePos.normalize().mul(CollisionEngine.DEFAULT_INTERACT_DISTANCE));
|
||||
}
|
||||
EntityUtils.setPosition(Globals.cursorState.playerCursor, cursorPos);
|
||||
|
||||
//clamp block cursor to nearest voxel
|
||||
if(clampToExistingBlock){
|
||||
cursorPos = cursorPos.add(new Vector3d(eyePos).normalize().mul(-BlockChunkData.BLOCK_SIZE_MULTIPLIER));
|
||||
cursorPos = cursorPos.add(eyePos.normalize().mul(BlockChunkData.BLOCK_SIZE_MULTIPLIER));
|
||||
}
|
||||
cursorPos.set(this.clampPositionToNearestBlock(cursorPos));
|
||||
if(Globals.cursorState.playerBlockCursor != null){
|
||||
@ -227,6 +230,10 @@ public class CursorState {
|
||||
CursorState.nudgeGridAlignment(cursorPos,gridAlignmentData);
|
||||
}
|
||||
EntityUtils.setPosition(CursorState.playerGridAlignedCursor, cursorPos);
|
||||
|
||||
//release to pool
|
||||
JomlPool.release(eyePos);
|
||||
JomlPool.release(centerPos);
|
||||
}
|
||||
Globals.profiler.endCpuSample();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user