Skip to content

Commit 14760b5

Browse files
authored
Merge pull request #572 from yamahigashi/develop
[mgear_solvers] Fix memory leak in rollSplineKine: replace dynamic MQuaternion array
2 parents 761dde9 + e20566f commit 14760b5

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

src/rollSplineKine.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,12 @@ MStatus mgear_rollSplineKine::compute(const MPlug& plug, MDataBlock& data)
213213
// Get roll, pos, tan, rot, scl
214214
MVectorArray pos(count);
215215
MVectorArray tan(count);
216-
MQuaternion *rot;
217-
rot = new MQuaternion[count];
218216
MVectorArray scl(count);
219217
double threeDoubles[3];
220218
for (int i = 0 ; i < count ; i++){
221219
MTransformationMatrix tp(inputsP[i]);
222220
MTransformationMatrix t(inputs[i]);
223221
pos[i] = t.getTranslation(MSpace::kWorld);
224-
rot[i] = tp.rotation();
225222

226223
t.getScale(threeDoubles, MSpace::kWorld);
227224
scl[i] = MVector(threeDoubles[0], threeDoubles[1], threeDoubles[2]);
@@ -325,7 +322,9 @@ MStatus mgear_rollSplineKine::compute(const MPlug& plug, MDataBlock& data)
325322
MVector scl1 = linearInterpolate(scl[index1temp], scl[index2temp],vtemp);
326323

327324
// compute the rotation!
328-
MQuaternion q = slerp(rot[index1temp], rot[index2temp], vtemp);
325+
MQuaternion rot1 = MTransformationMatrix(inputsP[index1temp]).rotation();
326+
MQuaternion rot2 = MTransformationMatrix(inputsP[index2temp]).rotation();
327+
MQuaternion q = slerp(rot1, rot2, vtemp);
329328
yAxis = MVector(0,1,0);
330329
yAxis = yAxis.rotateBy(q);
331330

0 commit comments

Comments
 (0)