diff --git a/buildNumber.properties b/buildNumber.properties index 80198752..cb3950ab 100644 --- a/buildNumber.properties +++ b/buildNumber.properties @@ -1,3 +1,3 @@ #maven.buildNumber.plugin properties file -#Sun Nov 24 15:46:03 EST 2024 -buildNumber=404 +#Mon Nov 25 18:13:49 EST 2024 +buildNumber=405 diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index bb1aba2f..ab4e079f 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -1162,6 +1162,7 @@ Geometry mesh generation class Cloud shader VisualShader refactoring VisualShader #include macro implementation +Fix particles not spawning in correct positions # TODO @@ -1190,12 +1191,10 @@ Implement gadgets Bug Fixes - Fix hitbox placement does not scale with entity scale on server - - Fix not all grass tiles update when updating a nearby voxel (ie it doesn't go into negative coordinates to scan for foliage updates) - Calculate bounding sphere for meshes by deforming vertices with bone default pose instead of no bone deform - Fix light cluster mapping for foliage shader - Fix foliage placement - Fix block tree preventing initiating an attack - - Fix particles not spawning in correct positions - Fix flickering when applying yoga signal (may need to rethink arch here) - Fix virtual scrollables not working - Fix foliage flickering on edit @@ -1220,8 +1219,7 @@ Code Generation Rearchitecting - Main render is a ui element (that we can have multiple of) - - Shader handling updates to allow for library based shader compilation - - Also allow injecting consts from the engine itself (ie max lights is dynamically injected, that way never have to worry about .glsl and .java not aligning) + - Shader injecting consts from the engine itself (ie max lights is dynamically injected, that way never have to worry about .glsl and .java not aligning) - Cache busting for particle atlas cache Code cleanup @@ -1269,9 +1267,6 @@ More Debug menus Revisit first attempt at instancing (its really laggy lol) - Maybe have draw call happen on top level entity and immediately queue all children recursively -Shader library system - - Abiltiy to include the shader library in individual files (ie implement #include) - Another pass at grass - Multiple foliage models in same cell diff --git a/src/main/java/electrosphere/client/entity/instance/InstanceTemplate.java b/src/main/java/electrosphere/client/entity/instance/InstanceTemplate.java index 076b3844..ba4f905e 100644 --- a/src/main/java/electrosphere/client/entity/instance/InstanceTemplate.java +++ b/src/main/java/electrosphere/client/entity/instance/InstanceTemplate.java @@ -11,13 +11,19 @@ import electrosphere.renderer.buffer.HomogenousUniformBuffer.HomogenousBufferTyp */ public class InstanceTemplate { - //The path for the model for this instance + /** + * The path for the model for this instance + */ protected String modelPath; - //The total number of instances to draw at a given time + /** + * The total number of instances to draw at a given time + */ protected int capacity; - //The map of all attributes for instanced foliage + /** + * The map of all attributes for instanced foliage + */ protected Map attributes; /** @@ -30,8 +36,14 @@ public class InstanceTemplate { */ int dataBindPoint; - //shader paths + /** + * Vertex shader path + */ protected String vertexPath; + + /** + * Fragment shader path + */ protected String fragmentPath; /** diff --git a/src/main/java/electrosphere/client/entity/particle/ParticleService.java b/src/main/java/electrosphere/client/entity/particle/ParticleService.java index a3d54881..ff443d4d 100644 --- a/src/main/java/electrosphere/client/entity/particle/ParticleService.java +++ b/src/main/java/electrosphere/client/entity/particle/ParticleService.java @@ -3,6 +3,7 @@ package electrosphere.client.entity.particle; import java.util.Arrays; import java.util.List; +import org.joml.Quaterniond; import org.joml.Vector3d; import electrosphere.client.entity.instance.InstanceTemplate; @@ -141,13 +142,16 @@ public class ParticleService extends SignalServiceImpl { * Spawns a particle * @param data The particle data for the particle * @param position The position of the particle + * @param rotation The rotation of the particle * @return The particle */ - public Entity spawn(ParticleData data, Vector3d position){ + public Entity spawn(ParticleData data, Vector3d position, Quaterniond rotation){ Entity rVal = EntityCreationUtils.createClientSpatialEntity(); - InstancedEntityUtils.makeEntityInstanced(rVal, instanceTemplate); + InstancedEntityUtils.makeEntityInstancedWithModelTransform(rVal, instanceTemplate, modelAttrib); DrawableUtils.makeEntityTransparent(rVal); EntityUtils.getPosition(rVal).set(position); + EntityUtils.getRotation(rVal).set(rotation); + EntityUtils.getScale(rVal).set(data.getSize()); ClientParticleTree.attachTree(rVal, data); return rVal; } diff --git a/src/main/java/electrosphere/entity/state/client/particle/ClientParticleEmitterComponent.java b/src/main/java/electrosphere/entity/state/client/particle/ClientParticleEmitterComponent.java index c17323da..7d24d378 100644 --- a/src/main/java/electrosphere/entity/state/client/particle/ClientParticleEmitterComponent.java +++ b/src/main/java/electrosphere/entity/state/client/particle/ClientParticleEmitterComponent.java @@ -47,10 +47,11 @@ public class ClientParticleEmitterComponent implements BehaviorTree { lastEmittedFrame = Globals.timekeeper.getNumberOfRenderFramesElapsed(); //create particle here Vector3d spawnPos = new Vector3d(entityPos); + Quaterniond rotation = new Quaterniond(EntityUtils.getRotation(parent)); if(this.particleEmitter.getOffset() != null){ - spawnPos = spawnPos.add(new Vector3d(this.particleEmitter.getOffset()).rotate(new Quaterniond(EntityUtils.getRotation(parent)))); + spawnPos = spawnPos.add(new Vector3d(this.particleEmitter.getOffset()).rotate(rotation)); } - Globals.particleService.spawn(this.getData(), spawnPos); + Globals.particleService.spawn(this.getData(), spawnPos, rotation); } } diff --git a/src/main/java/electrosphere/entity/state/client/particle/ClientParticleTree.java b/src/main/java/electrosphere/entity/state/client/particle/ClientParticleTree.java index 6018fbe6..1f7852fa 100644 --- a/src/main/java/electrosphere/entity/state/client/particle/ClientParticleTree.java +++ b/src/main/java/electrosphere/entity/state/client/particle/ClientParticleTree.java @@ -101,7 +101,7 @@ public class ClientParticleTree implements BehaviorTree { Vector3f cameraPos = CameraEntityUtils.getCameraCenter(Globals.playerCamera); //update position - position = position.set(new Vector3d(position).add(velocity)); + position.add(velocity); EntityUtils.getPosition(parent).set(position); //update velocity @@ -113,7 +113,7 @@ public class ClientParticleTree implements BehaviorTree { } //add radial acceleration if(this.emitterData.getRadialAcceleration() != null){ - Vector3d towardsParent = new Vector3d(EntityUtils.getPosition(this.particleData.getParentEmitter())).sub(position).normalize().mul(this.emitterData.getRadialAcceleration()); + Vector3d towardsParent = new Vector3d(EntityUtils.getPosition(this.particleData.getParentEmitter())).sub(position.x, position.y, position.z).normalize().mul(this.emitterData.getRadialAcceleration()); velocity = velocity.add(towardsParent); } @@ -155,7 +155,7 @@ public class ClientParticleTree implements BehaviorTree { TextureAtlas particleTextureAtlas = Globals.particleService.getTextureAtlas(); int textureIndex = particleTextureAtlas.getTextureIndex(this.particleData.getTexture()); instancedActor.setAttribute(Globals.particleService.getModelAttrib(), new Matrix4f().translationRotateScale( - new Vector3f((float)position.x,(float)position.y,(float)position.z).sub(cameraPos), + new Vector3f((float)position.x,(float)position.y,(float)position.z).sub(cameraPos.x, cameraPos.y, cameraPos.z), new Quaternionf(rotation), scale )); diff --git a/src/main/java/electrosphere/renderer/actor/instance/InstancedActor.java b/src/main/java/electrosphere/renderer/actor/instance/InstancedActor.java index 0930cbb8..0a46fe49 100644 --- a/src/main/java/electrosphere/renderer/actor/instance/InstancedActor.java +++ b/src/main/java/electrosphere/renderer/actor/instance/InstancedActor.java @@ -26,14 +26,25 @@ import electrosphere.renderer.model.Model; * An instanced actor is a static (not bone animated) actor for an instanced model (eg grass, trees, leaves, rocks, etc) */ public class InstancedActor implements Comparable { - //path of the model that this instanced actor uses + + /** + * Path of the model that this instanced actor uses + */ String modelPath; - //priority and index used for deciding to draw this and where in the data array it is + /** + * priority used for deciding to draw this actor or not + */ int priority; + + /** + * Index used for deciding where in the data array it is + */ int index; - //actually unique information about the instance + /** + * Actually unique information about the instance + */ Map attributes = new HashMap(); /** diff --git a/src/main/java/electrosphere/renderer/pipelines/MainContentPipeline.java b/src/main/java/electrosphere/renderer/pipelines/MainContentPipeline.java index a43cb1b9..619c7ace 100644 --- a/src/main/java/electrosphere/renderer/pipelines/MainContentPipeline.java +++ b/src/main/java/electrosphere/renderer/pipelines/MainContentPipeline.java @@ -117,7 +117,7 @@ public class MainContentPipeline implements RenderPipeline { } } //draw all instanced models - Globals.clientInstanceManager.draw(renderPipelineState,openGLState); + Globals.clientInstanceManager.draw(renderPipelineState, openGLState); this.firstPersonSubPipeline.render(openGLState, renderPipelineState); //