|
@@ -23,6 +23,7 @@ class FXAnimation extends h3d.scene.Object {
|
|
public var vecPool = new Evaluator.VecPool();
|
|
public var vecPool = new Evaluator.VecPool();
|
|
var evaluator : Evaluator;
|
|
var evaluator : Evaluator;
|
|
var random : hxd.Rand;
|
|
var random : hxd.Rand;
|
|
|
|
+ var prevTime = 0.0;
|
|
|
|
|
|
public function new(?parent) {
|
|
public function new(?parent) {
|
|
super(parent);
|
|
super(parent);
|
|
@@ -33,10 +34,14 @@ class FXAnimation extends h3d.scene.Object {
|
|
setTime(0);
|
|
setTime(0);
|
|
}
|
|
}
|
|
|
|
|
|
- function init(ctx: Context, prefab: FX) {
|
|
|
|
- initObjAnimations(ctx, prefab);
|
|
|
|
- initEmitters(ctx, prefab);
|
|
|
|
- BaseFX.getShaderAnims(ctx, prefab, shaderAnims);
|
|
|
|
|
|
+ function init(ctx: Context, def: FX, ?root: PrefabElement) {
|
|
|
|
+ if(root == null)
|
|
|
|
+ root = def;
|
|
|
|
+ initObjAnimations(ctx, root);
|
|
|
|
+ initEmitters(ctx, root);
|
|
|
|
+ BaseFX.getShaderAnims(ctx, root, shaderAnims);
|
|
|
|
+ events = initEvents(root, ctx);
|
|
|
|
+ initConstraints(ctx, root);
|
|
for(s in shaderAnims)
|
|
for(s in shaderAnims)
|
|
s.vecPool = vecPool;
|
|
s.vecPool = vecPool;
|
|
}
|
|
}
|
|
@@ -79,7 +84,6 @@ class FXAnimation extends h3d.scene.Object {
|
|
|
|
|
|
static var tempMat = new h3d.Matrix();
|
|
static var tempMat = new h3d.Matrix();
|
|
public function setTime( time : Float ) {
|
|
public function setTime( time : Float ) {
|
|
- var prevTime = this.localTime;
|
|
|
|
this.localTime = time;
|
|
this.localTime = time;
|
|
vecPool.begin();
|
|
vecPool.begin();
|
|
if(objAnims != null) {
|
|
if(objAnims != null) {
|
|
@@ -145,6 +149,20 @@ class FXAnimation extends h3d.scene.Object {
|
|
|
|
|
|
if(script != null)
|
|
if(script != null)
|
|
script.update();
|
|
script.update();
|
|
|
|
+
|
|
|
|
+ this.prevTime = localTime;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function initEvents(elt: PrefabElement, ctx: Context) {
|
|
|
|
+ var childEvents = [for(c in elt.children) if(c.to(Event) != null) c.to(Event)];
|
|
|
|
+ var ret = null;
|
|
|
|
+ for(evt in childEvents) {
|
|
|
|
+ var eventObj = evt.prepare(ctx);
|
|
|
|
+ if(eventObj == null) continue;
|
|
|
|
+ if(ret == null) ret = [];
|
|
|
|
+ ret.push(eventObj);
|
|
|
|
+ }
|
|
|
|
+ return ret;
|
|
}
|
|
}
|
|
|
|
|
|
function initObjAnimations(ctx:Context, elt: PrefabElement) {
|
|
function initObjAnimations(ctx:Context, elt: PrefabElement) {
|
|
@@ -206,14 +224,9 @@ class FXAnimation extends h3d.scene.Object {
|
|
visibility: makeVal("visibility", null),
|
|
visibility: makeVal("visibility", null),
|
|
};
|
|
};
|
|
|
|
|
|
- var childEvents = [for(c in elt.children) if(c.to(Event) != null) c.to(Event)];
|
|
|
|
- for(evt in childEvents) {
|
|
|
|
- var eventObj = evt.prepare(objCtx);
|
|
|
|
- if(eventObj == null) continue;
|
|
|
|
- if(anim.events == null) anim.events = [];
|
|
|
|
- anim.events.push(eventObj);
|
|
|
|
|
|
+ anim.events = initEvents(elt, objCtx);
|
|
|
|
+ if(anim.events != null)
|
|
anyFound = true;
|
|
anyFound = true;
|
|
- }
|
|
|
|
|
|
|
|
if(anyFound) {
|
|
if(anyFound) {
|
|
if(objAnims == null) objAnims = [];
|
|
if(objAnims == null) objAnims = [];
|
|
@@ -303,6 +316,7 @@ class FX extends BaseFX {
|
|
|
|
|
|
#if editor
|
|
#if editor
|
|
super.make(ctx);
|
|
super.make(ctx);
|
|
|
|
+ fxanim.init(ctx, this);
|
|
#else
|
|
#else
|
|
var root = getFXRoot(ctx, this);
|
|
var root = getFXRoot(ctx, this);
|
|
if(root != null){
|
|
if(root != null){
|
|
@@ -310,14 +324,12 @@ class FX extends BaseFX {
|
|
var co = Std.downcast(c , Constraint);
|
|
var co = Std.downcast(c , Constraint);
|
|
if(co == null) c.make(ctx);
|
|
if(co == null) c.make(ctx);
|
|
}
|
|
}
|
|
- fxanim.initConstraints(ctx, root);
|
|
|
|
}
|
|
}
|
|
else
|
|
else
|
|
super.make(ctx);
|
|
super.make(ctx);
|
|
|
|
+ fxanim.init(ctx, this, root);
|
|
#end
|
|
#end
|
|
|
|
|
|
- fxanim.init(ctx, this);
|
|
|
|
-
|
|
|
|
if(scriptCode != null && scriptCode != ""){
|
|
if(scriptCode != null && scriptCode != ""){
|
|
var parser = new FXScriptParser();
|
|
var parser = new FXScriptParser();
|
|
fxanim.script = parser.createFXScript(scriptCode, fxanim);
|
|
fxanim.script = parser.createFXScript(scriptCode, fxanim);
|