mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-18 07:06:45 +00:00
Coding style improvements, add Torso animation layer
This commit is contained in:
parent
ffc64205c5
commit
d8de56e33c
2 changed files with 42 additions and 12 deletions
|
@ -34,7 +34,8 @@ namespace Resource
|
||||||
|
|
||||||
bool RetrieveAnimationsVisitor::belongsToLeftUpperExtremity(const std::string& name)
|
bool RetrieveAnimationsVisitor::belongsToLeftUpperExtremity(const std::string& name)
|
||||||
{
|
{
|
||||||
static const std::string_view boneNames[25] = {
|
const int bodypartCount = 25;
|
||||||
|
static const std::array<std::string_view, bodypartCount> boneNames = {
|
||||||
"bip01_l_clavicle",
|
"bip01_l_clavicle",
|
||||||
"left_clavicle",
|
"left_clavicle",
|
||||||
"bip01_l_upperarm",
|
"bip01_l_upperarm",
|
||||||
|
@ -62,7 +63,7 @@ namespace Resource
|
||||||
"left_forearm"
|
"left_forearm"
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t i = 0; i < 25; i++)
|
for (unsigned short int i = 0; i < bodypartCount; i++)
|
||||||
{
|
{
|
||||||
if (name == boneNames[i])
|
if (name == boneNames[i])
|
||||||
return true;
|
return true;
|
||||||
|
@ -73,7 +74,8 @@ namespace Resource
|
||||||
|
|
||||||
bool RetrieveAnimationsVisitor::belongsToRightUpperExtremity(const std::string& name)
|
bool RetrieveAnimationsVisitor::belongsToRightUpperExtremity(const std::string& name)
|
||||||
{
|
{
|
||||||
static const std::string_view boneNames[25] = {
|
const int bodypartCount = 25;
|
||||||
|
static const std::array<std::string_view, bodypartCount> boneNames = {
|
||||||
"bip01_r_clavicle",
|
"bip01_r_clavicle",
|
||||||
"right_clavicle",
|
"right_clavicle",
|
||||||
"bip01_r_upperarm",
|
"bip01_r_upperarm",
|
||||||
|
@ -101,7 +103,7 @@ namespace Resource
|
||||||
"right_forearm"
|
"right_forearm"
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t i = 0; i < 25; i++)
|
for (unsigned short int i = 0; i < bodypartCount; i++)
|
||||||
{
|
{
|
||||||
if (name == boneNames[i])
|
if (name == boneNames[i])
|
||||||
return true;
|
return true;
|
||||||
|
@ -110,6 +112,23 @@ namespace Resource
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RetrieveAnimationsVisitor::belongsToTorso(const std::string& name)
|
||||||
|
{
|
||||||
|
const int bodypartCount = 8;
|
||||||
|
static const std::array<std::string_view, bodypartCount> boneNames = {
|
||||||
|
"bip01_spine1", "bip01_spine2", "bip01_neck", "bip01_head", "head", "neck", "chest", "groin"
|
||||||
|
};
|
||||||
|
|
||||||
|
for (unsigned short int i = 0; i < bodypartCount; i++)
|
||||||
|
{
|
||||||
|
if (name == boneNames[i])
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void RetrieveAnimationsVisitor::addKeyframeController(const std::string& name, const osg::Node& node)
|
void RetrieveAnimationsVisitor::addKeyframeController(const std::string& name, const osg::Node& node)
|
||||||
{
|
{
|
||||||
osg::ref_ptr<SceneUtil::OsgAnimationController> callback = new SceneUtil::OsgAnimationController();
|
osg::ref_ptr<SceneUtil::OsgAnimationController> callback = new SceneUtil::OsgAnimationController();
|
||||||
|
@ -139,13 +158,23 @@ namespace Resource
|
||||||
{
|
{
|
||||||
if (name == "Bip01 R Clavicle")
|
if (name == "Bip01 R Clavicle")
|
||||||
{
|
{
|
||||||
if (!belongsToRightUpperExtremity(channel->getTargetName())) continue;
|
if (!belongsToRightUpperExtremity(channel->getTargetName()))
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else if (name == "Bip01 L Clavicle")
|
else if (name == "Bip01 L Clavicle")
|
||||||
{
|
{
|
||||||
if (!belongsToLeftUpperExtremity(channel->getTargetName())) continue;
|
if (!belongsToLeftUpperExtremity(channel->getTargetName()))
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else if (belongsToRightUpperExtremity(channel->getTargetName()) || belongsToLeftUpperExtremity(channel->getTargetName())) continue;
|
else if (name == "Bip01 Spine1")
|
||||||
|
{
|
||||||
|
if (!belongsToTorso(channel->getTargetName()))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (belongsToRightUpperExtremity(channel->getTargetName())
|
||||||
|
|| belongsToLeftUpperExtremity(channel->getTargetName())
|
||||||
|
|| belongsToTorso(channel->getTargetName()))
|
||||||
|
continue;
|
||||||
|
|
||||||
mergedAnimationTrack->addChannel(channel.get()->clone()); // is ->clone needed?
|
mergedAnimationTrack->addChannel(channel.get()->clone()); // is ->clone needed?
|
||||||
}
|
}
|
||||||
|
@ -194,7 +223,7 @@ namespace Resource
|
||||||
&& Misc::StringUtils::lowerCase(node.getName()) == std::string_view("bip01"))
|
&& Misc::StringUtils::lowerCase(node.getName()) == std::string_view("bip01"))
|
||||||
{
|
{
|
||||||
addKeyframeController("bip01", node); /* Character root */
|
addKeyframeController("bip01", node); /* Character root */
|
||||||
//addKeyframeController("Bip01 Spine1", node); /* Torso */
|
addKeyframeController("Bip01 Spine1", node); /* Torso */
|
||||||
addKeyframeController("Bip01 L Clavicle", node); /* Left arm */
|
addKeyframeController("Bip01 L Clavicle", node); /* Left arm */
|
||||||
addKeyframeController("Bip01 R Clavicle", node); /* Right arm */
|
addKeyframeController("Bip01 R Clavicle", node); /* Right arm */
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ namespace Resource
|
||||||
|
|
||||||
bool belongsToLeftUpperExtremity(const std::string& name);
|
bool belongsToLeftUpperExtremity(const std::string& name);
|
||||||
bool belongsToRightUpperExtremity(const std::string& name);
|
bool belongsToRightUpperExtremity(const std::string& name);
|
||||||
|
bool belongsToTorso(const std::string& name);
|
||||||
|
|
||||||
void addKeyframeController(const std::string& name, const osg::Node& node);
|
void addKeyframeController(const std::string& name, const osg::Node& node);
|
||||||
virtual void apply(osg::Node& node) override;
|
virtual void apply(osg::Node& node) override;
|
||||||
|
|
Loading…
Reference in a new issue