Skip to content

Commit

Permalink
AABB optiomisation, take 5
Browse files Browse the repository at this point in the history
  • Loading branch information
Maksims Mihejevs committed Dec 3, 2015
1 parent 7cba0ec commit c76bc85
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/scene/scene_mesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,11 @@ pc.extend(pc, function () {
var offsetWF = offsetW / 4;
var vertSizeF = vertSize / 4;

var bMax, bMin;
var x, y, z;
var boneMin = [];
var boneMax = [];

for(i=0; i<numBones; i++) {
boneMin[i] = new pc.Vec3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
boneMax[i] = new pc.Vec3(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
Expand All @@ -180,13 +182,16 @@ pc.extend(pc, function () {
y = dataF[j * vertSizeF + offsetPF + 1];
z = dataF[j * vertSizeF + offsetPF + 2];

boneMin[index].x = Math.min(boneMin[index].x, x);
boneMin[index].y = Math.min(boneMin[index].y, y);
boneMin[index].z = Math.min(boneMin[index].z, z);
bMax = boneMax[index];
bMin = boneMin[index];

if (bMin.x > x) bMin.x = x;
if (bMin.y > y) bMin.y = y;
if (bMin.z > z) bMin.z = z;

boneMax[index].x = Math.max(boneMax[index].x, x);
boneMax[index].y = Math.max(boneMax[index].y, y);
boneMax[index].z = Math.max(boneMax[index].z, z);
if (bMax.x < x) bMax.x = x;
if (bMax.y < y) bMax.y = y;
if (bMax.z < z) bMax.z = z;
}
}
}
Expand Down

0 comments on commit c76bc85

Please sign in to comment.