RuntimeLib: Disable debug checks if not compiled for debug

You need to make sure that all your calls are valid now.
This commit is contained in:
Michael Fabian Dirks
2017-04-09 05:40:31 +02:00
parent 6980081f57
commit 4ce6f52085
2 changed files with 1312 additions and 1163 deletions
+184 -107
View File
@@ -10,7 +10,7 @@
#include "../blitz3d/camera.h"
#include "../blitz3d/sprite.h"
#include "../blitz3d/meshmodel.h"
#include "../blitz3d/loader_x.h"
//#include "../blitz3d/loader_x.h"
#include "../blitz3d/loader_3ds.h"
#include "../blitz3d/loader_b3d.h"
#include "../blitz3d/md2model.h"
@@ -37,11 +37,11 @@ static Listener *listener;
static bool stats_mode;
//converts 0...255 color to 0...1
static const float ctof=1.0f/255.0f;
static const float s_colorToFloat = 1.0f / 255.0f;
//degrees to radians and back
static const float dtor=0.0174532925199432957692369076848861f;
static const float rtod=1/dtor;
static const float s_degreesToRadians = 0.0174532925199432957692369076848861f;
static const float s_radiansToDegrees = 1 / s_degreesToRadians;
static Vector projected, tformed;
@@ -49,99 +49,171 @@ static ObjCollision picked;
extern float stats3d[10];
static Loader_X loader_x;
//static Loader_X loader_x;
static Loader_3DS loader_3ds;
static Loader_B3D loader_b3d;
static map<string, Transform> loader_mat_map;
static inline void debug3d() {
#ifdef DEBUG
if (debug && !gx_scene) ThrowRuntimeException("3D Graphics mode not set");
#else
return;
#endif
}
static inline void debugTexture(Texture *t) {
#ifdef DEBUG
if (debug && !texture_set.count(t)) ThrowRuntimeException("Texture does not exist");
#else
return;
#endif
}
static inline void debugBrush(Brush *b) {
#ifdef DEBUG
if (debug && !brush_set.count(b)) ThrowRuntimeException("Brush does not exist");
#else
return;
#endif
}
static inline void debugEntity(Entity *e) {
#ifdef DEBUG
if (debug && !entity_set.count(e)) ThrowRuntimeException("Entity does not exist");
#else
return;
#endif
}
static inline void debugParent(Entity *e) {
#ifdef DEBUG
if (debug) {
debug3d();
if (e && !entity_set.count(e)) ThrowRuntimeException("Parent entity does not exist");
}
#else
return;
#endif
}
static inline void debugMesh(MeshModel *m) {
#ifdef DEBUG
if (debug) {
debugEntity(m); if (!m->getMeshModel()) ThrowRuntimeException("Entity is not a mesh");
}
#else
return;
#endif
}
static inline void debugObject(Object *o) {
#ifdef DEBUG
if (debug) {
debugEntity(o); if (!o->getObject()) ThrowRuntimeException("Entity is not an object");
}
#else
return;
#endif
}
static inline void debugColl(Object *o, int index) {
#ifdef DEBUG
if (debug) {
debugObject(o);
if (index<1 || index>o->getCollisions().size()) ThrowRuntimeException("Collision index out of range");
}
#else
return;
#endif
}
static inline void debugCamera(Camera *c) {
#ifdef DEBUG
if (debug) {
debugEntity(c); if (!c->getCamera()) ThrowRuntimeException("Entity is not a camera");
}
#else
return;
#endif
}
static inline void debugLight(Light *l) {
#ifdef DEBUG
if (debug) {
debugEntity(l); if (!l->getLight()) ThrowRuntimeException("Entity is not a light");
}
#else
return;
#endif
}
static inline void debugModel(Model *m) {
#ifdef DEBUG
if (debug) {
debugEntity(m); if (!m->getModel()) ThrowRuntimeException("Entity is not a model");
}
#else
return;
#endif
}
static inline void debugSprite(Sprite *s) {
#ifdef DEBUG
if (debug) {
debugModel(s); if (!s->getSprite()) ThrowRuntimeException("Entity is not a sprite");
}
#else
return;
#endif
}
static inline void debugMD2(MD2Model *m) {
#ifdef DEBUG
if (debug) {
debugModel(m); if (!m->getMD2Model()) ThrowRuntimeException("Entity is not an MD2 Model");
}
#else
return;
#endif
}
static inline void debugBSP(Q3BSPModel *m) {
#ifdef DEBUG
if (debug) {
debugModel(m); if (!m->getBSPModel()) ThrowRuntimeException("Entity is not a BSP Model");
}
#else
return;
#endif
}
static inline void debugTerrain(Terrain *t) {
#ifdef DEBUG
if (debug) {
debugModel(t); if (!t->getTerrain()) ThrowRuntimeException("Entity is not a terrain");
}
#else
return;
#endif
}
static inline void debugSegs(int n) {
#ifdef DEBUG
if (debug) {
debug3d();
if (n < 3 || n>50) ThrowRuntimeException("Illegal number of segments");
}
#else
return;
#endif
}
static inline void debugVertex(Surface *s, int n) {
#ifdef DEBUG
if (debug) {
debug3d();
if (n < 0 || n >= s->numVertices()) ThrowRuntimeException("Vertex index out of range");
}
#else
return;
#endif
}
static inline void debugVertex(Surface *s, int n, int t) {
#ifdef DEBUG
if (debug) {
debug3d();
if (n < 0 || n >= s->numVertices()) ThrowRuntimeException("Vertex index out of range");
if (t < 0 || t>1) ThrowRuntimeException("Texture coordinate set out of range");
}
#else
return;
#endif
}
static Entity *loadEntity(string t, int hint) {
@@ -150,10 +222,15 @@ static Entity *loadEntity( string t,int hint ){
string ext = t.substr(n + 1);
MeshLoader *l;
if( ext=="x" ) l=&loader_x;
else if( ext=="3ds" ) l=&loader_3ds;
else if( ext=="b3d" ) l=&loader_b3d;
else return 0;
if (ext == "x") {
//l = &Loader_X;
} else if (ext == "3ds") {
l = &loader_3ds;
} else if (ext == "b3d") {
l = &loader_b3d;
} else {
return 0;
}
const Transform &conv = loader_mat_map[ext];
@@ -164,12 +241,12 @@ static Entity *loadEntity( string t,int hint ){
}
static void collapseMesh(MeshModel *mesh, Entity *e) {
while( e->children() ){
collapseMesh( mesh,e->children() );
while (e->GetChildren()) {
collapseMesh(mesh, e->GetChildren());
}
if (Model *p = e->getModel()) {
if (MeshModel *t = p->getMeshModel()) {
t->transform( e->getWorldTform() );
t->transform(e->GetWorldTransform());
mesh->add(*t);
}
}
@@ -178,22 +255,22 @@ static void collapseMesh( MeshModel *mesh,Entity *e ){
static void insert(Entity *e) {
if (debug) entity_set.insert(e);
e->setVisible(true);
e->setEnabled(true);
e->SetVisible(true);
e->SetEnabled(true);
e->getObject()->reset();
for( Entity *p=e->children();p;p=p->successor() ){
for (Entity *p = e->GetChildren(); p; p = p->GetSuccessor()) {
insert(p);
}
}
static Entity *insertEntity(Entity *e, Entity *p) {
e->setParent( p );
e->SetParent(p);
insert(e);
return e;
}
static void erase(Entity *e) {
for( Entity *p=e->children();p;p=p->successor() ){
for (Entity *p = e->GetChildren(); p; p = p->GetSuccessor()) {
erase(p);
}
if (e->getListener()) listener = 0;
@@ -202,7 +279,7 @@ static void erase( Entity *e ){
static Entity *findChild(Entity *e, const string &t) {
if (e->getName() == t) return e;
for( Entity *p=e->children();p;p=p->successor() ){
for (Entity *p = e->GetChildren(); p; p = p->GetSuccessor()) {
if (Entity *q = findChild(p, t)) return q;
}
return 0;
@@ -254,7 +331,7 @@ void bbWireFrame( int enable ){
void bbAmbientLight(float r, float g, float b) {
debug3d();
Vector t( r*ctof,g*ctof,b*ctof );
Vector t(r*s_colorToFloat, g*s_colorToFloat, b*s_colorToFloat);
gx_scene->setAmbient(&(t.x));
}
@@ -296,8 +373,7 @@ void bbRenderWorld( float tween ){
world->render(tween);
tri_count = gx_scene->getTrianglesDrawn() - tri_count;
return;
#endif
#else
int tris = gx_scene->getTrianglesDrawn();
int render_ms = gx_runtime->getMilliSecs();
world->render(tween);
@@ -335,6 +411,7 @@ void bbRenderWorld( float tween ){
string t = "FPS:" + t_fps + " UPS:" + t_ups + " RPS:" + t_rps + " TRIS:" + t_tris;
bbText(0, bbGraphicsHeight() - bbFontHeight(), new BBStr(t), 0, 0);
#endif
}
int bbTrisRendered() {
@@ -406,7 +483,7 @@ void bbScaleTexture( Texture *t,float u_scale,float v_scale ){
void bbRotateTexture(Texture *t, float angle) {
debugTexture(t);
t->setRotation( -angle*dtor );
t->setRotation(-angle*s_degreesToRadians);
}
void bbPositionTexture(Texture *t, float u_pos, float v_pos) {
@@ -477,7 +554,7 @@ void bbTextureFilter( BBStr *t,int flags ){
Brush * bbCreateBrush(float r, float g, float b) {
debug3d();
Brush *br = new Brush();
br->setColor( Vector( r*ctof,g*ctof,b*ctof ) );
br->setColor(Vector(r*s_colorToFloat, g*s_colorToFloat, b*s_colorToFloat));
brush_set.insert(br);
return br;
}
@@ -501,7 +578,7 @@ void bbFreeBrush( Brush *b ){
void bbBrushColor(Brush *br, float r, float g, float b) {
debugBrush(br);
br->setColor( Vector( r*ctof,g*ctof,b*ctof ) );
br->setColor(Vector(r*s_colorToFloat, g*s_colorToFloat, b*s_colorToFloat));
}
void bbBrushAlpha(Brush *b, float alpha) {
@@ -609,7 +686,7 @@ void bbScaleMesh( MeshModel *m,float x,float y,float z ){
void bbRotateMesh(MeshModel *m, float x, float y, float z) {
debugMesh(m);
m->transform( rotationMatrix(x*dtor,y*dtor,z*dtor) );
m->transform(rotationMatrix(x*s_degreesToRadians, y*s_degreesToRadians, z*s_degreesToRadians));
}
void bbPositionMesh(MeshModel *m, float x, float y, float z) {
@@ -668,7 +745,7 @@ void bbUpdateNormals( MeshModel *m ){
void bbLightMesh(MeshModel *m, float r, float g, float b, float range, float x, float y, float z) {
debugMesh(m);
MeshUtil::lightMesh( m,Vector(x,y,z),Vector(r*ctof,g*ctof,b*ctof),range );
MeshUtil::lightMesh(m, Vector(x, y, z), Vector(r*s_colorToFloat, g*s_colorToFloat, b*s_colorToFloat), range);
}
float bbMeshWidth(MeshModel *m) {
@@ -697,19 +774,19 @@ int bbCountSurfaces( MeshModel *m ){
}
Surface * bbGetSurface(MeshModel *m, int index) {
#ifdef DEBUG
if (debug) {
debugMesh(m);
if( index<1 || index>m->getSurfaces().size() ){
if ((size_t)index<1 || index>m->getSurfaces().size()) {
ThrowRuntimeException("Surface Index out of range");
}
}
#endif
return m->getSurfaces()[index - 1];
}
void bbMeshCullBox(MeshModel *m, float x, float y, float z, float width, float height, float depth) {
if( debug ){
debugMesh(m);
}
m->setCullBox(Box(Vector(x, y, z), Vector(x + width, y + height, z + depth)));
}
@@ -821,19 +898,19 @@ float bbVertexNZ( Surface *s,int n ){
}
float bbVertexRed(Surface *s, int n) {
debugVertex(s, n);
return (s->getVertex(n).color&0xff0000)>>16;
return (float)((s->getVertex(n).color & 0xff0000) >> 16);
}
float bbVertexGreen(Surface *s, int n) {
debugVertex(s, n);
return (s->getVertex(n).color&0xff00)>>8;
return (float)((s->getVertex(n).color & 0xff00) >> 8);
}
float bbVertexBlue(Surface *s, int n) {
debugVertex(s, n);
return s->getVertex(n).color&0xff;
return (float)(s->getVertex(n).color & 0xff);
}
float bbVertexAlpha(Surface *s, int n) {
debugVertex(s, n);
return ((s->getVertex(n).color&0xff000000)>>24)/255.0f;
return (float)(((s->getVertex(n).color & 0xff000000) >> 24) / 255.0f);
}
float bbVertexU(Surface *s, int n, int t) {
debugVertex(s, n, t);
@@ -875,7 +952,7 @@ void bbCameraRange( Camera *c,float nr,float fr ){
void bbCameraClsColor(Camera *c, float r, float g, float b) {
debugCamera(c);
c->setClsColor( Vector( r*ctof,g*ctof,b*ctof ) );
c->setClsColor(Vector(r*s_colorToFloat, g*s_colorToFloat, b*s_colorToFloat));
}
void bbCameraClsMode(Camera *c, int cls_color, int cls_zbuffer) {
@@ -900,7 +977,7 @@ void bbCameraFogRange( Camera *c,float nr,float fr ){
void bbCameraFogColor(Camera *c, float r, float g, float b) {
debugCamera(c);
c->setFogColor( Vector( r*ctof,g*ctof,b*ctof ) );
c->setFogColor(Vector(r*s_colorToFloat, g*s_colorToFloat, b*s_colorToFloat));
}
void bbCameraFogMode(Camera *c, int mode) {
@@ -910,7 +987,7 @@ void bbCameraFogMode( Camera *c,int mode ){
int bbCameraProject(Camera *c, float x, float y, float z) {
debugCamera(c);
Vector v=-c->getWorldTform()*Vector(x,y,z);
Vector v = -c->GetWorldTransform()*Vector(x, y, z);
const Frustum &f = c->getFrustum();
if (c->getProjMode() == Camera::PROJ_ORTHO) {
int vp_x, vp_y, vp_w, vp_h;
@@ -973,10 +1050,10 @@ Entity * bbCameraPick( Camera *c,float x,float y ){
Line l;
if (c->getProjMode() == Camera::PROJ_ORTHO) {
l=c->getWorldTform() * Line( Vector(x,y,0),Vector(0,0,fr) ); //x,y,fr) );
l = c->GetWorldTransform() * Line(Vector(x, y, 0), Vector(0, 0, fr)); //x,y,fr) );
} else {
x /= nr; y /= nr;
l=c->getWorldTform() * Line( Vector(),Vector( x*fr,y*fr,fr ) );
l = c->GetWorldTransform() * Line(Vector(), Vector(x*fr, y*fr, fr));
}
return doPick(l, 0);
@@ -993,7 +1070,7 @@ Entity * bbLinePick( float x,float y,float z,float dx,float dy,float dz,float r
Entity * bbEntityPick(Object *src, float range) {
debugEntity(src);
Line l( src->getWorldPosition(),src->getWorldTform().m.k * range );
Line l(src->GetWorldPosition(), src->GetWorldTransform().m.k * range);
return doPick(l, 0);
}
@@ -1001,7 +1078,7 @@ Entity * bbEntityPick( Object *src,float range ){
int bbEntityVisible(Object *src, Object *dest) {
if (debug) { debugObject(src); debugObject(dest); }
return world->checkLOS( src,dest ) ? 1 : 0;
return world->CheckLineOfSight(src, dest) ? 1 : 0;
}
int bbEntityInView(Entity *e, Camera *c) {
@@ -1009,7 +1086,7 @@ int bbEntityInView( Entity *e,Camera *c ){
if (Model *p = e->getModel()) {
if (MeshModel *m = p->getMeshModel()) {
const Box &b = m->getBox();
Transform t=-c->getWorldTform() * e->getWorldTform();
Transform t = -c->GetWorldTransform() * e->GetWorldTransform();
Vector p[] = {
t*b.corner(0),t*b.corner(1),t*b.corner(2),t*b.corner(3),
t*b.corner(4),t*b.corner(5),t*b.corner(6),t*b.corner(7)
@@ -1017,7 +1094,7 @@ int bbEntityInView( Entity *e,Camera *c ){
return c->getFrustum().cull(p, 8);
}
}
Vector p[]={ -c->getWorldTform() * e->getWorldPosition() };
Vector p[] = { -c->GetWorldTransform() * e->GetWorldPosition() };
return c->getFrustum().cull(p, 1);
}
@@ -1072,7 +1149,7 @@ Entity * bbCreateLight( int type,Entity *p ){
void bbLightColor(Light *light, float r, float g, float b) {
debugLight(light);
light->setColor( Vector(r*ctof,g*ctof,b*ctof) );
light->setColor(Vector(r*s_colorToFloat, g*s_colorToFloat, b*s_colorToFloat));
}
void bbLightRange(Light *light, float range) {
@@ -1082,8 +1159,8 @@ void bbLightRange( Light *light,float range ){
void bbLightConeAngles(Light *light, float inner, float outer) {
debugLight(light);
inner*=dtor;
outer*=dtor;
inner *= s_degreesToRadians;
outer *= s_degreesToRadians;
if (inner < 0) inner = 0;
else if (inner > PI) inner = PI;
if (outer < inner) outer = inner;
@@ -1127,7 +1204,7 @@ Entity * bbLoadSprite( BBStr *file,int flags,Entity *p ){
void bbRotateSprite(Sprite *s, float angle) {
debugSprite(s);
s->setRotation( angle*dtor );
s->setRotation(angle*s_degreesToRadians);
}
void bbScaleSprite(Sprite *s, float x, float y) {
@@ -1212,7 +1289,7 @@ Entity * bbLoadBSP( BBStr *file,float gam,Entity *p ){
void bbBSPAmbientLight(Q3BSPModel *t, float r, float g, float b) {
debugBSP(t);
t->setAmbient( Vector( r*ctof,g*ctof,b*ctof ) );
t->setAmbient(Vector(r*s_colorToFloat, g*s_colorToFloat, b*s_colorToFloat));
}
void bbBSPLighting(Q3BSPModel *t, int lmap) {
@@ -1224,8 +1301,8 @@ void bbBSPLighting( Q3BSPModel *t,int lmap ){
// TERRAIN COMMANDS //
//////////////////////
static float terrainHeight(Terrain *t, float x, float z) {
int ix=floor(x);
int iz=floor(z);
int ix = (int)floor(x);
int iz = (int)floor(z);
float tx = x - ix, tz = z - iz;
float h0 = t->getHeight(ix, iz);
float h1 = t->getHeight(ix + 1, iz);
@@ -1237,8 +1314,8 @@ static float terrainHeight( Terrain *t,float x,float z ){
}
static Vector terrainVector(Terrain *t, float x, float y, float z) {
Vector v=-t->getWorldTform() * Vector( x,y,z );
return t->getWorldTform() * Vector( v.x,terrainHeight( t,v.x,v.z ),v.z );
Vector v = -t->GetWorldTransform() * Vector(x, y, z);
return t->GetWorldTransform() * Vector(v.x, terrainHeight(t, v.x, v.z), v.z);
}
Entity * bbCreateTerrain(int n, Entity *p) {
@@ -1358,14 +1435,14 @@ void bbFreeEntity( Entity *e ){
void bbHideEntity(Entity *e) {
debugEntity(e);
e->setEnabled(false);
e->setVisible(false);
e->SetEnabled(false);
e->SetVisible(false);
}
void bbShowEntity(Entity *e) {
debugEntity(e);
e->setVisible(true);
e->setEnabled(true);
e->SetVisible(true);
e->SetEnabled(true);
e->getObject()->reset();
}
@@ -1385,11 +1462,11 @@ void bbEntityParent( Entity *e,Entity *p,int global ){
if (e->getParent() == p) return;
if (global) {
Transform t=e->getWorldTform();
e->setParent( p );
e->setWorldTform( t );
Transform t = e->GetWorldTransform();
e->SetParent(p);
e->SetWorldTransform(t);
} else {
e->setParent( p );
e->SetParent(p);
e->getObject()->reset();
}
}
@@ -1397,14 +1474,14 @@ void bbEntityParent( Entity *e,Entity *p,int global ){
int bbCountChildren(Entity *e) {
debugEntity(e);
int n = 0;
for( Entity *p=e->children();p;p=p->successor() ) ++n;
for (Entity *p = e->GetChildren(); p; p = p->GetSuccessor()) ++n;
return n;
}
Entity * bbGetChild(Entity *e, int index) {
debugEntity(e);
Entity *p=e->children();
while( --index && p ) p=p->successor();
Entity *p = e->GetChildren();
while (--index && p) p = p->GetSuccessor();
return p;
}
@@ -1457,9 +1534,9 @@ void bbAnimate( Object *o,int mode,float speed,int seq,float trans ){
void bbSetAnimKey(Object *o, int frame, int pos_key, int rot_key, int scl_key) {
debugObject(o);
Animation anim = o->getAnimation();
if( pos_key ) anim.setPositionKey( frame,o->getLocalPosition() );
if( rot_key ) anim.setRotationKey( frame,o->getLocalRotation() );
if( scl_key ) anim.setScaleKey( frame,o->getLocalScale() );
if (pos_key) anim.setPositionKey(frame, o->GetLocalPosition());
if (rot_key) anim.setRotationKey(frame, o->GetLocalRotation());
if (scl_key) anim.setScaleKey(frame, o->GetLocalScale());
o->setAnimation(anim);
}
@@ -1521,7 +1598,7 @@ void bbPaintEntity( Model *m,Brush *b ){
void bbEntityColor(Model *m, float r, float g, float b) {
debugModel(m);
m->setColor( Vector( r*ctof,g*ctof,b*ctof ) );
m->setColor(Vector(r*s_colorToFloat, g*s_colorToFloat, b*s_colorToFloat));
}
void bbEntityAlpha(Model *m, float alpha) {
@@ -1570,37 +1647,37 @@ void bbEntityOrder( Object *o,int n ){
//////////////////////////////
float bbEntityX(Entity *e, int global) {
debugEntity(e);
return global ? e->getWorldPosition().x : e->getLocalPosition().x;
return global ? e->GetWorldPosition().x : e->GetLocalPosition().x;
}
float bbEntityY(Entity *e, int global) {
debugEntity(e);
return global ? e->getWorldPosition().y : e->getLocalPosition().y;
return global ? e->GetWorldPosition().y : e->GetLocalPosition().y;
}
float bbEntityZ(Entity *e, int global) {
debugEntity(e);
return global ? e->getWorldPosition().z : e->getLocalPosition().z;
return global ? e->GetWorldPosition().z : e->GetLocalPosition().z;
}
float bbEntityPitch(Entity *e, int global) {
debugEntity(e);
return quatPitch( global ? e->getWorldRotation() : e->getLocalRotation() ) * rtod;
return quatPitch(global ? e->GetWorldRotation() : e->GetLocalRotation()) * s_radiansToDegrees;
}
float bbEntityYaw(Entity *e, int global) {
debugEntity(e);
return quatYaw( global ? e->getWorldRotation() : e->getLocalRotation() ) * rtod;
return quatYaw(global ? e->GetWorldRotation() : e->GetLocalRotation()) * s_radiansToDegrees;
}
float bbEntityRoll(Entity *e, int global) {
debugEntity(e);
return quatRoll( global ? e->getWorldRotation() : e->getLocalRotation() ) * rtod;
return quatRoll(global ? e->GetWorldRotation() : e->GetLocalRotation()) * s_radiansToDegrees;
}
float bbGetMatElement(Entity *e, int row, int col) {
debugEntity(e);
return row<3 ? e->getWorldTform().m[row][col] : e->getWorldTform().v[col];
return row < 3 ? e->GetWorldTransform().m[row][col] : e->GetWorldTransform().v[col];
}
void bbTFormPoint(float x, float y, float z, Entity *src, Entity *dest) {
@@ -1609,8 +1686,8 @@ void bbTFormPoint( float x,float y,float z,Entity *src,Entity *dest ){
if (dest) debugEntity(dest);
}
tformed = Vector(x, y, z);
if( src ) tformed=src->getWorldTform() * tformed;
if( dest ) tformed=-dest->getWorldTform() * tformed;
if (src) tformed = src->GetWorldTransform() * tformed;
if (dest) tformed = -dest->GetWorldTransform() * tformed;
}
void bbTFormVector(float x, float y, float z, Entity *src, Entity *dest) {
@@ -1619,8 +1696,8 @@ void bbTFormVector( float x,float y,float z,Entity *src,Entity *dest ){
if (dest) debugEntity(dest);
}
tformed = Vector(x, y, z);
if( src ) tformed=src->getWorldTform().m * tformed;
if( dest ) tformed=-dest->getWorldTform().m * tformed;
if (src) tformed = src->GetWorldTransform().m * tformed;
if (dest) tformed = -dest->GetWorldTransform().m * tformed;
}
void bbTFormNormal(float x, float y, float z, Entity *src, Entity *dest) {
@@ -1629,8 +1706,8 @@ void bbTFormNormal( float x,float y,float z,Entity *src,Entity *dest ){
if (dest) debugEntity(dest);
}
tformed = Vector(x, y, z);
if( src ) tformed=(src->getWorldTform().m).cofactor() * tformed;
if( dest ) tformed=(-dest->getWorldTform().m).cofactor() * tformed;
if (src) tformed = (src->GetWorldTransform().m).cofactor() * tformed;
if (dest) tformed = (-dest->GetWorldTransform().m).cofactor() * tformed;
tformed.normalize();
}
@@ -1647,29 +1724,29 @@ float bbTFormedZ(){
}
float bbVectorYaw(float x, float y, float z) {
return Vector(x,y,z).yaw() * rtod;
return Vector(x, y, z).yaw() * s_radiansToDegrees;
}
float bbVectorPitch(float x, float y, float z) {
return Vector(x,y,z).pitch() * rtod;
return Vector(x, y, z).pitch() * s_radiansToDegrees;
}
float bbDeltaYaw(Entity *src, Entity *dest) {
float x=src->getWorldTform().m.k.yaw();
float y=(dest->getWorldTform().v-src->getWorldTform().v).yaw();
float x = src->GetWorldTransform().m.k.yaw();
float y = (dest->GetWorldTransform().v - src->GetWorldTransform().v).yaw();
float d = y - x;
if (d < -PI) d += TWOPI;
else if (d >= PI) d -= TWOPI;
return d*rtod;
return d*s_radiansToDegrees;
}
float bbDeltaPitch(Entity *src, Entity *dest) {
float x=src->getWorldTform().m.k.pitch();
float y=(dest->getWorldTform().v-src->getWorldTform().v).pitch();
float x = src->GetWorldTransform().m.k.pitch();
float y = (dest->GetWorldTransform().v - src->GetWorldTransform().v).pitch();
float d = y - x;
if (d < -PI) d += TWOPI;
else if (d >= PI) d -= TWOPI;
return d*rtod;
return d*s_radiansToDegrees;
}
///////////////////////////////
@@ -1683,7 +1760,7 @@ void bbResetEntity( Object *o ){
static void entityType(Entity *e, int type) {
e->getObject()->setCollisionType(type);
e->getObject()->reset();
for( Entity *p=e->children();p;p=p->successor() ){
for (Entity *p = e->GetChildren(); p; p = p->GetSuccessor()) {
entityType(p, type);
}
}
@@ -1798,7 +1875,7 @@ int bbCollisionTriangle( Object *o,int index ){
float bbEntityDistance(Entity *src, Entity *dest) {
debugEntity(src);
debugEntity(dest);
return src->getWorldPosition().distance( dest->getWorldPosition() );
return src->GetWorldPosition().distance(dest->GetWorldPosition());
}
////////////////////////////////////
@@ -1806,48 +1883,48 @@ float bbEntityDistance( Entity *src,Entity *dest ){
////////////////////////////////////
void bbMoveEntity(Entity *e, float x, float y, float z) {
debugEntity(e);
e->setLocalPosition( e->getLocalPosition()+e->getLocalRotation()*Vector(x,y,z) );
e->SetLocalPosition(e->GetLocalPosition() + e->GetLocalRotation()*Vector(x, y, z));
}
void bbTurnEntity(Entity *e, float p, float y, float r, int global) {
debugEntity(e);
global ?
e->setWorldRotation( rotationQuat( p*dtor,y*dtor,r*dtor )*e->getWorldRotation() ):
e->setLocalRotation( e->getLocalRotation()*rotationQuat( p*dtor,y*dtor,r*dtor ) );
e->SetWorldRotation(rotationQuat(p*s_degreesToRadians, y*s_degreesToRadians, r*s_degreesToRadians)*e->GetWorldRotation()) :
e->SetLocalRotation(e->GetLocalRotation()*rotationQuat(p*s_degreesToRadians, y*s_degreesToRadians, r*s_degreesToRadians));
}
void bbTranslateEntity(Entity *e, float x, float y, float z, int global) {
debugEntity(e);
global ?
e->setWorldPosition( e->getWorldPosition()+Vector( x,y,z ) ):
e->setLocalPosition( e->getLocalPosition()+Vector( x,y,z ) );
e->SetWorldPosition(e->GetWorldPosition() + Vector(x, y, z)) :
e->SetLocalPosition(e->GetLocalPosition() + Vector(x, y, z));
}
void bbPositionEntity(Entity *e, float x, float y, float z, int global) {
debugEntity(e);
global ?
e->setWorldPosition(Vector(x,y,z)):
e->setLocalPosition(Vector(x,y,z));
e->SetWorldPosition(Vector(x, y, z)) :
e->SetLocalPosition(Vector(x, y, z));
}
void bbScaleEntity(Entity *e, float x, float y, float z, int global) {
debugEntity(e);
global ?
e->setWorldScale(Vector(x,y,z)):
e->setLocalScale(Vector(x,y,z));
e->SetWorldScale(Vector(x, y, z)) :
e->SetLocalScale(Vector(x, y, z));
}
void bbRotateEntity(Entity *e, float p, float y, float r, int global) {
debugEntity(e);
global ?
e->setWorldRotation( rotationQuat( p*dtor,y*dtor,r*dtor ) ):
e->setLocalRotation( rotationQuat( p*dtor,y*dtor,r*dtor ) );
e->SetWorldRotation(rotationQuat(p*s_degreesToRadians, y*s_degreesToRadians, r*s_degreesToRadians)) :
e->SetLocalRotation(rotationQuat(p*s_degreesToRadians, y*s_degreesToRadians, r*s_degreesToRadians));
}
void bbPointEntity(Entity *e, Entity *t, float roll) {
if (debug) { debugEntity(e); debugEntity(t); }
Vector v=t->getWorldTform().v-e->getWorldTform().v;
e->setWorldRotation( rotationQuat( v.pitch(),v.yaw(),roll*dtor ) );
Vector v = t->GetWorldTransform().v - e->GetWorldTransform().v;
e->SetWorldRotation(rotationQuat(v.pitch(), v.yaw(), roll*s_degreesToRadians));
}
void bbAlignToVector(Entity *e, float nx, float ny, float nz, int axis, float rate) {
@@ -1856,7 +1933,7 @@ void bbAlignToVector( Entity *e,float nx,float ny,float nz,int axis,float rate
if (l <= FLT_EPSILON) return;
ax /= l;
Quat q=e->getWorldRotation();
Quat q = e->GetWorldRotation();
Vector tv = (axis == 1) ? q.i() : (axis == 2 ? q.j() : q.k());
float dp = ax.dot(tv);
@@ -1866,13 +1943,13 @@ void bbAlignToVector( Entity *e,float nx,float ny,float nz,int axis,float rate
if (dp <= -1 + FLT_EPSILON) {
float an = PI*rate / 2;
Vector cp = (axis == 1) ? q.j() : (axis == 2 ? q.k() : q.i());
e->setWorldRotation( Quat( cosf(an),cp*sinf(an) ) * q );
e->SetWorldRotation(Quat(cosf(an), cp*sinf(an)) * q);
return;
}
float an = acosf(dp)*rate / 2;
Vector cp = ax.cross(tv).normalized();
e->setWorldRotation( Quat( cosf(an),cp*sinf(an) ) * q );
e->SetWorldRotation(Quat(cosf(an), cp*sinf(an)) * q);
}
//////////////////////////
@@ -1880,7 +1957,7 @@ void bbAlignToVector( Entity *e,float nx,float ny,float nz,int axis,float rate
//////////////////////////
void bbNameEntity(Entity *e, BBStr *t) {
debugEntity(e);
e->setName( *t );
e->SetName(*t);
delete t;
}
@@ -1909,7 +1986,7 @@ BBStr *bbEntityClass( Entity *e ){
void bbClearWorld(int e, int b, int t) {
if (e) {
while( Entity::orphans() ) bbFreeEntity( Entity::orphans() );
while (Entity::GetEntityOrphans()) bbFreeEntity(Entity::GetEntityOrphans());
}
if (b) {
while (brush_set.size()) bbFreeBrush(*brush_set.begin());
+77 -5
View File
@@ -9,6 +9,10 @@
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="RelWithDebInfo|Win32">
<Configuration>RelWithDebInfo</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<SccProjectName />
@@ -23,10 +27,17 @@
<PlatformToolset>v140</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v140_xp</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v140_xp</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
@@ -37,6 +48,10 @@
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
@@ -46,15 +61,22 @@
<OutDir>..\#Build\$(ProjectName)\$(Configuration)-$(PlatformTarget)\</OutDir>
<IntDir>..\#Intermediate\$(ProjectName)\$(Configuration)-$(PlatformTarget)\</IntDir>
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(DXSDK_DIR)Include\;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
<LibraryPath>$(DXSDK_DIR)Lib\x86\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86</LibraryPath>
<IncludePath>C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\shared;C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\um;$(IncludePath)</IncludePath>
<LibraryPath>C:\Program Files (x86)\Windows Kits\10\Lib\10.0.14393.0\um\x86;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>..\#Build\$(ProjectName)\$(Configuration)-$(PlatformTarget)\</OutDir>
<IntDir>..\#Intermediate\$(ProjectName)\$(Configuration)-$(PlatformTarget)\</IntDir>
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(DXSDK_DIR)Include\;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
<LibraryPath>$(DXSDK_DIR)Lib\x86\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86</LibraryPath>
<IncludePath>C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\shared;C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\um;$(IncludePath)</IncludePath>
<LibraryPath>C:\Program Files (x86)\Windows Kits\10\Lib\10.0.14393.0\um\x86;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">
<OutDir>..\#Build\$(ProjectName)\$(Configuration)-$(PlatformTarget)\</OutDir>
<IntDir>..\#Intermediate\$(ProjectName)\$(Configuration)-$(PlatformTarget)\</IntDir>
<LinkIncremental>false</LinkIncremental>
<IncludePath>C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\shared;C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\um;$(IncludePath)</IncludePath>
<LibraryPath>C:\Program Files (x86)\Windows Kits\10\Lib\10.0.14393.0\um\x86;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@@ -99,6 +121,54 @@
<CallingConvention>StdCall</CallingConvention>
<ExceptionHandling>Async</ExceptionHandling>
<RemoveUnreferencedCodeData>false</RemoveUnreferencedCodeData>
<Optimization>Full</Optimization>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<WholeProgramOptimization>true</WholeProgramOptimization>
<StructMemberAlignment>4Bytes</StructMemberAlignment>
<BufferSecurityCheck>false</BufferSecurityCheck>
<EnableParallelCodeGeneration>true</EnableParallelCodeGeneration>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
<FloatingPointModel>Fast</FloatingPointModel>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAsManaged>false</CompileAsManaged>
<SDLCheck>
</SDLCheck>
<MultiProcessorCompilation>false</MultiProcessorCompilation>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
</ClCompile>
<ResourceCompile>
<Culture>0x0409</Culture>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
<Bscmake>
<SuppressStartupBanner>true</SuppressStartupBanner>
<OutputFile>.\Release\bbruntime.bsc</OutputFile>
</Bscmake>
<Lib>
<SuppressStartupBanner>true</SuppressStartupBanner>
<TargetMachine>MachineX86</TargetMachine>
<LinkTimeCodeGeneration>true</LinkTimeCodeGeneration>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">
<ClCompile>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>false</FunctionLevelLinking>
<SuppressStartupBanner>true</SuppressStartupBanner>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<ControlFlowGuard>false</ControlFlowGuard>
<ProgramDataBaseFileName>$(IntDir)vc$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>
<CallingConvention>StdCall</CallingConvention>
<ExceptionHandling>Async</ExceptionHandling>
<RemoveUnreferencedCodeData>false</RemoveUnreferencedCodeData>
</ClCompile>
<ResourceCompile>
<Culture>0x0409</Culture>
@@ -136,7 +206,9 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">std.h</PrecompiledHeaderFile>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">Create</PrecompiledHeader>
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">std.h</PrecompiledHeaderFile>
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">std.h</PrecompiledHeaderFile>
</ClCompile>
<ClCompile Include="userlibs.cpp" />
</ItemGroup>