mirror of https://github.com/aap/librw.git
atomic world bounding sphere
This commit is contained in:
parent
7be2e634fe
commit
9bc57a0641
5
TODO
5
TODO
|
@ -2,14 +2,9 @@ BUGS:
|
|||
- fseek with negative offset on ps2 over ps2link messes up the current position
|
||||
|
||||
Clump & related:
|
||||
- make pointer arrays into lists
|
||||
- !!! work on ref counts, destruction, copying etc.
|
||||
- define and use types:
|
||||
sphere
|
||||
matrix
|
||||
color
|
||||
realcolor
|
||||
vector3
|
||||
triangle
|
||||
texcoord
|
||||
- implement plugins:
|
||||
|
|
|
@ -568,14 +568,14 @@ Atomic::create(void)
|
|||
assert(atomic != NULL);
|
||||
atomic->object.init(Atomic::ID, 0);
|
||||
atomic->geometry = NULL;
|
||||
atomic->worldBoundingSphere.center.set(0.0f, 0.0f, 0.0f);
|
||||
atomic->worldBoundingSphere.radius = 0.0f;
|
||||
atomic->setFrame(NULL);
|
||||
atomic->clump = NULL;
|
||||
atomic->pipeline = NULL;
|
||||
atomic->renderCB = Atomic::defaultRenderCB;
|
||||
atomic->object.flags = Atomic::COLLISIONTEST | Atomic::RENDER;
|
||||
atomic->constructPlugins();
|
||||
|
||||
// private flags:
|
||||
// rpATOMICPRIVATEWORLDBOUNDDIRTY = 0x01
|
||||
return atomic;
|
||||
}
|
||||
|
||||
|
@ -606,6 +606,22 @@ Atomic::destroy(void)
|
|||
free(this);
|
||||
}
|
||||
|
||||
Sphere*
|
||||
Atomic::getWorldBoundingSphere(void)
|
||||
{
|
||||
Sphere *s = &this->worldBoundingSphere;
|
||||
if(!this->getFrame()->dirty() &&
|
||||
(this->object.privateFlags & WORLDBOUNDDIRTY) == 0)
|
||||
return s;
|
||||
Matrix *ltm = this->getFrame()->getLTM();
|
||||
// TODO: support scaling
|
||||
s->center = ltm->transPoint(s->center);
|
||||
// TODO: if we ever support morphing, fix this:
|
||||
s->radius = this->geometry->morphTargets[0].boundingSphere.radius;
|
||||
this->object.privateFlags &= ~WORLDBOUNDDIRTY;
|
||||
return s;
|
||||
}
|
||||
|
||||
static uint32 atomicRights[2];
|
||||
|
||||
Atomic*
|
||||
|
|
|
@ -119,6 +119,8 @@ struct Frame : PluginBase<Frame>
|
|||
Frame *getParent(void){
|
||||
return (Frame*)this->object.parent; }
|
||||
int32 count(void);
|
||||
bool32 dirty(void) {
|
||||
return !!(this->root->object.privateFlags & HIERARCHYSYNC); }
|
||||
Matrix *getLTM(void);
|
||||
void updateObjects(void);
|
||||
|
||||
|
@ -558,11 +560,14 @@ struct Atomic : PluginBase<Atomic>
|
|||
enum { ID = 1 };
|
||||
enum {
|
||||
COLLISIONTEST = 0x01, // unused here
|
||||
RENDER = 0x04
|
||||
RENDER = 0x04,
|
||||
// private
|
||||
WORLDBOUNDDIRTY = 0x01
|
||||
};
|
||||
|
||||
ObjectWithFrame object;
|
||||
Geometry *geometry;
|
||||
Sphere worldBoundingSphere;
|
||||
Clump *clump;
|
||||
LLLink inClump;
|
||||
ObjPipeline *pipeline;
|
||||
|
@ -571,17 +576,21 @@ struct Atomic : PluginBase<Atomic>
|
|||
static Atomic *create(void);
|
||||
Atomic *clone(void);
|
||||
void destroy(void);
|
||||
void setFrame(Frame *f) { this->object.setFrame(f); }
|
||||
void setFrame(Frame *f) {
|
||||
this->object.setFrame(f);
|
||||
this->object.privateFlags |= WORLDBOUNDDIRTY;
|
||||
}
|
||||
Frame *getFrame(void) { return (Frame*)this->object.parent; }
|
||||
static Atomic *fromClump(LLLink *lnk){
|
||||
return LLLinkGetData(lnk, Atomic, inClump); }
|
||||
ObjPipeline *getPipeline(void);
|
||||
Sphere *getWorldBoundingSphere(void);
|
||||
static Atomic *streamReadClump(Stream *stream,
|
||||
Frame **frameList, Geometry **geometryList);
|
||||
Frame **frameList, Geometry **geometryList);
|
||||
void render(void) { this->renderCB(this); }
|
||||
bool streamWriteClump(Stream *stream,
|
||||
Frame **frameList, int32 numframes);
|
||||
uint32 streamGetSize(void);
|
||||
ObjPipeline *getPipeline(void);
|
||||
void render(void) { this->renderCB(this); }
|
||||
|
||||
static void defaultRenderCB(Atomic *atomic);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue