From 7bd0b17cb73ee4c28bffc3925c65eb7b9df24da0 Mon Sep 17 00:00:00 2001 From: Allanis Date: Sun, 19 Nov 2017 00:09:17 +0000 Subject: [PATCH] [Add] Flag for invisible stuff. --- src/info_view.cpp | 1 + src/sbre/brender.cpp | 5 +++++ src/sbre/primfunc.cpp | 2 ++ src/sbre/sbre.h | 4 ++-- src/sbre/sbre_int.h | 15 ++++++++------- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/info_view.cpp b/src/info_view.cpp index 7b1bbb6..0fa4889 100644 --- a/src/info_view.cpp +++ b/src/info_view.cpp @@ -89,6 +89,7 @@ void InfoView::Draw3D(void) { m.z1 = -rot[2]; m.z2 = -rot[6]; m.z3 = rot[10]; const ShipType& stype = L3D::player->GetShipType(); + sbreSetDepthRange(L3D::GetScrWidth()*0.5f, 0.0f, 1.0f); sbreRenderModel(&p, &m, stype.sbreModel, ¶ms); glPopAttrib(); } diff --git a/src/sbre/brender.cpp b/src/sbre/brender.cpp index d275572..7203614 100644 --- a/src/sbre/brender.cpp +++ b/src/sbre/brender.cpp @@ -88,6 +88,11 @@ static void ResolveVertices(Model* pMod, Vector* pRes, ObjParams* pObjParam) { static float g_dn, g_df, g_sd; static int g_wireframe = 0; +float SBRE_ZBIAS = 0; + +void sbreSetZBias(float zbias) { + SBRE_ZBIAS = zbias; +} void sbreSetDepthRange(float sd, float dn, float df) { glDepthRange(dn+SBRE_ZBIAS, df); diff --git a/src/sbre/primfunc.cpp b/src/sbre/primfunc.cpp index 37570cf..23b0827 100644 --- a/src/sbre/primfunc.cpp +++ b/src/sbre/primfunc.cpp @@ -102,6 +102,7 @@ static int PrimFuncZBias(uint16* pData, Model* pMod, RState* pState) { } static int PrimFuncTriFlat(uint16* pData, Model* pMod, RState* pState) { + if(pData[0] & RFLAG_INVISIBLE) return 4; Vector* pVtx = pState->pVtx; Vector* pVec; Vector norm, tv1, tv2; @@ -133,6 +134,7 @@ static int PrimFuncTriFlat(uint16* pData, Model* pMod, RState* pState) { } static int PrimFuncQuadFlat(uint16* pData, Model* pMod, RState* pState) { + if(pData[0] & RFLAG_INVISIBLE) return 5; Vector* pVtx = pState->pVtx; Vector* pVec; Vector norm, tv1, tv2; diff --git a/src/sbre/sbre.h b/src/sbre/sbre.h index 22a45f6..8c6ee81 100644 --- a/src/sbre/sbre.h +++ b/src/sbre/sbre.h @@ -1,5 +1,4 @@ #pragma once -#include "jjtypes.h" #include "jjvector.h" enum animsrc { @@ -16,7 +15,7 @@ enum animflag { struct ObjParams { float pAnim[10]; - uint8 pFlag[10]; + unsigned char pFlag[10]; float linthrust[3]; /* 1.0 to -1.0 */ float angthrust[3]; /* 1.0 to -1.0 */ @@ -46,6 +45,7 @@ struct CollMesh { * sd is screen depth in pixels, dn and df are like glDepthRange params. */ void sbreSetDepthRange(float sd, float dn, float df); +void sbreSetZBias(float zbias); void sbreSetViewport(int w, int h, float d, float zn, float zf, float dn, float df); void sbreSetDirLight(float* pColor, float* pDir); void sbreSetWireframe(int val); diff --git a/src/sbre/sbre_int.h b/src/sbre/sbre_int.h index efccf09..d40ed3a 100644 --- a/src/sbre/sbre_int.h +++ b/src/sbre/sbre_int.h @@ -149,16 +149,17 @@ enum primtype { extern int (*pPrimFuncTable[])(uint16*, Model*, RState*); extern int (*pCollFuncTable[])(uint16*, Model*, RState*); -static const int RFLAG_XREF = 0x8000; -static const int SUBOBJ_THRUST = 0x4000; +static const int RFLAG_XREF = 0x8000; +static const int RFLAG_INVISIBLE = 0x4000; +static const int SUBOBJ_THRUST = 0x4000; -static const int THRUST_XREF = 0x8000; -static const int THRUST_NOANG = 0x4000; +static const int THRUST_XREF = 0x8000; +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_AMB = 0.3f; +static const float SBRE_AMB = 0.3f; + +extern float SBRE_ZBIAS; enum comptype { COMP_END = 0,