optimizations
Some checks reported errors
studiorailgun/Renderer/pipeline/head Something is wrong with the build of this commit
Some checks reported errors
studiorailgun/Renderer/pipeline/head Something is wrong with the build of this commit
This commit is contained in:
parent
da021f889f
commit
50a816adc0
@ -1,3 +1,3 @@
|
|||||||
#maven.buildNumber.plugin properties file
|
#maven.buildNumber.plugin properties file
|
||||||
#Fri Mar 28 12:07:10 EDT 2025
|
#Fri Mar 28 19:50:10 EDT 2025
|
||||||
buildNumber=611
|
buildNumber=612
|
||||||
|
|||||||
@ -1363,6 +1363,8 @@ Lower duplicate physics frame count
|
|||||||
Various code cleanup
|
Various code cleanup
|
||||||
Stop sleeping during high frame time
|
Stop sleeping during high frame time
|
||||||
Actor bone spatial data caching for performance
|
Actor bone spatial data caching for performance
|
||||||
|
Volumetric pipeline optimization
|
||||||
|
Collidable tree simplification
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -75,7 +75,7 @@ public class CollisionEngine {
|
|||||||
* IE, if this value is 3, every main game engine frame, the physics simulation will run 3 frames.
|
* IE, if this value is 3, every main game engine frame, the physics simulation will run 3 frames.
|
||||||
* This keeps the physics simulation much more stable than it would be otherwise.
|
* This keeps the physics simulation much more stable than it would be otherwise.
|
||||||
*/
|
*/
|
||||||
public static final int PHYSICS_SIMULATION_RESOLUTION = 2;
|
public static final int PHYSICS_SIMULATION_RESOLUTION = 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Threshold after which the engine warns about collidable count
|
* Threshold after which the engine warns about collidable count
|
||||||
|
|||||||
@ -1,18 +1,12 @@
|
|||||||
package electrosphere.entity.state.collidable;
|
package electrosphere.entity.state.collidable;
|
||||||
|
|
||||||
import electrosphere.collision.PhysicsUtils;
|
|
||||||
import electrosphere.collision.collidable.Collidable;
|
import electrosphere.collision.collidable.Collidable;
|
||||||
import electrosphere.engine.Globals;
|
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.entity.EntityDataStrings;
|
import electrosphere.entity.EntityDataStrings;
|
||||||
import electrosphere.entity.EntityUtils;
|
|
||||||
import electrosphere.entity.btree.BehaviorTree;
|
import electrosphere.entity.btree.BehaviorTree;
|
||||||
import electrosphere.entity.state.gravity.ServerGravityTree;
|
import electrosphere.entity.state.gravity.ServerGravityTree;
|
||||||
import electrosphere.entity.state.movement.fall.ServerFallTree;
|
import electrosphere.entity.state.movement.fall.ServerFallTree;
|
||||||
import electrosphere.server.datacell.Realm;
|
|
||||||
|
|
||||||
import org.joml.Quaterniond;
|
|
||||||
import org.joml.Vector3d;
|
|
||||||
import org.ode4j.ode.DBody;
|
import org.ode4j.ode.DBody;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,9 +36,6 @@ public class ServerCollidableTree implements BehaviorTree {
|
|||||||
static int incrementer = 0;
|
static int incrementer = 0;
|
||||||
|
|
||||||
public void simulate(float deltaTime){
|
public void simulate(float deltaTime){
|
||||||
Vector3d position = EntityUtils.getPosition(parent);
|
|
||||||
Quaterniond rotation = EntityUtils.getRotation(parent);
|
|
||||||
Vector3d newPosition = new Vector3d(position);
|
|
||||||
//have we hit a terrain impulse?
|
//have we hit a terrain impulse?
|
||||||
//handle impulses
|
//handle impulses
|
||||||
for(Impulse impulse : collidable.getImpulses()){
|
for(Impulse impulse : collidable.getImpulses()){
|
||||||
@ -57,18 +48,6 @@ public class ServerCollidableTree implements BehaviorTree {
|
|||||||
this.resetGravityFall();
|
this.resetGravityFall();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Realm realm = Globals.realmManager.getEntityRealm(parent);
|
|
||||||
//bound to world bounds
|
|
||||||
if(newPosition.x < realm.getServerWorldData().getWorldBoundMin().x){
|
|
||||||
newPosition.x = realm.getServerWorldData().getWorldBoundMin().x;
|
|
||||||
}
|
|
||||||
if(newPosition.y < realm.getServerWorldData().getWorldBoundMin().y){
|
|
||||||
newPosition.y = realm.getServerWorldData().getWorldBoundMin().y;
|
|
||||||
}
|
|
||||||
if(newPosition.z < realm.getServerWorldData().getWorldBoundMin().z){
|
|
||||||
newPosition.z = realm.getServerWorldData().getWorldBoundMin().z;
|
|
||||||
}
|
|
||||||
PhysicsUtils.setRigidBodyTransform(realm.getCollisionEngine(), newPosition, rotation, body);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -69,6 +69,7 @@ public class MainContentPipeline implements RenderPipeline {
|
|||||||
//
|
//
|
||||||
// D R A W A L L E N T I T I E S
|
// D R A W A L L E N T I T I E S
|
||||||
//
|
//
|
||||||
|
Globals.profiler.beginCpuSample("MainContentPipeline.render - Solids non-instanced");
|
||||||
for(Entity currentEntity : Globals.clientScene.getEntitiesWithTag(EntityTags.DRAWABLE)){
|
for(Entity currentEntity : Globals.clientScene.getEntitiesWithTag(EntityTags.DRAWABLE)){
|
||||||
Vector3d position = EntityUtils.getPosition(currentEntity);
|
Vector3d position = EntityUtils.getPosition(currentEntity);
|
||||||
if(shouldDrawSolidPass(currentEntity)){
|
if(shouldDrawSolidPass(currentEntity)){
|
||||||
@ -86,7 +87,11 @@ public class MainContentPipeline implements RenderPipeline {
|
|||||||
currentActor.draw(renderPipelineState,openGLState);
|
currentActor.draw(renderPipelineState,openGLState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Globals.profiler.endCpuSample();
|
||||||
|
Globals.profiler.beginCpuSample("MainContentPipeline.render - Solids Foliage");
|
||||||
Globals.renderingEngine.getFoliagePipeline().render(openGLState, renderPipelineState);
|
Globals.renderingEngine.getFoliagePipeline().render(openGLState, renderPipelineState);
|
||||||
|
Globals.profiler.endCpuSample();
|
||||||
|
Globals.profiler.beginCpuSample("MainContentPipeline.render - Solids instanced");
|
||||||
for(Entity currentEntity : Globals.clientScene.getEntitiesWithTag(EntityTags.DRAW_INSTANCED)){
|
for(Entity currentEntity : Globals.clientScene.getEntitiesWithTag(EntityTags.DRAW_INSTANCED)){
|
||||||
Vector3d position = EntityUtils.getPosition(currentEntity);
|
Vector3d position = EntityUtils.getPosition(currentEntity);
|
||||||
if(shouldDrawSolidPass(currentEntity)){
|
if(shouldDrawSolidPass(currentEntity)){
|
||||||
@ -115,6 +120,7 @@ public class MainContentPipeline implements RenderPipeline {
|
|||||||
}
|
}
|
||||||
//draw all instanced models
|
//draw all instanced models
|
||||||
Globals.clientInstanceManager.draw(renderPipelineState, openGLState);
|
Globals.clientInstanceManager.draw(renderPipelineState, openGLState);
|
||||||
|
Globals.profiler.endCpuSample();
|
||||||
this.firstPersonSubPipeline.render(openGLState, renderPipelineState);
|
this.firstPersonSubPipeline.render(openGLState, renderPipelineState);
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -149,7 +155,7 @@ public class MainContentPipeline implements RenderPipeline {
|
|||||||
//TLDR OF ABOVE: DO NOT DRAW TRANSPARENT OBJECTS IN OPAQUE PASS
|
//TLDR OF ABOVE: DO NOT DRAW TRANSPARENT OBJECTS IN OPAQUE PASS
|
||||||
//
|
//
|
||||||
|
|
||||||
|
Globals.profiler.beginCpuSample("MainContentPipeline.render - Transparents non-instanced");
|
||||||
for(Entity currentEntity : Globals.clientScene.getEntitiesWithTag(EntityTags.DRAWABLE)){
|
for(Entity currentEntity : Globals.clientScene.getEntitiesWithTag(EntityTags.DRAWABLE)){
|
||||||
Vector3d position = EntityUtils.getPosition(currentEntity);
|
Vector3d position = EntityUtils.getPosition(currentEntity);
|
||||||
if(shouldDrawTransparentPass(currentEntity)){
|
if(shouldDrawTransparentPass(currentEntity)){
|
||||||
@ -167,6 +173,8 @@ public class MainContentPipeline implements RenderPipeline {
|
|||||||
currentActor.draw(renderPipelineState,openGLState);
|
currentActor.draw(renderPipelineState,openGLState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Globals.profiler.endCpuSample();
|
||||||
|
Globals.profiler.beginCpuSample("MainContentPipeline.render - Transparents instanced");
|
||||||
for(Entity currentEntity : Globals.clientScene.getEntitiesWithTag(EntityTags.DRAW_INSTANCED)){
|
for(Entity currentEntity : Globals.clientScene.getEntitiesWithTag(EntityTags.DRAW_INSTANCED)){
|
||||||
Vector3d position = EntityUtils.getPosition(currentEntity);
|
Vector3d position = EntityUtils.getPosition(currentEntity);
|
||||||
if(shouldDrawTransparentPass(currentEntity)){
|
if(shouldDrawTransparentPass(currentEntity)){
|
||||||
@ -195,6 +203,7 @@ public class MainContentPipeline implements RenderPipeline {
|
|||||||
}
|
}
|
||||||
//draw all instanced models
|
//draw all instanced models
|
||||||
Globals.clientInstanceManager.draw(renderPipelineState,openGLState);
|
Globals.clientInstanceManager.draw(renderPipelineState,openGLState);
|
||||||
|
Globals.profiler.endCpuSample();
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
package electrosphere.renderer.pipelines;
|
package electrosphere.renderer.pipelines;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.joml.Matrix4d;
|
import org.joml.Matrix4d;
|
||||||
import org.joml.Vector3d;
|
import org.joml.Vector3d;
|
||||||
import org.lwjgl.opengl.GL40;
|
import org.lwjgl.opengl.GL40;
|
||||||
@ -23,133 +25,138 @@ public class VolumeBufferPipeline implements RenderPipeline {
|
|||||||
@Override
|
@Override
|
||||||
public void render(OpenGLState openGLState, RenderPipelineState renderPipelineState) {
|
public void render(OpenGLState openGLState, RenderPipelineState renderPipelineState) {
|
||||||
Globals.profiler.beginCpuSample("VolumeBufferPipeline.render");
|
Globals.profiler.beginCpuSample("VolumeBufferPipeline.render");
|
||||||
Matrix4d modelTransformMatrix = new Matrix4d();
|
|
||||||
|
|
||||||
//set the viewport to shadow map size
|
|
||||||
openGLState.glViewport(Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT);
|
|
||||||
openGLState.glDepthTest(true);
|
|
||||||
openGLState.glDepthFunc(GL40.GL_LESS);
|
|
||||||
GL40.glDepthMask(true);
|
|
||||||
|
|
||||||
//stop rendering front faces
|
|
||||||
GL40.glEnable(GL40.GL_CULL_FACE);
|
|
||||||
GL40.glCullFace(GL40.GL_FRONT);
|
|
||||||
|
|
||||||
//setup rendering for back faces
|
Set<Entity> depthEntities = Globals.clientScene.getEntitiesWithTag(EntityTags.DRAW_VOLUMETIC_DEPTH_PASS);
|
||||||
openGLState.setActiveShader(renderPipelineState, RenderingEngine.volumeDepthShaderProgram);
|
|
||||||
RenderingEngine.volumeDepthBackfaceFramebuffer.bind(openGLState);
|
|
||||||
GL40.glClear(GL40.GL_DEPTH_BUFFER_BIT);
|
|
||||||
openGLState.glActiveTexture(GL40.GL_TEXTURE0);
|
|
||||||
|
|
||||||
GL40.glUniformMatrix4fv(GL40.glGetUniformLocation(openGLState.getActiveShader().getId(), "view"), false, Globals.viewMatrix.get(new float[16]));
|
if(depthEntities != null && depthEntities.size() > 0){
|
||||||
GL40.glUniformMatrix4fv(GL40.glGetUniformLocation(openGLState.getActiveShader().getId(), "projection"), false, RenderingEngine.nearVolumeProjectionMatrix.get(new float[16]));
|
Matrix4d modelTransformMatrix = new Matrix4d();
|
||||||
GL40.glUniform1f(GL40.glGetUniformLocation(openGLState.getActiveShader().getId(), "linearCoef"), RenderingEngine.volumeDepthLinearCoef);
|
|
||||||
GL40.glUniform1f(GL40.glGetUniformLocation(openGLState.getActiveShader().getId(), "quadCoef"), RenderingEngine.volumeDepthQuadCoef);
|
//set the viewport to shadow map size
|
||||||
GL40.glUniform1f(GL40.glGetUniformLocation(openGLState.getActiveShader().getId(), "near"), 0.1f);
|
openGLState.glViewport(Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT);
|
||||||
GL40.glUniform1f(GL40.glGetUniformLocation(openGLState.getActiveShader().getId(), "far"), 100f);
|
openGLState.glDepthTest(true);
|
||||||
|
openGLState.glDepthFunc(GL40.GL_LESS);
|
||||||
//
|
GL40.glDepthMask(true);
|
||||||
// Set render pipeline state
|
|
||||||
//
|
//stop rendering front faces
|
||||||
renderPipelineState.setUseMeshShader(false);
|
GL40.glEnable(GL40.GL_CULL_FACE);
|
||||||
renderPipelineState.setBufferStandardUniforms(false);
|
GL40.glCullFace(GL40.GL_FRONT);
|
||||||
renderPipelineState.setBufferNonStandardUniforms(true);
|
|
||||||
renderPipelineState.setUseMaterial(false);
|
//setup rendering for back faces
|
||||||
renderPipelineState.setUseShadowMap(false);
|
openGLState.setActiveShader(renderPipelineState, RenderingEngine.volumeDepthShaderProgram);
|
||||||
renderPipelineState.setUseBones(true);
|
RenderingEngine.volumeDepthBackfaceFramebuffer.bind(openGLState);
|
||||||
renderPipelineState.setUseLight(false);
|
GL40.glClear(GL40.GL_DEPTH_BUFFER_BIT);
|
||||||
|
openGLState.glActiveTexture(GL40.GL_TEXTURE0);
|
||||||
|
|
||||||
|
GL40.glUniformMatrix4fv(GL40.glGetUniformLocation(openGLState.getActiveShader().getId(), "view"), false, Globals.viewMatrix.get(new float[16]));
|
||||||
|
GL40.glUniformMatrix4fv(GL40.glGetUniformLocation(openGLState.getActiveShader().getId(), "projection"), false, RenderingEngine.nearVolumeProjectionMatrix.get(new float[16]));
|
||||||
|
GL40.glUniform1f(GL40.glGetUniformLocation(openGLState.getActiveShader().getId(), "linearCoef"), RenderingEngine.volumeDepthLinearCoef);
|
||||||
|
GL40.glUniform1f(GL40.glGetUniformLocation(openGLState.getActiveShader().getId(), "quadCoef"), RenderingEngine.volumeDepthQuadCoef);
|
||||||
|
GL40.glUniform1f(GL40.glGetUniformLocation(openGLState.getActiveShader().getId(), "near"), 0.1f);
|
||||||
|
GL40.glUniform1f(GL40.glGetUniformLocation(openGLState.getActiveShader().getId(), "far"), 100f);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Set render pipeline state
|
||||||
|
//
|
||||||
|
renderPipelineState.setUseMeshShader(false);
|
||||||
|
renderPipelineState.setBufferStandardUniforms(false);
|
||||||
|
renderPipelineState.setBufferNonStandardUniforms(true);
|
||||||
|
renderPipelineState.setUseMaterial(false);
|
||||||
|
renderPipelineState.setUseShadowMap(false);
|
||||||
|
renderPipelineState.setUseBones(true);
|
||||||
|
renderPipelineState.setUseLight(false);
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// D R A W A L L E N T I T I E S
|
// D R A W A L L E N T I T I E S
|
||||||
//
|
//
|
||||||
for(Entity currentEntity : Globals.clientScene.getEntitiesWithTag(EntityTags.DRAW_VOLUMETIC_DEPTH_PASS)){
|
for(Entity currentEntity : Globals.clientScene.getEntitiesWithTag(EntityTags.DRAW_VOLUMETIC_DEPTH_PASS)){
|
||||||
Vector3d position = EntityUtils.getPosition(currentEntity);
|
Vector3d position = EntityUtils.getPosition(currentEntity);
|
||||||
if(
|
if(
|
||||||
currentEntity.getData(EntityDataStrings.DATA_STRING_DRAW)!=null
|
currentEntity.getData(EntityDataStrings.DATA_STRING_DRAW)!=null
|
||||||
){
|
){
|
||||||
//fetch actor
|
//fetch actor
|
||||||
Actor currentActor = EntityUtils.getActor(currentEntity);
|
Actor currentActor = EntityUtils.getActor(currentEntity);
|
||||||
//calculate camera-modified vector3d
|
//calculate camera-modified vector3d
|
||||||
Vector3d cameraModifiedPosition = new Vector3d(position).sub(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
Vector3d cameraModifiedPosition = new Vector3d(position).sub(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
||||||
modelTransformMatrix = modelTransformMatrix.identity();
|
modelTransformMatrix = modelTransformMatrix.identity();
|
||||||
modelTransformMatrix.translate(cameraModifiedPosition);
|
modelTransformMatrix.translate(cameraModifiedPosition);
|
||||||
modelTransformMatrix.rotate(EntityUtils.getRotation(currentEntity));
|
modelTransformMatrix.rotate(EntityUtils.getRotation(currentEntity));
|
||||||
modelTransformMatrix.scale(new Vector3d(EntityUtils.getScale(currentEntity)));
|
modelTransformMatrix.scale(new Vector3d(EntityUtils.getScale(currentEntity)));
|
||||||
currentActor.applySpatialData(modelTransformMatrix,position);
|
currentActor.applySpatialData(modelTransformMatrix,position);
|
||||||
currentActor.draw(renderPipelineState,openGLState);
|
currentActor.draw(renderPipelineState,openGLState);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
//Draw front faces of all non-volumetrics
|
//Draw front faces of all non-volumetrics
|
||||||
//
|
//
|
||||||
for(Entity currentEntity : Globals.clientScene.getEntitiesWithTag(EntityTags.DRAW_VOLUMETIC_SOLIDS_PASS)){
|
for(Entity currentEntity : Globals.clientScene.getEntitiesWithTag(EntityTags.DRAW_VOLUMETIC_SOLIDS_PASS)){
|
||||||
Vector3d position = EntityUtils.getPosition(currentEntity);
|
Vector3d position = EntityUtils.getPosition(currentEntity);
|
||||||
if(
|
if(
|
||||||
(boolean)currentEntity.getData(EntityDataStrings.DATA_STRING_DRAW)
|
(boolean)currentEntity.getData(EntityDataStrings.DATA_STRING_DRAW)
|
||||||
){
|
){
|
||||||
//fetch actor
|
//fetch actor
|
||||||
Actor currentActor = EntityUtils.getActor(currentEntity);
|
Actor currentActor = EntityUtils.getActor(currentEntity);
|
||||||
//calculate camera-modified vector3d
|
//calculate camera-modified vector3d
|
||||||
Vector3d cameraModifiedPosition = new Vector3d(position).sub(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
Vector3d cameraModifiedPosition = new Vector3d(position).sub(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
||||||
//set projection matrix
|
//set projection matrix
|
||||||
modelTransformMatrix = modelTransformMatrix.identity();
|
modelTransformMatrix = modelTransformMatrix.identity();
|
||||||
modelTransformMatrix.translate(cameraModifiedPosition);
|
modelTransformMatrix.translate(cameraModifiedPosition);
|
||||||
modelTransformMatrix.rotate(EntityUtils.getRotation(currentEntity));
|
modelTransformMatrix.rotate(EntityUtils.getRotation(currentEntity));
|
||||||
modelTransformMatrix.scale(new Vector3d(EntityUtils.getScale(currentEntity)));
|
modelTransformMatrix.scale(new Vector3d(EntityUtils.getScale(currentEntity)));
|
||||||
currentActor.applySpatialData(modelTransformMatrix,position);
|
currentActor.applySpatialData(modelTransformMatrix,position);
|
||||||
currentActor.draw(renderPipelineState,openGLState);
|
currentActor.draw(renderPipelineState,openGLState);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//stop rendering front faces
|
//stop rendering front faces
|
||||||
GL40.glEnable(GL40.GL_CULL_FACE);
|
GL40.glEnable(GL40.GL_CULL_FACE);
|
||||||
GL40.glCullFace(GL40.GL_BACK);
|
GL40.glCullFace(GL40.GL_BACK);
|
||||||
|
|
||||||
//setup state for depth testing front faces
|
//setup state for depth testing front faces
|
||||||
openGLState.setActiveShader(renderPipelineState, RenderingEngine.volumeDepthShaderProgram);
|
openGLState.setActiveShader(renderPipelineState, RenderingEngine.volumeDepthShaderProgram);
|
||||||
RenderingEngine.volumeDepthFrontfaceFramebuffer.bind(openGLState);
|
RenderingEngine.volumeDepthFrontfaceFramebuffer.bind(openGLState);
|
||||||
GL40.glClear(GL40.GL_DEPTH_BUFFER_BIT);
|
GL40.glClear(GL40.GL_DEPTH_BUFFER_BIT);
|
||||||
openGLState.glActiveTexture(GL40.GL_TEXTURE0);
|
openGLState.glActiveTexture(GL40.GL_TEXTURE0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// D R A W A L L E N T I T I E S
|
// D R A W A L L E N T I T I E S
|
||||||
//
|
//
|
||||||
for(Entity currentEntity : Globals.clientScene.getEntitiesWithTag(EntityTags.DRAW_VOLUMETIC_DEPTH_PASS)){
|
for(Entity currentEntity : Globals.clientScene.getEntitiesWithTag(EntityTags.DRAW_VOLUMETIC_DEPTH_PASS)){
|
||||||
Vector3d position = EntityUtils.getPosition(currentEntity);
|
Vector3d position = EntityUtils.getPosition(currentEntity);
|
||||||
if(
|
if(
|
||||||
(boolean)currentEntity.getData(EntityDataStrings.DATA_STRING_DRAW)
|
(boolean)currentEntity.getData(EntityDataStrings.DATA_STRING_DRAW)
|
||||||
){
|
){
|
||||||
//fetch actor
|
//fetch actor
|
||||||
Actor currentActor = EntityUtils.getActor(currentEntity);
|
Actor currentActor = EntityUtils.getActor(currentEntity);
|
||||||
//calculate camera-modified vector3d
|
//calculate camera-modified vector3d
|
||||||
Vector3d cameraModifiedPosition = new Vector3d(position).sub(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
Vector3d cameraModifiedPosition = new Vector3d(position).sub(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
||||||
//calculate and apply model transform
|
//calculate and apply model transform
|
||||||
modelTransformMatrix = modelTransformMatrix.identity();
|
modelTransformMatrix = modelTransformMatrix.identity();
|
||||||
modelTransformMatrix.translate(cameraModifiedPosition);
|
modelTransformMatrix.translate(cameraModifiedPosition);
|
||||||
modelTransformMatrix.rotate(EntityUtils.getRotation(currentEntity));
|
modelTransformMatrix.rotate(EntityUtils.getRotation(currentEntity));
|
||||||
modelTransformMatrix.scale(new Vector3d(EntityUtils.getScale(currentEntity)));
|
modelTransformMatrix.scale(new Vector3d(EntityUtils.getScale(currentEntity)));
|
||||||
currentActor.applySpatialData(modelTransformMatrix,position);
|
currentActor.applySpatialData(modelTransformMatrix,position);
|
||||||
//draw
|
//draw
|
||||||
currentActor.draw(renderPipelineState,openGLState);
|
currentActor.draw(renderPipelineState,openGLState);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
GL40.glCullFace(GL40.GL_BACK);
|
GL40.glCullFace(GL40.GL_BACK);
|
||||||
//now cull back faces
|
//now cull back faces
|
||||||
|
|
||||||
//reset texture
|
//reset texture
|
||||||
openGLState.glActiveTexture(GL40.GL_TEXTURE0);
|
openGLState.glActiveTexture(GL40.GL_TEXTURE0);
|
||||||
openGLState.glBindTexture(GL40.GL_TEXTURE_2D, 0);
|
openGLState.glBindTexture(GL40.GL_TEXTURE_2D, 0);
|
||||||
//bind default framebuffer
|
//bind default framebuffer
|
||||||
openGLState.glBindFramebuffer(GL40.GL_FRAMEBUFFER,0);
|
openGLState.glBindFramebuffer(GL40.GL_FRAMEBUFFER,0);
|
||||||
//resume culling backface
|
//resume culling backface
|
||||||
GL40.glDisable(GL40.GL_CULL_FACE);
|
GL40.glDisable(GL40.GL_CULL_FACE);
|
||||||
|
}
|
||||||
|
|
||||||
Globals.profiler.endCpuSample();
|
Globals.profiler.endCpuSample();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user