more vector pooling
This commit is contained in:
parent
feac1383da
commit
45a4115675
@ -1987,6 +1987,7 @@ Performance improvements
|
|||||||
- Behavior tree addition/subtraction from scene optimization
|
- Behavior tree addition/subtraction from scene optimization
|
||||||
- Reduce bones on LOD human model
|
- Reduce bones on LOD human model
|
||||||
- Shallow clone on physics cell creation
|
- Shallow clone on physics cell creation
|
||||||
|
- More vector pool usage
|
||||||
Increase human move speed
|
Increase human move speed
|
||||||
LOD components re-attach physics
|
LOD components re-attach physics
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,8 @@ import java.util.List;
|
|||||||
import org.joml.Quaterniond;
|
import org.joml.Quaterniond;
|
||||||
import org.joml.Vector3d;
|
import org.joml.Vector3d;
|
||||||
|
|
||||||
|
import electrosphere.mem.VectorPool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts data structures between formats saved to disk vs formats used in engine
|
* Converts data structures between formats saved to disk vs formats used in engine
|
||||||
*/
|
*/
|
||||||
@ -43,12 +45,12 @@ public class DataFormatUtil {
|
|||||||
*/
|
*/
|
||||||
public static Vector3d getDoubleListAsVector(List<Double> values){
|
public static Vector3d getDoubleListAsVector(List<Double> values){
|
||||||
if(values == null){
|
if(values == null){
|
||||||
return new Vector3d();
|
return VectorPool.getD();
|
||||||
}
|
}
|
||||||
if(values.size() > 0){
|
if(values.size() > 0){
|
||||||
return new Vector3d(values.get(0),values.get(1),values.get(2));
|
return VectorPool.getD(values.get(0),values.get(1),values.get(2));
|
||||||
} else {
|
} else {
|
||||||
return new Vector3d();
|
return VectorPool.getD();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import electrosphere.entity.EntityDataStrings;
|
|||||||
import electrosphere.entity.EntityTags;
|
import electrosphere.entity.EntityTags;
|
||||||
import electrosphere.entity.EntityUtils;
|
import electrosphere.entity.EntityUtils;
|
||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
|
import electrosphere.mem.VectorPool;
|
||||||
import electrosphere.renderer.actor.Actor;
|
import electrosphere.renderer.actor.Actor;
|
||||||
import electrosphere.server.datacell.ServerDataCell;
|
import electrosphere.server.datacell.ServerDataCell;
|
||||||
import electrosphere.server.datacell.utils.ServerEntityTagUtils;
|
import electrosphere.server.datacell.utils.ServerEntityTagUtils;
|
||||||
@ -346,7 +347,7 @@ public class AttachUtils {
|
|||||||
Vector3d parentScale
|
Vector3d parentScale
|
||||||
){
|
){
|
||||||
//transform bone space
|
//transform bone space
|
||||||
Vector3d position = new Vector3d(offsetVector);
|
Vector3d position = VectorPool.getD(offsetVector);
|
||||||
position = position.rotate(new Quaterniond(boneRotation));
|
position = position.rotate(new Quaterniond(boneRotation));
|
||||||
position = position.add(bonePosition);
|
position = position.add(bonePosition);
|
||||||
position = position.mul(parentScale);
|
position = position.mul(parentScale);
|
||||||
|
|||||||
@ -26,6 +26,7 @@ import electrosphere.entity.EntityUtils;
|
|||||||
import electrosphere.entity.state.attach.AttachUtils;
|
import electrosphere.entity.state.attach.AttachUtils;
|
||||||
import electrosphere.entity.state.hitbox.HitboxCollectionState.HitboxState.HitboxShapeType;
|
import electrosphere.entity.state.hitbox.HitboxCollectionState.HitboxState.HitboxShapeType;
|
||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
|
import electrosphere.mem.VectorPool;
|
||||||
import electrosphere.server.datacell.Realm;
|
import electrosphere.server.datacell.Realm;
|
||||||
import electrosphere.server.entity.poseactor.PoseActor;
|
import electrosphere.server.entity.poseactor.PoseActor;
|
||||||
import electrosphere.util.math.SpatialMathUtils;
|
import electrosphere.util.math.SpatialMathUtils;
|
||||||
@ -461,22 +462,29 @@ public class HitboxCollectionState {
|
|||||||
Quaterniond offsetRotation = new Quaterniond();
|
Quaterniond offsetRotation = new Quaterniond();
|
||||||
|
|
||||||
//the bone's transform
|
//the bone's transform
|
||||||
Vector3d bonePositionD = new Vector3d();
|
Vector3d bonePositionD = VectorPool.getD();
|
||||||
if(bonePosition != null){
|
if(bonePosition != null){
|
||||||
bonePositionD = new Vector3d(bonePosition);
|
bonePositionD.set(bonePosition);
|
||||||
}
|
}
|
||||||
Quaterniond boneRotation = new Quaterniond();
|
Quaterniond boneRotation = new Quaterniond();
|
||||||
|
|
||||||
//the parent's transform
|
//the parent's transform
|
||||||
Vector3d parentPosition = EntityUtils.getPosition(parent);
|
Vector3d parentPosition = EntityUtils.getPosition(parent);
|
||||||
Quaterniond parentRotation = EntityUtils.getRotation(parent);
|
Quaterniond parentRotation = EntityUtils.getRotation(parent);
|
||||||
Vector3d parentScale = new Vector3d(EntityUtils.getScale(parent));
|
Vector3d parentScale = VectorPool.getD();
|
||||||
|
parentScale.set(EntityUtils.getScale(parent));
|
||||||
|
|
||||||
//calculate
|
//calculate
|
||||||
Vector3d hitboxPos = AttachUtils.calculateBoneAttachmentLocalPosition(offsetPosition, offsetRotation, bonePositionD, boneRotation, parentPosition, parentRotation, parentScale);
|
Vector3d hitboxPos = AttachUtils.calculateBoneAttachmentLocalPosition(offsetPosition, offsetRotation, bonePositionD, boneRotation, parentPosition, parentRotation, parentScale);
|
||||||
|
|
||||||
|
|
||||||
|
//actually set value
|
||||||
PhysicsEntityUtils.setGeometryOffsetPosition(collisionEngine, geom, hitboxPos, new Quaterniond());
|
PhysicsEntityUtils.setGeometryOffsetPosition(collisionEngine, geom, hitboxPos, new Quaterniond());
|
||||||
|
|
||||||
|
//free vecs used in computation
|
||||||
|
VectorPool.release(bonePositionD);
|
||||||
|
VectorPool.release(parentScale);
|
||||||
|
VectorPool.release(hitboxPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -73,6 +73,41 @@ public class VectorPool {
|
|||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a Vector3d from the pool. Allocates if no free one is available.
|
||||||
|
* @param source The source to copy from
|
||||||
|
* @return A Vector3d
|
||||||
|
*/
|
||||||
|
public static Vector3d getD(Vector3d source){
|
||||||
|
Vector3d rVal = null;
|
||||||
|
lock.lock();
|
||||||
|
if(vec3dPool.size() > 0){
|
||||||
|
rVal = vec3dPool.remove(0);
|
||||||
|
} else {
|
||||||
|
rVal = new Vector3d();
|
||||||
|
}
|
||||||
|
rVal.set(source);
|
||||||
|
lock.unlock();
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a Vector3d from the pool. Allocates if no free one is available.
|
||||||
|
* @return A Vector3d
|
||||||
|
*/
|
||||||
|
public static Vector3d getD(double x, double y, double z){
|
||||||
|
Vector3d rVal = null;
|
||||||
|
lock.lock();
|
||||||
|
if(vec3dPool.size() > 0){
|
||||||
|
rVal = vec3dPool.remove(0);
|
||||||
|
} else {
|
||||||
|
rVal = new Vector3d();
|
||||||
|
}
|
||||||
|
rVal.set(x,y,z);
|
||||||
|
lock.unlock();
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Releases a Vector3d back into the pool
|
* Releases a Vector3d back into the pool
|
||||||
* @param data The object to release
|
* @param data The object to release
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user