I created a simple creature with bone-scaling animation. As this does simply nothing, i debugged and have two questions…
a) in boneTrack.setTime(…) …
[java]// use len-1 so we never overflow the array
for (int i = 0; i < times.length-1; i++){
if (times < time){
startFrame = i;
endFrame = i + 1;
}
}[/java]
Is there a reason why you not simply break after geting the frame…? like this:
[java]// use len-1 so we never overflow the array
int max = times.length - 1; // just calculate once!
for (int i = 0; i < max; i++)
{
if (times >= time)
continue;
startFrame = i;
endFrame = i + 1;
break;
}
}[/java]
as this is done quite a lot for each frame, my code should bring some extra-promille in performance!
b) where (how?) is scaling applied. (is it?)
[java]Bone.setAnimTransforms(Vector3f translation, Quaternion rotation)
{
this.setAnimTransforms(translation, rotation, Vector3f.UNIT_XYZ);
}[/java]
That doesnt seem to care for the TempS-var of boneTrack, that is – in my case – not even filled because scales is null. If i interpret the code correctly, that var is interpolated in boneTrack.setTime(…)…
[java]tempS.interpolate(tempS, blend);[/java]
and then simply forgotten.
As for the scale being null, my skeleton.xml has clearly some scaling in it:
[xml]<keyframe time="0.080000">
<translate x="0.000000" y="0.000000" z="0.000000"/>
<rotate angle="0.000000">
<axis x="0.003020" y="0.999973" z="-0.006745"/>
</rotate>
<scale x="0.978498" y="0.978498" z="0.978498"/>
</keyframe>[/xml]
Yeah I agree, what i meant is there must be a way to optimize it without breaks and continues, that’s all, but you are right that this loop should not go through all frames no matter what.
as we already have lastFrame set up with …er…lastframe;-) and we already checked that current time is below…
[java]
int i = 0;
while (i < lastFrame && times >= time)
i++;
startFrame = i;
endFrame = i + 1;
[/java]
i really cant think of a faster way…
Nice
Thank you for this, but maybe you misunderstood me, I was not asking you to do it, I would have find a way.
Anyway thank you, i’ll put your code into the repo!
Yeah, my first contribution
No, i didnt misunderstood you. Its just that i have an eye for inefficient code and that is actually something where i can help even if im new to the code, so the guys with more insight have time to concentrate on the more sophisticated matters; like implementing bone scaling animation ;))
Bone scaling is not supported yet in OgreXML.
You mean, its not supported by jm3, do yo? The xml has that info…
Yes, the OgreXML importer does not parse that info.
It’s not supported by the engine, scale has been added recently to bone animation but is not functional atm.
About the for loop, yeah something could be done indeed to optimize this.
However i’m not really fond of continues and breaks honestly, it’s usually hell for maintenance.
But I guess there are plenty of other ways to break this loop
i’ll look into it
About the for loop, yeah something could be done indeed to optimize this.
However i'm not really fond of continues and breaks honestly, it's usually hell for maintenance
Thats true for breaks in the middle of nowhere. If you call a function once an hour, maintainance matters. But if you call a loop 10 times per frame, all should go into performance, eg, think assambler even if you dont write assambler.
rhavin said:
like implementing bone scaling animation ;))
So I did.
Bone animation now supports scaling of bones.
More tests to do though, I need to check if all goes well with ogre imported files.