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

View File

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

2
NODLib

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

2
hecl

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