Permalink
Browse files

minor fixes

  • Loading branch information...
1 parent a27c569 commit c828a31719b03f2e4c2393607436d145dc19302f @ncannasse ncannasse committed Dec 27, 2012
Showing with 30 additions and 17 deletions.
  1. +10 −10 h2d/CachedBitmap.hx
  2. +2 −2 h3d/fbx/Library.hx
  3. +18 −5 h3d/prim/Animation.hx
View
@@ -17,20 +17,22 @@ class CachedBitmap extends Drawable {
this.width = width;
this.height = height;
}
-
- override function onDelete() {
+
+ function clean() {
if( tex != null ) {
tex.dispose();
tex = null;
}
+ tile = null;
+ }
+
+ override function onDelete() {
+ clean();
super.onDelete();
}
function set_width(w) {
- if( tex != null ) {
- tex.dispose();
- tex = null;
- }
+ clean();
width = w;
return w;
}
@@ -65,10 +67,8 @@ class CachedBitmap extends Drawable {
override function render( engine : h3d.Engine ) {
updatePos();
- if( tex != null && ((width < 0 && tex.width < engine.width) || (height < 0 && tex.height < engine.height)) ) {
- tex.dispose();
- tex = null;
- }
+ if( tex != null && ((width < 0 && tex.width < engine.width) || (height < 0 && tex.height < engine.height)) )
+ clean();
var tile = getTile();
if( !freezed || !renderDone ) {
var oldA = matA, oldB = matB, oldC = matC, oldD = matD, oldX = absX, oldY = absY;
View
@@ -207,7 +207,7 @@ class Library {
}
if( animNode == null )
throw "Animation not found " + animName;
- var anim = new h3d.prim.Animation(animName);
+
var curves = new IntHash();
var P0 = new h3d.Point();
var P1 = new h3d.Point(1, 1, 1);
@@ -313,7 +313,7 @@ class Library {
curT = t;
}
var numFrames = maxTime == 0 ? 1 : 1 + Std.int(maxTime / minDT);
- anim.numFrames = numFrames;
+ var anim = new h3d.prim.Animation(animName, numFrames);
anim.sampling = 15.0 / (minDT / 3079077200); // this is the DT value we get from Max when using 15 FPS export
for( c in curves ) {
View
@@ -19,7 +19,9 @@ class AnimatedObject {
class Animation {
public var name : String;
- public var numFrames : Int;
+ public var numFrames(default, null) : Int;
+ public var loopFrame : Int;
+ public var stopFrame : Int;
public var time : Float;
public var speed : Float;
@@ -29,9 +31,11 @@ class Animation {
var objects : Array<AnimatedObject>;
var curFrame : Int;
- public function new(name) {
+ public function new(name,frames) {
this.name = name;
this.objects = [];
+ numFrames = frames;
+ stopFrame = -1;
curFrame = -1;
time = 0.;
speed = 1.;
@@ -53,11 +57,11 @@ class Animation {
@:access(h3d.scene.Skin.skinData)
public function createInstance( base : h3d.scene.Object ) {
- var anim = new Animation(name);
+ var anim = new Animation(name,numFrames);
anim.isInstance = true;
- anim.numFrames = numFrames;
anim.speed = speed;
anim.sampling = sampling;
+ anim.loopFrame = loopFrame;
var currentSkin : h3d.scene.Skin = null;
for( a in objects ) {
var a2 = new AnimatedObject(a.objectName, a.frames);
@@ -100,8 +104,17 @@ class Animation {
if( iframe < 0 ) iframe += numFrames;
if( iframe == curFrame )
return;
- if( iframe < curFrame )
+ if( stopFrame >= 0 && iframe >= stopFrame ) {
+ time += (stopFrame - iframe) / sampling;
+ iframe = stopFrame;
onAnimEnd();
+ } else if( iframe < curFrame ) {
+ if( iframe < loopFrame ) {
+ time += (loopFrame - iframe) / sampling;
+ iframe = loopFrame;
+ }
+ onAnimEnd();
+ }
curFrame = iframe;
for( o in objects ) {
if( o.alphas != null ) {

0 comments on commit c828a31

Please sign in to comment.