[Add] Depth sorting? Two odd things happened here. Magically lasers started working! YEYY! But also Earth disapeared. Nayy!
This commit is contained in:
parent
c19e9520b7
commit
64fefe0555
@ -89,6 +89,11 @@ static void ResolveVertices(Model* pMod, Vector* pRes, ObjParams* pObjParam) {
|
|||||||
static float g_dn, g_df, g_sd;
|
static float g_dn, g_df, g_sd;
|
||||||
static int g_wireframe = 0;
|
static int g_wireframe = 0;
|
||||||
|
|
||||||
|
void sbreSetDepthRange(float sd, float dn, float df) {
|
||||||
|
glDepthRange(dn+SBRE_ZBIAS, df);
|
||||||
|
g_dn = dn; g_df = df; g_sd = sd;
|
||||||
|
}
|
||||||
|
|
||||||
void sbreSetViewport(int w, int h, float d, float zn, float zf, float dn, float df) {
|
void sbreSetViewport(int w, int h, float d, float zn, float zf, float dn, float df) {
|
||||||
glViewport(0, 0, w, h);
|
glViewport(0, 0, w, h);
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ static int CollFuncMatVar(uint16* pData, Model* pMod, RState* pState) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int CollFuncZBias(uint16* pData, Model* pMod, RState* pState) {
|
static int CollFuncZBias(uint16* pData, Model* pMod, RState* pState) {
|
||||||
return 3;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int CollFuncTriFlat(uint16* pData, Model* pMod, RState* pState) {
|
static int CollFuncTriFlat(uint16* pData, Model* pMod, RState* pState) {
|
||||||
|
@ -323,17 +323,17 @@ static uint16 ship1data[] = {
|
|||||||
PTYPE_SUBOBJECT, 0x8000, SUB_WING1, 26, 52, 2, 100,
|
PTYPE_SUBOBJECT, 0x8000, SUB_WING1, 26, 52, 2, 100,
|
||||||
|
|
||||||
PTYPE_MATFIXED, 20, 20, 20, 0, 0, 0, 100, 0, 0, 0,
|
PTYPE_MATFIXED, 20, 20, 20, 0, 0, 0, 100, 0, 0, 0,
|
||||||
PTYPE_ZBIAS, 54, 5,
|
PTYPE_ZBIAS, 14, 54, 5,
|
||||||
PTYPE_TEXT, 0, 0x8000, 14, 54, 5, 500, 200, 1000,
|
PTYPE_TEXT, 0, 0x8000, 14, 54, 5, 500, 200, 1000,
|
||||||
PTYPE_ZBIAS, 55, 5,
|
PTYPE_ZBIAS, 12, 55, 5,
|
||||||
PTYPE_TEXT, 0, 0x8000, 12, 55, 2, 1100, 200, 1000,
|
PTYPE_TEXT, 0, 0x8000, 12, 55, 2, 1100, 200, 1000,
|
||||||
|
|
||||||
PTYPE_ZBIAS, 4, 5,
|
PTYPE_ZBIAS, 40, 4, 5,
|
||||||
PTYPE_SUBOBJECT, 0, SUB_NWUNIT, 40, 4, 5, 200,
|
PTYPE_SUBOBJECT, 0, SUB_NWUNIT, 40, 4, 5, 200,
|
||||||
PTYPE_SUBOBJECT, 0, SUB_MWUNIT, 41, 4, 5, 200,
|
PTYPE_SUBOBJECT, 0, SUB_MWUNIT, 41, 4, 5, 200,
|
||||||
|
|
||||||
// PTYPE_TEXT, -1, -1, 12, 0, 1, 5000,
|
// PTYPE_TEXT, -1, -1, 12, 0, 1, 5000,
|
||||||
PTYPE_ZBIAS, 0x8000, 5,
|
PTYPE_ZBIAS, 0x8000, 0, 0,
|
||||||
|
|
||||||
PTYPE_END,
|
PTYPE_END,
|
||||||
};
|
};
|
||||||
@ -587,7 +587,7 @@ static uint16 ship2data[] = {
|
|||||||
COMP_HERMITE, 16, 0, 47, 50,
|
COMP_HERMITE, 16, 0, 47, 50,
|
||||||
COMP_END,
|
COMP_END,
|
||||||
|
|
||||||
PTYPE_ZBIAS, 5, 5,
|
PTYPE_ZBIAS, 72, 5, 5,
|
||||||
PTYPE_MATFIXED, 30, 30, 30, 30, 30, 30, 200, 0, 0, 0,
|
PTYPE_MATFIXED, 30, 30, 30, 30, 30, 30, 200, 0, 0, 0,
|
||||||
PTYPE_TUBE | RFLAG_XREF, 8, 12, 72, 76, 1, 250, 200,
|
PTYPE_TUBE | RFLAG_XREF, 8, 12, 72, 76, 1, 250, 200,
|
||||||
PTYPE_MATANIM, AFUNC_THRUSTPULSE,
|
PTYPE_MATANIM, AFUNC_THRUSTPULSE,
|
||||||
@ -595,21 +595,23 @@ static uint16 ship2data[] = {
|
|||||||
0, 0, 0, 0, 0, 0, 100, 0, 0, 50,
|
0, 0, 0, 0, 0, 0, 100, 0, 0, 50,
|
||||||
PTYPE_CIRCLE | RFLAG_XREF, 9, 12, 72, 5, 1, 200,
|
PTYPE_CIRCLE | RFLAG_XREF, 9, 12, 72, 5, 1, 200,
|
||||||
|
|
||||||
PTYPE_ZBIAS, 120, 5,
|
PTYPE_ZBIAS, 77, 120, 5,
|
||||||
// PTYPE_MATFIXED, 30, 30, 30, 0, 0, 0, 100, 0, 0, 0,
|
// PTYPE_MATFIXED, 30, 30, 30, 0, 0, 0, 100, 0, 0, 0,
|
||||||
PTYPE_QUADFLAT | RFLAG_XREF, 77, 78, 80, 79,
|
PTYPE_QUADFLAT | RFLAG_XREF, 77, 78, 80, 79,
|
||||||
|
|
||||||
PTYPE_MATFIXED, 20, 20, 20, 0, 0, 0, 100, 0, 0, 0,
|
PTYPE_MATFIXED, 20, 20, 20, 0, 0, 0, 100, 0, 0, 0,
|
||||||
PTYPE_ZBIAS, 95, 5,
|
PTYPE_ZBIAS, 68, 95, 5,
|
||||||
PTYPE_TEXT, 0, 0x8000, 68, 95, 2, 1900, 50, 250,
|
PTYPE_TEXT, 0, 0x8000, 68, 95, 2, 1900, 50, 250,
|
||||||
PTYPE_ZBIAS, 96, 5,
|
PTYPE_ZBIAS, 97, 96, 5,
|
||||||
PTYPE_TEXT, 0, 0x8000, 97, 96, 5, 400, 50, 250,
|
PTYPE_TEXT, 0, 0x8000, 97, 96, 5, 400, 50, 250,
|
||||||
|
|
||||||
PTYPE_ZBIAS, 4, 5,
|
PTYPE_ZBIAS, 73, 4, 5,
|
||||||
PTYPE_SUBOBJECT, 0, SUB_NWUNIT, 73, 4, 5, 100,
|
PTYPE_SUBOBJECT, 0, SUB_NWUNIT, 73, 4, 5, 100,
|
||||||
|
PTYPE_ZBIAS, 74, 4, 5,
|
||||||
PTYPE_SUBOBJECT, 0, SUB_NWUNIT, 74, 4, 5, 64,
|
PTYPE_SUBOBJECT, 0, SUB_NWUNIT, 74, 4, 5, 64,
|
||||||
PTYPE_SUBOBJECT, 0, SUB_NWUNIT, 75, 4, 5, 64,
|
PTYPE_SUBOBJECT, 0, SUB_NWUNIT, 75, 4, 5, 64,
|
||||||
|
|
||||||
|
PTYPE_ZBIAS, 0x8000, 0, 0,
|
||||||
PTYPE_END,
|
PTYPE_END,
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -873,7 +875,7 @@ static uint16 ship3data[] = {
|
|||||||
COMP_LINE, 12, 4,
|
COMP_LINE, 12, 4,
|
||||||
COMP_END,
|
COMP_END,
|
||||||
|
|
||||||
PTYPE_ZBIAS, 5, 5,
|
PTYPE_ZBIAS, 33, 5, 5,
|
||||||
PTYPE_MATFIXED, 30, 30, 30, 30, 30, 30, 200, 0, 0, 0,
|
PTYPE_MATFIXED, 30, 30, 30, 30, 30, 30, 200, 0, 0, 0,
|
||||||
PTYPE_TUBE | RFLAG_XREF, 4, 12, 33, 34, 1, 300, 250,
|
PTYPE_TUBE | RFLAG_XREF, 4, 12, 33, 34, 1, 300, 250,
|
||||||
PTYPE_MATANIM, AFUNC_THRUSTPULSE,
|
PTYPE_MATANIM, AFUNC_THRUSTPULSE,
|
||||||
@ -891,11 +893,12 @@ static uint16 ship3data[] = {
|
|||||||
PTYPE_ZBIAS, 96, 5,
|
PTYPE_ZBIAS, 96, 5,
|
||||||
PTYPE_TEXT, 0, 0x8000, 97, 96, 5, 400, 50, 250,
|
PTYPE_TEXT, 0, 0x8000, 97, 96, 5, 400, 50, 250,
|
||||||
*/
|
*/
|
||||||
PTYPE_ZBIAS, 4, 5,
|
PTYPE_ZBIAS, 35, 4, 5,
|
||||||
PTYPE_SUBOBJECT, 0, SUB_NWUNIT, 35, 4, 5, 100,
|
PTYPE_SUBOBJECT, 0, SUB_NWUNIT, 35, 4, 5, 100,
|
||||||
PTYPE_SUBOBJECT, 0, SUB_MWUNIT, 36, 4, 5, 100,
|
PTYPE_SUBOBJECT, 0, SUB_MWUNIT, 36, 4, 5, 100,
|
||||||
PTYPE_SUBOBJECT, 0, SUB_MWUNIT, 37, 4, 5, 100,
|
PTYPE_SUBOBJECT, 0, SUB_MWUNIT, 37, 4, 5, 100,
|
||||||
|
|
||||||
|
PTYPE_ZBIAS, 0x8000, 0, 0,
|
||||||
PTYPE_END,
|
PTYPE_END,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -995,12 +998,12 @@ static uint16 ship4data[] = {
|
|||||||
PTYPE_EXTRUSION, 9, 8, 20, 21, 1, 85, 10,
|
PTYPE_EXTRUSION, 9, 8, 20, 21, 1, 85, 10,
|
||||||
|
|
||||||
PTYPE_MATFIXED, 20, 20, 20, 0, 0, 0, 100, 0, 0, 0,
|
PTYPE_MATFIXED, 20, 20, 20, 0, 0, 0, 100, 0, 0, 0,
|
||||||
PTYPE_ZBIAS, 0, 5,
|
PTYPE_ZBIAS, 32, 0, 5,
|
||||||
PTYPE_TEXT, 0, 0x8000, 32, 0, 2, 300, 250, 400,
|
PTYPE_TEXT, 0, 0x8000, 32, 0, 2, 300, 250, 400,
|
||||||
PTYPE_ZBIAS, 3, 5,
|
PTYPE_ZBIAS, 33, 3, 5,
|
||||||
PTYPE_TEXT, 0, 0x8000, 33, 3, 5, 300, 250, 400,
|
PTYPE_TEXT, 0, 0x8000, 33, 3, 5, 300, 250, 400,
|
||||||
|
|
||||||
PTYPE_ZBIAS, 4, 5,
|
PTYPE_ZBIAS, 34, 4, 5,
|
||||||
PTYPE_SUBOBJECT, 0, SUB_MWUNIT, 34, 4, 5, 60,
|
PTYPE_SUBOBJECT, 0, SUB_MWUNIT, 34, 4, 5, 60,
|
||||||
PTYPE_SUBOBJECT, 0, SUB_MWUNIT, 35, 4, 5, 60,
|
PTYPE_SUBOBJECT, 0, SUB_MWUNIT, 35, 4, 5, 60,
|
||||||
PTYPE_SUBOBJECT, 0, SUB_MWUNIT, 36, 4, 5, 50,
|
PTYPE_SUBOBJECT, 0, SUB_MWUNIT, 36, 4, 5, 50,
|
||||||
@ -1008,9 +1011,10 @@ static uint16 ship4data[] = {
|
|||||||
PTYPE_SUBOBJECT, 0, SUB_MWUNIT, 38, 4, 5, 50,
|
PTYPE_SUBOBJECT, 0, SUB_MWUNIT, 38, 4, 5, 50,
|
||||||
PTYPE_SUBOBJECT, 0, SUB_MWUNIT, 39, 4, 5, 50,
|
PTYPE_SUBOBJECT, 0, SUB_MWUNIT, 39, 4, 5, 50,
|
||||||
|
|
||||||
PTYPE_ZBIAS, 1, 5,
|
PTYPE_ZBIAS, 40, 1, 5,
|
||||||
PTYPE_SUBOBJECT, 0x8000, SUB_DISH, 40, 1, 100, 200,
|
PTYPE_SUBOBJECT, 0x8000, SUB_DISH, 40, 1, 100, 200,
|
||||||
|
|
||||||
|
PTYPE_ZBIAS, 0x8000, 0, 0,
|
||||||
PTYPE_END,
|
PTYPE_END,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -85,15 +85,20 @@ static int PrimFuncMatVar(uint16* pData, Model* pMod, RState* pState) {
|
|||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
uint16 PFUNC_ZBIAS
|
uint16 PFUNC_ZBIAS
|
||||||
uint16 offset /* To test if nearer - 0x8000 = reset. */
|
uint16 pos /* To test if nearer - 0x8000 = reset.
|
||||||
|
uint16 norm
|
||||||
uint16 units /* Integer units. not used. */
|
uint16 units /* Integer units. not used. */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int PrimFuncZBias(uint16* pData, Model* pMod, RState* pState) {
|
static int PrimFuncZBias(uint16* pData, Model* pMod, RState* pState) {
|
||||||
if(pData[1] & 0x8000) glDepthRange (pState->dn+SBRE_ZBIAS, pState->df);
|
if(pData[1] & 0x8000) glDepthRange (pState->dn+SBRE_ZBIAS, pState->df);
|
||||||
else if(VecDot(pState->pVtx+pData[1], &pState->campos) > 0.0f)
|
else {
|
||||||
|
Vector tv;
|
||||||
|
VecSub(&pState->campos, pState->pVtx+pData[1], &tv);
|
||||||
|
if(VecDot(&tv, pState->pVtx+pData[2]) > 0.0f)
|
||||||
glDepthRange(pState->dn, pState->df-SBRE_ZBIAS);
|
glDepthRange(pState->dn, pState->df-SBRE_ZBIAS);
|
||||||
return 3;
|
}
|
||||||
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int PrimFuncTriFlat(uint16* pData, Model* pMod, RState* pState) {
|
static int PrimFuncTriFlat(uint16* pData, Model* pMod, RState* pState) {
|
||||||
|
@ -41,10 +41,19 @@ struct CollMesh {
|
|||||||
int cflag;
|
int cflag;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If you don't call SetDepthRange, z bias and LOD will fail.
|
||||||
|
* sd is screen depth in pixels, dn and df are like glDepthRange params.
|
||||||
|
*/
|
||||||
|
void sbreSetDepthRange(float sd, float dn, float df);
|
||||||
void sbreSetViewport(int w, int h, float d, float zn, float zf, float dn, float df);
|
void sbreSetViewport(int w, int h, float d, float zn, float zf, float dn, float df);
|
||||||
void sbreSetDirLight(float* pColor, float* pDir);
|
void sbreSetDirLight(float* pColor, float* pDir);
|
||||||
void sbreSetWireframe(int val);
|
void sbreSetWireframe(int val);
|
||||||
void sbreRenderModel(Vector* pPos, Matrix* pOrient, int model, ObjParams* pParam,
|
void sbreRenderModel(Vector* pPos, Matrix* pOrient, int model, ObjParams* pParam,
|
||||||
float s=1.0f, Vector* pCompos=0);
|
float s=1.0f, Vector* pCompos=0);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Will preserve and realloc pointers in pCMesh.
|
||||||
|
*/
|
||||||
void sbreGenCollMesh(CollMesh* pCMesh, int model, ObjParams* pParam, float s = 1.0f);
|
void sbreGenCollMesh(CollMesh* pCMesh, int model, ObjParams* pParam, float s = 1.0f);
|
||||||
|
|
||||||
|
@ -155,6 +155,8 @@ static const int SUBOBJ_THRUST = 0x4000;
|
|||||||
static const int THRUST_XREF = 0x8000;
|
static const int THRUST_XREF = 0x8000;
|
||||||
static const int THRUST_NOANG = 0x4000;
|
static const int THRUST_NOANG = 0x4000;
|
||||||
|
|
||||||
|
/* Proper value for 16-bit depth buffer. */
|
||||||
|
//static const float SBRE_ZBIAS = 0.00002f;
|
||||||
static const float SBRE_ZBIAS = 0.00002f;
|
static const float SBRE_ZBIAS = 0.00002f;
|
||||||
static const float SBRE_AMB = 0.3f;
|
static const float SBRE_AMB = 0.3f;
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "l3d.h"
|
#include "l3d.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "star_system.h"
|
#include "star_system.h"
|
||||||
|
#include "sbre/sbre.h"
|
||||||
|
|
||||||
dWorldID Space::world;
|
dWorldID Space::world;
|
||||||
std::list<Body*> Space::bodies;
|
std::list<Body*> Space::bodies;
|
||||||
@ -220,6 +221,10 @@ void Space::Render(const Frame* cam_frame) {
|
|||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
sort(bz, bz+bodies.size(), body_zsort_compare());
|
sort(bz, bz+bodies.size(), body_zsort_compare());
|
||||||
|
|
||||||
|
/* Probably the right place for this when partitioning is done. */
|
||||||
|
sbreSetDepthRange(L3D::GetScrWidth()*0.5f, 0.0f, 1.0f);
|
||||||
|
|
||||||
for(unsigned int i = 0; i < bodies.size(); i++) {
|
for(unsigned int i = 0; i < bodies.size(); i++) {
|
||||||
bz[i].b->Render(cam_frame);
|
bz[i].b->Render(cam_frame);
|
||||||
}
|
}
|
||||||
|
@ -60,10 +60,9 @@ void WorldView::Draw3D(void) {
|
|||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
/* Wth did I give these functions large names for.. :/ */
|
/* Wth did I give these functions large names for.. :/ */
|
||||||
glFrustum(-L3D::GetScrWidth()*.5, L3D::GetScrWidth()*.5,
|
float fracH = L3D::GetScrHeight() * 0.5f / L3D::GetScrWidth();
|
||||||
-L3D::GetScrHeight()*.5, L3D::GetScrHeight()*.5,
|
glFrustum(-0.5, 0.5, -fracH, fracH, 1.0f, 1000.0f);
|
||||||
L3D::GetScrWidth()*.5, 100000);
|
//glDepthRange(-10, -100000); /* Uh, What?! */
|
||||||
glDepthRange(-10, -100000);
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glClearColor(0, 0, 0, 0);
|
glClearColor(0, 0, 0, 0);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
Loading…
Reference in New Issue
Block a user