Skip to content

Commit

Permalink
Animation: make accessors for events and objects, allowing animation …
Browse files Browse the repository at this point in the history
…wrappers
  • Loading branch information
trethaller committed Nov 19, 2018
1 parent 755d98b commit f836e0a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
6 changes: 5 additions & 1 deletion h3d/anim/Animation.hx
Expand Up @@ -35,7 +35,7 @@ class Animation implements hxd.impl.Serializable {
@:s public var pause : Bool;
@:s public var loop : Bool;

public var events(default, null) : Array<Array<String>>;
var events : Array<Array<String>>;

var isInstance : Bool;
var objects : Array<AnimatedObject>;
Expand Down Expand Up @@ -97,6 +97,10 @@ class Animation implements hxd.impl.Serializable {
events[frame].push(data);
}

public function getEvents() return events;

public function getObjects() return objects;

public function setFrame( f : Float ) {
frame = f;
lastEvent = -1;
Expand Down
14 changes: 9 additions & 5 deletions h3d/anim/SmoothTarget.hx
Expand Up @@ -36,7 +36,7 @@ class SmoothTarget extends Animation {

function initObjects() {
objects = [];
for( o in target.objects ) {
for( o in target.getObjects() ) {
var mat = null;
var s = new SmoothObject(o.objectName);
s.targetObject = o.targetObject;
Expand Down Expand Up @@ -79,14 +79,18 @@ class SmoothTarget extends Animation {
frame = target.frame;
}

function getObjects() : Array<SmoothObject> {
override function getEvents() {
return target.getEvents();
}

function getSmoothObjects() : Array<SmoothObject> {
return cast objects;
}

@:noDebug
override function sync( decompose = false ) {
if( decompose ) throw "assert";
var objects = getObjects();
var objects = getSmoothObjects();
var q1 = new h3d.Quat(), qout = new h3d.Quat();
target.sync(true);
for( o in objects ) {
Expand Down Expand Up @@ -150,10 +154,10 @@ class SmoothTarget extends Animation {
override function initAndBind( obj : h3d.scene.Object ) {
super.initAndBind(obj);
target.initAndBind(obj);
var old : Array<SmoothObject> = getObjects();
var old : Array<SmoothObject> = getSmoothObjects();
initObjects();
var index = 0;
var objects = [for( o in getObjects() ) o.objectName => o];
var objects = [for( o in getSmoothObjects() ) o.objectName => o];

for( i in 0...old.length ) {
var o = old[i];
Expand Down

0 comments on commit f836e0a

Please sign in to comment.