Skip to content

Commit

Permalink
Hack in the same CPU skinning from DX for now
Browse files Browse the repository at this point in the history
  • Loading branch information
dpogue committed Jul 5, 2022
1 parent 4154ed7 commit 4ab9068
Show file tree
Hide file tree
Showing 3 changed files with 395 additions and 5 deletions.
32 changes: 28 additions & 4 deletions Sources/Plasma/FeatureLib/pfGLPipeline/plGLDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,11 +487,38 @@ bool plGLDevice::EndRender()
return false;
}

static uint32_t IGetBufferFormatSize(uint8_t format)
{
uint32_t size = sizeof( float ) * 6 + sizeof( uint32_t ) * 2; // Position and normal, and two packed colors

switch (format & plGBufferGroup::kSkinWeightMask)
{
case plGBufferGroup::kSkinNoWeights:
break;
case plGBufferGroup::kSkin1Weight:
size += sizeof(float);
break;
default:
hsAssert( false, "Invalid skin weight value in IGetBufferFormatSize()" );
}

size += sizeof( float ) * 3 * plGBufferGroup::CalcNumUVs(format);

return size;
}

void plGLDevice::SetupVertexBufferRef(plGBufferGroup* owner, uint32_t idx, VertexBufferRef* vRef)
{
uint8_t format = owner->GetVertexFormat();

uint32_t vertSize = owner->GetVertexSize(); //IGetBufferFormatSize(format); // vertex stride
if (format & plGBufferGroup::kSkinIndices) {
format &= ~(plGBufferGroup::kSkinWeightMask | plGBufferGroup::kSkinIndices);
format |= plGBufferGroup::kSkinNoWeights; // Should do nothing, but just in case...
vRef->SetSkinned(true);
vRef->SetVolatile(true);
}

uint32_t vertSize = IGetBufferFormatSize(format); // vertex stride
uint32_t numVerts = owner->GetVertBufferCount(idx);

vRef->fOwner = owner;
Expand All @@ -504,9 +531,6 @@ void plGLDevice::SetupVertexBufferRef(plGBufferGroup* owner, uint32_t idx, Verte
vRef->SetRebuiltSinceUsed(true);
vRef->fData = nullptr;

if (format & plGBufferGroup::kSkinIndices)
vRef->SetSkinned(true);

vRef->SetVolatile(vRef->Volatile() || owner->AreVertsVolatile());

vRef->fIndex = idx;
Expand Down
Loading

0 comments on commit 4ab9068

Please sign in to comment.