Redid it, works
This commit is contained in:
parent
84be4bb04f
commit
843400b54f
|
@ -502,152 +502,132 @@ bool XTL::VertexPatcher::PatchStream(VertexPatchDesc *pPatchDesc,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(uint32 uiVertex = 0; uiVertex < pPatchDesc->dwVertexCount; uiVertex++)
|
for (uint32 uiVertex = 0; uiVertex < pPatchDesc->dwVertexCount; uiVertex++)
|
||||||
{
|
{
|
||||||
DWORD dwPosOrig = 0;
|
DWORD dwPosOrig = 0;
|
||||||
DWORD dwPosNew = 0;
|
uint08 *pOrigVertex = &pOrigData[uiVertex * uiStride];
|
||||||
for(UINT uiType = 0; uiType < pStreamPatch->NbrTypes; uiType++)
|
uint08 *pNewDataPos = &pNewData[uiVertex * pStreamPatch->ConvertedStride];
|
||||||
{
|
for (UINT uiType = 0; uiType < pStreamPatch->NbrTypes; uiType++)
|
||||||
switch(pStreamPatch->pTypes[uiType])
|
{
|
||||||
{
|
switch (pStreamPatch->pTypes[uiType])
|
||||||
case X_D3DVSDT_NORMPACKED3: // 0x16:
|
{
|
||||||
{
|
case X_D3DVSDT_NORMPACKED3: // 0x16:
|
||||||
DWORD dwPacked = ((DWORD *)&pOrigData[uiVertex * uiStride + dwPosOrig])[0];
|
{
|
||||||
|
DWORD dwPacked = ((DWORD *)&pOrigData[uiVertex * uiStride + dwPosOrig])[0];
|
||||||
|
|
||||||
((FLOAT *)&pNewData[uiVertex * pStreamPatch->ConvertedStride + dwPosNew])[0] = ((FLOAT)(dwPacked & 0x7ff)) / 1023.0f;
|
((FLOAT *)pNewDataPos)[0] = ((FLOAT)(dwPacked & 0x7ff)) / 1023.0f;
|
||||||
((FLOAT *)&pNewData[uiVertex * pStreamPatch->ConvertedStride + dwPosNew])[1] = ((FLOAT)((dwPacked >> 11) & 0x7ff)) / 1023.0f;
|
((FLOAT *)pNewDataPos)[1] = ((FLOAT)((dwPacked >> 11) & 0x7ff)) / 1023.0f;
|
||||||
((FLOAT *)&pNewData[uiVertex * pStreamPatch->ConvertedStride + dwPosNew])[2] = ((FLOAT)((dwPacked >> 22) & 0x3ff)) / 511.0f;
|
((FLOAT *)pNewDataPos)[2] = ((FLOAT)((dwPacked >> 22) & 0x3ff)) / 511.0f;
|
||||||
|
|
||||||
dwPosOrig += sizeof(DWORD);
|
dwPosOrig += sizeof(DWORD);
|
||||||
dwPosNew += 3 * sizeof(FLOAT);
|
break;
|
||||||
}
|
}
|
||||||
break;
|
case X_D3DVSDT_SHORT1: // 0x15:
|
||||||
case X_D3DVSDT_SHORT1: // 0x15:
|
// Make it a SHORT2
|
||||||
// Make it a SHORT2
|
((SHORT *)pNewDataPos)[0] = *(SHORT*)&pOrigData[uiVertex * uiStride + dwPosOrig];
|
||||||
(*((SHORT *)&pNewData[uiVertex * pStreamPatch->ConvertedStride + dwPosNew + 0 * sizeof(SHORT)])) = *(SHORT*)&pOrigData[uiVertex * uiStride + dwPosOrig];
|
((SHORT *)pNewDataPos)[1] = 0x00;
|
||||||
(*((SHORT *)&pNewData[uiVertex * pStreamPatch->ConvertedStride + dwPosNew + 1 * sizeof(SHORT)])) = 0x00;
|
|
||||||
|
|
||||||
dwPosOrig += 1 * sizeof(SHORT);
|
dwPosOrig += 1 * sizeof(SHORT);
|
||||||
dwPosNew += 2 * sizeof(SHORT);
|
break;
|
||||||
|
case X_D3DVSDT_SHORT3: // 0x35:
|
||||||
|
memcpy(pNewDataPos,
|
||||||
|
&pOrigData[uiVertex * uiStride + dwPosOrig],
|
||||||
|
3 * sizeof(SHORT));
|
||||||
|
// Make it a SHORT4 and set the last short to 1
|
||||||
|
//(*((SHORT *)&pNewData[uiVertex * pStreamPatch->ConvertedStride + dwPosNew + 3 * sizeof(SHORT)])) = 0x01;
|
||||||
|
((SHORT *)pNewDataPos)[3] = 0x01;
|
||||||
|
|
||||||
break;
|
dwPosOrig += 3 * sizeof(SHORT);
|
||||||
case X_D3DVSDT_SHORT2: // 0x25:
|
break;
|
||||||
memcpy(&pNewData[uiVertex * pStreamPatch->ConvertedStride + dwPosNew],
|
case X_D3DVSDT_PBYTE1: // 0x14:
|
||||||
&pOrigData[uiVertex * uiStride+dwPosOrig],
|
((FLOAT *)pNewDataPos)[0] = ((FLOAT)((BYTE*)&pOrigData[uiVertex * uiStride + dwPosOrig])[0]) / 255.0f;
|
||||||
2 * sizeof(SHORT));
|
|
||||||
dwPosOrig += 2 * sizeof(SHORT);
|
|
||||||
dwPosNew += 2 * sizeof(SHORT);
|
|
||||||
break;
|
|
||||||
case X_D3DVSDT_SHORT3: // 0x35:
|
|
||||||
memcpy(&pNewData[uiVertex * pStreamPatch->ConvertedStride + dwPosNew],
|
|
||||||
&pOrigData[uiVertex * uiStride + dwPosOrig],
|
|
||||||
3 * sizeof(SHORT));
|
|
||||||
// Make it a SHORT4 and set the last short to 1
|
|
||||||
(*((SHORT *)&pNewData[uiVertex * pStreamPatch->ConvertedStride + dwPosNew + 3 * sizeof(SHORT)])) = 0x01;
|
|
||||||
|
|
||||||
dwPosOrig += 3 * sizeof(SHORT);
|
dwPosOrig += 1 * sizeof(BYTE);
|
||||||
dwPosNew += 4 * sizeof(SHORT);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case X_D3DVSDT_SHORT4: // 0x45:
|
case X_D3DVSDT_PBYTE2: // 0x24:
|
||||||
memcpy(&pNewData[uiVertex * pStreamPatch->ConvertedStride + dwPosNew],
|
((FLOAT *)pNewDataPos)[0] = ((FLOAT)((BYTE*)&pOrigData[uiVertex * uiStride + dwPosOrig])[0]) / 255.0f;
|
||||||
&pOrigData[uiVertex * uiStride + dwPosOrig],
|
((FLOAT *)pNewDataPos)[1] = ((FLOAT)((BYTE*)&pOrigData[uiVertex * uiStride + dwPosOrig])[1]) / 255.0f;
|
||||||
4 * sizeof(SHORT));
|
|
||||||
dwPosOrig += 4 * sizeof(SHORT);
|
|
||||||
dwPosNew += 4 * sizeof(SHORT);
|
|
||||||
break;
|
|
||||||
case X_D3DVSDT_PBYTE1: // 0x14:
|
|
||||||
((FLOAT *)&pNewData[uiVertex * pStreamPatch->ConvertedStride + dwPosNew])[0] = ((FLOAT)((BYTE*)&pOrigData[uiVertex * uiStride + dwPosOrig])[0]) / 255.0f;
|
|
||||||
|
|
||||||
dwPosOrig += 1 * sizeof(BYTE);
|
dwPosOrig += 2 * sizeof(BYTE);
|
||||||
dwPosNew += 1 * sizeof(FLOAT);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case X_D3DVSDT_PBYTE2: // 0x24:
|
case X_D3DVSDT_PBYTE3: // 0x34:
|
||||||
((FLOAT *)&pNewData[uiVertex * pStreamPatch->ConvertedStride + dwPosNew])[0] = ((FLOAT)((BYTE*)&pOrigData[uiVertex * uiStride + dwPosOrig])[0]) / 255.0f;
|
((FLOAT *)pNewDataPos)[0] = ((FLOAT)((BYTE*)&pOrigData[uiVertex * uiStride + dwPosOrig])[0]) / 255.0f;
|
||||||
((FLOAT *)&pNewData[uiVertex * pStreamPatch->ConvertedStride + dwPosNew])[1] = ((FLOAT)((BYTE*)&pOrigData[uiVertex * uiStride + dwPosOrig])[1]) / 255.0f;
|
((FLOAT *)pNewDataPos)[1] = ((FLOAT)((BYTE*)&pOrigData[uiVertex * uiStride + dwPosOrig])[1]) / 255.0f;
|
||||||
|
((FLOAT *)pNewDataPos)[2] = ((FLOAT)((BYTE*)&pOrigData[uiVertex * uiStride + dwPosOrig])[2]) / 255.0f;
|
||||||
|
|
||||||
dwPosOrig += 2 * sizeof(BYTE);
|
dwPosOrig += 3 * sizeof(BYTE);
|
||||||
dwPosNew += 2 * sizeof(FLOAT);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case X_D3DVSDT_PBYTE3: // 0x34:
|
case X_D3DVSDT_PBYTE4: // 0x44:
|
||||||
((FLOAT *)&pNewData[uiVertex * pStreamPatch->ConvertedStride + dwPosNew])[0] = ((FLOAT)((BYTE*)&pOrigData[uiVertex * uiStride + dwPosOrig])[0]) / 255.0f;
|
((FLOAT *)pNewDataPos)[0] = ((FLOAT)((BYTE*)&pOrigData[uiVertex * uiStride + dwPosOrig])[0]) / 255.0f;
|
||||||
((FLOAT *)&pNewData[uiVertex * pStreamPatch->ConvertedStride + dwPosNew])[1] = ((FLOAT)((BYTE*)&pOrigData[uiVertex * uiStride + dwPosOrig])[1]) / 255.0f;
|
((FLOAT *)pNewDataPos)[1] = ((FLOAT)((BYTE*)&pOrigData[uiVertex * uiStride + dwPosOrig])[1]) / 255.0f;
|
||||||
((FLOAT *)&pNewData[uiVertex * pStreamPatch->ConvertedStride + dwPosNew])[2] = ((FLOAT)((BYTE*)&pOrigData[uiVertex * uiStride + dwPosOrig])[2]) / 255.0f;
|
((FLOAT *)pNewDataPos)[2] = ((FLOAT)((BYTE*)&pOrigData[uiVertex * uiStride + dwPosOrig])[2]) / 255.0f;
|
||||||
|
((FLOAT *)pNewDataPos)[3] = ((FLOAT)((BYTE*)&pOrigData[uiVertex * uiStride + dwPosOrig])[3]) / 255.0f;
|
||||||
|
|
||||||
dwPosOrig += 3 * sizeof(BYTE);
|
dwPosOrig += 4 * sizeof(BYTE);
|
||||||
dwPosNew += 3 * sizeof(FLOAT);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case X_D3DVSDT_PBYTE4: // 0x44:
|
case X_D3DVSDT_NORMSHORT1: // 0x11:
|
||||||
((FLOAT *)&pNewData[uiVertex * pStreamPatch->ConvertedStride + dwPosNew])[0] = ((FLOAT)((BYTE*)&pOrigData[uiVertex * uiStride + dwPosOrig])[0]) / 255.0f;
|
((FLOAT *)pNewDataPos)[0] = ((FLOAT)((SHORT*)&pOrigData[uiVertex * uiStride + dwPosOrig])[0]) / 32767.0f;
|
||||||
((FLOAT *)&pNewData[uiVertex * pStreamPatch->ConvertedStride + dwPosNew])[1] = ((FLOAT)((BYTE*)&pOrigData[uiVertex * uiStride + dwPosOrig])[1]) / 255.0f;
|
|
||||||
((FLOAT *)&pNewData[uiVertex * pStreamPatch->ConvertedStride + dwPosNew])[2] = ((FLOAT)((BYTE*)&pOrigData[uiVertex * uiStride + dwPosOrig])[2]) / 255.0f;
|
|
||||||
((FLOAT *)&pNewData[uiVertex * pStreamPatch->ConvertedStride + dwPosNew])[3] = ((FLOAT)((BYTE*)&pOrigData[uiVertex * uiStride + dwPosOrig])[3]) / 255.0f;
|
|
||||||
|
|
||||||
dwPosOrig += 4 * sizeof(BYTE);
|
dwPosOrig += 1 * sizeof(SHORT);
|
||||||
dwPosNew += 4 * sizeof(FLOAT);
|
break;
|
||||||
|
case X_D3DVSDT_NORMSHORT2: // 0x21:
|
||||||
|
((FLOAT *)pNewDataPos)[0] = ((FLOAT)((SHORT*)&pOrigData[uiVertex * uiStride + dwPosOrig])[0]) / 32767.0f;
|
||||||
|
((FLOAT *)pNewDataPos)[1] = ((FLOAT)((SHORT*)&pOrigData[uiVertex * uiStride + dwPosOrig])[1]) / 32767.0f;
|
||||||
|
|
||||||
break;
|
dwPosOrig += 2 * sizeof(SHORT);
|
||||||
case X_D3DVSDT_NORMSHORT1: // 0x11:
|
break;
|
||||||
((FLOAT *)&pNewData[uiVertex * pStreamPatch->ConvertedStride + dwPosNew])[0] = ((FLOAT)((SHORT*)&pOrigData[uiVertex * uiStride + dwPosOrig])[0]) / 32767.0f;
|
case X_D3DVSDT_NORMSHORT3: // 0x31:
|
||||||
|
((FLOAT *)pNewDataPos)[0] = ((FLOAT)((SHORT*)&pOrigData[uiVertex * uiStride + dwPosOrig])[0]) / 32767.0f;
|
||||||
|
((FLOAT *)pNewDataPos)[1] = ((FLOAT)((SHORT*)&pOrigData[uiVertex * uiStride + dwPosOrig])[1]) / 32767.0f;
|
||||||
|
((FLOAT *)pNewDataPos)[2] = ((FLOAT)((SHORT*)&pOrigData[uiVertex * uiStride + dwPosOrig])[2]) / 32767.0f;
|
||||||
|
|
||||||
dwPosOrig += 1 * sizeof(SHORT);
|
dwPosOrig += 3 * sizeof(SHORT);
|
||||||
dwPosNew += 1 * sizeof(FLOAT);
|
break;
|
||||||
break;
|
case X_D3DVSDT_NORMSHORT4: // 0x41:
|
||||||
case X_D3DVSDT_NORMSHORT2: // 0x21:
|
((FLOAT *)pNewDataPos)[0] = ((FLOAT)((SHORT*)&pOrigData[uiVertex * uiStride + dwPosOrig])[0]) / 32767.0f;
|
||||||
((FLOAT *)&pNewData[uiVertex * pStreamPatch->ConvertedStride + dwPosNew])[0] = ((FLOAT)((SHORT*)&pOrigData[uiVertex * uiStride + dwPosOrig])[0]) / 32767.0f;
|
((FLOAT *)pNewDataPos)[1] = ((FLOAT)((SHORT*)&pOrigData[uiVertex * uiStride + dwPosOrig])[1]) / 32767.0f;
|
||||||
((FLOAT *)&pNewData[uiVertex * pStreamPatch->ConvertedStride + dwPosNew])[1] = ((FLOAT)((SHORT*)&pOrigData[uiVertex * uiStride + dwPosOrig])[1]) / 32767.0f;
|
((FLOAT *)pNewDataPos)[2] = ((FLOAT)((SHORT*)&pOrigData[uiVertex * uiStride + dwPosOrig])[2]) / 32767.0f;
|
||||||
|
((FLOAT *)pNewDataPos)[3] = ((FLOAT)((SHORT*)&pOrigData[uiVertex * uiStride + dwPosOrig])[3]) / 32767.0f;
|
||||||
|
|
||||||
dwPosOrig += 2 * sizeof(SHORT);
|
dwPosOrig += 4 * sizeof(SHORT);
|
||||||
dwPosNew += 2 * sizeof(FLOAT);
|
break;
|
||||||
break;
|
case X_D3DVSDT_FLOAT2H: // 0x72:
|
||||||
case X_D3DVSDT_NORMSHORT3: // 0x31:
|
((FLOAT *)pNewDataPos)[0] = ((FLOAT*)&pOrigData[uiVertex * uiStride + dwPosOrig])[0];
|
||||||
((FLOAT *)&pNewData[uiVertex * pStreamPatch->ConvertedStride + dwPosNew])[0] = ((FLOAT)((SHORT*)&pOrigData[uiVertex * uiStride + dwPosOrig])[0]) / 32767.0f;
|
((FLOAT *)pNewDataPos)[1] = ((FLOAT*)&pOrigData[uiVertex * uiStride + dwPosOrig])[1];
|
||||||
((FLOAT *)&pNewData[uiVertex * pStreamPatch->ConvertedStride + dwPosNew])[1] = ((FLOAT)((SHORT*)&pOrigData[uiVertex * uiStride + dwPosOrig])[1]) / 32767.0f;
|
((FLOAT *)pNewDataPos)[2] = 0.0f;
|
||||||
((FLOAT *)&pNewData[uiVertex * pStreamPatch->ConvertedStride + dwPosNew])[2] = ((FLOAT)((SHORT*)&pOrigData[uiVertex * uiStride + dwPosOrig])[2]) / 32767.0f;
|
((FLOAT *)pNewDataPos)[3] = ((FLOAT*)&pOrigData[uiVertex * uiStride + dwPosOrig])[2];
|
||||||
|
break;
|
||||||
|
|
||||||
dwPosOrig += 3 * sizeof(SHORT);
|
/*TODO
|
||||||
dwPosNew += 3 * sizeof(FLOAT);
|
case X_D3DVSDT_NONE: // 0x02:
|
||||||
break;
|
printf("D3DVSDT_NONE / xbox ext. nsp /");
|
||||||
case X_D3DVSDT_NORMSHORT4: // 0x41:
|
dwNewDataType = 0xFF;
|
||||||
((FLOAT *)&pNewData[uiVertex * pStreamPatch->ConvertedStride + dwPosNew])[0] = ((FLOAT)((SHORT*)&pOrigData[uiVertex * uiStride + dwPosOrig])[0]) / 32767.0f;
|
|
||||||
((FLOAT *)&pNewData[uiVertex * pStreamPatch->ConvertedStride + dwPosNew])[1] = ((FLOAT)((SHORT*)&pOrigData[uiVertex * uiStride + dwPosOrig])[1]) / 32767.0f;
|
|
||||||
((FLOAT *)&pNewData[uiVertex * pStreamPatch->ConvertedStride + dwPosNew])[2] = ((FLOAT)((SHORT*)&pOrigData[uiVertex * uiStride + dwPosOrig])[2]) / 32767.0f;
|
|
||||||
((FLOAT *)&pNewData[uiVertex * pStreamPatch->ConvertedStride + dwPosNew])[3] = ((FLOAT)((SHORT*)&pOrigData[uiVertex * uiStride + dwPosOrig])[3]) / 32767.0f;
|
|
||||||
|
|
||||||
dwPosOrig += 4 * sizeof(SHORT);
|
|
||||||
dwPosNew += 4 * sizeof(FLOAT);
|
|
||||||
break;
|
|
||||||
case X_D3DVSDT_FLOAT2H: // 0x72:
|
|
||||||
((FLOAT *)&pNewData[uiVertex * pStreamPatch->ConvertedStride + dwPosNew])[0] = ((FLOAT*)&pOrigData[uiVertex * uiStride + dwPosOrig])[0];
|
|
||||||
((FLOAT *)&pNewData[uiVertex * pStreamPatch->ConvertedStride + dwPosNew])[1] = ((FLOAT*)&pOrigData[uiVertex * uiStride + dwPosOrig])[1];
|
|
||||||
((FLOAT *)&pNewData[uiVertex * pStreamPatch->ConvertedStride + dwPosNew])[2] = 0.0f;
|
|
||||||
((FLOAT *)&pNewData[uiVertex * pStreamPatch->ConvertedStride + dwPosNew])[3] = ((FLOAT*)&pOrigData[uiVertex * uiStride + dwPosOrig])[2];
|
|
||||||
break;
|
break;
|
||||||
|
*/
|
||||||
|
default:
|
||||||
|
// Generic 'conversion' - just make a copy :
|
||||||
|
memcpy(pNewDataPos,
|
||||||
|
&pOrigData[uiVertex * uiStride + dwPosOrig],
|
||||||
|
pStreamPatch->pSizes[uiType]);
|
||||||
|
dwPosOrig += pStreamPatch->pSizes[uiType];
|
||||||
|
break;
|
||||||
|
} // switch
|
||||||
|
|
||||||
/*TODO
|
// Increment the new pointer :
|
||||||
case X_D3DVSDT_NONE: // 0x02:
|
pNewDataPos += pStreamPatch->pSizes[uiType];
|
||||||
printf("D3DVSDT_NONE / xbox ext. nsp /");
|
|
||||||
dwNewDataType = 0xFF;
|
}
|
||||||
break;
|
}
|
||||||
*/
|
|
||||||
default:
|
|
||||||
// Generic 'conversion' - just make a copy :
|
|
||||||
memcpy(&pNewData[uiVertex * pStreamPatch->ConvertedStride + dwPosNew],
|
|
||||||
&pOrigData[uiVertex * uiStride + dwPosOrig],
|
|
||||||
pStreamPatch->pSizes[uiType]);
|
|
||||||
dwPosOrig += pStreamPatch->pSizes[uiType];
|
|
||||||
dwPosNew += pStreamPatch->pSizes[uiType];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!pPatchDesc->pVertexStreamZeroData)
|
if(!pPatchDesc->pVertexStreamZeroData)
|
||||||
{
|
{
|
||||||
pNewVertexBuffer->Unlock();
|
//if(pNewVertexBuffer != nullptr) // Dxbx addition
|
||||||
pOrigVertexBuffer->Unlock();
|
pNewVertexBuffer->Unlock();
|
||||||
|
//if (pOrigVertexBuffer != nullptr) // Dxbx addition
|
||||||
|
pOrigVertexBuffer->Unlock();
|
||||||
|
|
||||||
if(FAILED(g_pD3DDevice8->SetStreamSource(uiStream, pNewVertexBuffer, pStreamPatch->ConvertedStride)))
|
if(FAILED(g_pD3DDevice8->SetStreamSource(uiStream, pNewVertexBuffer, pStreamPatch->ConvertedStride)))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue