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
|
||||
- Basic model creation
|
||||
|
||||
|
||||
|
||||
# TODO
|
||||
|
||||
Fix character movement
|
||||
(03/21/2024)
|
||||
Fix character movement (allegedly fixed -- maybe by camera stuff?)
|
||||
- Walking left or right while turning camera is very jittery
|
||||
- Can lock on moving
|
||||
|
||||
Fix Frustum Culling for skybox
|
||||
|
||||
|
||||
# TODO
|
||||
|
||||
Fix Character creation preview not working
|
||||
|
||||
Clean up main method/class
|
||||
|
||||
@ -210,6 +210,7 @@ public class ClientLoading {
|
||||
//starry sky true skybox
|
||||
Entity skybox = EntityCreationUtils.createClientSpatialEntity();
|
||||
EntityCreationUtils.makeEntityDrawable(skybox, "Models/skyboxSphere.fbx");
|
||||
DrawableUtils.disableCulling(skybox);
|
||||
EntityUtils.getRotation(skybox).rotateX((float)(-Math.PI/2.0f));
|
||||
EntityUtils.getScale(skybox).mul(2000.0f);
|
||||
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
|
||||
Entity cloudRing = EntityCreationUtils.createClientSpatialEntity();
|
||||
EntityCreationUtils.makeEntityDrawable(cloudRing, "Models/cloudRing.fbx");
|
||||
DrawableUtils.disableCulling(cloudRing);
|
||||
EntityUtils.getRotation(cloudRing).rotateX((float)(-Math.PI/2.0f));
|
||||
EntityUtils.getScale(cloudRing).mul(1000.0f);
|
||||
Globals.clientScene.registerBehaviorTree(new ApplyRotationTree(cloudRing,new Quaterniond().rotationZ(0.0001)));
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package electrosphere.entity;
|
||||
|
||||
import electrosphere.renderer.actor.Actor;
|
||||
|
||||
/**
|
||||
* Utilities to manipulating drawable entities (eg making an entity transparent)
|
||||
*/
|
||||
@ -14,4 +16,15 @@ public class DrawableUtils {
|
||||
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;
|
||||
|
||||
import electrosphere.client.fluid.manager.ClientFluidManager;
|
||||
import electrosphere.entity.DrawableUtils;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityCreationUtils;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
@ -29,8 +30,7 @@ public class FluidChunk {
|
||||
// }
|
||||
|
||||
rVal.putData(EntityDataStrings.FLUID_IS_FLUID, true);
|
||||
rVal.putData(EntityDataStrings.DRAW_TRANSPARENT_PASS, true);
|
||||
rVal.removeData(EntityDataStrings.DRAW_SOLID_PASS);
|
||||
DrawableUtils.makeEntityTransparent(rVal);
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_MODEL_PATH, modelPath);
|
||||
|
||||
return rVal;
|
||||
|
||||
@ -61,6 +61,9 @@ public class Actor {
|
||||
|
||||
//static morph for this specific actor
|
||||
ActorStaticMorph staticMorph;
|
||||
|
||||
//Controls whether the actor should obey frustum culling
|
||||
boolean frustumCull = true;
|
||||
|
||||
public Actor(String modelPath){
|
||||
this.modelPath = modelPath;
|
||||
@ -198,7 +201,7 @@ public class Actor {
|
||||
public void draw(RenderPipelineState renderPipelineState, OpenGLState openGLState){
|
||||
Model model = Globals.assetManager.fetchModel(modelPath);
|
||||
boolean hasDrawn = false;
|
||||
if(model != null && isWithinFrustumBox(renderPipelineState,model)){
|
||||
if(model != null && isWithinFrustumBox(renderPipelineState,model,frustumCull)){
|
||||
applyAnimationMasks(model);
|
||||
meshMask.processMeshMaskQueue();
|
||||
model.setMeshMask(meshMask);
|
||||
@ -362,14 +365,30 @@ public class Actor {
|
||||
public ActorStaticMorph getStaticMorph(){
|
||||
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
|
||||
* @param renderPipelineState The render pipeline state
|
||||
* @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
|
||||
*/
|
||||
static boolean isWithinFrustumBox(RenderPipelineState renderPipelineState, Model model){
|
||||
static boolean isWithinFrustumBox(RenderPipelineState renderPipelineState, Model model, boolean frustumCull){
|
||||
if(!frustumCull){
|
||||
return true;
|
||||
}
|
||||
Sphered sphere = model.getBoundingSphere();
|
||||
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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user