ANIM performance improvements and a crash fix

This commit is contained in:
Jack Andersen 2015-08-31 14:31:52 -10:00
parent f9c35caf5e
commit 1e3d281136
4 changed files with 43 additions and 49 deletions

View File

@ -5,6 +5,8 @@ namespace Retro
namespace DNAMP1
{
using ANIMOutStream = HECL::BlenderConnection::PyOutStream::ANIMOutStream;
void ANIM::IANIM::sendANIMToBlender(HECL::BlenderConnection::PyOutStream& os, const CINF& cinf) const
{
os.format("act.hecl_fps = round(%f)\n", (1.0f / mainInterval));
@ -12,7 +14,11 @@ void ANIM::IANIM::sendANIMToBlender(HECL::BlenderConnection::PyOutStream& os, co
auto kit = chanKeys.begin();
for (const std::pair<atUint32, bool>& bone : bones)
{
os.format("bone_string = '%s'\n", cinf.getBoneNameFromId(bone.first)->c_str());
const std::string* bName = cinf.getBoneNameFromId(bone.first);
if (!bName)
continue;
os.format("bone_string = '%s'\n", bName->c_str());
os << "action_group = act.groups.new(bone_string)\n"
"\n"
"rotCurves = []\n"
@ -39,31 +45,24 @@ void ANIM::IANIM::sendANIMToBlender(HECL::BlenderConnection::PyOutStream& os, co
"\n";
const std::vector<DNAANIM::Value>& rotKeys = *kit++;
auto frameit = frames.begin();
for (const DNAANIM::Value& val : rotKeys)
ANIMOutStream ao = os.beginANIMCurve();
for (int c=0 ; c<4 ; ++c)
{
atUint32 frame = *frameit++;
for (int c=0 ; c<4 ; ++c)
os.format("crv = rotCurves[%d]\n"
"crv.keyframe_points.add()\n"
"crv.keyframe_points[-1].interpolation = 'LINEAR'\n"
"crv.keyframe_points[-1].co = (%u, %f)\n",
c, frame, val.v4.vec[c]);
auto frameit = frames.begin();
ao.changeCurve(ANIMOutStream::CurveRotate, c, rotKeys.size());
for (const DNAANIM::Value& val : rotKeys)
ao.write(*frameit++, val.v4.vec[c]);
}
if (bone.second)
{
const std::vector<DNAANIM::Value>& transKeys = *kit++;
auto frameit = frames.begin();
for (const DNAANIM::Value& val : transKeys)
for (int c=0 ; c<3 ; ++c)
{
atUint32 frame = *frameit++;
for (int c=0 ; c<3 ; ++c)
os.format("crv = transCurves[%d]\n"
"crv.keyframe_points.add()\n"
"crv.keyframe_points[-1].interpolation = 'LINEAR'\n"
"crv.keyframe_points[-1].co = (%u, %f - bone_trans_head[%d])\n",
c, frame, val.v4.vec[c], c);
auto frameit = frames.begin();
ao.changeCurve(ANIMOutStream::CurveTranslate, c, transKeys.size());
for (const DNAANIM::Value& val : transKeys)
ao.write(*frameit++, val.v3.vec[c]);
}
}
}

View File

@ -5,6 +5,8 @@ namespace Retro
namespace DNAMP2
{
using ANIMOutStream = HECL::BlenderConnection::PyOutStream::ANIMOutStream;
void ANIM::IANIM::sendANIMToBlender(HECL::BlenderConnection::PyOutStream& os, const CINF& cinf) const
{
os.format("act.hecl_fps = round(%f)\n", (1.0f / mainInterval));
@ -12,7 +14,11 @@ void ANIM::IANIM::sendANIMToBlender(HECL::BlenderConnection::PyOutStream& os, co
auto kit = chanKeys.begin();
for (const std::pair<atUint32, std::tuple<bool,bool,bool>>& bone : bones)
{
os.format("bone_string = '%s'\n", cinf.getBoneNameFromId(bone.first)->c_str());
const std::string* bName = cinf.getBoneNameFromId(bone.first);
if (!bName)
continue;
os.format("bone_string = '%s'\n", bName->c_str());
os << "action_group = act.groups.new(bone_string)\n"
"\n";
@ -47,51 +53,40 @@ void ANIM::IANIM::sendANIMToBlender(HECL::BlenderConnection::PyOutStream& os, co
"crv.keyframe_points[-1].interpolation = 'LINEAR'\n"
"\n";
ANIMOutStream ao = os.beginANIMCurve();
if (std::get<0>(bone.second))
{
const std::vector<DNAANIM::Value>& rotKeys = *kit++;
auto frameit = frames.begin();
for (const DNAANIM::Value& val : rotKeys)
for (int c=0 ; c<4 ; ++c)
{
atUint32 frame = *frameit++;
for (int c=0 ; c<4 ; ++c)
os.format("crv = rotCurves[%d]\n"
"crv.keyframe_points.add()\n"
"crv.keyframe_points[-1].interpolation = 'LINEAR'\n"
"crv.keyframe_points[-1].co = (%u, %f)\n",
c, frame, val.v4.vec[c]);
auto frameit = frames.begin();
ao.changeCurve(ANIMOutStream::CurveRotate, c, rotKeys.size());
for (const DNAANIM::Value& val : rotKeys)
ao.write(*frameit++, val.v4.vec[c]);
}
}
if (std::get<1>(bone.second))
{
const std::vector<DNAANIM::Value>& transKeys = *kit++;
auto frameit = frames.begin();
for (const DNAANIM::Value& val : transKeys)
for (int c=0 ; c<3 ; ++c)
{
atUint32 frame = *frameit++;
for (int c=0 ; c<3 ; ++c)
os.format("crv = transCurves[%d]\n"
"crv.keyframe_points.add()\n"
"crv.keyframe_points[-1].interpolation = 'LINEAR'\n"
"crv.keyframe_points[-1].co = (%u, %f - bone_trans_head[%d])\n",
c, frame, val.v3.vec[c], c);
auto frameit = frames.begin();
ao.changeCurve(ANIMOutStream::CurveTranslate, c, transKeys.size());
for (const DNAANIM::Value& val : transKeys)
ao.write(*frameit++, val.v3.vec[c]);
}
}
if (std::get<2>(bone.second))
{
const std::vector<DNAANIM::Value>& scaleKeys = *kit++;
auto frameit = frames.begin();
for (const DNAANIM::Value& val : scaleKeys)
for (int c=0 ; c<3 ; ++c)
{
atUint32 frame = *frameit++;
for (int c=0 ; c<3 ; ++c)
os.format("crv = scaleCurves[%d]\n"
"crv.keyframe_points.add()\n"
"crv.keyframe_points[-1].interpolation = 'LINEAR'\n"
"crv.keyframe_points[-1].co = (%u, %f)\n",
c, frame, val.v3.vec[c], c);
auto frameit = frames.begin();
ao.changeCurve(ANIMOutStream::CurveScale, c, scaleKeys.size());
for (const DNAANIM::Value& val : scaleKeys)
ao.write(*frameit++, val.v3.vec[c]);
}
}
}

2
NODLib

@ -1 +1 @@
Subproject commit 799e2cb6ee6cf2752ea386fc1a8934c79e143bd5
Subproject commit 960ba8e4623c30434c50ffd533c12b3083452a96

2
hecl

@ -1 +1 @@
Subproject commit b6d1ab64e38dba21afcd51ead2ebbcb980633cf3
Subproject commit 66f39d1b8fbc79f88e71ad06eafbbd5f09c76d78