mirror of https://github.com/aap/librw.git
fixed handling of NATIVE flag
This commit is contained in:
parent
0d8dc5d799
commit
8fc446f13b
|
@ -529,6 +529,25 @@ Atomic::getPipeline(void)
|
||||||
engine->driver[platform]->defaultPipeline;
|
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
|
void
|
||||||
Atomic::defaultRenderCB(Atomic *atomic)
|
Atomic::defaultRenderCB(Atomic *atomic)
|
||||||
{
|
{
|
||||||
|
|
|
@ -248,9 +248,9 @@ instance(rw::ObjPipeline *rwpipe, Atomic *atomic)
|
||||||
{
|
{
|
||||||
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
|
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
|
||||||
Geometry *geo = atomic->geometry;
|
Geometry *geo = atomic->geometry;
|
||||||
if(geo->flags & Geometry::NATIVE)
|
// TODO: allow for REINSTANCE
|
||||||
|
if(geo->instData)
|
||||||
return;
|
return;
|
||||||
geo->flags |= Geometry::NATIVE;
|
|
||||||
InstanceDataHeader *header = new InstanceDataHeader;
|
InstanceDataHeader *header = new InstanceDataHeader;
|
||||||
MeshHeader *meshh = geo->meshHeader;
|
MeshHeader *meshh = geo->meshHeader;
|
||||||
geo->instData = header;
|
geo->instData = header;
|
||||||
|
@ -328,7 +328,8 @@ render(rw::ObjPipeline *rwpipe, Atomic *atomic)
|
||||||
{
|
{
|
||||||
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
|
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
|
||||||
Geometry *geo = atomic->geometry;
|
Geometry *geo = atomic->geometry;
|
||||||
if((geo->flags & Geometry::NATIVE) == 0)
|
// TODO: allow for REINSTANCE
|
||||||
|
if(geo->instData == nil)
|
||||||
pipe->instance(atomic);
|
pipe->instance(atomic);
|
||||||
assert(geo->instData != nil);
|
assert(geo->instData != nil);
|
||||||
assert(geo->instData->platform == PLATFORM_D3D8);
|
assert(geo->instData->platform == PLATFORM_D3D8);
|
||||||
|
|
|
@ -313,9 +313,9 @@ instance(rw::ObjPipeline *rwpipe, Atomic *atomic)
|
||||||
{
|
{
|
||||||
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
|
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
|
||||||
Geometry *geo = atomic->geometry;
|
Geometry *geo = atomic->geometry;
|
||||||
if(geo->flags & Geometry::NATIVE)
|
// TODO: allow for REINSTANCE
|
||||||
|
if(geo->instData)
|
||||||
return;
|
return;
|
||||||
geo->flags |= Geometry::NATIVE;
|
|
||||||
InstanceDataHeader *header = new InstanceDataHeader;
|
InstanceDataHeader *header = new InstanceDataHeader;
|
||||||
MeshHeader *meshh = geo->meshHeader;
|
MeshHeader *meshh = geo->meshHeader;
|
||||||
geo->instData = header;
|
geo->instData = header;
|
||||||
|
@ -399,7 +399,8 @@ render(rw::ObjPipeline *rwpipe, Atomic *atomic)
|
||||||
{
|
{
|
||||||
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
|
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
|
||||||
Geometry *geo = atomic->geometry;
|
Geometry *geo = atomic->geometry;
|
||||||
if((geo->flags & Geometry::NATIVE) == 0)
|
// TODO: allow for REINSTANCE
|
||||||
|
if(geo->instData == nil)
|
||||||
pipe->instance(atomic);
|
pipe->instance(atomic);
|
||||||
assert(geo->instData != nil);
|
assert(geo->instData != nil);
|
||||||
assert(geo->instData->platform == PLATFORM_D3D9);
|
assert(geo->instData->platform == PLATFORM_D3D9);
|
||||||
|
|
|
@ -197,9 +197,9 @@ instance(rw::ObjPipeline *rwpipe, Atomic *atomic)
|
||||||
|
|
||||||
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
|
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
|
||||||
Geometry *geo = atomic->geometry;
|
Geometry *geo = atomic->geometry;
|
||||||
if(geo->flags & Geometry::NATIVE)
|
// TODO: allow for REINSTANCE (or not, xbox can't render)
|
||||||
|
if(geo->instData)
|
||||||
return;
|
return;
|
||||||
geo->flags |= Geometry::NATIVE;
|
|
||||||
InstanceDataHeader *header = new InstanceDataHeader;
|
InstanceDataHeader *header = new InstanceDataHeader;
|
||||||
MeshHeader *meshh = geo->meshHeader;
|
MeshHeader *meshh = geo->meshHeader;
|
||||||
geo->instData = header;
|
geo->instData = header;
|
||||||
|
|
|
@ -19,6 +19,7 @@ PluginList Material::s_plglist = { sizeof(Material), sizeof(Material), nil, nil
|
||||||
|
|
||||||
SurfaceProperties defaultSurfaceProps = { 1.0f, 1.0f, 1.0f };
|
SurfaceProperties defaultSurfaceProps = { 1.0f, 1.0f, 1.0f };
|
||||||
|
|
||||||
|
// TODO: allocate everything in one chunk
|
||||||
Geometry*
|
Geometry*
|
||||||
Geometry::create(int32 numVerts, int32 numTris, uint32 flags)
|
Geometry::create(int32 numVerts, int32 numTris, uint32 flags)
|
||||||
{
|
{
|
||||||
|
@ -321,6 +322,7 @@ Geometry::hasColoredMaterial(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: allocate as one chunk
|
||||||
void
|
void
|
||||||
Geometry::allocateData(void)
|
Geometry::allocateData(void)
|
||||||
{
|
{
|
||||||
|
@ -475,7 +477,7 @@ Geometry::correctTristripWinding(void)
|
||||||
{
|
{
|
||||||
MeshHeader *header = this->meshHeader;
|
MeshHeader *header = this->meshHeader;
|
||||||
if(header == nil || header->flags != MeshHeader::TRISTRIP ||
|
if(header == nil || header->flags != MeshHeader::TRISTRIP ||
|
||||||
this->flags & NATIVE)
|
this->instData)
|
||||||
return;
|
return;
|
||||||
MeshHeader *newhead = new MeshHeader;
|
MeshHeader *newhead = new MeshHeader;
|
||||||
newhead->flags = header->flags;
|
newhead->flags = header->flags;
|
||||||
|
|
|
@ -27,9 +27,9 @@ instance(rw::ObjPipeline *rwpipe, Atomic *atomic)
|
||||||
{
|
{
|
||||||
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
|
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
|
||||||
Geometry *geo = atomic->geometry;
|
Geometry *geo = atomic->geometry;
|
||||||
if(geo->flags & Geometry::NATIVE)
|
// TODO: allow for REINSTANCE
|
||||||
|
if(geo->instData)
|
||||||
return;
|
return;
|
||||||
geo->flags |= Geometry::NATIVE;
|
|
||||||
InstanceDataHeader *header = new InstanceDataHeader;
|
InstanceDataHeader *header = new InstanceDataHeader;
|
||||||
MeshHeader *meshh = geo->meshHeader;
|
MeshHeader *meshh = geo->meshHeader;
|
||||||
geo->instData = header;
|
geo->instData = header;
|
||||||
|
@ -87,7 +87,8 @@ render(rw::ObjPipeline *rwpipe, Atomic *atomic)
|
||||||
{
|
{
|
||||||
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
|
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
|
||||||
Geometry *geo = atomic->geometry;
|
Geometry *geo = atomic->geometry;
|
||||||
if((geo->flags & Geometry::NATIVE) == 0)
|
// TODO: allow for REINSTANCE
|
||||||
|
if(geo->instData == nil)
|
||||||
pipe->instance(atomic);
|
pipe->instance(atomic);
|
||||||
assert(geo->instData != nil);
|
assert(geo->instData != nil);
|
||||||
assert(geo->instData->platform == PLATFORM_GL3);
|
assert(geo->instData->platform == PLATFORM_GL3);
|
||||||
|
|
|
@ -322,7 +322,8 @@ instance(rw::ObjPipeline *rwpipe, Atomic *atomic)
|
||||||
{
|
{
|
||||||
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
|
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
|
||||||
Geometry *geo = atomic->geometry;
|
Geometry *geo = atomic->geometry;
|
||||||
if(geo->flags & Geometry::NATIVE)
|
// TODO: allow for REINSTANCE (or not, wdgl can't render)
|
||||||
|
if(geo->instData)
|
||||||
return;
|
return;
|
||||||
InstanceDataHeader *header = new InstanceDataHeader;
|
InstanceDataHeader *header = new InstanceDataHeader;
|
||||||
geo->instData = header;
|
geo->instData = header;
|
||||||
|
@ -441,7 +442,6 @@ instance(rw::ObjPipeline *rwpipe, Atomic *atomic)
|
||||||
}
|
}
|
||||||
a++;
|
a++;
|
||||||
}
|
}
|
||||||
geo->flags |= Geometry::NATIVE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -85,8 +85,9 @@ TexDictionary::streamRead(Stream *stream)
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
int32 numTex = stream->readI16();
|
int32 numTex = stream->readI16();
|
||||||
stream->readI16(); // some platform id (1 = d3d8, 2 = d3d9, 5 = opengl,
|
stream->readI16(); // device id (0 = unknown, 1 = d3d8, 2 = d3d9,
|
||||||
// 6 = ps2, 8 = xbox)
|
// 3 = gcn, 4 = null, 5 = opengl,
|
||||||
|
// 6 = ps2, 7 = softras, 8 = xbox, 9 = psp)
|
||||||
TexDictionary *txd = TexDictionary::create();
|
TexDictionary *txd = TexDictionary::create();
|
||||||
if(txd == nil)
|
if(txd == nil)
|
||||||
return nil;
|
return nil;
|
||||||
|
|
|
@ -749,7 +749,8 @@ objInstance(rw::ObjPipeline *rwpipe, Atomic *atomic)
|
||||||
{
|
{
|
||||||
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
|
ObjPipeline *pipe = (ObjPipeline*)rwpipe;
|
||||||
Geometry *geo = atomic->geometry;
|
Geometry *geo = atomic->geometry;
|
||||||
if(geo->flags & Geometry::NATIVE)
|
// TODO: allow for REINSTANCE
|
||||||
|
if(geo->instData)
|
||||||
return;
|
return;
|
||||||
InstanceDataHeader *header = new InstanceDataHeader;
|
InstanceDataHeader *header = new InstanceDataHeader;
|
||||||
geo->instData = header;
|
geo->instData = header;
|
||||||
|
@ -770,7 +771,6 @@ objInstance(rw::ObjPipeline *rwpipe, Atomic *atomic)
|
||||||
m->instance(geo, instance, mesh);
|
m->instance(geo, instance, mesh);
|
||||||
instance->material = mesh->material;
|
instance->material = mesh->material;
|
||||||
}
|
}
|
||||||
geo->flags |= Geometry::NATIVE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -403,6 +403,7 @@ struct MaterialList
|
||||||
uint32 streamGetSize(void);
|
uint32 streamGetSize(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO: implement locking
|
||||||
struct Geometry
|
struct Geometry
|
||||||
{
|
{
|
||||||
PLUGINBASE
|
PLUGINBASE
|
||||||
|
@ -451,6 +452,10 @@ struct Geometry
|
||||||
LIGHT = 0x20,
|
LIGHT = 0x20,
|
||||||
MODULATE = 0x40,
|
MODULATE = 0x40,
|
||||||
TEXTURED2 = 0x80,
|
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,
|
NATIVE = 0x01000000,
|
||||||
// Just for documentation: RW sets this flag
|
// Just for documentation: RW sets this flag
|
||||||
// to prevent rendering when executing a pipeline,
|
// to prevent rendering when executing a pipeline,
|
||||||
|
@ -507,6 +512,8 @@ struct Atomic
|
||||||
void setGeometry(Geometry *geo, uint32 flags);
|
void setGeometry(Geometry *geo, uint32 flags);
|
||||||
Sphere *getWorldBoundingSphere(void);
|
Sphere *getWorldBoundingSphere(void);
|
||||||
ObjPipeline *getPipeline(void);
|
ObjPipeline *getPipeline(void);
|
||||||
|
void instance(void);
|
||||||
|
void uninstance(void);
|
||||||
void render(void) { this->renderCB(this); }
|
void render(void) { this->renderCB(this); }
|
||||||
void setRenderCB(RenderCB renderCB){
|
void setRenderCB(RenderCB renderCB){
|
||||||
this->renderCB = renderCB;
|
this->renderCB = renderCB;
|
||||||
|
|
Loading…
Reference in New Issue