fixed handling of NATIVE flag

This commit is contained in:
aap 2017-08-21 23:15:31 +02:00
parent 0d8dc5d799
commit 8fc446f13b
10 changed files with 50 additions and 18 deletions

View File

@ -529,6 +529,25 @@ Atomic::getPipeline(void)
engine->driver[platform]->defaultPipeline;
}
void
Atomic::instance(void)
{
if(this->geometry->flags & Geometry::NATIVE)
return;
this->getPipeline()->instance(this);
this->geometry->flags |= Geometry::NATIVE;
}
void
Atomic::uninstance(void)
{
if(!(this->geometry->flags & Geometry::NATIVE))
return;
this->getPipeline()->uninstance(this);
// this should be done by the CB already, just make sure
this->geometry->flags &= ~Geometry::NATIVE;
}
void
Atomic::defaultRenderCB(Atomic *atomic)
{

View File

@ -248,9 +248,9 @@ instance(rw::ObjPipeline *rwpipe, Atomic *atomic)
{
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
Geometry *geo = atomic->geometry;
if(geo->flags & Geometry::NATIVE)
// TODO: allow for REINSTANCE
if(geo->instData)
return;
geo->flags |= Geometry::NATIVE;
InstanceDataHeader *header = new InstanceDataHeader;
MeshHeader *meshh = geo->meshHeader;
geo->instData = header;
@ -328,7 +328,8 @@ render(rw::ObjPipeline *rwpipe, Atomic *atomic)
{
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
Geometry *geo = atomic->geometry;
if((geo->flags & Geometry::NATIVE) == 0)
// TODO: allow for REINSTANCE
if(geo->instData == nil)
pipe->instance(atomic);
assert(geo->instData != nil);
assert(geo->instData->platform == PLATFORM_D3D8);

View File

@ -313,9 +313,9 @@ instance(rw::ObjPipeline *rwpipe, Atomic *atomic)
{
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
Geometry *geo = atomic->geometry;
if(geo->flags & Geometry::NATIVE)
// TODO: allow for REINSTANCE
if(geo->instData)
return;
geo->flags |= Geometry::NATIVE;
InstanceDataHeader *header = new InstanceDataHeader;
MeshHeader *meshh = geo->meshHeader;
geo->instData = header;
@ -399,7 +399,8 @@ render(rw::ObjPipeline *rwpipe, Atomic *atomic)
{
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
Geometry *geo = atomic->geometry;
if((geo->flags & Geometry::NATIVE) == 0)
// TODO: allow for REINSTANCE
if(geo->instData == nil)
pipe->instance(atomic);
assert(geo->instData != nil);
assert(geo->instData->platform == PLATFORM_D3D9);

View File

@ -197,9 +197,9 @@ instance(rw::ObjPipeline *rwpipe, Atomic *atomic)
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
Geometry *geo = atomic->geometry;
if(geo->flags & Geometry::NATIVE)
// TODO: allow for REINSTANCE (or not, xbox can't render)
if(geo->instData)
return;
geo->flags |= Geometry::NATIVE;
InstanceDataHeader *header = new InstanceDataHeader;
MeshHeader *meshh = geo->meshHeader;
geo->instData = header;

View File

@ -19,6 +19,7 @@ PluginList Material::s_plglist = { sizeof(Material), sizeof(Material), nil, nil
SurfaceProperties defaultSurfaceProps = { 1.0f, 1.0f, 1.0f };
// TODO: allocate everything in one chunk
Geometry*
Geometry::create(int32 numVerts, int32 numTris, uint32 flags)
{
@ -321,6 +322,7 @@ Geometry::hasColoredMaterial(void)
return 0;
}
// TODO: allocate as one chunk
void
Geometry::allocateData(void)
{
@ -475,7 +477,7 @@ Geometry::correctTristripWinding(void)
{
MeshHeader *header = this->meshHeader;
if(header == nil || header->flags != MeshHeader::TRISTRIP ||
this->flags & NATIVE)
this->instData)
return;
MeshHeader *newhead = new MeshHeader;
newhead->flags = header->flags;

View File

@ -27,9 +27,9 @@ instance(rw::ObjPipeline *rwpipe, Atomic *atomic)
{
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
Geometry *geo = atomic->geometry;
if(geo->flags & Geometry::NATIVE)
// TODO: allow for REINSTANCE
if(geo->instData)
return;
geo->flags |= Geometry::NATIVE;
InstanceDataHeader *header = new InstanceDataHeader;
MeshHeader *meshh = geo->meshHeader;
geo->instData = header;
@ -87,7 +87,8 @@ render(rw::ObjPipeline *rwpipe, Atomic *atomic)
{
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
Geometry *geo = atomic->geometry;
if((geo->flags & Geometry::NATIVE) == 0)
// TODO: allow for REINSTANCE
if(geo->instData == nil)
pipe->instance(atomic);
assert(geo->instData != nil);
assert(geo->instData->platform == PLATFORM_GL3);

View File

@ -322,7 +322,8 @@ instance(rw::ObjPipeline *rwpipe, Atomic *atomic)
{
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
Geometry *geo = atomic->geometry;
if(geo->flags & Geometry::NATIVE)
// TODO: allow for REINSTANCE (or not, wdgl can't render)
if(geo->instData)
return;
InstanceDataHeader *header = new InstanceDataHeader;
geo->instData = header;
@ -441,7 +442,6 @@ instance(rw::ObjPipeline *rwpipe, Atomic *atomic)
}
a++;
}
geo->flags |= Geometry::NATIVE;
}
static void

View File

@ -85,8 +85,9 @@ TexDictionary::streamRead(Stream *stream)
return nil;
}
int32 numTex = stream->readI16();
stream->readI16(); // some platform id (1 = d3d8, 2 = d3d9, 5 = opengl,
// 6 = ps2, 8 = xbox)
stream->readI16(); // device id (0 = unknown, 1 = d3d8, 2 = d3d9,
// 3 = gcn, 4 = null, 5 = opengl,
// 6 = ps2, 7 = softras, 8 = xbox, 9 = psp)
TexDictionary *txd = TexDictionary::create();
if(txd == nil)
return nil;

View File

@ -749,7 +749,8 @@ objInstance(rw::ObjPipeline *rwpipe, Atomic *atomic)
{
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
Geometry *geo = atomic->geometry;
if(geo->flags & Geometry::NATIVE)
// TODO: allow for REINSTANCE
if(geo->instData)
return;
InstanceDataHeader *header = new InstanceDataHeader;
geo->instData = header;
@ -770,7 +771,6 @@ objInstance(rw::ObjPipeline *rwpipe, Atomic *atomic)
m->instance(geo, instance, mesh);
instance->material = mesh->material;
}
geo->flags |= Geometry::NATIVE;
}
/*

View File

@ -403,6 +403,7 @@ struct MaterialList
uint32 streamGetSize(void);
};
// TODO: implement locking
struct Geometry
{
PLUGINBASE
@ -451,6 +452,10 @@ struct Geometry
LIGHT = 0x20,
MODULATE = 0x40,
TEXTURED2 = 0x80,
// When this flag is set the geometry has
// native geometry. When streamed out this geometry
// is written out instead of the platform independent data.
// When streamed in with this flag, the geometry is mostly empty.
NATIVE = 0x01000000,
// Just for documentation: RW sets this flag
// to prevent rendering when executing a pipeline,
@ -507,6 +512,8 @@ struct Atomic
void setGeometry(Geometry *geo, uint32 flags);
Sphere *getWorldBoundingSphere(void);
ObjPipeline *getPipeline(void);
void instance(void);
void uninstance(void);
void render(void) { this->renderCB(this); }
void setRenderCB(RenderCB renderCB){
this->renderCB = renderCB;