|
@ -71,14 +71,11 @@ static void pchan_deform_accumulate(const DualQuat *deform_dq,
|
|||
mul_v3_m4v3(dst, mdq.scale, co_in);
|
||||
sub_v3_v3(dst, co_in);
|
||||
float w = mdq.quat[0], x = mdq.quat[1], y = mdq.quat[2], z = mdq.quat[3];
|
||||
himisa marked this conversation as resolved
Outdated
|
||||
float dstx = mdq.scale[3][0], dsty = mdq.scale[3][1], dstz = mdq.scale[3][2];
|
||||
mdq.scale[3][0] -= dst[0];
|
||||
mdq.scale[3][1] -= dst[1];
|
||||
mdq.scale[3][2] -= dst[2];
|
||||
mdq.trans[0] -= .5f * (x * dst[0] + y * dst[1] + z * dst[2]);
|
||||
mdq.trans[1] += .5f * (w * dst[0] + y * dst[2] - z * dst[1]);
|
||||
mdq.trans[2] += .5f * (w * dst[1] + z * dst[0] - x * dst[2]);
|
||||
mdq.trans[3] += .5f * (w * dst[2] + x * dst[1] - y * dst[0]);
|
||||
mdq.scale_weight = 0.f;
|
||||
deform_dq = &mdq;
|
||||
himisa marked this conversation as resolved
Outdated
Nathan Vegdahl
commented
`deform_dq` is declared `const`, so it feels like bad form to modify its pointer. I think it would be better to get rid of this assignment entirely, and just use `mdq` directly below.
himisa
commented
If ptr is declared as `const Type *ptr = &value` means the content of `value` shall not be changed via `ptr`. It is well defined to modify `ptr` itself.
If ptr is declared as `Type * const ptr`, `ptr` itself is a `const`, modifying `ptr` is bad formed.
himisa
commented
I updated code. But If we use I strongly recommand to use I updated code.
But If we use `mdq` directly, then a `else` statement repeating `add_weighted_dq_dq(...` will be necessary for no scaling case.
I strongly recommand to use `deform_dq = &mdq;`, so that one unified call of `add_weighted_dq_dq` is sufficient.
Nathan Vegdahl
commented
Ah, yeah. I'm well aware of the semantics of All other things being equal, I think I'd prefer an Ah, yeah. I'm well aware of the semantics of `const *`, but I wasn't following the control flow correctly: I forgot about the case where the `if` branch is skipped.
All other things being equal, I think I'd prefer an `else` branch that calls `add_weighted_dq_dq(...` with different arguments. By convention, I think of const input parameters as sort of indication to not modify them, even though the semantics allow it. But I don't really feel too strongly one way or the other. So let's just leave it as-is.
Nathan Vegdahl
commented
Ah! I should have looked at the changes first. Yeah, I think I prefer the else branch, like you've written it now. Thanks so much! Ah! I should have looked at the changes first. Yeah, I think I prefer the else branch, like you've written it now. Thanks so much!
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
I think it's already fairly obvious that
mdq.quat[i]
are the wxyz components of the quaternion, so I'd say get rid of the temporary variables and just usemdq.quat
directly.I just want to avoid repeating
mdq.quad[
for 12 times.