Skip to content

Commit 416b9ca

Browse files
slimbuckDonovan Hutchence
andauthored
combine bounds correctly (playcanvas#2030)
Co-authored-by: Donovan Hutchence <dhutchence@snapchat.com>
1 parent 3b82ddf commit 416b9ca

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/scene/morph.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,9 @@ Object.assign(pc, function () {
9595
this.aabb.copy(this._baseAabb);
9696

9797
var numIndices;
98-
var i, j, target, index, id;
98+
var i, j, target;
9999
var x, y, z;
100100

101-
var vertSizeF = this._vertSizeF;
102-
var offsetPF = this._offsetPF;
103-
var baseData = this._baseData;
104-
105101
for (i = 0; i < this._targets.length; i++) {
106102
target = this._targets[i];
107103

@@ -112,12 +108,9 @@ Object.assign(pc, function () {
112108

113109
numIndices = target.indices.length;
114110
for (j = 0; j < numIndices; j++) {
115-
index = target.indices[j];
116-
id = index * vertSizeF + offsetPF;
117-
118-
x = baseData[id] + target.deltaPositions[j * 3];
119-
y = baseData[id + 1] + target.deltaPositions[j * 3 + 1];
120-
z = baseData[id + 2] + target.deltaPositions[j * 3 + 2];
111+
x = target.deltaPositions[j * 3];
112+
y = target.deltaPositions[j * 3 + 1];
113+
z = target.deltaPositions[j * 3 + 2];
121114

122115
if (_morphMin.x > x) _morphMin.x = x;
123116
if (_morphMin.y > y) _morphMin.y = y;
@@ -129,7 +122,13 @@ Object.assign(pc, function () {
129122
}
130123
target.aabb.setMinMax(_morphMin, _morphMax);
131124
}
132-
if (target.aabb) this.aabb.add(target.aabb);
125+
if (target.aabb) {
126+
var newMin = new pc.Vec3();
127+
var newMax = new pc.Vec3();
128+
newMin.add2(this.aabb.getMin(), target.aabb.getMin());
129+
newMax.add2(this.aabb.getMax(), target.aabb.getMax());
130+
this.aabb.setMinMax(newMin, newMax);
131+
}
133132
}
134133
this._aabbDirty = false;
135134
},

0 commit comments

Comments
 (0)