2
0
Эх сурвалжийг харах

FX: support seedgroup on emitters

trethaller 5 жил өмнө
parent
commit
9c2d2b292e

+ 4 - 1
hrt/prefab/fx/Emitter.hx

@@ -297,6 +297,7 @@ class EmitterObject extends h3d.scene.Object {
 
 	public var particleTemplate : hrt.prefab.Object3D;
 	public var maxCount = 20;
+	public var seedGroup = 0;
 	public var lifeTime = 2.0;
 	public var lifeTimeRand = 0.0;
 	public var emitShape : EmitShape = Cylinder;
@@ -633,7 +634,7 @@ class EmitterObject extends h3d.scene.Object {
 	}
 
 	public function setRandSeed(seed: Int) {
-		randomSeed = seed;
+		randomSeed = seed ^ seedGroup;
 		reset();
 	}
 
@@ -675,6 +676,7 @@ class Emitter extends Object3D {
 		{ name: "lifeTime", t: PFloat(0, 10), def: 1.0 },
 		{ name: "lifeTimeRand", t: PFloat(0, 1), def: 0.0 },
 		{ name: "maxCount", t: PInt(0, 100), def: 20, },
+		{ name: "seedGroup", t: PInt(0, 100), def: 0, },
 		{ name: "emitShape", t: PEnum(EmitShape), def: EmitShape.Sphere, disp: "Emit Shape", },
 		{ name: "emitAngle", t: PFloat(0, 360.0), disp: "Angle", },
 		{ name: "emitRad1", t: PFloat(0, 1.0), def: 1.0, disp: "Radius 1", },
@@ -865,6 +867,7 @@ class Emitter extends Object3D {
 		emitterObj.lifeTime = getParamVal("lifeTime");
 		emitterObj.lifeTimeRand = getParamVal("lifeTimeRand");
 		emitterObj.maxCount = getParamVal("maxCount");
+		emitterObj.seedGroup = getParamVal("seedGroup");
 		emitterObj.emitRate = makeParam(this, "emitRate");
 		emitterObj.emitShape = getParamVal("emitShape");
 		emitterObj.emitOrientation = getParamVal("emitOrientation");

+ 8 - 3
hrt/prefab/fx/FX.hx

@@ -24,10 +24,12 @@ class FXAnimation extends h3d.scene.Object {
 	var evaluator : Evaluator;
 	var random : hxd.Rand;
 	var prevTime = -1.0;
+	var randSeed : Int;
 
 	public function new(?parent) {
 		super(parent);
-		random = new hxd.Rand(Std.random(0xFFFFFF));
+		randSeed = Std.random(0xFFFFFF);
+		random = new hxd.Rand(randSeed);
 		evaluator = new Evaluator(random);
 		evaluator.vecPool = vecPool;
 		name = "FXAnimation";
@@ -57,10 +59,11 @@ class FXAnimation extends h3d.scene.Object {
 	}
 
 	public function setRandSeed(seed: Int) {
+		randSeed = seed;
 		random.init(seed);
 		if(emitters != null)
 			for(em in emitters)
-				em.setRandSeed(seed);
+				em.setRandSeed(randSeed);
 	}
 
 	override function sync( ctx : h3d.scene.RenderContext ) {
@@ -241,7 +244,9 @@ class FXAnimation extends h3d.scene.Object {
 			for(emCtx in ctx.shared.getContexts(elt)) {
 				if(emCtx.local3d == null) continue;
 				if(emitters == null) emitters = [];
-				emitters.push(cast emCtx.local3d);
+				var emobj : hrt.prefab.fx.Emitter.EmitterObject = cast emCtx.local3d;
+				emobj.setRandSeed(randSeed);
+				emitters.push(emobj);
 			}
 		}
 		else {