Skip to content

Commit

Permalink
Fix crash on select particle when its null
Browse files Browse the repository at this point in the history
Adjust velocity over time in attached/non attached modes
  • Loading branch information
Tom-Ski committed Oct 16, 2024
1 parent 95634ef commit 16e81a6
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public void report(String value) {
ButtonPropertyWidget<String> playButton = new ButtonPropertyWidget<String>("Play", new ButtonPropertyWidget.ButtonListener<String>() {
@Override
public void clicked (ButtonPropertyWidget<String> widget) {
if (component == null || component.getEffectRef() == null) return;
component.getEffectRef().restart();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
import com.artemis.utils.IntBag;
import com.badlogic.gdx.Files;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.VertexAttribute;
import com.badlogic.gdx.graphics.VertexAttributes;
import com.badlogic.gdx.graphics.*;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.g3d.utils.RenderContext;
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
Expand Down Expand Up @@ -182,21 +179,25 @@ public void render (ParticleEffectInstance particleEffectInstance) {
meshGenerator.render(this, drawableModule.getMaterialModule(), particleEmitter.pointData());


// simple3DBatch.end();
// ShapeRenderer shapeRenderer = new ShapeRenderer();
// shapeRenderer.setProjectionMatrix(cameras.getGameCamera().combined);
// shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
// Array<ParticlePointGroup> pointData = particlePointDataGeneratorModule.pointData;
// Array<ParticlePointGroup> pointData = particleEmitter.pointData();
// for (ParticlePointGroup group : pointData) {
// shapeRenderer.setColor(1f, 0, 0, 1f);
// for (ParticlePointData particlePointData : group.pointDataArray) {
// shapeRenderer.circle(particlePointData.x, particlePointData.y, 0.25f, 20);
// }
// shapeRenderer.setColor(Color.RED);
// shapeRenderer.circle(particlePointData.x, particlePointData.y, 0.15f, 20);
// }
// }
// shapeRenderer.end();

//

particleEmitter.getScope().setCurrentRequestMode(cachedMode);
particleEmitter.getScope().setCurrentRequesterID(cachedRequesterID);

// simple3DBatch.begin(cameras.getGameCamera(), shaderProgram.getShaderProgram());
}

simple3DBatch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ public void applyAlpha (float alpha, float delta) {
//Velocity is driven by velocity over time
final Vector3 velocityOverTime = particleModule.getVelocityOverTime();
velocity.set(velocityOverTime);
velocity.rotate(initialWorldRotation, 0, 0, 1);
if (!emitterReference.getEmitterModule().isAttached()) {
velocity.rotate(initialWorldRotation, 0, 0, 1); //not attached rotate it
velocity.scl(worldScale.x, worldScale.y, 0);
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,21 @@ public void render (ParticleEffectInstance particleEffectInstance) {
particleEmitter.getScope().setCurrentRequestMode(ScopePayload.SUB_PARTICLE_ALPHA);
meshGenerator.render(this, drawableModule.getMaterialModule(), particleEmitter.pointData());

// batch.end();
// ShapeRenderer shapeRenderer = new ShapeRenderer();
// shapeRenderer.setProjectionMatrix(camera.combined);
// shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
// Array<ParticlePointGroup> pointData = particleEmitter.pointData();
// for (ParticlePointGroup group : pointData) {
// shapeRenderer.setColor(1f, 0, 0, 1f);
// for (ParticlePointData particlePointData : group.pointDataArray) {
// shapeRenderer.circle(particlePointData.x, particlePointData.y, 10.15f, 20);
// }
// }
// shapeRenderer.end();
// shapeRenderer.dispose();
// batch.begin();

particleEmitter.getScope().setCurrentRequestMode(cachedMode);
particleEmitter.getScope().setCurrentRequesterID(cachedRequesterID);

Expand Down

0 comments on commit 16e81a6

Please sign in to comment.