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
|
||||
Fix foliage inconsistently placing on varied terrain
|
||||
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
|
||||
|
||||
@ -45,7 +45,7 @@ public class FoliageCellManager {
|
||||
/**
|
||||
* 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
|
||||
@ -55,7 +55,7 @@ public class FoliageCellManager {
|
||||
/**
|
||||
* 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
|
||||
|
||||
@ -170,6 +170,9 @@ public class FoliageModel {
|
||||
currVoxelPos.z + currWorldPos.z * ServerTerrainChunk.CHUNK_PLACEMENT_OFFSET
|
||||
);
|
||||
ChunkData data = Globals.clientTerrainManager.getChunkDataAtWorldPoint(currWorldPos,ChunkData.NO_STRIDE);
|
||||
if(data == null){
|
||||
continue;
|
||||
}
|
||||
List<String> currentList = Globals.gameConfigCurrent.getVoxelData().getTypeFromId(data.getType(currVoxelPos)).getAmbientFoliage();
|
||||
if(currentList == null){
|
||||
continue;
|
||||
|
||||
@ -13,7 +13,7 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import org.joml.Matrix4d;
|
||||
import org.joml.Quaterniond;
|
||||
@ -101,7 +101,7 @@ public class CollisionEngine {
|
||||
//Ode-specific stuff
|
||||
private DWorld world;
|
||||
private DSpace space;
|
||||
private static Semaphore spaceLock = new Semaphore(1);
|
||||
private static ReentrantLock spaceLock = new ReentrantLock();
|
||||
private DJointGroup contactgroup;
|
||||
|
||||
// maximum number of contact points per body
|
||||
@ -247,11 +247,11 @@ public class CollisionEngine {
|
||||
}
|
||||
|
||||
public void clearCollidableImpulseLists(){
|
||||
spaceLock.acquireUninterruptibly();
|
||||
spaceLock.lock();
|
||||
for(Collidable collidable : collidableList){
|
||||
collidable.clear();
|
||||
}
|
||||
spaceLock.release();
|
||||
spaceLock.unlock();
|
||||
}
|
||||
|
||||
public List<Collidable> getCollidables(){
|
||||
@ -295,7 +295,7 @@ public class CollisionEngine {
|
||||
*/
|
||||
public void simulatePhysics(float time){
|
||||
Globals.profiler.beginCpuSample("physics");
|
||||
spaceLock.acquireUninterruptibly();
|
||||
spaceLock.lock();
|
||||
for(int i = 0; i < PHYSICS_SIMULATION_RESOLUTION; i++){
|
||||
Globals.profiler.beginCpuSample("collide");
|
||||
OdeHelper.spaceCollide(space, 0, nearCallback);
|
||||
@ -310,7 +310,7 @@ public class CollisionEngine {
|
||||
// remove all contact joints
|
||||
contactgroup.empty();
|
||||
}
|
||||
spaceLock.release();
|
||||
spaceLock.unlock();
|
||||
Globals.profiler.endCpuSample();
|
||||
}
|
||||
|
||||
@ -319,14 +319,14 @@ public class CollisionEngine {
|
||||
*/
|
||||
public void collide(){
|
||||
Globals.profiler.beginCpuSample("physics");
|
||||
spaceLock.acquireUninterruptibly();
|
||||
spaceLock.lock();
|
||||
Globals.profiler.beginCpuSample("collide");
|
||||
OdeHelper.spaceCollide(space, 0, nearCallback);
|
||||
Globals.profiler.endCpuSample();
|
||||
|
||||
// remove all contact joints
|
||||
contactgroup.empty();
|
||||
spaceLock.release();
|
||||
spaceLock.unlock();
|
||||
Globals.profiler.endCpuSample();
|
||||
}
|
||||
|
||||
@ -564,7 +564,7 @@ public class CollisionEngine {
|
||||
*/
|
||||
public void updateDynamicObjectTransforms(){
|
||||
Globals.profiler.beginCpuSample("updateDynamicObjectTransforms");
|
||||
spaceLock.acquireUninterruptibly();
|
||||
spaceLock.lock();
|
||||
if(this.collisionWorldData != null){
|
||||
for(Collidable collidable : collidableList){
|
||||
if(collidable.getParentTracksCollidable()){
|
||||
@ -583,7 +583,7 @@ public class CollisionEngine {
|
||||
}
|
||||
}
|
||||
}
|
||||
spaceLock.release();
|
||||
spaceLock.unlock();
|
||||
Globals.profiler.endCpuSample();
|
||||
}
|
||||
|
||||
@ -593,11 +593,11 @@ public class CollisionEngine {
|
||||
* @param collidable The corresponding collidable
|
||||
*/
|
||||
public void registerCollisionObject(DBody body, Collidable collidable){
|
||||
spaceLock.acquireUninterruptibly();
|
||||
spaceLock.lock();
|
||||
this.registerPhysicsObject(body);
|
||||
bodyPointerMap.put(body,collidable);
|
||||
collidableList.add(collidable);
|
||||
spaceLock.release();
|
||||
spaceLock.unlock();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -605,10 +605,10 @@ public class CollisionEngine {
|
||||
* @param collidable The collidable
|
||||
*/
|
||||
public void deregisterCollisionObject(DBody body, Collidable collidable){
|
||||
spaceLock.acquireUninterruptibly();
|
||||
spaceLock.lock();
|
||||
bodyPointerMap.remove(body);
|
||||
collidableList.remove(collidable);
|
||||
spaceLock.release();
|
||||
spaceLock.unlock();
|
||||
}
|
||||
|
||||
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.
|
||||
*/
|
||||
public Entity rayCast(Vector3d start, Vector3d direction, double length, List<String> typeMask){
|
||||
spaceLock.acquireUninterruptibly();
|
||||
spaceLock.lock();
|
||||
Vector3d unitDir = new Vector3d(direction).normalize();
|
||||
//create the ray
|
||||
DRay ray = OdeHelper.createRay(space, length);
|
||||
@ -653,7 +653,7 @@ public class CollisionEngine {
|
||||
space.collide2(space, data, rayCastCallback);
|
||||
//destroy ray
|
||||
ray.destroy();
|
||||
spaceLock.release();
|
||||
spaceLock.unlock();
|
||||
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.
|
||||
*/
|
||||
public Vector3d rayCastPosition(Vector3d start, Vector3d direction, double length){
|
||||
spaceLock.acquireUninterruptibly();
|
||||
spaceLock.lock();
|
||||
Vector3d unitDir = new Vector3d(direction).normalize();
|
||||
//create the ray
|
||||
DRay ray = OdeHelper.createRay(space, length);
|
||||
@ -677,7 +677,7 @@ public class CollisionEngine {
|
||||
space.collide2(ray, data, rayCastCallback);
|
||||
//destroy ray
|
||||
ray.destroy();
|
||||
spaceLock.release();
|
||||
spaceLock.unlock();
|
||||
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.
|
||||
*/
|
||||
public Vector3d rayCastPositionMasked(Vector3d start, Vector3d direction, double length, List<String> typeMask){
|
||||
spaceLock.acquireUninterruptibly();
|
||||
spaceLock.lock();
|
||||
Vector3d unitDir = new Vector3d(direction).normalize();
|
||||
//create the ray
|
||||
DRay ray = OdeHelper.createRay(space, length);
|
||||
@ -701,7 +701,7 @@ public class CollisionEngine {
|
||||
space.collide2(ray, data, rayCastCallback);
|
||||
//destroy ray
|
||||
ray.destroy();
|
||||
spaceLock.release();
|
||||
spaceLock.unlock();
|
||||
return data.collisionPosition;
|
||||
}
|
||||
|
||||
@ -724,7 +724,7 @@ public class CollisionEngine {
|
||||
* @param body The DBody to destroy
|
||||
*/
|
||||
protected void destroyDBody(DBody body){
|
||||
spaceLock.acquireUninterruptibly();
|
||||
spaceLock.lock();
|
||||
try {
|
||||
if(bodies.contains(body)){
|
||||
bodies.remove(body);
|
||||
@ -748,7 +748,7 @@ public class CollisionEngine {
|
||||
} catch (NullPointerException ex){
|
||||
LoggerInterface.loggerEngine.ERROR(ex);
|
||||
}
|
||||
spaceLock.release();
|
||||
spaceLock.unlock();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -778,7 +778,7 @@ public class CollisionEngine {
|
||||
* @return The DTriMesh
|
||||
*/
|
||||
protected DTriMesh createTrimeshGeom(float[] verts, int[] indices, long categoryBits){
|
||||
spaceLock.acquireUninterruptibly();
|
||||
spaceLock.lock();
|
||||
DTriMeshData data = OdeHelper.createTriMeshData();
|
||||
data.build(verts, indices);
|
||||
final int preprocessFlags =
|
||||
@ -790,7 +790,7 @@ public class CollisionEngine {
|
||||
DTriMesh rVal = OdeHelper.createTriMesh(space, data);
|
||||
rVal.setTrimeshData(data);
|
||||
rVal.setCategoryBits(categoryBits);
|
||||
spaceLock.release();
|
||||
spaceLock.unlock();
|
||||
return rVal;
|
||||
}
|
||||
|
||||
@ -800,10 +800,10 @@ public class CollisionEngine {
|
||||
* @return The DBox
|
||||
*/
|
||||
protected DBox createCubeGeom(Vector3d dimensions, long categoryBits){
|
||||
spaceLock.acquireUninterruptibly();
|
||||
spaceLock.lock();
|
||||
DBox boxGeom = OdeHelper.createBox(space, dimensions.x, dimensions.y, dimensions.z);
|
||||
boxGeom.setCategoryBits(categoryBits);
|
||||
spaceLock.release();
|
||||
spaceLock.unlock();
|
||||
return boxGeom;
|
||||
}
|
||||
|
||||
@ -813,10 +813,10 @@ public class CollisionEngine {
|
||||
* @return The cylinder geometry
|
||||
*/
|
||||
protected DCylinder createCylinderGeom(double radius, double length, long categoryBits){
|
||||
spaceLock.acquireUninterruptibly();
|
||||
spaceLock.lock();
|
||||
DCylinder cylinderGeom = OdeHelper.createCylinder(space, radius, length);
|
||||
cylinderGeom.setCategoryBits(categoryBits);
|
||||
spaceLock.release();
|
||||
spaceLock.unlock();
|
||||
return cylinderGeom;
|
||||
}
|
||||
|
||||
@ -826,10 +826,10 @@ public class CollisionEngine {
|
||||
* @return The sphere geometry
|
||||
*/
|
||||
protected DSphere createSphereGeom(double radius, long categoryBits){
|
||||
spaceLock.acquireUninterruptibly();
|
||||
spaceLock.lock();
|
||||
DSphere sphereGeom = OdeHelper.createSphere(space, radius);
|
||||
sphereGeom.setCategoryBits(categoryBits);
|
||||
spaceLock.release();
|
||||
spaceLock.unlock();
|
||||
return sphereGeom;
|
||||
}
|
||||
|
||||
@ -840,10 +840,10 @@ public class CollisionEngine {
|
||||
* @return The capsule geometry
|
||||
*/
|
||||
protected DCapsule createCapsuleGeom(double radius, double length, long categoryBits){
|
||||
spaceLock.acquireUninterruptibly();
|
||||
spaceLock.lock();
|
||||
DCapsule capsuleGeom = OdeHelper.createCapsule(space, radius, length);
|
||||
capsuleGeom.setCategoryBits(categoryBits);
|
||||
spaceLock.release();
|
||||
spaceLock.unlock();
|
||||
return capsuleGeom;
|
||||
}
|
||||
|
||||
@ -853,7 +853,7 @@ public class CollisionEngine {
|
||||
* @return The DBody
|
||||
*/
|
||||
protected DBody createDBody(DGeom ...geom){
|
||||
spaceLock.acquireUninterruptibly();
|
||||
spaceLock.lock();
|
||||
DBody body = OdeHelper.createBody(world);
|
||||
body.setDamping(DEFAULT_LINEAR_DAMPING, DEFAULT_ANGULAR_DAMPING);
|
||||
body.setMaxAngularSpeed(DEFAULT_MAX_ANGULAR_SPEED);
|
||||
@ -864,7 +864,7 @@ public class CollisionEngine {
|
||||
}
|
||||
}
|
||||
}
|
||||
spaceLock.release();
|
||||
spaceLock.unlock();
|
||||
return body;
|
||||
}
|
||||
|
||||
@ -877,11 +877,11 @@ public class CollisionEngine {
|
||||
* @return The DMass
|
||||
*/
|
||||
protected DMass createCylinderMass(double massValue, double radius, double length, DBody body, Vector3d offset, Quaterniond rotation){
|
||||
spaceLock.acquireUninterruptibly();
|
||||
spaceLock.lock();
|
||||
DMass mass = OdeHelper.createMass();
|
||||
mass.setCylinder(massValue, 2, radius, length);
|
||||
body.setMass(mass);
|
||||
spaceLock.release();
|
||||
spaceLock.unlock();
|
||||
return mass;
|
||||
}
|
||||
|
||||
@ -893,11 +893,11 @@ public class CollisionEngine {
|
||||
* @return The DMass
|
||||
*/
|
||||
protected DMass createBoxMass(double massValue, Vector3d dims, DBody body, Vector3d offset, Quaterniond rotation){
|
||||
spaceLock.acquireUninterruptibly();
|
||||
spaceLock.lock();
|
||||
DMass mass = OdeHelper.createMass();
|
||||
mass.setBox(massValue, dims.x, dims.y, dims.z);
|
||||
body.setMass(mass);
|
||||
spaceLock.release();
|
||||
spaceLock.unlock();
|
||||
return mass;
|
||||
}
|
||||
|
||||
@ -910,11 +910,11 @@ public class CollisionEngine {
|
||||
* @return The DMass
|
||||
*/
|
||||
protected DMass createCapsuleMass(double massValue, double radius, double length, DBody body, Vector3d offset, Quaterniond rotation){
|
||||
spaceLock.acquireUninterruptibly();
|
||||
spaceLock.lock();
|
||||
DMass mass = OdeHelper.createMass();
|
||||
mass.setCapsule(massValue, 2, radius, length);
|
||||
body.setMass(mass);
|
||||
spaceLock.release();
|
||||
spaceLock.unlock();
|
||||
return mass;
|
||||
}
|
||||
|
||||
@ -927,12 +927,12 @@ public class CollisionEngine {
|
||||
* @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){
|
||||
spaceLock.acquireUninterruptibly();
|
||||
spaceLock.lock();
|
||||
body.setAutoDisableFlag(autoDisable);
|
||||
body.setAutoDisableLinearThreshold(0.1);
|
||||
body.setAutoDisableAngularThreshold(angularThreshold);
|
||||
body.setAutoDisableSteps(steps);
|
||||
spaceLock.release();
|
||||
spaceLock.unlock();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -942,9 +942,9 @@ public class CollisionEngine {
|
||||
* @param angularDamping The angular damping
|
||||
*/
|
||||
protected void setDamping(DBody body, double linearDamping, double angularDamping){
|
||||
spaceLock.acquireUninterruptibly();
|
||||
spaceLock.lock();
|
||||
body.setDamping(linearDamping, angularDamping);
|
||||
spaceLock.release();
|
||||
spaceLock.unlock();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -954,10 +954,10 @@ public class CollisionEngine {
|
||||
* @param rotation The rotation
|
||||
*/
|
||||
protected void setBodyTransform(DBody body, Vector3d position, Quaterniond rotation){
|
||||
spaceLock.acquireUninterruptibly();
|
||||
spaceLock.lock();
|
||||
body.setPosition(position.x, position.y, position.z);
|
||||
body.setQuaternion(PhysicsUtils.jomlQuatToOdeQuat(rotation));
|
||||
spaceLock.release();
|
||||
spaceLock.unlock();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -971,14 +971,14 @@ public class CollisionEngine {
|
||||
* @param angularForce The angular force
|
||||
*/
|
||||
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.setQuaternion(PhysicsUtils.jomlQuatToOdeQuat(rotation));
|
||||
body.setLinearVel(PhysicsUtils.jomlVecToOdeVec(linearVel));
|
||||
body.setAngularVel(PhysicsUtils.jomlVecToOdeVec(angularVel));
|
||||
body.setForce(PhysicsUtils.jomlVecToOdeVec(linearForce));
|
||||
body.setTorque(PhysicsUtils.jomlVecToOdeVec(angularForce));
|
||||
spaceLock.release();
|
||||
spaceLock.unlock();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -989,7 +989,7 @@ public class CollisionEngine {
|
||||
* @param scale The 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.setQuaternion(PhysicsUtils.jomlQuatToOdeQuat(rotation));
|
||||
DGeom firstGeom = body.getFirstGeom();
|
||||
@ -1000,7 +1000,7 @@ public class CollisionEngine {
|
||||
} else if(firstGeom instanceof DCapsule){
|
||||
((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
|
||||
*/
|
||||
protected void setGeomTransform(DGeom geom, Vector3d position, Quaterniond rotation){
|
||||
spaceLock.acquireUninterruptibly();
|
||||
spaceLock.lock();
|
||||
geom.setOffsetWorldPosition(position.x, position.y, position.z);
|
||||
geom.setOffsetQuaternion(PhysicsUtils.jomlQuatToOdeQuat(rotation));
|
||||
spaceLock.release();
|
||||
spaceLock.unlock();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1021,9 +1021,9 @@ public class CollisionEngine {
|
||||
* @param geom the geometry to correct
|
||||
*/
|
||||
protected void setOffsetRotation(DGeom geom){
|
||||
spaceLock.acquireUninterruptibly();
|
||||
spaceLock.lock();
|
||||
geom.setOffsetRotation(CollisionBodyCreation.AXIS_CORRECTION_MATRIX);
|
||||
spaceLock.release();
|
||||
spaceLock.unlock();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1033,9 +1033,9 @@ public class CollisionEngine {
|
||||
*/
|
||||
protected Vector3d getBodyPosition(DBody body){
|
||||
Vector3d rVal = null;
|
||||
spaceLock.acquireUninterruptibly();
|
||||
spaceLock.lock();
|
||||
rVal = PhysicsUtils.odeVecToJomlVec(body.getPosition());
|
||||
spaceLock.release();
|
||||
spaceLock.unlock();
|
||||
return rVal;
|
||||
}
|
||||
|
||||
@ -1046,9 +1046,9 @@ public class CollisionEngine {
|
||||
*/
|
||||
protected Quaterniond getBodyRotation(DBody body){
|
||||
Quaterniond rVal = null;
|
||||
spaceLock.acquireUninterruptibly();
|
||||
spaceLock.lock();
|
||||
rVal = PhysicsUtils.odeQuatToJomlQuat(body.getQuaternion());
|
||||
spaceLock.release();
|
||||
spaceLock.unlock();
|
||||
return rVal;
|
||||
}
|
||||
|
||||
@ -1057,9 +1057,9 @@ public class CollisionEngine {
|
||||
* @param body The body to set
|
||||
*/
|
||||
protected void setKinematic(DBody body){
|
||||
spaceLock.acquireUninterruptibly();
|
||||
spaceLock.lock();
|
||||
body.setKinematic();
|
||||
spaceLock.release();
|
||||
spaceLock.unlock();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1068,9 +1068,9 @@ public class CollisionEngine {
|
||||
* @param gravityMode the gravity mode
|
||||
*/
|
||||
protected void setGravityMode(DBody body, boolean gravityMode){
|
||||
spaceLock.acquireUninterruptibly();
|
||||
spaceLock.lock();
|
||||
body.setGravityMode(gravityMode);
|
||||
spaceLock.release();
|
||||
spaceLock.unlock();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1079,9 +1079,9 @@ public class CollisionEngine {
|
||||
* @param offsetVector The offset position
|
||||
*/
|
||||
protected void setOffsetPosition(DBody body, Vector3d offsetVector){
|
||||
spaceLock.acquireUninterruptibly();
|
||||
spaceLock.lock();
|
||||
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
|
||||
*/
|
||||
protected void setAngularlyStatic(DBody body, boolean angularlyStatic){
|
||||
spaceLock.acquireUninterruptibly();
|
||||
spaceLock.lock();
|
||||
if(angularlyStatic){
|
||||
body.setMaxAngularSpeed(0);
|
||||
} else {
|
||||
body.setMaxAngularSpeed(DEFAULT_MAX_ANGULAR_SPEED);
|
||||
}
|
||||
spaceLock.release();
|
||||
spaceLock.unlock();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1113,11 +1113,11 @@ public class CollisionEngine {
|
||||
* @param geom The geometry
|
||||
*/
|
||||
protected void destroyGeom(DGeom geom){
|
||||
spaceLock.acquireUninterruptibly();
|
||||
spaceLock.lock();
|
||||
this.space.remove(geom);
|
||||
geom.DESTRUCTOR();
|
||||
geom.destroy();
|
||||
spaceLock.release();
|
||||
spaceLock.unlock();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -30,7 +30,7 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import org.lwjgl.assimp.AIScene;
|
||||
import org.ode4j.ode.DBody;
|
||||
@ -47,6 +47,7 @@ public class AssetManager {
|
||||
|
||||
Map<String,Texture> texturesLoadedIntoMemory = new ConcurrentHashMap<String,Texture>();
|
||||
List<String> texturesInQueue = new CopyOnWriteArrayList<String>();
|
||||
List<String> texturesInDeleteQueue = new CopyOnWriteArrayList<String>();
|
||||
|
||||
Map<String,AudioBuffer> audioLoadedIntoMemory = new ConcurrentHashMap<String,AudioBuffer>();
|
||||
List<String> audioInQueue = new CopyOnWriteArrayList<String>();
|
||||
@ -74,8 +75,8 @@ public class AssetManager {
|
||||
|
||||
|
||||
//assets queued to be loaded
|
||||
Semaphore queuedAssetLock = new Semaphore(1);
|
||||
List<QueuedAsset> queuedAssets = new CopyOnWriteArrayList<QueuedAsset>();
|
||||
ReentrantLock queuedAssetLock = new ReentrantLock();
|
||||
List<QueuedAsset> queuedAssets = new LinkedList<QueuedAsset>();
|
||||
|
||||
|
||||
|
||||
@ -158,12 +159,12 @@ public class AssetManager {
|
||||
}
|
||||
//queued assets
|
||||
LoggerInterface.loggerEngine.DEBUG_LOOP("AssetManager - Load queued assets");
|
||||
queuedAssetLock.acquireUninterruptibly();
|
||||
queuedAssetLock.lock();
|
||||
for(QueuedAsset queuedAsset : queuedAssets){
|
||||
queuedAsset.load();
|
||||
}
|
||||
queuedAssets.clear();
|
||||
queuedAssetLock.release();
|
||||
queuedAssetLock.unlock();
|
||||
|
||||
//allocate homogenous buffers
|
||||
LoggerInterface.loggerEngine.DEBUG_LOOP("AssetManager - Allocate homogenous buffers");
|
||||
@ -192,6 +193,19 @@ public class AssetManager {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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){
|
||||
Texture rVal = null;
|
||||
@ -585,9 +607,9 @@ public class AssetManager {
|
||||
* @param asset the asset
|
||||
*/
|
||||
public void queuedAsset(QueuedAsset asset){
|
||||
queuedAssetLock.acquireUninterruptibly();
|
||||
queuedAssetLock.lock();
|
||||
this.queuedAssets.add(asset);
|
||||
queuedAssetLock.release();
|
||||
queuedAssetLock.unlock();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -62,6 +62,7 @@ public class QueuedTexture implements QueuedAsset {
|
||||
texture = new Texture(Globals.renderingEngine.getOpenGLState(), data);
|
||||
} else if(buffer != null){
|
||||
texture = new Texture(Globals.renderingEngine.getOpenGLState(),buffer,width,height);
|
||||
this.buffer = null;
|
||||
}
|
||||
hasLoaded = true;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user