unconvert ADC implemented

This commit is contained in:
aap
2015-12-20 13:05:32 +01:00
parent 83d1420dd1
commit 37e1e239f9
9 changed files with 83 additions and 220 deletions

View File

@@ -71,14 +71,7 @@ Geometry::~Geometry(void)
delete[] m->normals;
}
delete[] this->morphTargets;
if(this->meshHeader){
// first mesh holds pointer to all indices
delete[] this->meshHeader->mesh[0].indices;
delete[] this->meshHeader->mesh;
delete this->meshHeader;
}
delete this->meshHeader;
for(int32 i = 0; i < this->numMaterials; i++)
this->materialList[i]->decRef();
delete[] this->materialList;

View File

@@ -816,37 +816,37 @@ registerCollisionPlugin(void)
using namespace ps2;
PipeAttribute saXYZADC = {
rw::PipeAttribute saXYZADC = {
"saXYZADC",
AT_V4_16 | AT_RW
};
PipeAttribute saUV = {
rw::PipeAttribute saUV = {
"saUV",
AT_V2_16 | AT_RW
};
PipeAttribute saUV2 = {
rw::PipeAttribute saUV2 = {
"saUV2",
AT_V4_16 | AT_RW
};
PipeAttribute saRGBA = {
rw::PipeAttribute saRGBA = {
"saRGBA",
AT_V4_8 | AT_UNSGN | AT_RW
};
PipeAttribute saRGBA2 = {
rw::PipeAttribute saRGBA2 = {
"saRGBA2",
AT_V4_16 | AT_UNSGN | AT_RW
};
PipeAttribute saNormal = {
rw::PipeAttribute saNormal = {
"saNormal",
AT_V4_8 | AT_RW
};
PipeAttribute saWeights = {
rw::PipeAttribute saWeights = {
"saWeights",
AT_V4_32 | AT_RW
};

View File

@@ -295,6 +295,13 @@ registerMeshPlugin(void)
Geometry::registerPluginStream(0x50E, readMesh, writeMesh, getSizeMesh);
}
MeshHeader::~MeshHeader(void)
{
// first mesh holds pointer to all indices
delete[] this->mesh[0].indices;
delete[] this->mesh;
}
void
MeshHeader::allocateIndices(void)
{

View File

@@ -1217,6 +1217,55 @@ debugadc(Geometry *g, MeshHeader *mh, ADCData *adc)
return n;
}
// Not optimal but works
void
unconvertADC(Geometry *g)
{
ADCData *adc = PLUGINOFFSET(ADCData, g, adcOffset);
if(!adc->adcFormatted)
return;
int8 *b = adc->adcBits;
MeshHeader *h = new MeshHeader;
h->flags = g->meshHeader->flags; // should be tristrip
h->numMeshes = g->meshHeader->numMeshes;
h->mesh = new Mesh[h->numMeshes];
Mesh *oldm = g->meshHeader->mesh;
Mesh *newm = h->mesh;
h->totalIndices = 0;
for(int32 i = 0; i < h->numMeshes; i++){
newm->material = oldm->material;
newm->numIndices = oldm->numIndices;
for(uint32 j = 0; j < oldm->numIndices; j++)
if(*b++)
newm->numIndices += 2;
h->totalIndices += newm->numIndices;
newm++;
oldm++;
}
h->allocateIndices();
b = adc->adcBits;
oldm = g->meshHeader->mesh;
newm = h->mesh;
for(int32 i = 0; i < h->numMeshes; i++){
int32 n = 0;
for(uint32 j = 0; j < oldm->numIndices; j++){
if(*b++){
newm->indices[n++] = oldm->indices[j-1];
newm->indices[n++] = oldm->indices[j-1];
}
newm->indices[n++] = oldm->indices[j];
}
newm++;
oldm++;
}
delete g->meshHeader;
g->meshHeader = h;
adc->adcFormatted = 0;
delete[] adc->adcBits;
adc->adcBits = 0;
adc->numBits = NULL;
}
void
allocateADC(Geometry *geo)
{

View File

@@ -291,6 +291,7 @@ struct MeshHeader
Mesh *mesh; // RW has a byte offset here
void allocateIndices(void);
~MeshHeader(void);
};
struct MorphTarget

View File

@@ -136,6 +136,7 @@ struct ADCData
extern int32 adcOffset;
void registerADCPlugin(void);
void unconvertADC(Geometry *geo);
void allocateADC(Geometry *geo);
// PDS plugin