some renaming, frame synching, camera update

This commit is contained in:
aap 2016-06-21 23:16:09 +02:00
parent 634a96be07
commit 3271713d16
23 changed files with 387 additions and 207 deletions

View File

@ -6,11 +6,31 @@
#include "rwplg.h" #include "rwplg.h"
#include "rwpipeline.h" #include "rwpipeline.h"
#include "rwobjects.h" #include "rwobjects.h"
#include "rwengine.h"
#define PLUGIN_ID 0 #define PLUGIN_ID 0
namespace rw { namespace rw {
void
defaultBeginUpdateCB(Camera *cam)
{
engine.currentCamera = cam;
Frame::syncDirty();
DRIVER.beginUpdate(cam);
}
void
defaultEndUpdateCB(Camera *cam)
{
DRIVER.endUpdate(cam);
}
static void
cameraSync(ObjectWithFrame*)
{
}
Camera* Camera*
Camera::create(void) Camera::create(void)
{ {
@ -20,6 +40,7 @@ Camera::create(void)
return nil; return nil;
} }
cam->object.object.init(Camera::ID, 0); cam->object.object.init(Camera::ID, 0);
cam->object.syncCB = cameraSync;
cam->viewWindow.set(1.0f, 1.0f); cam->viewWindow.set(1.0f, 1.0f);
cam->viewOffset.set(0.0f, 0.0f); cam->viewOffset.set(0.0f, 0.0f);
cam->nearPlane = 0.05f; cam->nearPlane = 0.05f;
@ -28,6 +49,10 @@ Camera::create(void)
cam->projection = Camera::PERSPECTIVE; cam->projection = Camera::PERSPECTIVE;
cam->clump = nil; cam->clump = nil;
cam->inClump.init(); cam->inClump.init();
cam->beginUpdateCB = defaultBeginUpdateCB;
cam->endUpdateCB = defaultEndUpdateCB;
cam->constructPlugins(); cam->constructPlugins();
return cam; return cam;
} }
@ -153,6 +178,29 @@ Camera::updateProjectionMatrix(void)
this->projMat[14] = -this->nearPlane*this->projMat[10]; this->projMat[14] = -this->nearPlane*this->projMat[10];
this->projMat[15] = 1.0f; this->projMat[15] = 1.0f;
} }
}else if(rw::platform == PLATFORM_WDGL || rw::platform == PLATFORM_GL3){
this->projMat[0] = invwx;
this->projMat[1] = 0.0f;
this->projMat[2] = 0.0f;
this->projMat[3] = 0.0f;
this->projMat[4] = 0.0f;
this->projMat[5] = invwy;
this->projMat[6] = 0.0f;
this->projMat[7] = 0.0f;
if(this->projection == PERSPECTIVE){
this->projMat[8] = this->viewOffset.x*invwx;
this->projMat[9] = this->viewOffset.y*invwy;
this->projMat[10] = (this->farPlane+this->nearPlane)*invz;
this->projMat[11] = 1.0f;
this->projMat[12] = 0.0f;
this->projMat[13] = 0.0f;
this->projMat[14] = -2.0f*this->nearPlane*this->farPlane*invz;
this->projMat[15] = 0.0f;
}else{
}
} }
} }

View File

@ -315,6 +315,11 @@ Clump::render(void)
// Atomic // Atomic
// //
static void
atomicSync(ObjectWithFrame*)
{
}
Atomic* Atomic*
Atomic::create(void) Atomic::create(void)
{ {
@ -324,6 +329,7 @@ Atomic::create(void)
return nil; return nil;
} }
atomic->object.object.init(Atomic::ID, 0); atomic->object.object.init(Atomic::ID, 0);
atomic->object.syncCB = atomicSync;
atomic->geometry = nil; atomic->geometry = nil;
atomic->worldBoundingSphere.center.set(0.0f, 0.0f, 0.0f); atomic->worldBoundingSphere.center.set(0.0f, 0.0f, 0.0f);
atomic->worldBoundingSphere.radius = 0.0f; atomic->worldBoundingSphere.radius = 0.0f;
@ -491,7 +497,7 @@ Atomic::getPipeline(void)
{ {
return this->pipeline ? return this->pipeline ?
this->pipeline : this->pipeline :
engine[platform].defaultPipeline; driver[platform].defaultPipeline;
} }
void void

View File

@ -10,15 +10,13 @@
#include "rwengine.h" #include "rwengine.h"
#include "rwd3d.h" #include "rwd3d.h"
using namespace std;
namespace rw { namespace rw {
namespace d3d { namespace d3d {
bool32 isP8supported = 1; bool32 isP8supported = 1;
#ifdef RW_D3D9 #ifdef RW_D3D9
IDirect3DDevice9 *device = NULL; IDirect3DDevice9 *device = nil;
#else #else
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \ #define MAKEFOURCC(ch0, ch1, ch2, ch3) \
((uint32)(uint8)(ch0) | ((uint32)(uint8)(ch1) << 8) | \ ((uint32)(uint8)(ch0) | ((uint32)(uint8)(ch1) << 8) | \
@ -198,8 +196,8 @@ createIndexBuffer(uint32 length)
uint16* uint16*
lockIndices(void *indexBuffer, uint32 offset, uint32 size, uint32 flags) lockIndices(void *indexBuffer, uint32 offset, uint32 size, uint32 flags)
{ {
if(indexBuffer == NULL) if(indexBuffer == nil)
return NULL; return nil;
#ifdef RW_D3D9 #ifdef RW_D3D9
uint16 *indices; uint16 *indices;
IDirect3DIndexBuffer9 *ibuf = (IDirect3DIndexBuffer9*)indexBuffer; IDirect3DIndexBuffer9 *ibuf = (IDirect3DIndexBuffer9*)indexBuffer;
@ -216,7 +214,7 @@ lockIndices(void *indexBuffer, uint32 offset, uint32 size, uint32 flags)
void void
unlockIndices(void *indexBuffer) unlockIndices(void *indexBuffer)
{ {
if(indexBuffer == NULL) if(indexBuffer == nil)
return; return;
#ifdef RW_D3D9 #ifdef RW_D3D9
IDirect3DIndexBuffer9 *ibuf = (IDirect3DIndexBuffer9*)indexBuffer; IDirect3DIndexBuffer9 *ibuf = (IDirect3DIndexBuffer9*)indexBuffer;
@ -241,8 +239,8 @@ createVertexBuffer(uint32 length, uint32 fvf, int32 pool)
uint8* uint8*
lockVertices(void *vertexBuffer, uint32 offset, uint32 size, uint32 flags) lockVertices(void *vertexBuffer, uint32 offset, uint32 size, uint32 flags)
{ {
if(vertexBuffer == NULL) if(vertexBuffer == nil)
return NULL; return nil;
#ifdef RW_D3D9 #ifdef RW_D3D9
uint8 *verts; uint8 *verts;
IDirect3DVertexBuffer9 *vertbuf = (IDirect3DVertexBuffer9*)vertexBuffer; IDirect3DVertexBuffer9 *vertbuf = (IDirect3DVertexBuffer9*)vertexBuffer;
@ -259,7 +257,7 @@ lockVertices(void *vertexBuffer, uint32 offset, uint32 size, uint32 flags)
void void
unlockVertices(void *vertexBuffer) unlockVertices(void *vertexBuffer)
{ {
if(vertexBuffer == NULL) if(vertexBuffer == nil)
return; return;
#ifdef RW_D3D9 #ifdef RW_D3D9
IDirect3DVertexBuffer9 *vertbuf = (IDirect3DVertexBuffer9*)vertexBuffer; IDirect3DVertexBuffer9 *vertbuf = (IDirect3DVertexBuffer9*)vertexBuffer;
@ -273,7 +271,7 @@ createTexture(int32 width, int32 height, int32 numlevels, uint32 format)
#ifdef RW_D3D9 #ifdef RW_D3D9
IDirect3DTexture9 *tex; IDirect3DTexture9 *tex;
device->CreateTexture(width, height, numlevels, 0, device->CreateTexture(width, height, numlevels, 0,
(D3DFORMAT)format, D3DPOOL_MANAGED, &tex, NULL); (D3DFORMAT)format, D3DPOOL_MANAGED, &tex, nil);
return tex; return tex;
#else #else
int32 w = width; int32 w = width;
@ -336,7 +334,7 @@ unlockTexture(void *texture, int32 level)
void void
deleteObject(void *object) deleteObject(void *object)
{ {
if(object == NULL) if(object == nil)
return; return;
#ifdef RW_D3D9 #ifdef RW_D3D9
IUnknown *unk = (IUnknown*)object; IUnknown *unk = (IUnknown*)object;
@ -560,8 +558,8 @@ static void*
createNativeRaster(void *object, int32 offset, int32) createNativeRaster(void *object, int32 offset, int32)
{ {
D3dRaster *raster = PLUGINOFFSET(D3dRaster, object, offset); D3dRaster *raster = PLUGINOFFSET(D3dRaster, object, offset);
raster->texture = NULL; raster->texture = nil;
raster->palette = NULL; raster->palette = nil;
raster->format = 0; raster->format = 0;
raster->hasAlpha = 0; raster->hasAlpha = 0;
raster->customFormat = 0; raster->customFormat = 0;
@ -580,8 +578,8 @@ static void*
copyNativeRaster(void *dst, void *, int32 offset, int32) copyNativeRaster(void *dst, void *, int32 offset, int32)
{ {
D3dRaster *raster = PLUGINOFFSET(D3dRaster, dst, offset); D3dRaster *raster = PLUGINOFFSET(D3dRaster, dst, offset);
raster->texture = NULL; raster->texture = nil;
raster->palette = NULL; raster->palette = nil;
raster->format = 0; raster->format = 0;
raster->hasAlpha = 0; raster->hasAlpha = 0;
raster->customFormat = 0; raster->customFormat = 0;
@ -596,19 +594,19 @@ registerNativeRaster(void)
createNativeRaster, createNativeRaster,
destroyNativeRaster, destroyNativeRaster,
copyNativeRaster); copyNativeRaster);
engine[PLATFORM_D3D8].rasterNativeOffset = nativeRasterOffset; driver[PLATFORM_D3D8].rasterNativeOffset = nativeRasterOffset;
engine[PLATFORM_D3D8].rasterCreate = rasterCreate; driver[PLATFORM_D3D8].rasterCreate = rasterCreate;
engine[PLATFORM_D3D8].rasterLock = rasterLock; driver[PLATFORM_D3D8].rasterLock = rasterLock;
engine[PLATFORM_D3D8].rasterUnlock = rasterUnlock; driver[PLATFORM_D3D8].rasterUnlock = rasterUnlock;
engine[PLATFORM_D3D8].rasterNumLevels = rasterNumLevels; driver[PLATFORM_D3D8].rasterNumLevels = rasterNumLevels;
engine[PLATFORM_D3D8].rasterFromImage = rasterFromImage; driver[PLATFORM_D3D8].rasterFromImage = rasterFromImage;
engine[PLATFORM_D3D9].rasterNativeOffset = nativeRasterOffset; driver[PLATFORM_D3D9].rasterNativeOffset = nativeRasterOffset;
engine[PLATFORM_D3D9].rasterCreate = rasterCreate; driver[PLATFORM_D3D9].rasterCreate = rasterCreate;
engine[PLATFORM_D3D9].rasterLock = rasterLock; driver[PLATFORM_D3D9].rasterLock = rasterLock;
engine[PLATFORM_D3D9].rasterUnlock = rasterUnlock; driver[PLATFORM_D3D9].rasterUnlock = rasterUnlock;
engine[PLATFORM_D3D9].rasterNumLevels = rasterNumLevels; driver[PLATFORM_D3D9].rasterNumLevels = rasterNumLevels;
engine[PLATFORM_D3D9].rasterFromImage = rasterFromImage; driver[PLATFORM_D3D9].rasterFromImage = rasterFromImage;
} }
} }

View File

@ -21,7 +21,7 @@ using namespace d3d;
void void
initializePlatform(void) initializePlatform(void)
{ {
engine[PLATFORM_D3D8].defaultPipeline = makeDefaultPipeline(); driver[PLATFORM_D3D8].defaultPipeline = makeDefaultPipeline();
} }
uint32 uint32

View File

@ -28,7 +28,7 @@ using namespace d3d;
void void
initializePlatform(void) initializePlatform(void)
{ {
engine[PLATFORM_D3D9].defaultPipeline = makeDefaultPipeline(); driver[PLATFORM_D3D9].defaultPipeline = makeDefaultPipeline();
} }
void* void*

View File

@ -110,14 +110,14 @@ setSamplerState(uint32 stage, uint32 type, uint32 value)
void void
setRasterStage(uint32 stage, Raster *raster) setRasterStage(uint32 stage, Raster *raster)
{ {
D3dRaster *d3draster = NULL; D3dRaster *d3draster = nil;
if(raster != d3dRaster[stage]){ if(raster != d3dRaster[stage]){
d3dRaster[stage] = raster; d3dRaster[stage] = raster;
if(raster){ if(raster){
d3draster = PLUGINOFFSET(D3dRaster, raster, nativeRasterOffset); d3draster = PLUGINOFFSET(D3dRaster, raster, nativeRasterOffset);
device->SetTexture(stage, (IDirect3DTexture9*)d3draster->texture); device->SetTexture(stage, (IDirect3DTexture9*)d3draster->texture);
}else }else
device->SetTexture(stage, NULL); device->SetTexture(stage, nil);
} }
} }
@ -133,8 +133,8 @@ setTexture(uint32 stage, Texture *tex)
0, D3DTADDRESS_WRAP, D3DTADDRESS_MIRROR, 0, D3DTADDRESS_WRAP, D3DTADDRESS_MIRROR,
D3DTADDRESS_CLAMP, D3DTADDRESS_BORDER D3DTADDRESS_CLAMP, D3DTADDRESS_BORDER
}; };
if(tex == NULL){ if(tex == nil){
setRasterStage(stage, NULL); setRasterStage(stage, nil);
return; return;
} }
if(tex->raster){ if(tex->raster){

View File

@ -10,10 +10,17 @@
namespace rw { namespace rw {
Engine engine[NUM_PLATFORMS]; Engine engine;
Driver driver[NUM_PLATFORMS];
namespace null { namespace null {
void beginUpdate(Camera*) { }
void endUpdate(Camera*) { }
void void
rasterCreate(Raster*) rasterCreate(Raster*)
{ {
@ -24,7 +31,7 @@ uint8*
rasterLock(Raster*, int32) rasterLock(Raster*, int32)
{ {
assert(0 && "lockRaster not implemented"); assert(0 && "lockRaster not implemented");
return NULL; return nil;
} }
void void

View File

@ -17,14 +17,14 @@ Frame*
Frame::create(void) Frame::create(void)
{ {
Frame *f = (Frame*)malloc(PluginBase::s_size); Frame *f = (Frame*)malloc(PluginBase::s_size);
if(f == NULL){ if(f == nil){
RWERROR((ERR_ALLOC, PluginBase::s_size)); RWERROR((ERR_ALLOC, PluginBase::s_size));
return NULL; return nil;
} }
f->object.init(Frame::ID, 0); f->object.init(Frame::ID, 0);
f->objectList.init(); f->objectList.init();
f->child = NULL; f->child = nil;
f->next = NULL; f->next = nil;
f->root = f; f->root = f;
f->matrix.setIdentity(); f->matrix.setIdentity();
f->ltm.setIdentity(); f->ltm.setIdentity();
@ -35,7 +35,7 @@ Frame::create(void)
Frame* Frame*
Frame::cloneHierarchy(void) Frame::cloneHierarchy(void)
{ {
Frame *frame = this->cloneAndLink(NULL); Frame *frame = this->cloneAndLink(nil);
frame->purgeClone(); frame->purgeClone();
return frame; return frame;
} }
@ -56,12 +56,12 @@ Frame::destroy(void)
; ;
child->next = this->next; child->next = this->next;
} }
this->object.parent = NULL; this->object.parent = nil;
// Doesn't seem to make much sense, blame criterion. // Doesn't seem to make much sense, blame criterion.
this->setHierarchyRoot(this); this->setHierarchyRoot(this);
} }
for(Frame *f = this->child; f; f = f->next) for(Frame *f = this->child; f; f = f->next)
f->object.parent = NULL; f->object.parent = nil;
free(this); free(this);
} }
@ -84,13 +84,13 @@ Frame::addChild(Frame *child, bool32 append)
if(child->getParent()) if(child->getParent())
child->removeChild(); child->removeChild();
if(append){ if(append){
if(this->child == NULL) if(this->child == nil)
this->child = child; this->child = child;
else{ else{
for(c = this->child; c->next; c = c->next); for(c = this->child; c->next; c = c->next);
c->next = child; c->next = child;
} }
child->next = NULL; child->next = nil;
}else{ }else{
child->next = this->child; child->next = this->child;
this->child = child; this->child = child;
@ -99,6 +99,7 @@ Frame::addChild(Frame *child, bool32 append)
child->root = this->root; child->root = this->root;
for(c = child->child; c; c = c->next) for(c = child->child; c; c = c->next)
c->setHierarchyRoot(this); c->setHierarchyRoot(this);
// If the child was a root, remove from dirty list
if(child->object.privateFlags & Frame::HIERARCHYSYNC){ if(child->object.privateFlags & Frame::HIERARCHYSYNC){
child->inDirtyList.remove(); child->inDirtyList.remove();
child->object.privateFlags &= ~Frame::HIERARCHYSYNC; child->object.privateFlags &= ~Frame::HIERARCHYSYNC;
@ -119,7 +120,7 @@ Frame::removeChild(void)
child = child->next; child = child->next;
child->next = this->next; child->next = this->next;
} }
this->object.parent = this->next = NULL; this->object.parent = this->next = nil;
this->root = this; this->root = this;
for(child = this->child; child; child = child->next) for(child = this->child; child; child = child->next)
child->setHierarchyRoot(this); child->setHierarchyRoot(this);
@ -151,36 +152,74 @@ Frame::count(void)
return count; return count;
} }
/*
* Synching is a bit complicated. If anything in the hierarchy is not synched,
* the root of the hierarchy is marked with the HIERARCHYSYNC flags.
* Every unsynched frame is marked with the SUBTREESYNC flags.
* If the LTM is not synched, the LTM flags are set.
* If attached objects need synching, the OBJ flags are set.
*/
/* Synch just LTM matrices in a hierarchy */
static void static void
syncRecurse(Frame *frame, uint8 flags) syncLTMRecurse(Frame *frame, uint8 hierarchyFlags)
{ {
uint8 flg;
for(; frame; frame = frame->next){ for(; frame; frame = frame->next){
flg = flags | frame->object.privateFlags; // If frame is dirty or any parent was dirty, update LTM
if(flg & Frame::SUBTREESYNCLTM){ hierarchyFlags |= frame->object.privateFlags;
if(hierarchyFlags & Frame::SUBTREESYNCLTM){
Matrix::mult(&frame->ltm, &frame->getParent()->ltm, Matrix::mult(&frame->ltm, &frame->getParent()->ltm,
&frame->matrix); &frame->matrix);
frame->object.privateFlags &= ~Frame::SUBTREESYNCLTM; frame->object.privateFlags &= ~Frame::SUBTREESYNCLTM;
} }
syncRecurse(frame->child, flg); // And synch all children
syncLTMRecurse(frame->child, hierarchyFlags);
} }
} }
/* Synch just objects in a hierarchy */
static void
syncObjRecurse(Frame *frame)
{
for(; frame; frame = frame->next){
// Synch attached objects
FORLIST(lnk, frame->objectList)
ObjectWithFrame::fromFrame(lnk)->sync();
frame->object.privateFlags &= ~Frame::SUBTREESYNCOBJ;
// And synch all children
syncObjRecurse(frame->child);
}
}
/* Synch LTM and objects */
static void
syncRecurse(Frame *frame, uint8 hierarchyFlags)
{
for(; frame; frame = frame->next){
// If frame is dirty or any parent was dirty, update LTM
hierarchyFlags |= frame->object.privateFlags;
if(hierarchyFlags & Frame::SUBTREESYNCLTM)
Matrix::mult(&frame->ltm, &frame->getParent()->ltm,
&frame->matrix);
// Synch attached objects
FORLIST(lnk, frame->objectList)
ObjectWithFrame::fromFrame(lnk)->sync();
frame->object.privateFlags &= ~Frame::SUBTREESYNC;
// And synch all children
syncRecurse(frame->child, hierarchyFlags);
}
}
/* Sync the LTMs of the hierarchy of which 'this' is the root */
void void
Frame::syncHierarchyLTM(void) Frame::syncHierarchyLTM(void)
{ {
Frame *child; // Sync root's LTM
uint8 flg;
if(this->object.privateFlags & Frame::SUBTREESYNCLTM) if(this->object.privateFlags & Frame::SUBTREESYNCLTM)
this->ltm = this->matrix; this->ltm = this->matrix;
for(child = this->child; child; child = child->next){ // ...and children
flg = this->object.privateFlags | child->object.privateFlags; syncLTMRecurse(this->child, this->object.privateFlags);
if(flg & Frame::SUBTREESYNCLTM){ // all clean now
Matrix::mult(&child->ltm, &this->ltm, &child->matrix);
child->object.privateFlags &= ~Frame::SUBTREESYNCLTM;
}
syncRecurse(child, flg);
}
this->object.privateFlags &= ~Frame::SYNCLTM; this->object.privateFlags &= ~Frame::SYNCLTM;
} }
@ -192,12 +231,42 @@ Frame::getLTM(void)
return &this->ltm; return &this->ltm;
} }
/* Synch all dirty frames; LTMs and objects */
void
Frame::syncDirty(void)
{
Frame *frame;
FORLIST(lnk, Frame::dirtyList){
frame = LLLinkGetData(lnk, Frame, inDirtyList);
if(frame->object.privateFlags & Frame::HIERARCHYSYNCLTM){
// Sync root's LTM
if(frame->object.privateFlags & Frame::SUBTREESYNCLTM)
frame->ltm = frame->matrix;
// Synch attached objects
FORLIST(lnk, frame->objectList)
ObjectWithFrame::fromFrame(lnk)->sync();
// ...and children
syncRecurse(frame->child, frame->object.privateFlags);
}else{
// LTMs are clean, just synch objects
FORLIST(lnk, frame->objectList)
ObjectWithFrame::fromFrame(lnk)->sync();
syncObjRecurse(frame->child);
}
// all clean now
frame->object.privateFlags &= ~(Frame::SYNCLTM | Frame::SYNCOBJ);
}
Frame::dirtyList.init();
}
void void
Frame::updateObjects(void) Frame::updateObjects(void)
{ {
// Mark root as dirty and insert into dirty list if necessary
if((this->root->object.privateFlags & HIERARCHYSYNC) == 0) if((this->root->object.privateFlags & HIERARCHYSYNC) == 0)
Frame::dirtyList.add(&this->inDirtyList); Frame::dirtyList.add(&this->root->inDirtyList);
this->root->object.privateFlags |= HIERARCHYSYNC; this->root->object.privateFlags |= HIERARCHYSYNC;
// Mark subtree as dirty as well
this->object.privateFlags |= SUBTREESYNC; this->object.privateFlags |= SUBTREESYNC;
} }
@ -214,11 +283,10 @@ Frame*
Frame::cloneAndLink(Frame *clonedroot) Frame::cloneAndLink(Frame *clonedroot)
{ {
Frame *frame = Frame::create(); Frame *frame = Frame::create();
if(clonedroot == NULL) if(clonedroot == nil)
clonedroot = frame; clonedroot = frame;
frame->object.copy(&this->object); frame->object.copy(&this->object);
frame->matrix = this->matrix; frame->matrix = this->matrix;
//memcpy(frame->matrix, this->matrix, sizeof(this->matrix));
frame->root = clonedroot; frame->root = clonedroot;
this->root = frame; // Remember cloned frame this->root = frame; // Remember cloned frame
for(Frame *child = this->child; child; child = child->next){ for(Frame *child = this->child; child; child = child->next){

View File

@ -691,7 +691,7 @@ Raster::create(int32 width, int32 height, int32 depth, int32 format, int32 platf
raster->texels = raster->palette = nil; raster->texels = raster->palette = nil;
raster->constructPlugins(); raster->constructPlugins();
engine[raster->platform].rasterCreate(raster); driver[raster->platform].rasterCreate(raster);
return raster; return raster;
} }
@ -707,19 +707,19 @@ Raster::destroy(void)
uint8* uint8*
Raster::lock(int32 level) Raster::lock(int32 level)
{ {
return engine[this->platform].rasterLock(this, level); return driver[this->platform].rasterLock(this, level);
} }
void void
Raster::unlock(int32 level) Raster::unlock(int32 level)
{ {
engine[this->platform].rasterUnlock(this, level); driver[this->platform].rasterUnlock(this, level);
} }
int32 int32
Raster::getNumLevels(void) Raster::getNumLevels(void)
{ {
return engine[this->platform].rasterNumLevels(this); return driver[this->platform].rasterNumLevels(this);
} }
int32 int32
@ -737,7 +737,7 @@ Raster::createFromImage(Image *image)
{ {
Raster *raster = Raster::create(image->width, image->height, Raster *raster = Raster::create(image->width, image->height,
image->depth, 4 | 0x80); image->depth, 4 | 0x80);
engine[raster->platform].rasterFromImage(raster, image); driver[raster->platform].rasterFromImage(raster, image);
return raster; return raster;
} }

View File

@ -11,6 +11,11 @@
namespace rw { namespace rw {
static void
lightSync(ObjectWithFrame*)
{
}
Light* Light*
Light::create(int32 type) Light::create(int32 type)
{ {
@ -20,6 +25,7 @@ Light::create(int32 type)
return nil; return nil;
} }
light->object.object.init(Light::ID, type); light->object.object.init(Light::ID, type);
light->object.syncCB = lightSync;
light->radius = 0.0f; light->radius = 0.0f;
light->color.red = 1.0f; light->color.red = 1.0f;
light->color.green = 1.0f; light->color.green = 1.0f;

View File

@ -28,7 +28,7 @@ getPDSPipe(uint32 data)
for(int32 i = 0; i < pdsGlobals.numPipes; i++) for(int32 i = 0; i < pdsGlobals.numPipes; i++)
if(pdsGlobals.pipes[i]->pluginData == data) if(pdsGlobals.pipes[i]->pluginData == data)
return pdsGlobals.pipes[i]; return pdsGlobals.pipes[i];
return NULL; return nil;
} }
void void
@ -60,10 +60,10 @@ registerPDSPlugin(int32 n)
pdsGlobals.maxPipes = n; pdsGlobals.maxPipes = n;
pdsGlobals.numPipes = 0; pdsGlobals.numPipes = 0;
pdsGlobals.pipes = new Pipeline*[n]; pdsGlobals.pipes = new Pipeline*[n];
Atomic::registerPlugin(0, ID_PDS, NULL, NULL, NULL); Atomic::registerPlugin(0, ID_PDS, nil, nil, nil);
Atomic::setStreamRightsCallback(ID_PDS, atomicPDSRights); Atomic::setStreamRightsCallback(ID_PDS, atomicPDSRights);
Material::registerPlugin(0, ID_PDS, NULL, NULL, NULL); Material::registerPlugin(0, ID_PDS, nil, nil, nil);
Material::setStreamRightsCallback(ID_PDS, materialPDSRights); Material::setStreamRightsCallback(ID_PDS, materialPDSRights);
} }

View File

@ -12,8 +12,6 @@
#define COLOR_ARGB(a,r,g,b) \ #define COLOR_ARGB(a,r,g,b) \
((uint32)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff))) ((uint32)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff)))
using namespace std;
namespace rw { namespace rw {
static void nothing(ObjPipeline *, Atomic*) {} static void nothing(ObjPipeline *, Atomic*) {}
@ -47,8 +45,10 @@ findMinVertAndNumVertices(uint16 *indices, uint32 numIndices, uint32 *minVert, i
max = *indices; max = *indices;
indices++; indices++;
} }
*minVert = min; if(minVert)
*numVertices = max - min + 1; *minVert = min;
if(numVertices)
*numVertices = max - min + 1;
} }
void void
@ -128,16 +128,31 @@ uninstV2d(int type, float *dst, uint8 *src, uint32 numVertices, uint32 stride)
bool32 bool32
instColor(int type, uint8 *dst, uint8 *src, uint32 numVertices, uint32 stride) instColor(int type, uint8 *dst, uint8 *src, uint32 numVertices, uint32 stride)
{ {
assert(type == VERT_ARGB);
bool32 hasAlpha = 0; bool32 hasAlpha = 0;
for(uint32 i = 0; i < numVertices; i++){ if(type == VERT_ARGB){
dst[0] = src[2]; for(uint32 i = 0; i < numVertices; i++){
dst[1] = src[1]; dst[0] = src[2];
dst[2] = src[0]; dst[1] = src[1];
dst[3] = src[3]; dst[2] = src[0];
dst += stride; dst[3] = src[3];
src += 4; if(dst[3] != 0xFF)
} hasAlpha = 1;
dst += stride;
src += 4;
}
}else if(type == VERT_RGBA){
for(uint32 i = 0; i < numVertices; i++){
dst[0] = src[0];
dst[1] = src[1];
dst[2] = src[2];
dst[3] = src[3];
if(dst[3] != 0xFF)
hasAlpha = 1;
dst += stride;
src += 4;
}
}else
assert(0 && "unsupported color type");
return hasAlpha; return hasAlpha;
} }

View File

@ -35,10 +35,10 @@ HAnimHierarchy::create(int32 numNodes, int32 *nodeFlags, int32 *nodeIDs, int32 f
hier->numNodes = numNodes; hier->numNodes = numNodes;
hier->flags = flags; hier->flags = flags;
hier->maxInterpKeyFrameSize = maxKeySize; hier->maxInterpKeyFrameSize = maxKeySize;
hier->parentFrame = NULL; hier->parentFrame = nil;
hier->parentHierarchy = hier; hier->parentHierarchy = hier;
if(hier->flags & 2) if(hier->flags & 2)
hier->matrices = hier->matricesUnaligned = NULL; hier->matrices = hier->matricesUnaligned = nil;
else{ else{
hier->matricesUnaligned = hier->matricesUnaligned =
(float*) new uint8[hier->numNodes*64 + 15]; (float*) new uint8[hier->numNodes*64 + 15];
@ -50,7 +50,7 @@ HAnimHierarchy::create(int32 numNodes, int32 *nodeFlags, int32 *nodeIDs, int32 f
hier->nodeInfo[i].id = nodeIDs[i]; hier->nodeInfo[i].id = nodeIDs[i];
hier->nodeInfo[i].index = i; hier->nodeInfo[i].index = i;
hier->nodeInfo[i].flags = nodeFlags[i]; hier->nodeInfo[i].flags = nodeFlags[i];
hier->nodeInfo[i].frame = NULL; hier->nodeInfo[i].frame = nil;
} }
return hier; return hier;
} }
@ -66,7 +66,7 @@ HAnimHierarchy::destroy(void)
static Frame* static Frame*
findById(Frame *f, int32 id) findById(Frame *f, int32 id)
{ {
if(f == NULL) return NULL; if(f == nil) return nil;
HAnimData *hanim = HAnimData::get(f); HAnimData *hanim = HAnimData::get(f);
if(hanim->id >= 0 && hanim->id == id) return f; if(hanim->id >= 0 && hanim->id == id) return f;
Frame *ff = findById(f->next, id); Frame *ff = findById(f->next, id);
@ -107,7 +107,7 @@ HAnimHierarchy::get(Frame *f)
HAnimHierarchy* HAnimHierarchy*
HAnimHierarchy::find(Frame *f) HAnimHierarchy::find(Frame *f)
{ {
if(f == NULL) return NULL; if(f == nil) return nil;
HAnimHierarchy *hier = HAnimHierarchy::get(f); HAnimHierarchy *hier = HAnimHierarchy::get(f);
if(hier) return hier; if(hier) return hier;
hier = HAnimHierarchy::find(f->next); hier = HAnimHierarchy::find(f->next);
@ -126,7 +126,7 @@ createHAnim(void *object, int32 offset, int32)
{ {
HAnimData *hanim = PLUGINOFFSET(HAnimData, object, offset); HAnimData *hanim = PLUGINOFFSET(HAnimData, object, offset);
hanim->id = -1; hanim->id = -1;
hanim->hierarchy = NULL; hanim->hierarchy = nil;
return object; return object;
} }
@ -137,7 +137,7 @@ destroyHAnim(void *object, int32 offset, int32)
if(hanim->hierarchy) if(hanim->hierarchy)
hanim->hierarchy->destroy(); hanim->hierarchy->destroy();
hanim->id = -1; hanim->id = -1;
hanim->hierarchy = NULL; hanim->hierarchy = nil;
return object; return object;
} }
@ -148,7 +148,7 @@ copyHAnim(void *dst, void *src, int32 offset, int32)
HAnimData *srchanim = PLUGINOFFSET(HAnimData, src, offset); HAnimData *srchanim = PLUGINOFFSET(HAnimData, src, offset);
dsthanim->id = srchanim->id; dsthanim->id = srchanim->id;
// TODO // TODO
dsthanim->hierarchy = NULL; dsthanim->hierarchy = nil;
return dst; return dst;
} }
@ -186,7 +186,7 @@ writeHAnim(Stream *stream, int32, void *object, int32 offset, int32)
HAnimData *hanim = PLUGINOFFSET(HAnimData, object, offset); HAnimData *hanim = PLUGINOFFSET(HAnimData, object, offset);
stream->writeI32(256); stream->writeI32(256);
stream->writeI32(hanim->id); stream->writeI32(hanim->id);
if(hanim->hierarchy == NULL){ if(hanim->hierarchy == nil){
stream->writeI32(0); stream->writeI32(0);
return stream; return stream;
} }
@ -207,7 +207,7 @@ getSizeHAnim(void *object, int32 offset, int32)
{ {
HAnimData *hanim = PLUGINOFFSET(HAnimData, object, offset); HAnimData *hanim = PLUGINOFFSET(HAnimData, object, offset);
if(!hAnimDoStream || if(!hAnimDoStream ||
version >= 0x35000 && hanim->id == -1 && hanim->hierarchy == NULL) version >= 0x35000 && hanim->id == -1 && hanim->hierarchy == nil)
return 0; return 0;
if(hanim->hierarchy) if(hanim->hierarchy)
return 12 + 8 + hanim->hierarchy->numNodes*12; return 12 + 8 + hanim->hierarchy->numNodes*12;
@ -287,14 +287,14 @@ readMesh(Stream *stream, int32 len, void *object, int32, int32)
geo->meshHeader->mesh = new Mesh[geo->meshHeader->numMeshes]; geo->meshHeader->mesh = new Mesh[geo->meshHeader->numMeshes];
Mesh *mesh = geo->meshHeader->mesh; Mesh *mesh = geo->meshHeader->mesh;
bool hasData = len > 12+geo->meshHeader->numMeshes*8; bool hasData = len > 12+geo->meshHeader->numMeshes*8;
uint16 *p = NULL; uint16 *p = nil;
if(!(geo->geoflags & Geometry::NATIVE) || hasData) if(!(geo->geoflags & Geometry::NATIVE) || hasData)
p = new uint16[geo->meshHeader->totalIndices]; p = new uint16[geo->meshHeader->totalIndices];
for(uint32 i = 0; i < geo->meshHeader->numMeshes; i++){ for(uint32 i = 0; i < geo->meshHeader->numMeshes; i++){
stream->read(buf, 8); stream->read(buf, 8);
mesh->numIndices = buf[0]; mesh->numIndices = buf[0];
mesh->material = geo->materialList[buf[1]]; mesh->material = geo->materialList[buf[1]];
mesh->indices = NULL; mesh->indices = nil;
if(geo->geoflags & Geometry::NATIVE){ if(geo->geoflags & Geometry::NATIVE){
// OpenGL stores uint16 indices here // OpenGL stores uint16 indices here
if(hasData){ if(hasData){
@ -339,7 +339,7 @@ writeMesh(Stream *stream, int32, void *object, int32, int32)
geo->numMaterials); geo->numMaterials);
stream->write(buf, 8); stream->write(buf, 8);
if(geo->geoflags & Geometry::NATIVE){ if(geo->geoflags & Geometry::NATIVE){
assert(geo->instData != NULL); assert(geo->instData != nil);
if(geo->instData->platform == PLATFORM_WDGL) if(geo->instData->platform == PLATFORM_WDGL)
stream->write(mesh->indices, stream->write(mesh->indices,
mesh->numIndices*2); mesh->numIndices*2);
@ -363,11 +363,11 @@ static int32
getSizeMesh(void *object, int32, int32) getSizeMesh(void *object, int32, int32)
{ {
Geometry *geo = (Geometry*)object; Geometry *geo = (Geometry*)object;
if(geo->meshHeader == NULL) if(geo->meshHeader == nil)
return -1; return -1;
int32 size = 12 + geo->meshHeader->numMeshes*8; int32 size = 12 + geo->meshHeader->numMeshes*8;
if(geo->geoflags & Geometry::NATIVE){ if(geo->geoflags & Geometry::NATIVE){
assert(geo->instData != NULL); assert(geo->instData != nil);
if(geo->instData->platform == PLATFORM_WDGL) if(geo->instData->platform == PLATFORM_WDGL)
size += geo->meshHeader->totalIndices*2; size += geo->meshHeader->totalIndices*2;
}else{ }else{
@ -379,7 +379,7 @@ getSizeMesh(void *object, int32, int32)
void void
registerMeshPlugin(void) registerMeshPlugin(void)
{ {
Geometry::registerPlugin(0, 0x50E, NULL, NULL, NULL); Geometry::registerPlugin(0, 0x50E, nil, nil, nil);
Geometry::registerPluginStream(0x50E, readMesh, writeMesh, getSizeMesh); Geometry::registerPluginStream(0x50E, readMesh, writeMesh, getSizeMesh);
} }
@ -408,7 +408,7 @@ static void*
destroyNativeData(void *object, int32 offset, int32 size) destroyNativeData(void *object, int32 offset, int32 size)
{ {
Geometry *geometry = (Geometry*)object; Geometry *geometry = (Geometry*)object;
if(geometry->instData == NULL) if(geometry->instData == nil)
return object; return object;
if(geometry->instData->platform == PLATFORM_PS2) if(geometry->instData->platform == PLATFORM_PS2)
return ps2::destroyNativeData(object, offset, size); return ps2::destroyNativeData(object, offset, size);
@ -460,7 +460,7 @@ static Stream*
writeNativeData(Stream *stream, int32 len, void *object, int32 o, int32 s) writeNativeData(Stream *stream, int32 len, void *object, int32 o, int32 s)
{ {
Geometry *geometry = (Geometry*)object; Geometry *geometry = (Geometry*)object;
if(geometry->instData == NULL) if(geometry->instData == nil)
return stream; return stream;
if(geometry->instData->platform == PLATFORM_PS2) if(geometry->instData->platform == PLATFORM_PS2)
return ps2::writeNativeData(stream, len, object, o, s); return ps2::writeNativeData(stream, len, object, o, s);
@ -479,7 +479,7 @@ static int32
getSizeNativeData(void *object, int32 offset, int32 size) getSizeNativeData(void *object, int32 offset, int32 size)
{ {
Geometry *geometry = (Geometry*)object; Geometry *geometry = (Geometry*)object;
if(geometry->instData == NULL) if(geometry->instData == nil)
return 0; return 0;
if(geometry->instData->platform == PLATFORM_PS2) if(geometry->instData->platform == PLATFORM_PS2)
return ps2::getSizeNativeData(object, offset, size); return ps2::getSizeNativeData(object, offset, size);
@ -498,7 +498,7 @@ void
registerNativeDataPlugin(void) registerNativeDataPlugin(void)
{ {
Geometry::registerPlugin(0, ID_NATIVEDATA, Geometry::registerPlugin(0, ID_NATIVEDATA,
NULL, destroyNativeData, NULL); nil, destroyNativeData, nil);
Geometry::registerPluginStream(ID_NATIVEDATA, Geometry::registerPluginStream(ID_NATIVEDATA,
readNativeData, readNativeData,
writeNativeData, writeNativeData,
@ -509,12 +509,12 @@ registerNativeDataPlugin(void)
// Skin // Skin
// //
SkinGlobals skinGlobals = { 0, { NULL } }; SkinGlobals skinGlobals = { 0, { nil } };
static void* static void*
createSkin(void *object, int32 offset, int32) createSkin(void *object, int32 offset, int32)
{ {
*PLUGINOFFSET(Skin*, object, offset) = NULL; *PLUGINOFFSET(Skin*, object, offset) = nil;
return object; return object;
} }
@ -534,10 +534,10 @@ static void*
copySkin(void *dst, void *src, int32 offset, int32) copySkin(void *dst, void *src, int32 offset, int32)
{ {
Skin *srcskin = *PLUGINOFFSET(Skin*, src, offset); Skin *srcskin = *PLUGINOFFSET(Skin*, src, offset);
if(srcskin == NULL) if(srcskin == nil)
return dst; return dst;
Geometry *geometry = (Geometry*)src; Geometry *geometry = (Geometry*)src;
assert(geometry->instData == NULL); assert(geometry->instData == nil);
assert(((Geometry*)src)->numVertices == ((Geometry*)dst)->numVertices); assert(((Geometry*)src)->numVertices == ((Geometry*)dst)->numVertices);
Skin *dstskin = new Skin; Skin *dstskin = new Skin;
*PLUGINOFFSET(Skin*, dst, offset) = dstskin; *PLUGINOFFSET(Skin*, dst, offset) = dstskin;
@ -695,7 +695,7 @@ getSizeSkin(void *object, int32 offset, int32)
} }
Skin *skin = *PLUGINOFFSET(Skin*, object, offset); Skin *skin = *PLUGINOFFSET(Skin*, object, offset);
if(skin == NULL) if(skin == nil)
return -1; return -1;
int32 size = 4 + geometry->numVertices*(16+4) + int32 size = 4 + geometry->numVertices*(16+4) +
@ -717,7 +717,7 @@ skinRights(void *object, int32, int32, uint32)
void void
registerSkinPlugin(void) registerSkinPlugin(void)
{ {
ObjPipeline *defpipe = new ObjPipeline(PLATFORM_NULL); ObjPipeline *defpipe = new ObjPipeline(PLATFORM_nil);
defpipe->pluginID = ID_SKIN; defpipe->pluginID = ID_SKIN;
defpipe->pluginData = 1; defpipe->pluginData = 1;
for(uint i = 0; i < nelem(skinGlobals.pipelines); i++) for(uint i = 0; i < nelem(skinGlobals.pipelines); i++)
@ -739,7 +739,7 @@ registerSkinPlugin(void)
copySkin); copySkin);
Geometry::registerPluginStream(ID_SKIN, Geometry::registerPluginStream(ID_SKIN,
readSkin, writeSkin, getSizeSkin); readSkin, writeSkin, getSizeSkin);
Atomic::registerPlugin(0, ID_SKIN, NULL, NULL, NULL); Atomic::registerPlugin(0, ID_SKIN, nil, nil, nil);
Atomic::setStreamRightsCallback(ID_SKIN, skinRights); Atomic::setStreamRightsCallback(ID_SKIN, skinRights);
} }
@ -754,30 +754,30 @@ Skin::init(int32 numBones, int32 numUsedBones, int32 numVertices)
this->data = new uint8[size]; this->data = new uint8[size];
uint8 *p = this->data; uint8 *p = this->data;
this->usedBones = NULL; this->usedBones = nil;
if(this->numUsedBones){ if(this->numUsedBones){
this->usedBones = p; this->usedBones = p;
p += this->numUsedBones; p += this->numUsedBones;
} }
p = (uint8*)(((uintptr)p + 0xF) & ~0xF); p = (uint8*)(((uintptr)p + 0xF) & ~0xF);
this->inverseMatrices = NULL; this->inverseMatrices = nil;
if(this->numBones){ if(this->numBones){
this->inverseMatrices = (float*)p; this->inverseMatrices = (float*)p;
p += 64*this->numBones; p += 64*this->numBones;
} }
this->indices = NULL; this->indices = nil;
if(numVertices){ if(numVertices){
this->indices = p; this->indices = p;
p += 4*numVertices; p += 4*numVertices;
} }
this->weights = NULL; this->weights = nil;
if(numVertices) if(numVertices)
this->weights = (float*)p; this->weights = (float*)p;
this->platformData = NULL; this->platformData = nil;
} }
void void
@ -871,7 +871,7 @@ getSizeAtomicMatFX(void *object, int32 offset, int32)
// Material // Material
MatFXGlobals matFXGlobals = { 0, 0, { NULL } }; MatFXGlobals matFXGlobals = { 0, 0, { nil } };
// TODO: Frames and Matrices? // TODO: Frames and Matrices?
static void static void
@ -1003,7 +1003,7 @@ MatFX::setDualDestBlend(int32 blend)
static void* static void*
createMaterialMatFX(void *object, int32 offset, int32) createMaterialMatFX(void *object, int32 offset, int32)
{ {
*PLUGINOFFSET(MatFX*, object, offset) = NULL; *PLUGINOFFSET(MatFX*, object, offset) = nil;
return object; return object;
} }
@ -1022,7 +1022,7 @@ static void*
copyMaterialMatFX(void *dst, void *src, int32 offset, int32) copyMaterialMatFX(void *dst, void *src, int32 offset, int32)
{ {
MatFX *srcfx = *PLUGINOFFSET(MatFX*, src, offset); MatFX *srcfx = *PLUGINOFFSET(MatFX*, src, offset);
if(srcfx == NULL) if(srcfx == nil)
return dst; return dst;
MatFX *dstfx = new MatFX; MatFX *dstfx = new MatFX;
*PLUGINOFFSET(MatFX*, dst, offset) = dstfx; *PLUGINOFFSET(MatFX*, dst, offset) = dstfx;
@ -1068,10 +1068,10 @@ readMaterialMatFX(Stream *stream, int32, void *object, int32 offset, int32)
switch(type){ switch(type){
case MatFX::BUMPMAP: case MatFX::BUMPMAP:
coefficient = stream->readF32(); coefficient = stream->readF32();
bumpedTex = tex = NULL; bumpedTex = tex = nil;
if(stream->readI32()){ if(stream->readI32()){
if(!findChunk(stream, ID_TEXTURE, if(!findChunk(stream, ID_TEXTURE,
NULL, NULL)){ nil, nil)){
RWERROR((ERR_CHUNK, "TEXTURE")); RWERROR((ERR_CHUNK, "TEXTURE"));
return nil; return nil;
} }
@ -1079,7 +1079,7 @@ readMaterialMatFX(Stream *stream, int32, void *object, int32 offset, int32)
} }
if(stream->readI32()){ if(stream->readI32()){
if(!findChunk(stream, ID_TEXTURE, if(!findChunk(stream, ID_TEXTURE,
NULL, NULL)){ nil, nil)){
RWERROR((ERR_CHUNK, "TEXTURE")); RWERROR((ERR_CHUNK, "TEXTURE"));
return nil; return nil;
} }
@ -1095,10 +1095,10 @@ readMaterialMatFX(Stream *stream, int32, void *object, int32 offset, int32)
case MatFX::ENVMAP: case MatFX::ENVMAP:
coefficient = stream->readF32(); coefficient = stream->readF32();
fbAlpha = stream->readI32(); fbAlpha = stream->readI32();
tex = NULL; tex = nil;
if(stream->readI32()){ if(stream->readI32()){
if(!findChunk(stream, ID_TEXTURE, if(!findChunk(stream, ID_TEXTURE,
NULL, NULL)){ nil, nil)){
RWERROR((ERR_CHUNK, "TEXTURE")); RWERROR((ERR_CHUNK, "TEXTURE"));
return nil; return nil;
} }
@ -1114,10 +1114,10 @@ readMaterialMatFX(Stream *stream, int32, void *object, int32 offset, int32)
case MatFX::DUAL: case MatFX::DUAL:
srcBlend = stream->readI32(); srcBlend = stream->readI32();
dstBlend = stream->readI32(); dstBlend = stream->readI32();
tex = NULL; tex = nil;
if(stream->readI32()){ if(stream->readI32()){
if(!findChunk(stream, ID_TEXTURE, if(!findChunk(stream, ID_TEXTURE,
NULL, NULL)){ nil, nil)){
RWERROR((ERR_CHUNK, "TEXTURE")); RWERROR((ERR_CHUNK, "TEXTURE"));
return nil; return nil;
} }
@ -1145,10 +1145,10 @@ writeMaterialMatFX(Stream *stream, int32, void *object, int32 offset, int32)
switch(matfx->fx[i].type){ switch(matfx->fx[i].type){
case MatFX::BUMPMAP: case MatFX::BUMPMAP:
stream->writeF32(matfx->fx[i].bump.coefficient); stream->writeF32(matfx->fx[i].bump.coefficient);
stream->writeI32(matfx->fx[i].bump.bumpedTex != NULL); stream->writeI32(matfx->fx[i].bump.bumpedTex != nil);
if(matfx->fx[i].bump.bumpedTex) if(matfx->fx[i].bump.bumpedTex)
matfx->fx[i].bump.bumpedTex->streamWrite(stream); matfx->fx[i].bump.bumpedTex->streamWrite(stream);
stream->writeI32(matfx->fx[i].bump.tex != NULL); stream->writeI32(matfx->fx[i].bump.tex != nil);
if(matfx->fx[i].bump.tex) if(matfx->fx[i].bump.tex)
matfx->fx[i].bump.tex->streamWrite(stream); matfx->fx[i].bump.tex->streamWrite(stream);
break; break;
@ -1156,7 +1156,7 @@ writeMaterialMatFX(Stream *stream, int32, void *object, int32 offset, int32)
case MatFX::ENVMAP: case MatFX::ENVMAP:
stream->writeF32(matfx->fx[i].env.coefficient); stream->writeF32(matfx->fx[i].env.coefficient);
stream->writeI32(matfx->fx[i].env.fbAlpha); stream->writeI32(matfx->fx[i].env.fbAlpha);
stream->writeI32(matfx->fx[i].env.tex != NULL); stream->writeI32(matfx->fx[i].env.tex != nil);
if(matfx->fx[i].env.tex) if(matfx->fx[i].env.tex)
matfx->fx[i].env.tex->streamWrite(stream); matfx->fx[i].env.tex->streamWrite(stream);
break; break;
@ -1164,7 +1164,7 @@ writeMaterialMatFX(Stream *stream, int32, void *object, int32 offset, int32)
case MatFX::DUAL: case MatFX::DUAL:
stream->writeI32(matfx->fx[i].dual.srcBlend); stream->writeI32(matfx->fx[i].dual.srcBlend);
stream->writeI32(matfx->fx[i].dual.dstBlend); stream->writeI32(matfx->fx[i].dual.dstBlend);
stream->writeI32(matfx->fx[i].dual.tex != NULL); stream->writeI32(matfx->fx[i].dual.tex != nil);
if(matfx->fx[i].dual.tex) if(matfx->fx[i].dual.tex)
matfx->fx[i].dual.tex->streamWrite(stream); matfx->fx[i].dual.tex->streamWrite(stream);
break; break;
@ -1177,7 +1177,7 @@ static int32
getSizeMaterialMatFX(void *object, int32 offset, int32) getSizeMaterialMatFX(void *object, int32 offset, int32)
{ {
MatFX *matfx = *PLUGINOFFSET(MatFX*, object, offset); MatFX *matfx = *PLUGINOFFSET(MatFX*, object, offset);
if(matfx == NULL) if(matfx == nil)
return -1; return -1;
int32 size = 4 + 4 + 4; int32 size = 4 + 4 + 4;
@ -1220,7 +1220,7 @@ MatFX::enableEffects(Atomic *atomic)
void void
registerMatFXPlugin(void) registerMatFXPlugin(void)
{ {
ObjPipeline *defpipe = new ObjPipeline(PLATFORM_NULL); ObjPipeline *defpipe = new ObjPipeline(PLATFORM_nil);
defpipe->pluginID = 0; //ID_MATFX; defpipe->pluginID = 0; //ID_MATFX;
defpipe->pluginData = 0; defpipe->pluginData = 0;
for(uint i = 0; i < nelem(matFXGlobals.pipelines); i++) for(uint i = 0; i < nelem(matFXGlobals.pipelines); i++)
@ -1238,7 +1238,7 @@ registerMatFXPlugin(void)
matFXGlobals.atomicOffset = matFXGlobals.atomicOffset =
Atomic::registerPlugin(sizeof(int32), ID_MATFX, Atomic::registerPlugin(sizeof(int32), ID_MATFX,
createAtomicMatFX, NULL, copyAtomicMatFX); createAtomicMatFX, nil, copyAtomicMatFX);
Atomic::registerPluginStream(ID_MATFX, Atomic::registerPluginStream(ID_MATFX,
readAtomicMatFX, readAtomicMatFX,
writeAtomicMatFX, writeAtomicMatFX,

View File

@ -21,7 +21,7 @@ namespace ps2 {
void void
initializePlatform(void) initializePlatform(void)
{ {
engine[PLATFORM_PS2].defaultPipeline = makeDefaultPipeline(); driver[PLATFORM_PS2].defaultPipeline = makeDefaultPipeline();
} }
ObjPipeline *defaultObjPipe; ObjPipeline *defaultObjPipe;

View File

@ -484,11 +484,11 @@ registerNativeRaster(void)
createNativeRaster, createNativeRaster,
destroyNativeRaster, destroyNativeRaster,
copyNativeRaster); copyNativeRaster);
engine[PLATFORM_PS2].rasterNativeOffset = nativeRasterOffset; driver[PLATFORM_PS2].rasterNativeOffset = nativeRasterOffset;
engine[PLATFORM_PS2].rasterCreate = rasterCreate; driver[PLATFORM_PS2].rasterCreate = rasterCreate;
engine[PLATFORM_PS2].rasterLock = rasterLock; driver[PLATFORM_PS2].rasterLock = rasterLock;
engine[PLATFORM_PS2].rasterUnlock = rasterUnlock; driver[PLATFORM_PS2].rasterUnlock = rasterUnlock;
engine[PLATFORM_PS2].rasterNumLevels = rasterNumLevels; driver[PLATFORM_PS2].rasterNumLevels = rasterNumLevels;
Texture::registerPlugin(0, ID_SKYMIPMAP, nil, nil, nil); Texture::registerPlugin(0, ID_SKYMIPMAP, nil, nil, nil);
Texture::registerPluginStream(ID_SKYMIPMAP, readMipmap, writeMipmap, getSizeMipmap); Texture::registerPluginStream(ID_SKYMIPMAP, readMipmap, writeMipmap, getSizeMipmap);

View File

@ -18,8 +18,6 @@
#include "rwd3d9.h" #include "rwd3d9.h"
#include "rwwdgl.h" #include "rwwdgl.h"
using namespace std;
namespace rw { namespace rw {
#define PLUGIN_ID 0 #define PLUGIN_ID 0
@ -33,9 +31,9 @@ int32 build = 0xFFFF;
#elif RW_D3D9 #elif RW_D3D9
int32 platform = PLATFORM_D3D9; int32 platform = PLATFORM_D3D9;
#else #else
int32 platform = PLATFORM_NULL; int32 platform = PLATFORM_nil;
#endif #endif
char *debugFile = NULL; char *debugFile = nil;
// TODO: comparison tolerances // TODO: comparison tolerances
@ -55,15 +53,18 @@ static Matrix3 identMat3 = {
void void
initialize(void) initialize(void)
{ {
ObjPipeline *defpipe = new ObjPipeline(PLATFORM_NULL); ObjPipeline *defpipe = new ObjPipeline(PLATFORM_nil);
for(uint i = 0; i < NUM_PLATFORMS; i++){ for(uint i = 0; i < NUM_PLATFORMS; i++){
engine[i].defaultPipeline = defpipe; driver[i].defaultPipeline = defpipe;
engine[i].rasterCreate = null::rasterCreate; driver[i].beginUpdate = null::beginUpdate;
engine[i].rasterLock = null::rasterLock; driver[i].endUpdate = null::endUpdate;
engine[i].rasterUnlock = null::rasterUnlock;
engine[i].rasterNumLevels = null::rasterNumLevels; driver[i].rasterCreate = null::rasterCreate;
engine[i].rasterFromImage = null::rasterFromImage; driver[i].rasterLock = null::rasterLock;
driver[i].rasterUnlock = null::rasterUnlock;
driver[i].rasterNumLevels = null::rasterNumLevels;
driver[i].rasterFromImage = null::rasterFromImage;
} }
@ -668,9 +669,9 @@ StreamFile*
StreamFile::open(const char *path, const char *mode) StreamFile::open(const char *path, const char *mode)
{ {
this->file = fopen(path, mode); this->file = fopen(path, mode);
if(this->file == NULL){ if(this->file == nil){
RWERROR((ERR_FILE, path)); RWERROR((ERR_FILE, path));
return NULL; return nil;
} }
return this; return this;
} }
@ -732,7 +733,7 @@ readChunkHeaderInfo(Stream *s, ChunkHeaderInfo *header)
s->read(&buf, 12); s->read(&buf, 12);
if(s->eof()) if(s->eof())
return false; return false;
assert(header != NULL); assert(header != nil);
header->type = buf.type; header->type = buf.type;
header->length = buf.size; header->length = buf.size;
header->version = libraryIDUnpackVersion(buf.id); header->version = libraryIDUnpackVersion(buf.id);
@ -773,7 +774,7 @@ uint8*
getFileContents(char *name, uint32 *len) getFileContents(char *name, uint32 *len)
{ {
FILE *cf = fopen(name, "rb"); FILE *cf = fopen(name, "rb");
assert(cf != NULL); assert(cf != nil);
fseek(cf, 0, SEEK_END); fseek(cf, 0, SEEK_END);
*len = ftell(cf); *len = ftell(cf);
fseek(cf, 0, SEEK_SET); fseek(cf, 0, SEEK_SET);

View File

@ -227,7 +227,7 @@ public:
enum Platform enum Platform
{ {
PLATFORM_NULL = 0, PLATFORM_nil = 0,
// D3D7 // D3D7
PLATFORM_GL = 2, PLATFORM_GL = 2,
// MAC // MAC

View File

@ -1,10 +1,23 @@
namespace rw { namespace rw {
// TODO: move more stuff into this
struct Engine struct Engine
{
Camera *currentCamera;
};
extern Engine engine;
struct Driver
{ {
ObjPipeline *defaultPipeline; ObjPipeline *defaultPipeline;
int32 rasterNativeOffset; int32 rasterNativeOffset;
void (*beginUpdate)(Camera*);
void (*endUpdate)(Camera*);
void (*rasterCreate)(Raster*); void (*rasterCreate)(Raster*);
uint8 *(*rasterLock)(Raster*, int32 level); uint8 *(*rasterLock)(Raster*, int32 level);
void (*rasterUnlock)(Raster*, int32 level); void (*rasterUnlock)(Raster*, int32 level);
@ -12,9 +25,13 @@ struct Engine
void (*rasterFromImage)(Raster*, Image*); void (*rasterFromImage)(Raster*, Image*);
}; };
extern Engine engine[NUM_PLATFORMS]; extern Driver driver[NUM_PLATFORMS];
#define DRIVER driver[rw::platform]
namespace null { namespace null {
void beginUpdate(Camera*);
void endUpdate(Camera*);
void rasterCreate(Raster*); void rasterCreate(Raster*);
uint8 *rasterLock(Raster*, int32 level); uint8 *rasterLock(Raster*, int32 level);
void rasterUnlock(Raster*, int32 level); void rasterUnlock(Raster*, int32 level);

View File

@ -7,8 +7,8 @@ struct LLLink
LLLink *next; LLLink *next;
LLLink *prev; LLLink *prev;
void init(void){ void init(void){
this->next = NULL; this->next = nil;
this->prev = NULL; this->prev = nil;
} }
void remove(void){ void remove(void){
this->prev->next = this->next; this->prev->next = this->next;
@ -21,7 +21,7 @@ struct LLLink
// Have to be careful since the link might be deleted. // Have to be careful since the link might be deleted.
#define FORLIST(_link, _list) \ #define FORLIST(_link, _list) \
for(rw::LLLink *_next = NULL, *_link = (_list).link.next; \ for(rw::LLLink *_next = nil, *_link = (_list).link.next; \
_next = (_link)->next, (_link) != (_list).end(); \ _next = (_link)->next, (_link) != (_list).end(); \
(_link) = _next) (_link) = _next)
@ -71,14 +71,14 @@ struct Object
this->subType = subType; this->subType = subType;
this->flags = 0; this->flags = 0;
this->privateFlags = 0; this->privateFlags = 0;
this->parent = NULL; this->parent = nil;
} }
void copy(Object *o){ void copy(Object *o){
this->type = o->type; this->type = o->type;
this->subType = o->subType; this->subType = o->subType;
this->flags = o->flags; this->flags = o->flags;
this->privateFlags = o->privateFlags; this->privateFlags = o->privateFlags;
this->parent = NULL; this->parent = nil;
} }
}; };
@ -86,10 +86,12 @@ struct Frame : PluginBase<Frame>
{ {
typedef Frame *(*Callback)(Frame *f, void *data); typedef Frame *(*Callback)(Frame *f, void *data);
enum { ID = 0 }; enum { ID = 0 };
enum { // private flags enum { // private flags
HIERARCHYSYNCLTM = 0x01, // The hierarchy has unsynched frames
HIERARCHYSYNCOBJ = 0x02, HIERARCHYSYNCLTM = 0x01, // LTM not synched
HIERARCHYSYNCOBJ = 0x02, // attached objects not synched
HIERARCHYSYNC = HIERARCHYSYNCLTM | HIERARCHYSYNCOBJ, HIERARCHYSYNC = HIERARCHYSYNCLTM | HIERARCHYSYNCOBJ,
// This frame is not synched
SUBTREESYNCLTM = 0x04, SUBTREESYNCLTM = 0x04,
SUBTREESYNCOBJ = 0x08, SUBTREESYNCOBJ = 0x08,
SUBTREESYNC = SUBTREESYNCLTM | SUBTREESYNCOBJ, SUBTREESYNC = SUBTREESYNCLTM | SUBTREESYNCOBJ,
@ -107,8 +109,6 @@ struct Frame : PluginBase<Frame>
Frame *next; Frame *next;
Frame *root; Frame *root;
static LinkList dirtyList;
static Frame *create(void); static Frame *create(void);
Frame *cloneHierarchy(void); Frame *cloneHierarchy(void);
void destroy(void); void destroy(void);
@ -124,10 +124,15 @@ struct Frame : PluginBase<Frame>
Matrix *getLTM(void); Matrix *getLTM(void);
void updateObjects(void); void updateObjects(void);
void syncHierarchyLTM(void); void syncHierarchyLTM(void);
void setHierarchyRoot(Frame *root); void setHierarchyRoot(Frame *root);
Frame *cloneAndLink(Frame *clonedroot); Frame *cloneAndLink(Frame *clonedroot);
void purgeClone(void); void purgeClone(void);
static LinkList dirtyList;
static void syncDirty(void);
}; };
struct FrameList_ struct FrameList_
@ -145,6 +150,8 @@ struct ObjectWithFrame
{ {
Object object; Object object;
LLLink inFrame; LLLink inFrame;
void (*syncCB)(ObjectWithFrame*);
void setFrame(Frame *f){ void setFrame(Frame *f){
if(this->object.parent) if(this->object.parent)
this->inFrame.remove(); this->inFrame.remove();
@ -152,6 +159,7 @@ struct ObjectWithFrame
if(f) if(f)
f->objectList.add(&this->inFrame); f->objectList.add(&this->inFrame);
} }
void sync(void){ this->syncCB(this); }
static ObjectWithFrame *fromFrame(LLLink *lnk){ static ObjectWithFrame *fromFrame(LLLink *lnk){
return LLLinkGetData(lnk, ObjectWithFrame, inFrame); return LLLinkGetData(lnk, ObjectWithFrame, inFrame);
} }
@ -380,7 +388,7 @@ struct Geometry : PluginBase<Geometry>
void calculateBoundingSphere(void); void calculateBoundingSphere(void);
bool32 hasColoredMaterial(void); bool32 hasColoredMaterial(void);
void allocateData(void); void allocateData(void);
void generateTriangles(int8 *adc = NULL); void generateTriangles(int8 *adc = nil);
void buildMeshes(void); void buildMeshes(void);
void removeUnusedMaterials(void); void removeUnusedMaterials(void);
@ -503,6 +511,9 @@ struct Camera : PluginBase<Camera>
Clump *clump; Clump *clump;
LLLink inClump; LLLink inClump;
void (*beginUpdateCB)(Camera*);
void (*endUpdateCB)(Camera*);
static Camera *create(void); static Camera *create(void);
Camera *clone(void); Camera *clone(void);
void destroy(void); void destroy(void);
@ -510,6 +521,8 @@ struct Camera : PluginBase<Camera>
Frame *getFrame(void){ return (Frame*)this->object.object.parent; } Frame *getFrame(void){ return (Frame*)this->object.object.parent; }
static Camera *fromClump(LLLink *lnk){ static Camera *fromClump(LLLink *lnk){
return LLLinkGetData(lnk, Camera, inClump); } return LLLinkGetData(lnk, Camera, inClump); }
void beginUpdate(void) { this->beginUpdateCB(this); }
void endUpdate(void) { this->endUpdateCB(this); }
static Camera *streamRead(Stream *stream); static Camera *streamRead(Stream *stream);
bool streamWrite(Stream *stream); bool streamWrite(Stream *stream);
uint32 streamGetSize(void); uint32 streamGetSize(void);

View File

@ -42,6 +42,7 @@ enum {
VERT_FLOAT2, VERT_FLOAT2,
VERT_FLOAT3, VERT_FLOAT3,
VERT_ARGB, VERT_ARGB,
VERT_RGBA,
VERT_COMPNORM VERT_COMPNORM
}; };

View File

@ -86,7 +86,7 @@ PluginBase<T>::streamReadPlugins(Stream *stream)
{ {
int32 length; int32 length;
ChunkHeaderInfo header; ChunkHeaderInfo header;
if(!findChunk(stream, ID_EXTENSION, (uint32*)&length, NULL)) if(!findChunk(stream, ID_EXTENSION, (uint32*)&length, nil))
return false; return false;
while(length > 0){ while(length > 0){
if(!readChunkHeaderInfo(stream, &header)) if(!readChunkHeaderInfo(stream, &header))
@ -112,7 +112,7 @@ PluginBase<T>::streamWritePlugins(Stream *stream)
int size = this->streamGetPluginSize(); int size = this->streamGetPluginSize();
writeChunkHeader(stream, ID_EXTENSION, size); writeChunkHeader(stream, ID_EXTENSION, size);
for(Plugin *p = this->s_plugins; p; p = p->next){ for(Plugin *p = this->s_plugins; p; p = p->next){
if(p->getSize == NULL || if(p->getSize == nil ||
(size = p->getSize(this, p->offset, p->size)) <= 0) (size = p->getSize(this, p->offset, p->size)) <= 0)
continue; continue;
writeChunkHeader(stream, p->id, size); writeChunkHeader(stream, p->id, size);
@ -157,16 +157,16 @@ PluginBase<T>::registerPlugin(int32 size, uint32 id,
p->constructor = ctor; p->constructor = ctor;
p->copy = cctor; p->copy = cctor;
p->destructor = dtor; p->destructor = dtor;
p->read = NULL; p->read = nil;
p->write = NULL; p->write = nil;
p->getSize = NULL; p->getSize = nil;
p->rightsCallback = NULL; p->rightsCallback = nil;
Plugin **next; Plugin **next;
for(next = &s_plugins; *next; next = &(*next)->next) for(next = &s_plugins; *next; next = &(*next)->next)
; ;
*next = p; *next = p;
p->next = NULL; p->next = nil;
return p->offset; return p->offset;
} }
@ -208,7 +208,7 @@ template <typename T> void*
PluginBase<T>::operator new(size_t) PluginBase<T>::operator new(size_t)
{ {
abort(); abort();
return NULL; return nil;
} }
template <typename T> void template <typename T> void

View File

@ -24,7 +24,7 @@ namespace wdgl {
void void
initializePlatform(void) initializePlatform(void)
{ {
engine[PLATFORM_WDGL].defaultPipeline = makeDefaultPipeline(); driver[PLATFORM_WDGL].defaultPipeline = makeDefaultPipeline();
} }
@ -223,7 +223,7 @@ destroyNativeData(void *object, int32, int32)
return object; return object;
InstanceDataHeader *header = InstanceDataHeader *header =
(InstanceDataHeader*)geometry->instData; (InstanceDataHeader*)geometry->instData;
geometry->instData = NULL; geometry->instData = nil;
// TODO: delete ibo and vbo // TODO: delete ibo and vbo
delete[] header->attribs; delete[] header->attribs;
delete[] header->data; delete[] header->data;
@ -279,7 +279,7 @@ void
registerNativeDataPlugin(void) registerNativeDataPlugin(void)
{ {
Geometry::registerPlugin(0, ID_NATIVEDATA, Geometry::registerPlugin(0, ID_NATIVEDATA,
NULL, destroyNativeData, NULL); nil, destroyNativeData, nil);
Geometry::registerPluginStream(ID_NATIVEDATA, Geometry::registerPluginStream(ID_NATIVEDATA,
readNativeData, readNativeData,
writeNativeData, writeNativeData,
@ -290,7 +290,7 @@ void
printPipeinfo(Atomic *a) printPipeinfo(Atomic *a)
{ {
Geometry *g = a->geometry; Geometry *g = a->geometry;
if(g->instData == NULL || g->instData->platform != PLATFORM_WDGL) if(g->instData == nil || g->instData->platform != PLATFORM_WDGL)
return; return;
int32 plgid = 0; int32 plgid = 0;
if(a->pipeline) if(a->pipeline)
@ -436,7 +436,7 @@ uninstance(rw::ObjPipeline *rwpipe, Atomic *atomic)
Geometry *geo = atomic->geometry; Geometry *geo = atomic->geometry;
if((geo->geoflags & Geometry::NATIVE) == 0) if((geo->geoflags & Geometry::NATIVE) == 0)
return; return;
assert(geo->instData != NULL); assert(geo->instData != nil);
assert(geo->instData->platform == PLATFORM_WDGL); assert(geo->instData->platform == PLATFORM_WDGL);
geo->geoflags &= ~Geometry::NATIVE; geo->geoflags &= ~Geometry::NATIVE;
geo->allocateData(); geo->allocateData();
@ -507,8 +507,8 @@ ObjPipeline::ObjPipeline(uint32 platform)
this->numCustomAttribs = 0; this->numCustomAttribs = 0;
this->impl.instance = wdgl::instance; this->impl.instance = wdgl::instance;
this->impl.uninstance = wdgl::uninstance; this->impl.uninstance = wdgl::uninstance;
this->instanceCB = NULL; this->instanceCB = nil;
this->uninstanceCB = NULL; this->uninstanceCB = nil;
} }
ObjPipeline* ObjPipeline*
@ -558,7 +558,7 @@ int32
getSizeNativeSkin(void *object, int32 offset) getSizeNativeSkin(void *object, int32 offset)
{ {
Skin *skin = *PLUGINOFFSET(Skin*, object, offset); Skin *skin = *PLUGINOFFSET(Skin*, object, offset);
if(skin == NULL) if(skin == nil)
return -1; return -1;
int32 size = 12 + 4 + 4 + skin->numBones*64; int32 size = 12 + 4 + 4 + skin->numBones*64;
return size; return size;
@ -590,7 +590,7 @@ skinInstanceCB(Geometry *g, int32 i, uint32 offset)
header->data = new uint8[header->dataSize]; header->data = new uint8[header->dataSize];
Skin *skin = *PLUGINOFFSET(Skin*, g, skinGlobals.offset); Skin *skin = *PLUGINOFFSET(Skin*, g, skinGlobals.offset);
if(skin == NULL) if(skin == nil)
return 8; return 8;
a = &header->attribs[i]; a = &header->attribs[i];
@ -618,7 +618,7 @@ skinUninstanceCB(Geometry *geo)
InstanceDataHeader *header = (InstanceDataHeader*)geo->instData; InstanceDataHeader *header = (InstanceDataHeader*)geo->instData;
Skin *skin = *PLUGINOFFSET(Skin*, geo, skinGlobals.offset); Skin *skin = *PLUGINOFFSET(Skin*, geo, skinGlobals.offset);
if(skin == NULL) if(skin == nil)
return; return;
uint8 *data = skin->data; uint8 *data = skin->data;

View File

@ -20,7 +20,7 @@ namespace xbox {
void void
initializePlatform(void) initializePlatform(void)
{ {
engine[PLATFORM_XBOX].defaultPipeline = makeDefaultPipeline(); driver[PLATFORM_XBOX].defaultPipeline = makeDefaultPipeline();
} }
void* void*
@ -32,7 +32,7 @@ destroyNativeData(void *object, int32, int32)
return object; return object;
InstanceDataHeader *header = InstanceDataHeader *header =
(InstanceDataHeader*)geometry->instData; (InstanceDataHeader*)geometry->instData;
geometry->instData = NULL; geometry->instData = nil;
delete[] (uint8*)header->vertexBuffer; delete[] (uint8*)header->vertexBuffer;
delete[] header->begin; delete[] header->begin;
delete[] header->data; delete[] header->data;
@ -156,7 +156,7 @@ void
registerNativeDataPlugin(void) registerNativeDataPlugin(void)
{ {
Geometry::registerPlugin(0, ID_NATIVEDATA, Geometry::registerPlugin(0, ID_NATIVEDATA,
NULL, destroyNativeData, NULL); nil, destroyNativeData, nil);
Geometry::registerPluginStream(ID_NATIVEDATA, Geometry::registerPluginStream(ID_NATIVEDATA,
readNativeData, readNativeData,
writeNativeData, writeNativeData,
@ -195,7 +195,7 @@ instance(rw::ObjPipeline *rwpipe, Atomic *atomic)
header->vertexAlpha = 0; header->vertexAlpha = 0;
// set by the instanceCB // set by the instanceCB
header->stride = 0; header->stride = 0;
header->vertexBuffer = NULL; header->vertexBuffer = nil;
InstanceData *inst = new InstanceData[header->numMeshes]; InstanceData *inst = new InstanceData[header->numMeshes];
header->begin = inst; header->begin = inst;
@ -225,7 +225,7 @@ uninstance(rw::ObjPipeline *rwpipe, Atomic *atomic)
Geometry *geo = atomic->geometry; Geometry *geo = atomic->geometry;
if((geo->geoflags & Geometry::NATIVE) == 0) if((geo->geoflags & Geometry::NATIVE) == 0)
return; return;
assert(geo->instData != NULL); assert(geo->instData != nil);
assert(geo->instData->platform == PLATFORM_XBOX); assert(geo->instData->platform == PLATFORM_XBOX);
geo->geoflags &= ~Geometry::NATIVE; geo->geoflags &= ~Geometry::NATIVE;
geo->allocateData(); geo->allocateData();
@ -251,8 +251,8 @@ ObjPipeline::ObjPipeline(uint32 platform)
{ {
this->impl.instance = xbox::instance; this->impl.instance = xbox::instance;
this->impl.uninstance = xbox::uninstance; this->impl.uninstance = xbox::uninstance;
this->instanceCB = NULL; this->instanceCB = nil;
this->uninstanceCB = NULL; this->uninstanceCB = nil;
} }
@ -435,9 +435,9 @@ getSizeNativeSkin(void *object, int32 offset)
{ {
Geometry *geometry = (Geometry*)object; Geometry *geometry = (Geometry*)object;
Skin *skin = *PLUGINOFFSET(Skin*, object, offset); Skin *skin = *PLUGINOFFSET(Skin*, object, offset);
if(skin == NULL) if(skin == nil)
return -1; return -1;
if(skin->platformData == NULL) if(skin->platformData == nil)
return -1; return -1;
NativeSkin *natskin = (NativeSkin*)skin->platformData; NativeSkin *natskin = (NativeSkin*)skin->platformData;
return 12 + 8 + 2*256*4 + 4*4 + return 12 + 8 + 2*256*4 + 4*4 +
@ -450,7 +450,7 @@ skinInstanceCB(Geometry *geo, InstanceDataHeader *header)
defaultInstanceCB(geo, header); defaultInstanceCB(geo, header);
Skin *skin = *PLUGINOFFSET(Skin*, geo, skinGlobals.offset); Skin *skin = *PLUGINOFFSET(Skin*, geo, skinGlobals.offset);
if(skin == NULL) if(skin == nil)
return; return;
NativeSkin *natskin = new NativeSkin; NativeSkin *natskin = new NativeSkin;
skin->platformData = natskin; skin->platformData = natskin;
@ -504,7 +504,7 @@ skinUninstanceCB(Geometry *geo, InstanceDataHeader *header)
defaultUninstanceCB(geo, header); defaultUninstanceCB(geo, header);
Skin *skin = *PLUGINOFFSET(Skin*, geo, skinGlobals.offset); Skin *skin = *PLUGINOFFSET(Skin*, geo, skinGlobals.offset);
if(skin == NULL) if(skin == nil)
return; return;
NativeSkin *natskin = (NativeSkin*)skin->platformData; NativeSkin *natskin = (NativeSkin*)skin->platformData;
@ -660,7 +660,7 @@ void
registerVertexFormatPlugin(void) registerVertexFormatPlugin(void)
{ {
vertexFmtOffset = Geometry::registerPlugin(sizeof(uint32), ID_VERTEXFMT, vertexFmtOffset = Geometry::registerPlugin(sizeof(uint32), ID_VERTEXFMT,
createVertexFmt, NULL, copyVertexFmt); createVertexFmt, nil, copyVertexFmt);
Geometry::registerPluginStream(ID_VERTEXFMT, Geometry::registerPluginStream(ID_VERTEXFMT,
readVertexFmt, readVertexFmt,
writeVertexFmt, writeVertexFmt,
@ -872,8 +872,8 @@ static void*
createNativeRaster(void *object, int32 offset, int32) createNativeRaster(void *object, int32 offset, int32)
{ {
XboxRaster *raster = PLUGINOFFSET(XboxRaster, object, offset); XboxRaster *raster = PLUGINOFFSET(XboxRaster, object, offset);
raster->texture = NULL; raster->texture = nil;
raster->palette = NULL; raster->palette = nil;
raster->format = 0; raster->format = 0;
raster->hasAlpha = 0; raster->hasAlpha = 0;
raster->unknownFlag = 0; raster->unknownFlag = 0;
@ -891,8 +891,8 @@ static void*
copyNativeRaster(void *dst, void *, int32 offset, int32) copyNativeRaster(void *dst, void *, int32 offset, int32)
{ {
XboxRaster *raster = PLUGINOFFSET(XboxRaster, dst, offset); XboxRaster *raster = PLUGINOFFSET(XboxRaster, dst, offset);
raster->texture = NULL; raster->texture = nil;
raster->palette = NULL; raster->palette = nil;
raster->format = 0; raster->format = 0;
raster->hasAlpha = 0; raster->hasAlpha = 0;
raster->unknownFlag = 0; raster->unknownFlag = 0;
@ -907,11 +907,11 @@ registerNativeRaster(void)
createNativeRaster, createNativeRaster,
destroyNativeRaster, destroyNativeRaster,
copyNativeRaster); copyNativeRaster);
engine[PLATFORM_XBOX].rasterNativeOffset = nativeRasterOffset; driver[PLATFORM_XBOX].rasterNativeOffset = nativeRasterOffset;
engine[PLATFORM_XBOX].rasterCreate = rasterCreate; driver[PLATFORM_XBOX].rasterCreate = rasterCreate;
engine[PLATFORM_XBOX].rasterLock = rasterLock; driver[PLATFORM_XBOX].rasterLock = rasterLock;
engine[PLATFORM_XBOX].rasterUnlock = rasterUnlock; driver[PLATFORM_XBOX].rasterUnlock = rasterUnlock;
engine[PLATFORM_XBOX].rasterNumLevels = rasterNumLevels; driver[PLATFORM_XBOX].rasterNumLevels = rasterNumLevels;
} }
Texture* Texture*