Re: Question for Diego Park and oc you
"Jack" wrote:
memcpy(iktransf,keyframes+animations[animation].index,numbones*sizeof(spatial_t<real>));
More info:
spatial_t<real> iktransf[MAX_BONES];
////////////////////////////////
template <class real>
class spatial_t
{
public:
spatial_t();
vector3_t<real> operator*(const vector3_t<real>& vec) const;
matrix3_t<real> rotation;
vector3_t<real> position;
};
Animation is spatial_t<real>, but its member "index" is an
"int".
numbones is an int as well. How can a class be added to an
integer and then memcpy'ed to a spatial<real>
Any thoughts?
Jack, the information you provided doesn't make sense. What is
`keyframes'? According to the declaration of `spatial_t' template
there is no `index' member, too. Also, `matrix3_t' and `vector3_t'
types are undefined, so it's impossible to tell definitely what's
going on there.
It seems that one or more instances of `spatial_t' are copied to
an array with `memcpy' call. Usually copying objects with `memcpy'
is wrong because `memcpy' just copies memory bits and completely
ignores class' copy semantics. Only POD (plain old data)
structures can be copied with defined result.
Unless `matrix3_t' and `vector3_t' classes (and other members of
`spatial_t' template) are specifically designed to be copied with
`memcpy' such copy will break them. Why don't you just assign it:
spatial_t<real>* src =
keyframes + animations[animation].index;
for(size_t i = 0; i < numbones && i < MAX_BONES; ++i)
{
iktransf[i] = src[i];
}
HTH
Alex