mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Refactor: Merge [IC]SkinnedMesh
into SkinnedMesh
(#15511)
This commit is contained in:
parent
810f39767c
commit
3e10d9ccf5
18 changed files with 326 additions and 646 deletions
|
@ -57,7 +57,7 @@ IAnimatedMesh *CXMeshFileLoader::createMesh(io::IReadFile *file)
|
|||
u32 time = os::Timer::getRealTime();
|
||||
#endif
|
||||
|
||||
AnimatedMesh = new CSkinnedMesh();
|
||||
AnimatedMesh = new SkinnedMesh();
|
||||
|
||||
if (load(file)) {
|
||||
AnimatedMesh->finalize();
|
||||
|
@ -203,8 +203,8 @@ bool CXMeshFileLoader::load(io::IReadFile *file)
|
|||
}
|
||||
|
||||
for (u32 j = 0; j < mesh->WeightJoint.size(); ++j) {
|
||||
ISkinnedMesh::SJoint *joint = AnimatedMesh->getAllJoints()[mesh->WeightJoint[j]];
|
||||
ISkinnedMesh::SWeight &weight = joint->Weights[mesh->WeightNum[j]];
|
||||
SkinnedMesh::SJoint *joint = AnimatedMesh->getAllJoints()[mesh->WeightJoint[j]];
|
||||
SkinnedMesh::SWeight &weight = joint->Weights[mesh->WeightNum[j]];
|
||||
|
||||
u32 id = weight.vertex_id;
|
||||
|
||||
|
@ -219,7 +219,7 @@ bool CXMeshFileLoader::load(io::IReadFile *file)
|
|||
weight.buffer_id = verticesLinkBuffer[id][0];
|
||||
} else if (verticesLinkBuffer[id].size() != 0) {
|
||||
for (u32 k = 1; k < verticesLinkBuffer[id].size(); ++k) {
|
||||
ISkinnedMesh::SWeight *WeightClone = AnimatedMesh->addWeight(joint);
|
||||
SkinnedMesh::SWeight *WeightClone = AnimatedMesh->addWeight(joint);
|
||||
WeightClone->strength = weight.strength;
|
||||
WeightClone->vertex_id = verticesLinkIndex[id][k];
|
||||
WeightClone->buffer_id = verticesLinkBuffer[id][k];
|
||||
|
@ -314,7 +314,7 @@ bool CXMeshFileLoader::load(io::IReadFile *file)
|
|||
}
|
||||
|
||||
for (u32 j = 0; j < mesh->WeightJoint.size(); ++j) {
|
||||
ISkinnedMesh::SWeight &weight = (AnimatedMesh->getAllJoints()[mesh->WeightJoint[j]]->Weights[mesh->WeightNum[j]]);
|
||||
SkinnedMesh::SWeight &weight = (AnimatedMesh->getAllJoints()[mesh->WeightJoint[j]]->Weights[mesh->WeightNum[j]]);
|
||||
|
||||
u32 id = weight.vertex_id;
|
||||
|
||||
|
@ -486,7 +486,7 @@ bool CXMeshFileLoader::parseDataObjectTemplate()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool CXMeshFileLoader::parseDataObjectFrame(CSkinnedMesh::SJoint *Parent)
|
||||
bool CXMeshFileLoader::parseDataObjectFrame(SkinnedMesh::SJoint *Parent)
|
||||
{
|
||||
#ifdef _XREADER_DEBUG
|
||||
os::Printer::log("CXFileReader: Reading frame", ELL_DEBUG);
|
||||
|
@ -508,7 +508,7 @@ bool CXMeshFileLoader::parseDataObjectFrame(CSkinnedMesh::SJoint *Parent)
|
|||
SET_ERR_AND_RETURN();
|
||||
}
|
||||
|
||||
CSkinnedMesh::SJoint *joint = 0;
|
||||
SkinnedMesh::SJoint *joint = 0;
|
||||
|
||||
if (name.size()) {
|
||||
auto n = AnimatedMesh->getJointNumber(name.c_str());
|
||||
|
@ -947,7 +947,7 @@ bool CXMeshFileLoader::parseDataObjectSkinWeights(SXMesh &mesh)
|
|||
mesh.HasSkinning = true;
|
||||
|
||||
auto n = AnimatedMesh->getJointNumber(TransformNodeName.c_str());
|
||||
CSkinnedMesh::SJoint *joint = n.has_value() ? AnimatedMesh->getAllJoints()[*n] : nullptr;
|
||||
SkinnedMesh::SJoint *joint = n.has_value() ? AnimatedMesh->getAllJoints()[*n] : nullptr;
|
||||
|
||||
if (!joint) {
|
||||
#ifdef _XREADER_DEBUG
|
||||
|
@ -974,7 +974,7 @@ bool CXMeshFileLoader::parseDataObjectSkinWeights(SXMesh &mesh)
|
|||
mesh.WeightJoint.push_back(*n);
|
||||
mesh.WeightNum.push_back(joint->Weights.size());
|
||||
|
||||
CSkinnedMesh::SWeight *weight = AnimatedMesh->addWeight(joint);
|
||||
SkinnedMesh::SWeight *weight = AnimatedMesh->addWeight(joint);
|
||||
|
||||
weight->buffer_id = 0;
|
||||
weight->vertex_id = readInt();
|
||||
|
@ -1358,7 +1358,7 @@ bool CXMeshFileLoader::parseDataObjectAnimation()
|
|||
|
||||
// anim.closed = true;
|
||||
// anim.linearPositionQuality = true;
|
||||
CSkinnedMesh::SJoint animationDump;
|
||||
SkinnedMesh::SJoint animationDump;
|
||||
|
||||
core::stringc FrameName;
|
||||
|
||||
|
@ -1400,7 +1400,7 @@ bool CXMeshFileLoader::parseDataObjectAnimation()
|
|||
#endif
|
||||
auto n = AnimatedMesh->getJointNumber(FrameName.c_str());
|
||||
|
||||
CSkinnedMesh::SJoint *joint;
|
||||
SkinnedMesh::SJoint *joint;
|
||||
if (n.has_value()) {
|
||||
joint = AnimatedMesh->getAllJoints()[*n];
|
||||
} else {
|
||||
|
@ -1431,7 +1431,7 @@ bool CXMeshFileLoader::parseDataObjectAnimation()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool CXMeshFileLoader::parseDataObjectAnimationKey(ISkinnedMesh::SJoint *joint)
|
||||
bool CXMeshFileLoader::parseDataObjectAnimationKey(SkinnedMesh::SJoint *joint)
|
||||
{
|
||||
#ifdef _XREADER_DEBUG
|
||||
os::Printer::log("CXFileReader: reading animation key", ELL_DEBUG);
|
||||
|
@ -1488,7 +1488,7 @@ bool CXMeshFileLoader::parseDataObjectAnimationKey(ISkinnedMesh::SJoint *joint)
|
|||
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_WARNING);
|
||||
}
|
||||
|
||||
ISkinnedMesh::SRotationKey *key = AnimatedMesh->addRotationKey(joint);
|
||||
SkinnedMesh::SRotationKey *key = AnimatedMesh->addRotationKey(joint);
|
||||
key->frame = time;
|
||||
key->rotation.set(X, Y, Z, W);
|
||||
key->rotation.normalize();
|
||||
|
@ -1514,11 +1514,11 @@ bool CXMeshFileLoader::parseDataObjectAnimationKey(ISkinnedMesh::SJoint *joint)
|
|||
}
|
||||
|
||||
if (keyType == 2) {
|
||||
ISkinnedMesh::SPositionKey *key = AnimatedMesh->addPositionKey(joint);
|
||||
SkinnedMesh::SPositionKey *key = AnimatedMesh->addPositionKey(joint);
|
||||
key->frame = time;
|
||||
key->position = vector;
|
||||
} else {
|
||||
ISkinnedMesh::SScaleKey *key = AnimatedMesh->addScaleKey(joint);
|
||||
SkinnedMesh::SScaleKey *key = AnimatedMesh->addScaleKey(joint);
|
||||
key->frame = time;
|
||||
key->scale = vector;
|
||||
}
|
||||
|
@ -1547,14 +1547,14 @@ bool CXMeshFileLoader::parseDataObjectAnimationKey(ISkinnedMesh::SJoint *joint)
|
|||
|
||||
// core::vector3df rotation = mat.getRotationDegrees();
|
||||
|
||||
ISkinnedMesh::SRotationKey *keyR = AnimatedMesh->addRotationKey(joint);
|
||||
SkinnedMesh::SRotationKey *keyR = AnimatedMesh->addRotationKey(joint);
|
||||
keyR->frame = time;
|
||||
|
||||
// IRR_TEST_BROKEN_QUATERNION_USE: TODO - switched from mat to mat.getTransposed() for downward compatibility.
|
||||
// Not tested so far if this was correct or wrong before quaternion fix!
|
||||
keyR->rotation = core::quaternion(mat.getTransposed());
|
||||
|
||||
ISkinnedMesh::SPositionKey *keyP = AnimatedMesh->addPositionKey(joint);
|
||||
SkinnedMesh::SPositionKey *keyP = AnimatedMesh->addPositionKey(joint);
|
||||
keyP->frame = time;
|
||||
keyP->position = mat.getTranslation();
|
||||
|
||||
|
@ -1567,7 +1567,7 @@ bool CXMeshFileLoader::parseDataObjectAnimationKey(ISkinnedMesh::SJoint *joint)
|
|||
scale.Y=1;
|
||||
if (scale.Z==0)
|
||||
scale.Z=1;
|
||||
ISkinnedMesh::SScaleKey *keyS=AnimatedMesh->addScaleKey(joint);
|
||||
SkinnedMesh::SScaleKey *keyS=AnimatedMesh->addScaleKey(joint);
|
||||
keyS->frame=time;
|
||||
keyS->scale=scale;
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue