Ticket #2026: skinning0.patch

File skinning0.patch, 2.0 KB (added by fsincos, 8 years ago)

Batch processing version of SkinPoint.

  • source/graphics/Model.cpp

    diff --git a/source/graphics/Model.cpp b/source/graphics/Model.cpp
    index da8d3c1..df81fda 100644
    a b void CModel::CalcAnimatedObjectBounds(CSkeletonAnimDef* anim, CBoundingBoxAligne  
    177177        ValidatePosition();
    178178
    179179        // extend bounds by vertex positions at the frame
    180         for (size_t i=0;i<numverts;i++)
    181         {
    182             result += CModelDef::SkinPoint(verts[i], GetAnimatedBoneMatrices());
    183         }
     180        result += CModelDef::SkinPoints(numverts, verts, GetAnimatedBoneMatrices());
    184181        // advance to next frame
    185182        m_AnimTime += anim->GetFrameTime();
    186183    }
  • source/graphics/ModelDef.cpp

    diff --git a/source/graphics/ModelDef.cpp b/source/graphics/ModelDef.cpp
    index d2891f1..1e135bb 100644
    a b CVector3D CModelDef::SkinPoint(const SModelVertex& vtx,  
    4343    return result;
    4444}
    4545
     46CVector3D CModelDef::SkinPoints(
     47        size_t numVertices,
     48        const SModelVertex* vertices,
     49        const CMatrix3D newPoseMatrices[])
     50{
     51    CVector3D result (0, 0, 0);
     52
     53    for (size_t j = 0; j < numVertices; ++j)
     54    {
     55        const SModelVertex& vtx = vertices[j];
     56
     57        for (int i = 0; i < SVertexBlend::SIZE && vtx.m_Blend.m_Bone[i] != 0xff; ++i)
     58            result += newPoseMatrices[vtx.m_Blend.m_Bone[i]].Transform(vtx.m_Coords) * vtx.m_Blend.m_Weight[i];
     59    }
     60    return result;
     61}
     62
    4663CVector3D CModelDef::SkinNormal(const SModelVertex& vtx,
    4764                                const CMatrix3D newPoseMatrices[])
    4865{
  • source/graphics/ModelDef.h

    diff --git a/source/graphics/ModelDef.h b/source/graphics/ModelDef.h
    index 0cd1c05..1e071bc 100644
    a b public:  
    194194     */
    195195    static CVector3D SkinPoint(const SModelVertex& vtx,
    196196        const CMatrix3D newPoseMatrices[]);
    197 
     197    /**
     198     * Add up all results of SkinPoint over vertices.
     199     */
     200    static CVector3D SkinPoints(
     201        size_t numVertices,
     202        const SModelVertex* vertices,
     203        const CMatrix3D newPoseMatrices[]);
    198204    /**
    199205     * Transform the given vertex's normal from the bind pose into the new pose.
    200206     *