mirror of https://github.com/AxioDL/metaforce.git
Generate pool skin index for CPU-based skinning operations
This commit is contained in:
parent
e7f170c403
commit
2674989a4a
|
@ -35,6 +35,19 @@ extern logvisor::Module BlenderLog;
|
|||
extern class BlenderToken SharedBlenderToken;
|
||||
class HMDLBuffers;
|
||||
|
||||
struct PoolSkinIndex
|
||||
{
|
||||
size_t m_poolSz = 0;
|
||||
std::unique_ptr<uint32_t[]> m_poolToSkinIndex;
|
||||
|
||||
void allocate(size_t poolSz)
|
||||
{
|
||||
m_poolSz = poolSz;
|
||||
if (poolSz)
|
||||
m_poolToSkinIndex.reset(new uint32_t[poolSz]);
|
||||
}
|
||||
};
|
||||
|
||||
class BlenderConnection
|
||||
{
|
||||
public:
|
||||
|
@ -586,7 +599,7 @@ public:
|
|||
/** Prepares mesh representation for indexed access on modern APIs.
|
||||
* Mesh must remain resident for accessing reference members
|
||||
*/
|
||||
HMDLBuffers getHMDLBuffers(bool absoluteCoords) const;
|
||||
HMDLBuffers getHMDLBuffers(bool absoluteCoords, PoolSkinIndex& poolSkinIndex) const;
|
||||
};
|
||||
|
||||
/** Intermediate collision mesh representation prepared by blender from a single mesh object */
|
||||
|
|
|
@ -136,7 +136,6 @@ std::string GLSL::GenerateReflectionExpr(ReflectionType type) const
|
|||
switch (type)
|
||||
{
|
||||
case ReflectionType::None:
|
||||
default:
|
||||
return "vec3(0.0, 0.0, 0.0)";
|
||||
case ReflectionType::Simple:
|
||||
return "texture(reflectionTex, vtf.reflectTcgs[1]).rgb * vtf.reflectAlpha";
|
||||
|
|
|
@ -23,7 +23,8 @@ atVec3f BlenderConnection::DataStream::MtxVecMul3RM(const Matrix4f& mtx, const V
|
|||
return res;
|
||||
}
|
||||
|
||||
HMDLBuffers BlenderConnection::DataStream::Mesh::getHMDLBuffers(bool absoluteCoords) const
|
||||
HMDLBuffers BlenderConnection::DataStream::Mesh::getHMDLBuffers(bool absoluteCoords,
|
||||
PoolSkinIndex& poolSkinIndex) const
|
||||
{
|
||||
/* If skinned, compute max weight vec count */
|
||||
size_t weightCount = 0;
|
||||
|
@ -89,8 +90,10 @@ HMDLBuffers BlenderConnection::DataStream::Mesh::getHMDLBuffers(bool absoluteCoo
|
|||
metaOut.indexCount = iboData.size();
|
||||
|
||||
size_t vboSz = metaOut.vertCount * metaOut.vertStride;
|
||||
poolSkinIndex.allocate(vertPool.size());
|
||||
HMDLBuffers ret(std::move(metaOut), vboSz, iboData, std::move(outSurfaces), skinBanks);
|
||||
athena::io::MemoryWriter vboW(ret.m_vboData.get(), vboSz);
|
||||
uint32_t curPoolIdx = 0;
|
||||
for (const std::pair<const Surface*, const Surface::Vert*>& sv : vertPool)
|
||||
{
|
||||
const Surface& s = *sv.first;
|
||||
|
@ -155,6 +158,10 @@ HMDLBuffers BlenderConnection::DataStream::Mesh::getHMDLBuffers(bool absoluteCoo
|
|||
vboW.writeVec4fLittle(vec);
|
||||
}
|
||||
}
|
||||
|
||||
/* mapping pool verts to skin indices */
|
||||
poolSkinIndex.m_poolToSkinIndex[curPoolIdx] = sv.second->iSkin;
|
||||
++curPoolIdx;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
Loading…
Reference in New Issue