mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-17 17:05:37 +00:00
CBoneTransformData: Pass by const where applicable
These don't modify their input.
This commit is contained in:
@@ -12,8 +12,8 @@ class CBoneTransformData
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
CBoneTransformData() = default;
|
CBoneTransformData() = default;
|
||||||
explicit CBoneTransformData(CSkeleton *pSkel) { ResizeToSkeleton(pSkel); }
|
explicit CBoneTransformData(const CSkeleton *pSkel) { ResizeToSkeleton(pSkel); }
|
||||||
void ResizeToSkeleton(CSkeleton *pSkel) { mBoneMatrices.resize(pSkel ? pSkel->MaxBoneID() + 1 : 0); }
|
void ResizeToSkeleton(const CSkeleton *pSkel) { mBoneMatrices.resize(pSkel ? pSkel->MaxBoneID() + 1 : 0); }
|
||||||
CTransform4f& BoneMatrix(size_t BoneID) { return mBoneMatrices[BoneID]; }
|
CTransform4f& BoneMatrix(size_t BoneID) { return mBoneMatrices[BoneID]; }
|
||||||
const CTransform4f& BoneMatrix(size_t BoneID) const { return mBoneMatrices[BoneID]; }
|
const CTransform4f& BoneMatrix(size_t BoneID) const { return mBoneMatrices[BoneID]; }
|
||||||
const void* Data() const { return mBoneMatrices.data(); }
|
const void* Data() const { return mBoneMatrices.data(); }
|
||||||
|
|||||||
@@ -28,7 +28,9 @@ void CCharacterNode::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkView
|
|||||||
{
|
{
|
||||||
// todo: frustum check. Currently don't have a means of pulling the AABox for the
|
// todo: frustum check. Currently don't have a means of pulling the AABox for the
|
||||||
// current animation so this isn't in yet.
|
// current animation so this isn't in yet.
|
||||||
if (!mpCharacter) return;
|
if (!mpCharacter)
|
||||||
|
return;
|
||||||
|
|
||||||
UpdateTransformData();
|
UpdateTransformData();
|
||||||
|
|
||||||
CModel *pModel = mpCharacter->Character(mActiveCharSet)->pModel;
|
CModel *pModel = mpCharacter->Character(mActiveCharSet)->pModel;
|
||||||
@@ -54,9 +56,7 @@ void CCharacterNode::Draw(FRenderOptions Options, int ComponentIndex, ERenderCom
|
|||||||
LoadModelMatrix();
|
LoadModelMatrix();
|
||||||
pSkel->Draw(Options, &mTransformData);
|
pSkel->Draw(Options, &mTransformData);
|
||||||
}
|
}
|
||||||
|
else // Draw mesh
|
||||||
// Draw mesh
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// Set lighting
|
// Set lighting
|
||||||
CGraphics::SetDefaultLighting();
|
CGraphics::SetDefaultLighting();
|
||||||
@@ -89,15 +89,15 @@ SRayIntersection CCharacterNode::RayNodeIntersectTest(const CRay& rkRay, uint32
|
|||||||
if (pSkel)
|
if (pSkel)
|
||||||
{
|
{
|
||||||
UpdateTransformData();
|
UpdateTransformData();
|
||||||
std::pair<int32,float> Hit = pSkel->RayIntersect(rkRay, mTransformData);
|
const auto [index, distance] = pSkel->RayIntersect(rkRay, mTransformData);
|
||||||
|
|
||||||
if (Hit.first != -1)
|
if (index != -1)
|
||||||
{
|
{
|
||||||
SRayIntersection Intersect;
|
SRayIntersection Intersect;
|
||||||
Intersect.Hit = true;
|
Intersect.Hit = true;
|
||||||
Intersect.ComponentIndex = Hit.first;
|
Intersect.ComponentIndex = index;
|
||||||
Intersect.Distance = Hit.second;
|
Intersect.Distance = distance;
|
||||||
Intersect.HitPoint = rkRay.PointOnRay(Hit.second);
|
Intersect.HitPoint = rkRay.PointOnRay(distance);
|
||||||
Intersect.pNode = this;
|
Intersect.pNode = this;
|
||||||
return Intersect;
|
return Intersect;
|
||||||
}
|
}
|
||||||
@@ -110,11 +110,12 @@ SRayIntersection CCharacterNode::RayNodeIntersectTest(const CRay& rkRay, uint32
|
|||||||
CVector3f CCharacterNode::BonePosition(uint32 BoneID)
|
CVector3f CCharacterNode::BonePosition(uint32 BoneID)
|
||||||
{
|
{
|
||||||
UpdateTransformData();
|
UpdateTransformData();
|
||||||
CSkeleton *pSkel = (mpCharacter ? mpCharacter->Character(mActiveCharSet)->pSkeleton : nullptr);
|
const CSkeleton* pSkel = mpCharacter ? mpCharacter->Character(mActiveCharSet)->pSkeleton : nullptr;
|
||||||
CBone *pBone = (pSkel ? pSkel->BoneByID(BoneID) : nullptr);
|
const CBone* pBone = pSkel ? pSkel->BoneByID(BoneID) : nullptr;
|
||||||
|
|
||||||
CVector3f Out = AbsolutePosition();
|
CVector3f Out = AbsolutePosition();
|
||||||
if (pBone) Out += pBone->TransformedPosition(mTransformData);
|
if (pBone)
|
||||||
|
Out += pBone->TransformedPosition(mTransformData);
|
||||||
return Out;
|
return Out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,7 +137,7 @@ void CCharacterNode::SetActiveChar(uint32 CharIndex)
|
|||||||
|
|
||||||
if (mpCharacter)
|
if (mpCharacter)
|
||||||
{
|
{
|
||||||
CModel *pModel = mpCharacter->Character(CharIndex)->pModel;
|
const CModel* pModel = mpCharacter->Character(CharIndex)->pModel;
|
||||||
mTransformData.ResizeToSkeleton(mpCharacter->Character(CharIndex)->pSkeleton);
|
mTransformData.ResizeToSkeleton(mpCharacter->Character(CharIndex)->pSkeleton);
|
||||||
mLocalAABox = pModel ? pModel->AABox() : CAABox::Zero();
|
mLocalAABox = pModel ? pModel->AABox() : CAABox::Zero();
|
||||||
MarkTransformChanged();
|
MarkTransformChanged();
|
||||||
@@ -154,8 +155,9 @@ void CCharacterNode::UpdateTransformData()
|
|||||||
{
|
{
|
||||||
if (mTransformDataDirty)
|
if (mTransformDataDirty)
|
||||||
{
|
{
|
||||||
CSkeleton *pSkel = mpCharacter->Character(mActiveCharSet)->pSkeleton;
|
if (CSkeleton* pSkel = mpCharacter->Character(mActiveCharSet)->pSkeleton)
|
||||||
if (pSkel) pSkel->UpdateTransform(mTransformData, CurrentAnim(), mAnimTime, false);
|
pSkel->UpdateTransform(mTransformData, CurrentAnim(), mAnimTime, false);
|
||||||
|
|
||||||
mTransformDataDirty = false;
|
mTransformDataDirty = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user