Skip to content

Commit

Permalink
Prepare iron to c port
Browse files Browse the repository at this point in the history
  • Loading branch information
luboslenco committed Jan 29, 2024
1 parent ab5b4b4 commit 270ceaa
Show file tree
Hide file tree
Showing 24 changed files with 590 additions and 894 deletions.
30 changes: 16 additions & 14 deletions Sources/iron/Animation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,6 @@ class Animation {
armature: Armature; // Bone
///end

// Lerp
static m1 = Mat4.identity();
static m2 = Mat4.identity();
static vpos = new Vec4();
static vpos2 = new Vec4();
static vscl = new Vec4();
static vscl2 = new Vec4();
static q1 = new Quat();
static q2 = new Quat();
static q3 = new Quat();
static vp = new Vec4();
static vs = new Vec4();

time: f32 = 0.0;
speed: f32 = 1.0;
loop = true;
Expand All @@ -39,6 +26,19 @@ class Animation {
lastFrameIndex = -1;
markerEvents: Map<string, (()=>void)[]> = null;

// Lerp
static m1 = Mat4.identity();
static m2 = Mat4.identity();
static vpos = new Vec4();
static vpos2 = new Vec4();
static vscl = new Vec4();
static vscl2 = new Vec4();
static q1 = new Quat();
static q2 = new Quat();
static q3 = new Quat();
static vp = new Vec4();
static vs = new Vec4();

constructor() {
Scene.active.animations.push(this);
}
Expand All @@ -61,11 +61,13 @@ class Animation {

play = this.playSuper;

blend = (action1: string, action2: string, factor: f32) => {
blendSuper = (action1: string, action2: string, factor: f32) => {
this.blendTime = 1.0; // Enable blending
this.blendFactor = factor;
}

blend = this.blendSuper;

pause = () => {
this.paused = true;
}
Expand Down
34 changes: 0 additions & 34 deletions Sources/iron/BaseObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ class BaseObject {

animation: Animation = null;
visible = true; // Skip render, keep updating
visibleMesh = true;
culled = false; // BaseObject was culled last frame
culledMesh = false;
isEmpty = false;

constructor() {
Expand Down Expand Up @@ -48,7 +46,6 @@ class BaseObject {
if (this.isEmpty && Scene.active != null) array_remove(Scene.active.empties, this);
if (this.animation != null) this.animation.remove();
while (this.children.length > 0) this.children[0].remove();
while (this.traits.length > 0) this.traits[0].remove();
if (this.parent != null) {
array_remove(this.parent.children, this);
this.parent = null;
Expand Down Expand Up @@ -78,37 +75,6 @@ class BaseObject {
return retChildren;
}

// getChildOfType<T: BaseObject> = (type: Class<T>): T => {
// if (this.constructor == type) return this;
// else {
// for (let c of children) {
// let r = c.getChildOfType(type);
// if (r != null) return r;
// }
// }
// return null;
// }

addTrait = (t: any) => {
this.traits.push(t);
t.object = this;

// if (t._add != null) {
// for (let f of t._add) f();
// t._add = null;
// }
}

removeTrait = (t: any) => {
t.remove();
array_remove(this.traits, t);
}

getTrait = (c: any): any => {
for (let t of this.traits) if (t.constructor == c) return t;
return null;
}

///if arm_skin
getParentArmature = (name: string): BoneAnimation => {
for (let a of Scene.active.animations) if (a.armature != null && a.armature.name == name) return a as BoneAnimation;
Expand Down
Loading

0 comments on commit 270ceaa

Please sign in to comment.