fix raycast overalloc
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
028ac3ebb6
commit
385e01821e
@ -2140,6 +2140,7 @@ Work to reduce allocations
|
|||||||
Prevent mouse event re-allocation every frame
|
Prevent mouse event re-allocation every frame
|
||||||
More allocation work
|
More allocation work
|
||||||
Frametime reporting work
|
Frametime reporting work
|
||||||
|
Raycast allocation fix
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -938,6 +938,7 @@ public class CollisionEngine {
|
|||||||
* @return The position, in world coordinates, of the closest collision of the way, or null if it did not collide with anything.
|
* @return The position, in world coordinates, of the closest collision of the way, or null if it did not collide with anything.
|
||||||
*/
|
*/
|
||||||
public Vector3d rayCastPosition(Vector3d start, Vector3d direction, double length){
|
public Vector3d rayCastPosition(Vector3d start, Vector3d direction, double length){
|
||||||
|
Globals.profiler.beginCpuSample("CollisionEngine.rayCastPosition");
|
||||||
spaceLock.lock();
|
spaceLock.lock();
|
||||||
Vector3d unitDir = new Vector3d(direction).normalize();
|
Vector3d unitDir = new Vector3d(direction).normalize();
|
||||||
//create the ray
|
//create the ray
|
||||||
@ -951,6 +952,7 @@ public class CollisionEngine {
|
|||||||
//destroy ray
|
//destroy ray
|
||||||
ray.destroy();
|
ray.destroy();
|
||||||
spaceLock.unlock();
|
spaceLock.unlock();
|
||||||
|
Globals.profiler.endCpuSample();
|
||||||
return data.collisionPosition;
|
return data.collisionPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -57,6 +57,11 @@ void RayCallback(void *Data, dGeomID Geometry1, dGeomID Geometry2) {
|
|||||||
//This should be reset every time a ray cast is called in collision engine by calling setLength in this object.
|
//This should be reset every time a ray cast is called in collision engine by calling setLength in this object.
|
||||||
double shortestLength = REALLY_LONG_DISTANCE;
|
double shortestLength = REALLY_LONG_DISTANCE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The contact buffer
|
||||||
|
*/
|
||||||
|
DContactBuffer contacts = new DContactBuffer(MAX_CONTACTS);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void call(Object data, DGeom o1, DGeom o2) {
|
public void call(Object data, DGeom o1, DGeom o2) {
|
||||||
RayCastCallbackData rayCastData = (RayCastCallbackData)data;
|
RayCastCallbackData rayCastData = (RayCastCallbackData)data;
|
||||||
@ -107,8 +112,8 @@ void RayCallback(void *Data, dGeomID Geometry1, dGeomID Geometry2) {
|
|||||||
(o1 instanceof DRay && collidable2 != null && rayCastData.collidableTypeMask.contains(collidable2.getType())) ||
|
(o1 instanceof DRay && collidable2 != null && rayCastData.collidableTypeMask.contains(collidable2.getType())) ||
|
||||||
(o2 instanceof DRay && collidable1 != null && rayCastData.collidableTypeMask.contains(collidable1.getType()))
|
(o2 instanceof DRay && collidable1 != null && rayCastData.collidableTypeMask.contains(collidable1.getType()))
|
||||||
){
|
){
|
||||||
//creates a buffer to store potential collisions
|
//reset contact buffer
|
||||||
DContactBuffer contacts = new DContactBuffer(MAX_CONTACTS); // up to MAX_CONTACTS contacts per box-box
|
contacts.nullify();
|
||||||
//calculate collisions
|
//calculate collisions
|
||||||
int numc = OdeHelper.collide(o1,o2,MAX_CONTACTS,contacts.getGeomBuffer());
|
int numc = OdeHelper.collide(o1,o2,MAX_CONTACTS,contacts.getGeomBuffer());
|
||||||
//create DContacts based on each collision that occurs
|
//create DContacts based on each collision that occurs
|
||||||
|
|||||||
@ -424,10 +424,10 @@ public class BlockMeshgen {
|
|||||||
BlockMeshgen.meshifyBox(meshGenStore,quad1,zEnd,quad1.type,scalingFactor);
|
BlockMeshgen.meshifyBox(meshGenStore,quad1,zEnd,quad1.type,scalingFactor);
|
||||||
quad1 = quad2;
|
quad1 = quad2;
|
||||||
|
|
||||||
// BlockSingleShape blockSingleShape = BlockMeshgen.copyDataToShape(meshGenStore, vertCount, faceCount);
|
BlockSingleShape blockSingleShape = BlockMeshgen.copyDataToShape(meshGenStore, vertCount, faceCount);
|
||||||
// vertCount = meshGenStore.getVertCount();
|
vertCount = meshGenStore.getVertCount();
|
||||||
// faceCount = meshGenStore.getFaceCount();
|
faceCount = meshGenStore.getFaceCount();
|
||||||
// rVal.shapeData.add(blockSingleShape);
|
rVal.shapeData.add(blockSingleShape);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -435,10 +435,10 @@ public class BlockMeshgen {
|
|||||||
}
|
}
|
||||||
if(quad1 != null){
|
if(quad1 != null){
|
||||||
BlockMeshgen.meshifyBox(meshGenStore,quad1,zEnd,quad1.type,scalingFactor);
|
BlockMeshgen.meshifyBox(meshGenStore,quad1,zEnd,quad1.type,scalingFactor);
|
||||||
// BlockSingleShape blockSingleShape = BlockMeshgen.copyDataToShape(meshGenStore, vertCount, faceCount);
|
BlockSingleShape blockSingleShape = BlockMeshgen.copyDataToShape(meshGenStore, vertCount, faceCount);
|
||||||
// vertCount = meshGenStore.getVertCount();
|
vertCount = meshGenStore.getVertCount();
|
||||||
// faceCount = meshGenStore.getFaceCount();
|
faceCount = meshGenStore.getFaceCount();
|
||||||
// rVal.shapeData.add(blockSingleShape);
|
rVal.shapeData.add(blockSingleShape);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user