Foliage 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
2926a2abf3
commit
eed0170894
@ -1115,6 +1115,10 @@ Reduce near clip to remove flickering on far chunks
|
|||||||
Complete overhaul of foliage management
|
Complete overhaul of foliage management
|
||||||
Fix foliage inconsistently placing on varied terrain
|
Fix foliage inconsistently placing on varied terrain
|
||||||
Fix foliage texture wrapping when drawing too many foliage items
|
Fix foliage texture wrapping when drawing too many foliage items
|
||||||
|
Fix memory management in asset loader for queued assets
|
||||||
|
Add functionality for texture freeing from asset manager
|
||||||
|
Increase foliage chunk range
|
||||||
|
Swtich collision engine to use reentrant lock
|
||||||
|
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
|
|||||||
@ -45,7 +45,7 @@ public class FoliageCellManager {
|
|||||||
/**
|
/**
|
||||||
* The distance for quarter resolution
|
* The distance for quarter resolution
|
||||||
*/
|
*/
|
||||||
public static final double QUARTER_RES_DIST = 24 * 24;
|
public static final double QUARTER_RES_DIST = 20 * 20;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The distance for eighth resolution
|
* The distance for eighth resolution
|
||||||
@ -55,7 +55,7 @@ public class FoliageCellManager {
|
|||||||
/**
|
/**
|
||||||
* The distance for sixteenth resolution
|
* The distance for sixteenth resolution
|
||||||
*/
|
*/
|
||||||
public static final double SIXTEENTH_RES_DIST = 48 * 48;
|
public static final double SIXTEENTH_RES_DIST = 128 * 128;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lod value for a full res chunk
|
* Lod value for a full res chunk
|
||||||
|
|||||||
@ -170,6 +170,9 @@ public class FoliageModel {
|
|||||||
currVoxelPos.z + currWorldPos.z * ServerTerrainChunk.CHUNK_PLACEMENT_OFFSET
|
currVoxelPos.z + currWorldPos.z * ServerTerrainChunk.CHUNK_PLACEMENT_OFFSET
|
||||||
);
|
);
|
||||||
ChunkData data = Globals.clientTerrainManager.getChunkDataAtWorldPoint(currWorldPos,ChunkData.NO_STRIDE);
|
ChunkData data = Globals.clientTerrainManager.getChunkDataAtWorldPoint(currWorldPos,ChunkData.NO_STRIDE);
|
||||||
|
if(data == null){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
List<String> currentList = Globals.gameConfigCurrent.getVoxelData().getTypeFromId(data.getType(currVoxelPos)).getAmbientFoliage();
|
List<String> currentList = Globals.gameConfigCurrent.getVoxelData().getTypeFromId(data.getType(currVoxelPos)).getAmbientFoliage();
|
||||||
if(currentList == null){
|
if(currentList == null){
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.Semaphore;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
import org.joml.Matrix4d;
|
import org.joml.Matrix4d;
|
||||||
import org.joml.Quaterniond;
|
import org.joml.Quaterniond;
|
||||||
@ -101,7 +101,7 @@ public class CollisionEngine {
|
|||||||
//Ode-specific stuff
|
//Ode-specific stuff
|
||||||
private DWorld world;
|
private DWorld world;
|
||||||
private DSpace space;
|
private DSpace space;
|
||||||
private static Semaphore spaceLock = new Semaphore(1);
|
private static ReentrantLock spaceLock = new ReentrantLock();
|
||||||
private DJointGroup contactgroup;
|
private DJointGroup contactgroup;
|
||||||
|
|
||||||
// maximum number of contact points per body
|
// maximum number of contact points per body
|
||||||
@ -247,11 +247,11 @@ public class CollisionEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void clearCollidableImpulseLists(){
|
public void clearCollidableImpulseLists(){
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.lock();
|
||||||
for(Collidable collidable : collidableList){
|
for(Collidable collidable : collidableList){
|
||||||
collidable.clear();
|
collidable.clear();
|
||||||
}
|
}
|
||||||
spaceLock.release();
|
spaceLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Collidable> getCollidables(){
|
public List<Collidable> getCollidables(){
|
||||||
@ -295,7 +295,7 @@ public class CollisionEngine {
|
|||||||
*/
|
*/
|
||||||
public void simulatePhysics(float time){
|
public void simulatePhysics(float time){
|
||||||
Globals.profiler.beginCpuSample("physics");
|
Globals.profiler.beginCpuSample("physics");
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.lock();
|
||||||
for(int i = 0; i < PHYSICS_SIMULATION_RESOLUTION; i++){
|
for(int i = 0; i < PHYSICS_SIMULATION_RESOLUTION; i++){
|
||||||
Globals.profiler.beginCpuSample("collide");
|
Globals.profiler.beginCpuSample("collide");
|
||||||
OdeHelper.spaceCollide(space, 0, nearCallback);
|
OdeHelper.spaceCollide(space, 0, nearCallback);
|
||||||
@ -310,7 +310,7 @@ public class CollisionEngine {
|
|||||||
// remove all contact joints
|
// remove all contact joints
|
||||||
contactgroup.empty();
|
contactgroup.empty();
|
||||||
}
|
}
|
||||||
spaceLock.release();
|
spaceLock.unlock();
|
||||||
Globals.profiler.endCpuSample();
|
Globals.profiler.endCpuSample();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,14 +319,14 @@ public class CollisionEngine {
|
|||||||
*/
|
*/
|
||||||
public void collide(){
|
public void collide(){
|
||||||
Globals.profiler.beginCpuSample("physics");
|
Globals.profiler.beginCpuSample("physics");
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.lock();
|
||||||
Globals.profiler.beginCpuSample("collide");
|
Globals.profiler.beginCpuSample("collide");
|
||||||
OdeHelper.spaceCollide(space, 0, nearCallback);
|
OdeHelper.spaceCollide(space, 0, nearCallback);
|
||||||
Globals.profiler.endCpuSample();
|
Globals.profiler.endCpuSample();
|
||||||
|
|
||||||
// remove all contact joints
|
// remove all contact joints
|
||||||
contactgroup.empty();
|
contactgroup.empty();
|
||||||
spaceLock.release();
|
spaceLock.unlock();
|
||||||
Globals.profiler.endCpuSample();
|
Globals.profiler.endCpuSample();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -564,7 +564,7 @@ public class CollisionEngine {
|
|||||||
*/
|
*/
|
||||||
public void updateDynamicObjectTransforms(){
|
public void updateDynamicObjectTransforms(){
|
||||||
Globals.profiler.beginCpuSample("updateDynamicObjectTransforms");
|
Globals.profiler.beginCpuSample("updateDynamicObjectTransforms");
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.lock();
|
||||||
if(this.collisionWorldData != null){
|
if(this.collisionWorldData != null){
|
||||||
for(Collidable collidable : collidableList){
|
for(Collidable collidable : collidableList){
|
||||||
if(collidable.getParentTracksCollidable()){
|
if(collidable.getParentTracksCollidable()){
|
||||||
@ -583,7 +583,7 @@ public class CollisionEngine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
spaceLock.release();
|
spaceLock.unlock();
|
||||||
Globals.profiler.endCpuSample();
|
Globals.profiler.endCpuSample();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -593,11 +593,11 @@ public class CollisionEngine {
|
|||||||
* @param collidable The corresponding collidable
|
* @param collidable The corresponding collidable
|
||||||
*/
|
*/
|
||||||
public void registerCollisionObject(DBody body, Collidable collidable){
|
public void registerCollisionObject(DBody body, Collidable collidable){
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.lock();
|
||||||
this.registerPhysicsObject(body);
|
this.registerPhysicsObject(body);
|
||||||
bodyPointerMap.put(body,collidable);
|
bodyPointerMap.put(body,collidable);
|
||||||
collidableList.add(collidable);
|
collidableList.add(collidable);
|
||||||
spaceLock.release();
|
spaceLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -605,10 +605,10 @@ public class CollisionEngine {
|
|||||||
* @param collidable The collidable
|
* @param collidable The collidable
|
||||||
*/
|
*/
|
||||||
public void deregisterCollisionObject(DBody body, Collidable collidable){
|
public void deregisterCollisionObject(DBody body, Collidable collidable){
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.lock();
|
||||||
bodyPointerMap.remove(body);
|
bodyPointerMap.remove(body);
|
||||||
collidableList.remove(collidable);
|
collidableList.remove(collidable);
|
||||||
spaceLock.release();
|
spaceLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void listBodyPositions(){
|
public void listBodyPositions(){
|
||||||
@ -642,7 +642,7 @@ public class CollisionEngine {
|
|||||||
* @return The entity that the ray cast collided with. Will be null if no entity was collided with.
|
* @return The entity that the ray cast collided with. Will be null if no entity was collided with.
|
||||||
*/
|
*/
|
||||||
public Entity rayCast(Vector3d start, Vector3d direction, double length, List<String> typeMask){
|
public Entity rayCast(Vector3d start, Vector3d direction, double length, List<String> typeMask){
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.lock();
|
||||||
Vector3d unitDir = new Vector3d(direction).normalize();
|
Vector3d unitDir = new Vector3d(direction).normalize();
|
||||||
//create the ray
|
//create the ray
|
||||||
DRay ray = OdeHelper.createRay(space, length);
|
DRay ray = OdeHelper.createRay(space, length);
|
||||||
@ -653,7 +653,7 @@ public class CollisionEngine {
|
|||||||
space.collide2(space, data, rayCastCallback);
|
space.collide2(space, data, rayCastCallback);
|
||||||
//destroy ray
|
//destroy ray
|
||||||
ray.destroy();
|
ray.destroy();
|
||||||
spaceLock.release();
|
spaceLock.unlock();
|
||||||
return data.collidedEntity;
|
return data.collidedEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -666,7 +666,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){
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.lock();
|
||||||
Vector3d unitDir = new Vector3d(direction).normalize();
|
Vector3d unitDir = new Vector3d(direction).normalize();
|
||||||
//create the ray
|
//create the ray
|
||||||
DRay ray = OdeHelper.createRay(space, length);
|
DRay ray = OdeHelper.createRay(space, length);
|
||||||
@ -677,7 +677,7 @@ public class CollisionEngine {
|
|||||||
space.collide2(ray, data, rayCastCallback);
|
space.collide2(ray, data, rayCastCallback);
|
||||||
//destroy ray
|
//destroy ray
|
||||||
ray.destroy();
|
ray.destroy();
|
||||||
spaceLock.release();
|
spaceLock.unlock();
|
||||||
return data.collisionPosition;
|
return data.collisionPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -690,7 +690,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 rayCastPositionMasked(Vector3d start, Vector3d direction, double length, List<String> typeMask){
|
public Vector3d rayCastPositionMasked(Vector3d start, Vector3d direction, double length, List<String> typeMask){
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.lock();
|
||||||
Vector3d unitDir = new Vector3d(direction).normalize();
|
Vector3d unitDir = new Vector3d(direction).normalize();
|
||||||
//create the ray
|
//create the ray
|
||||||
DRay ray = OdeHelper.createRay(space, length);
|
DRay ray = OdeHelper.createRay(space, length);
|
||||||
@ -701,7 +701,7 @@ public class CollisionEngine {
|
|||||||
space.collide2(ray, data, rayCastCallback);
|
space.collide2(ray, data, rayCastCallback);
|
||||||
//destroy ray
|
//destroy ray
|
||||||
ray.destroy();
|
ray.destroy();
|
||||||
spaceLock.release();
|
spaceLock.unlock();
|
||||||
return data.collisionPosition;
|
return data.collisionPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -724,7 +724,7 @@ public class CollisionEngine {
|
|||||||
* @param body The DBody to destroy
|
* @param body The DBody to destroy
|
||||||
*/
|
*/
|
||||||
protected void destroyDBody(DBody body){
|
protected void destroyDBody(DBody body){
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.lock();
|
||||||
try {
|
try {
|
||||||
if(bodies.contains(body)){
|
if(bodies.contains(body)){
|
||||||
bodies.remove(body);
|
bodies.remove(body);
|
||||||
@ -748,7 +748,7 @@ public class CollisionEngine {
|
|||||||
} catch (NullPointerException ex){
|
} catch (NullPointerException ex){
|
||||||
LoggerInterface.loggerEngine.ERROR(ex);
|
LoggerInterface.loggerEngine.ERROR(ex);
|
||||||
}
|
}
|
||||||
spaceLock.release();
|
spaceLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -778,7 +778,7 @@ public class CollisionEngine {
|
|||||||
* @return The DTriMesh
|
* @return The DTriMesh
|
||||||
*/
|
*/
|
||||||
protected DTriMesh createTrimeshGeom(float[] verts, int[] indices, long categoryBits){
|
protected DTriMesh createTrimeshGeom(float[] verts, int[] indices, long categoryBits){
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.lock();
|
||||||
DTriMeshData data = OdeHelper.createTriMeshData();
|
DTriMeshData data = OdeHelper.createTriMeshData();
|
||||||
data.build(verts, indices);
|
data.build(verts, indices);
|
||||||
final int preprocessFlags =
|
final int preprocessFlags =
|
||||||
@ -790,7 +790,7 @@ public class CollisionEngine {
|
|||||||
DTriMesh rVal = OdeHelper.createTriMesh(space, data);
|
DTriMesh rVal = OdeHelper.createTriMesh(space, data);
|
||||||
rVal.setTrimeshData(data);
|
rVal.setTrimeshData(data);
|
||||||
rVal.setCategoryBits(categoryBits);
|
rVal.setCategoryBits(categoryBits);
|
||||||
spaceLock.release();
|
spaceLock.unlock();
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -800,10 +800,10 @@ public class CollisionEngine {
|
|||||||
* @return The DBox
|
* @return The DBox
|
||||||
*/
|
*/
|
||||||
protected DBox createCubeGeom(Vector3d dimensions, long categoryBits){
|
protected DBox createCubeGeom(Vector3d dimensions, long categoryBits){
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.lock();
|
||||||
DBox boxGeom = OdeHelper.createBox(space, dimensions.x, dimensions.y, dimensions.z);
|
DBox boxGeom = OdeHelper.createBox(space, dimensions.x, dimensions.y, dimensions.z);
|
||||||
boxGeom.setCategoryBits(categoryBits);
|
boxGeom.setCategoryBits(categoryBits);
|
||||||
spaceLock.release();
|
spaceLock.unlock();
|
||||||
return boxGeom;
|
return boxGeom;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -813,10 +813,10 @@ public class CollisionEngine {
|
|||||||
* @return The cylinder geometry
|
* @return The cylinder geometry
|
||||||
*/
|
*/
|
||||||
protected DCylinder createCylinderGeom(double radius, double length, long categoryBits){
|
protected DCylinder createCylinderGeom(double radius, double length, long categoryBits){
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.lock();
|
||||||
DCylinder cylinderGeom = OdeHelper.createCylinder(space, radius, length);
|
DCylinder cylinderGeom = OdeHelper.createCylinder(space, radius, length);
|
||||||
cylinderGeom.setCategoryBits(categoryBits);
|
cylinderGeom.setCategoryBits(categoryBits);
|
||||||
spaceLock.release();
|
spaceLock.unlock();
|
||||||
return cylinderGeom;
|
return cylinderGeom;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -826,10 +826,10 @@ public class CollisionEngine {
|
|||||||
* @return The sphere geometry
|
* @return The sphere geometry
|
||||||
*/
|
*/
|
||||||
protected DSphere createSphereGeom(double radius, long categoryBits){
|
protected DSphere createSphereGeom(double radius, long categoryBits){
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.lock();
|
||||||
DSphere sphereGeom = OdeHelper.createSphere(space, radius);
|
DSphere sphereGeom = OdeHelper.createSphere(space, radius);
|
||||||
sphereGeom.setCategoryBits(categoryBits);
|
sphereGeom.setCategoryBits(categoryBits);
|
||||||
spaceLock.release();
|
spaceLock.unlock();
|
||||||
return sphereGeom;
|
return sphereGeom;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -840,10 +840,10 @@ public class CollisionEngine {
|
|||||||
* @return The capsule geometry
|
* @return The capsule geometry
|
||||||
*/
|
*/
|
||||||
protected DCapsule createCapsuleGeom(double radius, double length, long categoryBits){
|
protected DCapsule createCapsuleGeom(double radius, double length, long categoryBits){
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.lock();
|
||||||
DCapsule capsuleGeom = OdeHelper.createCapsule(space, radius, length);
|
DCapsule capsuleGeom = OdeHelper.createCapsule(space, radius, length);
|
||||||
capsuleGeom.setCategoryBits(categoryBits);
|
capsuleGeom.setCategoryBits(categoryBits);
|
||||||
spaceLock.release();
|
spaceLock.unlock();
|
||||||
return capsuleGeom;
|
return capsuleGeom;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -853,7 +853,7 @@ public class CollisionEngine {
|
|||||||
* @return The DBody
|
* @return The DBody
|
||||||
*/
|
*/
|
||||||
protected DBody createDBody(DGeom ...geom){
|
protected DBody createDBody(DGeom ...geom){
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.lock();
|
||||||
DBody body = OdeHelper.createBody(world);
|
DBody body = OdeHelper.createBody(world);
|
||||||
body.setDamping(DEFAULT_LINEAR_DAMPING, DEFAULT_ANGULAR_DAMPING);
|
body.setDamping(DEFAULT_LINEAR_DAMPING, DEFAULT_ANGULAR_DAMPING);
|
||||||
body.setMaxAngularSpeed(DEFAULT_MAX_ANGULAR_SPEED);
|
body.setMaxAngularSpeed(DEFAULT_MAX_ANGULAR_SPEED);
|
||||||
@ -864,7 +864,7 @@ public class CollisionEngine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
spaceLock.release();
|
spaceLock.unlock();
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -877,11 +877,11 @@ public class CollisionEngine {
|
|||||||
* @return The DMass
|
* @return The DMass
|
||||||
*/
|
*/
|
||||||
protected DMass createCylinderMass(double massValue, double radius, double length, DBody body, Vector3d offset, Quaterniond rotation){
|
protected DMass createCylinderMass(double massValue, double radius, double length, DBody body, Vector3d offset, Quaterniond rotation){
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.lock();
|
||||||
DMass mass = OdeHelper.createMass();
|
DMass mass = OdeHelper.createMass();
|
||||||
mass.setCylinder(massValue, 2, radius, length);
|
mass.setCylinder(massValue, 2, radius, length);
|
||||||
body.setMass(mass);
|
body.setMass(mass);
|
||||||
spaceLock.release();
|
spaceLock.unlock();
|
||||||
return mass;
|
return mass;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -893,11 +893,11 @@ public class CollisionEngine {
|
|||||||
* @return The DMass
|
* @return The DMass
|
||||||
*/
|
*/
|
||||||
protected DMass createBoxMass(double massValue, Vector3d dims, DBody body, Vector3d offset, Quaterniond rotation){
|
protected DMass createBoxMass(double massValue, Vector3d dims, DBody body, Vector3d offset, Quaterniond rotation){
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.lock();
|
||||||
DMass mass = OdeHelper.createMass();
|
DMass mass = OdeHelper.createMass();
|
||||||
mass.setBox(massValue, dims.x, dims.y, dims.z);
|
mass.setBox(massValue, dims.x, dims.y, dims.z);
|
||||||
body.setMass(mass);
|
body.setMass(mass);
|
||||||
spaceLock.release();
|
spaceLock.unlock();
|
||||||
return mass;
|
return mass;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -910,11 +910,11 @@ public class CollisionEngine {
|
|||||||
* @return The DMass
|
* @return The DMass
|
||||||
*/
|
*/
|
||||||
protected DMass createCapsuleMass(double massValue, double radius, double length, DBody body, Vector3d offset, Quaterniond rotation){
|
protected DMass createCapsuleMass(double massValue, double radius, double length, DBody body, Vector3d offset, Quaterniond rotation){
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.lock();
|
||||||
DMass mass = OdeHelper.createMass();
|
DMass mass = OdeHelper.createMass();
|
||||||
mass.setCapsule(massValue, 2, radius, length);
|
mass.setCapsule(massValue, 2, radius, length);
|
||||||
body.setMass(mass);
|
body.setMass(mass);
|
||||||
spaceLock.release();
|
spaceLock.unlock();
|
||||||
return mass;
|
return mass;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -927,12 +927,12 @@ public class CollisionEngine {
|
|||||||
* @param steps The number of steps the body must be beneath the threshold before disabling
|
* @param steps The number of steps the body must be beneath the threshold before disabling
|
||||||
*/
|
*/
|
||||||
protected void setAutoDisableFlags(DBody body, boolean autoDisable, double linearThreshold, double angularThreshold, int steps){
|
protected void setAutoDisableFlags(DBody body, boolean autoDisable, double linearThreshold, double angularThreshold, int steps){
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.lock();
|
||||||
body.setAutoDisableFlag(autoDisable);
|
body.setAutoDisableFlag(autoDisable);
|
||||||
body.setAutoDisableLinearThreshold(0.1);
|
body.setAutoDisableLinearThreshold(0.1);
|
||||||
body.setAutoDisableAngularThreshold(angularThreshold);
|
body.setAutoDisableAngularThreshold(angularThreshold);
|
||||||
body.setAutoDisableSteps(steps);
|
body.setAutoDisableSteps(steps);
|
||||||
spaceLock.release();
|
spaceLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -942,9 +942,9 @@ public class CollisionEngine {
|
|||||||
* @param angularDamping The angular damping
|
* @param angularDamping The angular damping
|
||||||
*/
|
*/
|
||||||
protected void setDamping(DBody body, double linearDamping, double angularDamping){
|
protected void setDamping(DBody body, double linearDamping, double angularDamping){
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.lock();
|
||||||
body.setDamping(linearDamping, angularDamping);
|
body.setDamping(linearDamping, angularDamping);
|
||||||
spaceLock.release();
|
spaceLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -954,10 +954,10 @@ public class CollisionEngine {
|
|||||||
* @param rotation The rotation
|
* @param rotation The rotation
|
||||||
*/
|
*/
|
||||||
protected void setBodyTransform(DBody body, Vector3d position, Quaterniond rotation){
|
protected void setBodyTransform(DBody body, Vector3d position, Quaterniond rotation){
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.lock();
|
||||||
body.setPosition(position.x, position.y, position.z);
|
body.setPosition(position.x, position.y, position.z);
|
||||||
body.setQuaternion(PhysicsUtils.jomlQuatToOdeQuat(rotation));
|
body.setQuaternion(PhysicsUtils.jomlQuatToOdeQuat(rotation));
|
||||||
spaceLock.release();
|
spaceLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -971,14 +971,14 @@ public class CollisionEngine {
|
|||||||
* @param angularForce The angular force
|
* @param angularForce The angular force
|
||||||
*/
|
*/
|
||||||
protected void synchronizeData(DBody body, Vector3d position, Quaterniond rotation, Vector3d linearVel, Vector3d angularVel, Vector3d linearForce, Vector3d angularForce){
|
protected void synchronizeData(DBody body, Vector3d position, Quaterniond rotation, Vector3d linearVel, Vector3d angularVel, Vector3d linearForce, Vector3d angularForce){
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.lock();
|
||||||
body.setPosition(position.x, position.y, position.z);
|
body.setPosition(position.x, position.y, position.z);
|
||||||
body.setQuaternion(PhysicsUtils.jomlQuatToOdeQuat(rotation));
|
body.setQuaternion(PhysicsUtils.jomlQuatToOdeQuat(rotation));
|
||||||
body.setLinearVel(PhysicsUtils.jomlVecToOdeVec(linearVel));
|
body.setLinearVel(PhysicsUtils.jomlVecToOdeVec(linearVel));
|
||||||
body.setAngularVel(PhysicsUtils.jomlVecToOdeVec(angularVel));
|
body.setAngularVel(PhysicsUtils.jomlVecToOdeVec(angularVel));
|
||||||
body.setForce(PhysicsUtils.jomlVecToOdeVec(linearForce));
|
body.setForce(PhysicsUtils.jomlVecToOdeVec(linearForce));
|
||||||
body.setTorque(PhysicsUtils.jomlVecToOdeVec(angularForce));
|
body.setTorque(PhysicsUtils.jomlVecToOdeVec(angularForce));
|
||||||
spaceLock.release();
|
spaceLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -989,7 +989,7 @@ public class CollisionEngine {
|
|||||||
* @param scale The scale
|
* @param scale The scale
|
||||||
*/
|
*/
|
||||||
protected void setBodyTransform(DBody body, CollidableTemplate template, Vector3d position, Quaterniond rotation, Vector3d scale){
|
protected void setBodyTransform(DBody body, CollidableTemplate template, Vector3d position, Quaterniond rotation, Vector3d scale){
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.lock();
|
||||||
body.setPosition(position.x, position.y, position.z);
|
body.setPosition(position.x, position.y, position.z);
|
||||||
body.setQuaternion(PhysicsUtils.jomlQuatToOdeQuat(rotation));
|
body.setQuaternion(PhysicsUtils.jomlQuatToOdeQuat(rotation));
|
||||||
DGeom firstGeom = body.getFirstGeom();
|
DGeom firstGeom = body.getFirstGeom();
|
||||||
@ -1000,7 +1000,7 @@ public class CollisionEngine {
|
|||||||
} else if(firstGeom instanceof DCapsule){
|
} else if(firstGeom instanceof DCapsule){
|
||||||
((DCapsule)firstGeom).setParams(template.getDimension1() * scale.x,template.getDimension2() * scale.y);
|
((DCapsule)firstGeom).setParams(template.getDimension1() * scale.x,template.getDimension2() * scale.y);
|
||||||
}
|
}
|
||||||
spaceLock.release();
|
spaceLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1010,10 +1010,10 @@ public class CollisionEngine {
|
|||||||
* @param rotation The rotation
|
* @param rotation The rotation
|
||||||
*/
|
*/
|
||||||
protected void setGeomTransform(DGeom geom, Vector3d position, Quaterniond rotation){
|
protected void setGeomTransform(DGeom geom, Vector3d position, Quaterniond rotation){
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.lock();
|
||||||
geom.setOffsetWorldPosition(position.x, position.y, position.z);
|
geom.setOffsetWorldPosition(position.x, position.y, position.z);
|
||||||
geom.setOffsetQuaternion(PhysicsUtils.jomlQuatToOdeQuat(rotation));
|
geom.setOffsetQuaternion(PhysicsUtils.jomlQuatToOdeQuat(rotation));
|
||||||
spaceLock.release();
|
spaceLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1021,9 +1021,9 @@ public class CollisionEngine {
|
|||||||
* @param geom the geometry to correct
|
* @param geom the geometry to correct
|
||||||
*/
|
*/
|
||||||
protected void setOffsetRotation(DGeom geom){
|
protected void setOffsetRotation(DGeom geom){
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.lock();
|
||||||
geom.setOffsetRotation(CollisionBodyCreation.AXIS_CORRECTION_MATRIX);
|
geom.setOffsetRotation(CollisionBodyCreation.AXIS_CORRECTION_MATRIX);
|
||||||
spaceLock.release();
|
spaceLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1033,9 +1033,9 @@ public class CollisionEngine {
|
|||||||
*/
|
*/
|
||||||
protected Vector3d getBodyPosition(DBody body){
|
protected Vector3d getBodyPosition(DBody body){
|
||||||
Vector3d rVal = null;
|
Vector3d rVal = null;
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.lock();
|
||||||
rVal = PhysicsUtils.odeVecToJomlVec(body.getPosition());
|
rVal = PhysicsUtils.odeVecToJomlVec(body.getPosition());
|
||||||
spaceLock.release();
|
spaceLock.unlock();
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1046,9 +1046,9 @@ public class CollisionEngine {
|
|||||||
*/
|
*/
|
||||||
protected Quaterniond getBodyRotation(DBody body){
|
protected Quaterniond getBodyRotation(DBody body){
|
||||||
Quaterniond rVal = null;
|
Quaterniond rVal = null;
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.lock();
|
||||||
rVal = PhysicsUtils.odeQuatToJomlQuat(body.getQuaternion());
|
rVal = PhysicsUtils.odeQuatToJomlQuat(body.getQuaternion());
|
||||||
spaceLock.release();
|
spaceLock.unlock();
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1057,9 +1057,9 @@ public class CollisionEngine {
|
|||||||
* @param body The body to set
|
* @param body The body to set
|
||||||
*/
|
*/
|
||||||
protected void setKinematic(DBody body){
|
protected void setKinematic(DBody body){
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.lock();
|
||||||
body.setKinematic();
|
body.setKinematic();
|
||||||
spaceLock.release();
|
spaceLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1068,9 +1068,9 @@ public class CollisionEngine {
|
|||||||
* @param gravityMode the gravity mode
|
* @param gravityMode the gravity mode
|
||||||
*/
|
*/
|
||||||
protected void setGravityMode(DBody body, boolean gravityMode){
|
protected void setGravityMode(DBody body, boolean gravityMode){
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.lock();
|
||||||
body.setGravityMode(gravityMode);
|
body.setGravityMode(gravityMode);
|
||||||
spaceLock.release();
|
spaceLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1079,9 +1079,9 @@ public class CollisionEngine {
|
|||||||
* @param offsetVector The offset position
|
* @param offsetVector The offset position
|
||||||
*/
|
*/
|
||||||
protected void setOffsetPosition(DBody body, Vector3d offsetVector){
|
protected void setOffsetPosition(DBody body, Vector3d offsetVector){
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.lock();
|
||||||
body.getGeomIterator().next().setOffsetPosition(offsetVector.x,offsetVector.y,offsetVector.z);
|
body.getGeomIterator().next().setOffsetPosition(offsetVector.x,offsetVector.y,offsetVector.z);
|
||||||
spaceLock.release();
|
spaceLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1090,13 +1090,13 @@ public class CollisionEngine {
|
|||||||
* @param angularlyStatic true if angularly static, false otherwise
|
* @param angularlyStatic true if angularly static, false otherwise
|
||||||
*/
|
*/
|
||||||
protected void setAngularlyStatic(DBody body, boolean angularlyStatic){
|
protected void setAngularlyStatic(DBody body, boolean angularlyStatic){
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.lock();
|
||||||
if(angularlyStatic){
|
if(angularlyStatic){
|
||||||
body.setMaxAngularSpeed(0);
|
body.setMaxAngularSpeed(0);
|
||||||
} else {
|
} else {
|
||||||
body.setMaxAngularSpeed(DEFAULT_MAX_ANGULAR_SPEED);
|
body.setMaxAngularSpeed(DEFAULT_MAX_ANGULAR_SPEED);
|
||||||
}
|
}
|
||||||
spaceLock.release();
|
spaceLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1113,11 +1113,11 @@ public class CollisionEngine {
|
|||||||
* @param geom The geometry
|
* @param geom The geometry
|
||||||
*/
|
*/
|
||||||
protected void destroyGeom(DGeom geom){
|
protected void destroyGeom(DGeom geom){
|
||||||
spaceLock.acquireUninterruptibly();
|
spaceLock.lock();
|
||||||
this.space.remove(geom);
|
this.space.remove(geom);
|
||||||
geom.DESTRUCTOR();
|
geom.DESTRUCTOR();
|
||||||
geom.destroy();
|
geom.destroy();
|
||||||
spaceLock.release();
|
spaceLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -30,7 +30,7 @@ import java.util.Map;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.concurrent.Semaphore;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
import org.lwjgl.assimp.AIScene;
|
import org.lwjgl.assimp.AIScene;
|
||||||
import org.ode4j.ode.DBody;
|
import org.ode4j.ode.DBody;
|
||||||
@ -47,6 +47,7 @@ public class AssetManager {
|
|||||||
|
|
||||||
Map<String,Texture> texturesLoadedIntoMemory = new ConcurrentHashMap<String,Texture>();
|
Map<String,Texture> texturesLoadedIntoMemory = new ConcurrentHashMap<String,Texture>();
|
||||||
List<String> texturesInQueue = new CopyOnWriteArrayList<String>();
|
List<String> texturesInQueue = new CopyOnWriteArrayList<String>();
|
||||||
|
List<String> texturesInDeleteQueue = new CopyOnWriteArrayList<String>();
|
||||||
|
|
||||||
Map<String,AudioBuffer> audioLoadedIntoMemory = new ConcurrentHashMap<String,AudioBuffer>();
|
Map<String,AudioBuffer> audioLoadedIntoMemory = new ConcurrentHashMap<String,AudioBuffer>();
|
||||||
List<String> audioInQueue = new CopyOnWriteArrayList<String>();
|
List<String> audioInQueue = new CopyOnWriteArrayList<String>();
|
||||||
@ -74,8 +75,8 @@ public class AssetManager {
|
|||||||
|
|
||||||
|
|
||||||
//assets queued to be loaded
|
//assets queued to be loaded
|
||||||
Semaphore queuedAssetLock = new Semaphore(1);
|
ReentrantLock queuedAssetLock = new ReentrantLock();
|
||||||
List<QueuedAsset> queuedAssets = new CopyOnWriteArrayList<QueuedAsset>();
|
List<QueuedAsset> queuedAssets = new LinkedList<QueuedAsset>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -158,12 +159,12 @@ public class AssetManager {
|
|||||||
}
|
}
|
||||||
//queued assets
|
//queued assets
|
||||||
LoggerInterface.loggerEngine.DEBUG_LOOP("AssetManager - Load queued assets");
|
LoggerInterface.loggerEngine.DEBUG_LOOP("AssetManager - Load queued assets");
|
||||||
queuedAssetLock.acquireUninterruptibly();
|
queuedAssetLock.lock();
|
||||||
for(QueuedAsset queuedAsset : queuedAssets){
|
for(QueuedAsset queuedAsset : queuedAssets){
|
||||||
queuedAsset.load();
|
queuedAsset.load();
|
||||||
}
|
}
|
||||||
queuedAssets.clear();
|
queuedAssets.clear();
|
||||||
queuedAssetLock.release();
|
queuedAssetLock.unlock();
|
||||||
|
|
||||||
//allocate homogenous buffers
|
//allocate homogenous buffers
|
||||||
LoggerInterface.loggerEngine.DEBUG_LOOP("AssetManager - Allocate homogenous buffers");
|
LoggerInterface.loggerEngine.DEBUG_LOOP("AssetManager - Allocate homogenous buffers");
|
||||||
@ -192,6 +193,19 @@ public class AssetManager {
|
|||||||
this.modelsLoadedIntoMemory.remove(modelPath);
|
this.modelsLoadedIntoMemory.remove(modelPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes all textures in the delete queue
|
||||||
|
*/
|
||||||
|
public void deleteTexturesInDeleteQueue(){
|
||||||
|
for(String texturePath : texturesInDeleteQueue){
|
||||||
|
Texture texture = this.fetchTexture(texturePath);
|
||||||
|
if(texture != null){
|
||||||
|
texture.free();
|
||||||
|
}
|
||||||
|
this.texturesLoadedIntoMemory.remove(texturePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -341,6 +355,14 @@ public class AssetManager {
|
|||||||
texturesInQueue.add(path);
|
texturesInQueue.add(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Queues a texture for deletion
|
||||||
|
* @param texturePath The path to the texture
|
||||||
|
*/
|
||||||
|
public void queueTextureForDeletion(String texturePath){
|
||||||
|
texturesInDeleteQueue.add(texturePath);
|
||||||
|
}
|
||||||
|
|
||||||
public Texture fetchTexture(String path){
|
public Texture fetchTexture(String path){
|
||||||
Texture rVal = null;
|
Texture rVal = null;
|
||||||
@ -585,9 +607,9 @@ public class AssetManager {
|
|||||||
* @param asset the asset
|
* @param asset the asset
|
||||||
*/
|
*/
|
||||||
public void queuedAsset(QueuedAsset asset){
|
public void queuedAsset(QueuedAsset asset){
|
||||||
queuedAssetLock.acquireUninterruptibly();
|
queuedAssetLock.lock();
|
||||||
this.queuedAssets.add(asset);
|
this.queuedAssets.add(asset);
|
||||||
queuedAssetLock.release();
|
queuedAssetLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -62,6 +62,7 @@ public class QueuedTexture implements QueuedAsset {
|
|||||||
texture = new Texture(Globals.renderingEngine.getOpenGLState(), data);
|
texture = new Texture(Globals.renderingEngine.getOpenGLState(), data);
|
||||||
} else if(buffer != null){
|
} else if(buffer != null){
|
||||||
texture = new Texture(Globals.renderingEngine.getOpenGLState(),buffer,width,height);
|
texture = new Texture(Globals.renderingEngine.getOpenGLState(),buffer,width,height);
|
||||||
|
this.buffer = null;
|
||||||
}
|
}
|
||||||
hasLoaded = true;
|
hasLoaded = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user