Provide way to usurp frustum culling on actor
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
This commit is contained in:
parent
ba5537bcf7
commit
8c1607d34b
@ -170,16 +170,16 @@ Half pass at cellular automata fluid dynamics system
|
|||||||
- Streaming chunks over network
|
- Streaming chunks over network
|
||||||
- Basic model creation
|
- Basic model creation
|
||||||
|
|
||||||
|
(03/21/2024)
|
||||||
|
Fix character movement (allegedly fixed -- maybe by camera stuff?)
|
||||||
# TODO
|
|
||||||
|
|
||||||
Fix character movement
|
|
||||||
- Walking left or right while turning camera is very jittery
|
- Walking left or right while turning camera is very jittery
|
||||||
- Can lock on moving
|
- Can lock on moving
|
||||||
|
|
||||||
Fix Frustum Culling for skybox
|
Fix Frustum Culling for skybox
|
||||||
|
|
||||||
|
|
||||||
|
# TODO
|
||||||
|
|
||||||
Fix Character creation preview not working
|
Fix Character creation preview not working
|
||||||
|
|
||||||
Clean up main method/class
|
Clean up main method/class
|
||||||
|
|||||||
@ -210,6 +210,7 @@ public class ClientLoading {
|
|||||||
//starry sky true skybox
|
//starry sky true skybox
|
||||||
Entity skybox = EntityCreationUtils.createClientSpatialEntity();
|
Entity skybox = EntityCreationUtils.createClientSpatialEntity();
|
||||||
EntityCreationUtils.makeEntityDrawable(skybox, "Models/skyboxSphere.fbx");
|
EntityCreationUtils.makeEntityDrawable(skybox, "Models/skyboxSphere.fbx");
|
||||||
|
DrawableUtils.disableCulling(skybox);
|
||||||
EntityUtils.getRotation(skybox).rotateX((float)(-Math.PI/2.0f));
|
EntityUtils.getRotation(skybox).rotateX((float)(-Math.PI/2.0f));
|
||||||
EntityUtils.getScale(skybox).mul(2000.0f);
|
EntityUtils.getScale(skybox).mul(2000.0f);
|
||||||
Globals.assetManager.queueOverrideMeshShader("Models/skyboxSphere.fbx", "Sphere", "Shaders/skysphere/skysphere.vs", "Shaders/skysphere/skysphere.fs");
|
Globals.assetManager.queueOverrideMeshShader("Models/skyboxSphere.fbx", "Sphere", "Shaders/skysphere/skysphere.vs", "Shaders/skysphere/skysphere.fs");
|
||||||
@ -217,6 +218,7 @@ public class ClientLoading {
|
|||||||
//cloud ring pseudo skybox
|
//cloud ring pseudo skybox
|
||||||
Entity cloudRing = EntityCreationUtils.createClientSpatialEntity();
|
Entity cloudRing = EntityCreationUtils.createClientSpatialEntity();
|
||||||
EntityCreationUtils.makeEntityDrawable(cloudRing, "Models/cloudRing.fbx");
|
EntityCreationUtils.makeEntityDrawable(cloudRing, "Models/cloudRing.fbx");
|
||||||
|
DrawableUtils.disableCulling(cloudRing);
|
||||||
EntityUtils.getRotation(cloudRing).rotateX((float)(-Math.PI/2.0f));
|
EntityUtils.getRotation(cloudRing).rotateX((float)(-Math.PI/2.0f));
|
||||||
EntityUtils.getScale(cloudRing).mul(1000.0f);
|
EntityUtils.getScale(cloudRing).mul(1000.0f);
|
||||||
Globals.clientScene.registerBehaviorTree(new ApplyRotationTree(cloudRing,new Quaterniond().rotationZ(0.0001)));
|
Globals.clientScene.registerBehaviorTree(new ApplyRotationTree(cloudRing,new Quaterniond().rotationZ(0.0001)));
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
package electrosphere.entity;
|
package electrosphere.entity;
|
||||||
|
|
||||||
|
import electrosphere.renderer.actor.Actor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utilities to manipulating drawable entities (eg making an entity transparent)
|
* Utilities to manipulating drawable entities (eg making an entity transparent)
|
||||||
*/
|
*/
|
||||||
@ -14,4 +16,15 @@ public class DrawableUtils {
|
|||||||
entity.removeData(EntityDataStrings.DRAW_SOLID_PASS);
|
entity.removeData(EntityDataStrings.DRAW_SOLID_PASS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disables culling for the actor on a given entity
|
||||||
|
* @param entity The entity
|
||||||
|
*/
|
||||||
|
public static void disableCulling(Entity entity){
|
||||||
|
Actor actor = EntityUtils.getActor(entity);
|
||||||
|
if(actor != null){
|
||||||
|
actor.setFrustumCull(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package electrosphere.entity.types.fluid;
|
package electrosphere.entity.types.fluid;
|
||||||
|
|
||||||
import electrosphere.client.fluid.manager.ClientFluidManager;
|
import electrosphere.client.fluid.manager.ClientFluidManager;
|
||||||
|
import electrosphere.entity.DrawableUtils;
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.entity.EntityCreationUtils;
|
import electrosphere.entity.EntityCreationUtils;
|
||||||
import electrosphere.entity.EntityDataStrings;
|
import electrosphere.entity.EntityDataStrings;
|
||||||
@ -29,8 +30,7 @@ public class FluidChunk {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
rVal.putData(EntityDataStrings.FLUID_IS_FLUID, true);
|
rVal.putData(EntityDataStrings.FLUID_IS_FLUID, true);
|
||||||
rVal.putData(EntityDataStrings.DRAW_TRANSPARENT_PASS, true);
|
DrawableUtils.makeEntityTransparent(rVal);
|
||||||
rVal.removeData(EntityDataStrings.DRAW_SOLID_PASS);
|
|
||||||
rVal.putData(EntityDataStrings.DATA_STRING_MODEL_PATH, modelPath);
|
rVal.putData(EntityDataStrings.DATA_STRING_MODEL_PATH, modelPath);
|
||||||
|
|
||||||
return rVal;
|
return rVal;
|
||||||
|
|||||||
@ -62,6 +62,9 @@ public class Actor {
|
|||||||
//static morph for this specific actor
|
//static morph for this specific actor
|
||||||
ActorStaticMorph staticMorph;
|
ActorStaticMorph staticMorph;
|
||||||
|
|
||||||
|
//Controls whether the actor should obey frustum culling
|
||||||
|
boolean frustumCull = true;
|
||||||
|
|
||||||
public Actor(String modelPath){
|
public Actor(String modelPath){
|
||||||
this.modelPath = modelPath;
|
this.modelPath = modelPath;
|
||||||
}
|
}
|
||||||
@ -198,7 +201,7 @@ public class Actor {
|
|||||||
public void draw(RenderPipelineState renderPipelineState, OpenGLState openGLState){
|
public void draw(RenderPipelineState renderPipelineState, OpenGLState openGLState){
|
||||||
Model model = Globals.assetManager.fetchModel(modelPath);
|
Model model = Globals.assetManager.fetchModel(modelPath);
|
||||||
boolean hasDrawn = false;
|
boolean hasDrawn = false;
|
||||||
if(model != null && isWithinFrustumBox(renderPipelineState,model)){
|
if(model != null && isWithinFrustumBox(renderPipelineState,model,frustumCull)){
|
||||||
applyAnimationMasks(model);
|
applyAnimationMasks(model);
|
||||||
meshMask.processMeshMaskQueue();
|
meshMask.processMeshMaskQueue();
|
||||||
model.setMeshMask(meshMask);
|
model.setMeshMask(meshMask);
|
||||||
@ -363,13 +366,29 @@ public class Actor {
|
|||||||
return this.staticMorph;
|
return this.staticMorph;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//set should frustum cull
|
||||||
|
public void setFrustumCull(boolean frustumCull){
|
||||||
|
this.frustumCull = frustumCull;
|
||||||
|
}
|
||||||
|
|
||||||
|
//get should frustum cull
|
||||||
|
public boolean getFrustumCull(){
|
||||||
|
return frustumCull;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a given model is within the render pipeline state's frustum box
|
* Checks if a given model is within the render pipeline state's frustum box
|
||||||
* @param renderPipelineState The render pipeline state
|
* @param renderPipelineState The render pipeline state
|
||||||
* @param model The model
|
* @param model The model
|
||||||
|
* @param frustumCull Controls whether the frustum cull should actually be executed or not
|
||||||
* @return true if it is within the box, false otherwise
|
* @return true if it is within the box, false otherwise
|
||||||
*/
|
*/
|
||||||
static boolean isWithinFrustumBox(RenderPipelineState renderPipelineState, Model model){
|
static boolean isWithinFrustumBox(RenderPipelineState renderPipelineState, Model model, boolean frustumCull){
|
||||||
|
if(!frustumCull){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
Sphered sphere = model.getBoundingSphere();
|
Sphered sphere = model.getBoundingSphere();
|
||||||
Vector3d modelPosition = model.getModelMatrix().getTranslation(new Vector3d());
|
Vector3d modelPosition = model.getModelMatrix().getTranslation(new Vector3d());
|
||||||
return renderPipelineState.getFrustumIntersection().testSphere((float)(sphere.x + modelPosition.x), (float)(sphere.y + modelPosition.y), (float)(sphere.z + modelPosition.z), (float)sphere.r);
|
return renderPipelineState.getFrustumIntersection().testSphere((float)(sphere.x + modelPosition.x), (float)(sphere.y + modelPosition.y), (float)(sphere.z + modelPosition.z), (float)sphere.r);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user