From e6ef2f12dea9139c4fb303992c2d8f906e302a49 Mon Sep 17 00:00:00 2001 From: aap Date: Tue, 5 Jan 2021 11:12:48 +0100 Subject: first version of new renderer --- src/rw/VisibilityPlugins.cpp | 20 ++++++++++++++++++++ src/rw/VisibilityPlugins.h | 3 +++ 2 files changed, 23 insertions(+) (limited to 'src/rw') diff --git a/src/rw/VisibilityPlugins.cpp b/src/rw/VisibilityPlugins.cpp index 916696de..32461d1c 100644 --- a/src/rw/VisibilityPlugins.cpp +++ b/src/rw/VisibilityPlugins.cpp @@ -2,6 +2,7 @@ #include "RwHelper.h" #include "templates.h" +#include "main.h" #include "Entity.h" #include "ModelInfo.h" #include "Lights.h" @@ -14,6 +15,9 @@ CLinkList CVisibilityPlugins::m_alphaList; CLinkList CVisibilityPlugins::m_alphaEntityList; +#ifdef NEW_RENDERER +CLinkList CVisibilityPlugins::m_alphaBuildingList; +#endif int32 CVisibilityPlugins::ms_atomicPluginOffset = -1; int32 CVisibilityPlugins::ms_framePluginOffset = -1; @@ -158,6 +162,12 @@ CVisibilityPlugins::Initialise(void) #endif // ASPECT_RATIO_SCALE m_alphaEntityList.head.item.sort = 0.0f; m_alphaEntityList.tail.item.sort = 100000000.0f; + +#ifdef NEW_RENDERER + m_alphaBuildingList.Init(NUMALPHAENTITYLIST); + m_alphaBuildingList.head.item.sort = 0.0f; + m_alphaBuildingList.tail.item.sort = 100000000.0f; +#endif } void @@ -165,12 +175,18 @@ CVisibilityPlugins::Shutdown(void) { m_alphaList.Shutdown(); m_alphaEntityList.Shutdown(); +#ifdef NEW_RENDERER + m_alphaBuildingList.Shutdown(); +#endif } void CVisibilityPlugins::InitAlphaEntityList(void) { m_alphaEntityList.Clear(); +#ifdef NEW_RENDERER + m_alphaBuildingList.Clear(); +#endif } bool @@ -179,6 +195,10 @@ CVisibilityPlugins::InsertEntityIntoSortedList(CEntity *e, float dist) AlphaObjectInfo item; item.entity = e; item.sort = dist; +#ifdef NEW_RENDERER + if(gbNewRenderer && e->IsBuilding()) + return !!m_alphaBuildingList.InsertSorted(item); +#endif bool ret = !!m_alphaEntityList.InsertSorted(item); // if(!ret) // printf("list full %d\n", m_alphaEntityList.Count()); diff --git a/src/rw/VisibilityPlugins.h b/src/rw/VisibilityPlugins.h index 0721dfcc..f092de5a 100644 --- a/src/rw/VisibilityPlugins.h +++ b/src/rw/VisibilityPlugins.h @@ -22,6 +22,9 @@ public: static CLinkList m_alphaList; static CLinkList m_alphaEntityList; +#ifdef NEW_RENDERER + static CLinkList m_alphaBuildingList; +#endif static RwCamera *ms_pCamera; static RwV3d *ms_pCameraPosn; static float ms_cullCompsDist; -- cgit v1.2.3 From 48ce6151f919d14731cfa79c1b814786b123a80b Mon Sep 17 00:00:00 2001 From: aap Date: Tue, 12 Jan 2021 18:55:14 +0100 Subject: fix building with PED_SKIN --- src/rw/RwHelper.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/rw') diff --git a/src/rw/RwHelper.cpp b/src/rw/RwHelper.cpp index 4ee3a0b3..dd356b96 100644 --- a/src/rw/RwHelper.cpp +++ b/src/rw/RwHelper.cpp @@ -2,6 +2,7 @@ #define WITHD3D #endif #include "common.h" +#include #include "RwHelper.h" #include "Timecycle.h" -- cgit v1.2.3 From 57201187de74da42437dfa984a6cd36fe663a5e4 Mon Sep 17 00:00:00 2001 From: erorcun Date: Wed, 13 Jan 2021 14:22:31 +0300 Subject: Fix build without FIX_BUGS, divide to 0 fixes --- src/rw/MemoryMgr.cpp | 2 +- src/rw/RwHelper.cpp | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src/rw') diff --git a/src/rw/MemoryMgr.cpp b/src/rw/MemoryMgr.cpp index e2f6f144..2379692c 100644 --- a/src/rw/MemoryMgr.cpp +++ b/src/rw/MemoryMgr.cpp @@ -93,7 +93,7 @@ MemoryMgrFree(void *ptr) void * RwMallocAlign(RwUInt32 size, RwUInt32 align) { -#ifdef FIX_BUGS +#if defined (FIX_BUGS) || defined(FIX_BUGS_64) uintptr ptralign = align-1; void *mem = (void *)MemoryMgrMalloc(size + sizeof(uintptr) + ptralign); diff --git a/src/rw/RwHelper.cpp b/src/rw/RwHelper.cpp index dd356b96..d004656c 100644 --- a/src/rw/RwHelper.cpp +++ b/src/rw/RwHelper.cpp @@ -291,7 +291,8 @@ SkinGetBonePositionsToTable(RpClump *clump, RwV3d *boneTable) parent = stack[sp--]; else parent = i; - assert(parent >= 0 && parent < numBones); + + //assert(parent >= 0 && parent < numBones); } } @@ -299,7 +300,7 @@ RpHAnimAnimation* HAnimAnimationCreateForHierarchy(RpHAnimHierarchy *hier) { int i; -#ifdef FIX_BUGS +#if defined FIX_BUGS || defined LIBRW int numNodes = hier->numNodes*2; // you're supposed to have at least two KFs per node #else int numNodes = hier->numNodes; @@ -313,7 +314,7 @@ HAnimAnimationCreateForHierarchy(RpHAnimHierarchy *hier) frame->q.real = 1.0f; frame->q.imag.x = frame->q.imag.y = frame->q.imag.z = 0.0f; frame->t.x = frame->t.y = frame->t.z = 0.0f; -#ifdef FIX_BUGS +#if defined FIX_BUGS || defined LIBRW // times are subtracted and divided giving NaNs // so they can't both be 0 frame->time = i/hier->numNodes; @@ -401,7 +402,7 @@ CameraSize(RwCamera * camera, RwRect * rect, RwRaster *zRaster; // BUG: game just changes camera raster's sizes, but this is a hack -#ifdef FIX_BUGS +#if defined FIX_BUGS || defined LIBRW /* * Destroy rasters... */ -- cgit v1.2.3 From 5a47379bf5f011a65c1d0f88a0cb5f2130feb9db Mon Sep 17 00:00:00 2001 From: erorcun Date: Sat, 16 Jan 2021 16:44:59 +0300 Subject: Includes overhaul, fix some compiler warnings --- src/rw/RwHelper.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/rw') diff --git a/src/rw/RwHelper.cpp b/src/rw/RwHelper.cpp index d004656c..65e342ed 100644 --- a/src/rw/RwHelper.cpp +++ b/src/rw/RwHelper.cpp @@ -1,6 +1,4 @@ -#if defined RW_D3D9 || defined RWLIBS #define WITHD3D -#endif #include "common.h" #include -- cgit v1.2.3 From c67273e92a60e50d67d8146f6a150a5b39a2a641 Mon Sep 17 00:00:00 2001 From: aap Date: Thu, 21 Jan 2021 22:30:20 +0100 Subject: fixed anisotropic filtering; updated librw --- src/rw/TexRead.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/rw') diff --git a/src/rw/TexRead.cpp b/src/rw/TexRead.cpp index d0addcca..c009af96 100644 --- a/src/rw/TexRead.cpp +++ b/src/rw/TexRead.cpp @@ -2,6 +2,9 @@ #pragma warning( disable : 4005) #pragma warning( pop ) #include "common.h" +#ifdef ANISOTROPIC_FILTERING +#include "rpanisot.h" +#endif #include "crossplatform.h" #include "platform.h" @@ -48,6 +51,12 @@ RwTextureGtaStreamRead(RwStream *stream) texLoadTime = (texNumLoaded * texLoadTime + (float)CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond() - preloadTime) / (float)(texNumLoaded+1); texNumLoaded++; } + +#ifdef ANISOTROPIC_FILTERING + if(tex && RpAnisotGetMaxSupportedMaxAnisotropy() > 1) // BUG? this was RpAnisotTextureGetMaxAnisotropy, but that doesn't make much sense + RpAnisotTextureSetMaxAnisotropy(tex, RpAnisotGetMaxSupportedMaxAnisotropy()); +#endif + return tex; } -- cgit v1.2.3 From d2cf090ace79720770e4ad3d5a1ae6f7a53286b7 Mon Sep 17 00:00:00 2001 From: GaryOderNichts <12049776+GaryOderNichts@users.noreply.github.com> Date: Wed, 27 Jan 2021 23:05:46 +0100 Subject: Fix texture conversion box --- src/rw/TexRead.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/rw') diff --git a/src/rw/TexRead.cpp b/src/rw/TexRead.cpp index c009af96..98e7d180 100644 --- a/src/rw/TexRead.cpp +++ b/src/rw/TexRead.cpp @@ -1,6 +1,7 @@ #pragma warning( push ) #pragma warning( disable : 4005) #pragma warning( pop ) +#define FORCE_PC_SCALING #include "common.h" #ifdef ANISOTROPIC_FILTERING #include "rpanisot.h" -- cgit v1.2.3 From da378077f78a1773a6c4bf5a768c6ebb5a7c75b5 Mon Sep 17 00:00:00 2001 From: withmorten Date: Sun, 31 Jan 2021 02:08:42 +0100 Subject: renderer fix from miami --- src/rw/VisibilityPlugins.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/rw') diff --git a/src/rw/VisibilityPlugins.cpp b/src/rw/VisibilityPlugins.cpp index 32461d1c..051a6883 100644 --- a/src/rw/VisibilityPlugins.cpp +++ b/src/rw/VisibilityPlugins.cpp @@ -192,6 +192,10 @@ CVisibilityPlugins::InitAlphaEntityList(void) bool CVisibilityPlugins::InsertEntityIntoSortedList(CEntity *e, float dist) { +#ifdef FIX_BUGS + if (!e->m_rwObject) return true; +#endif + AlphaObjectInfo item; item.entity = e; item.sort = dist; -- cgit v1.2.3 From 9db87fc6365ee76f3281ca2474f92ec4f155920d Mon Sep 17 00:00:00 2001 From: aap Date: Thu, 18 Feb 2021 12:21:47 +0100 Subject: add debug render groups --- src/rw/VisibilityPlugins.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/rw') diff --git a/src/rw/VisibilityPlugins.cpp b/src/rw/VisibilityPlugins.cpp index 051a6883..9ea5b11c 100644 --- a/src/rw/VisibilityPlugins.cpp +++ b/src/rw/VisibilityPlugins.cpp @@ -293,6 +293,7 @@ CVisibilityPlugins::RenderFadingEntities(void) continue; #endif mi = (CSimpleModelInfo *)CModelInfo::GetModelInfo(e->GetModelIndex()); + #ifdef FIX_BUGS if(mi->GetModelType() == MITYPE_SIMPLE && mi->m_noZwrite) #else @@ -308,7 +309,9 @@ CVisibilityPlugins::RenderFadingEntities(void) DeActivateDirectional(); SetAmbientColours(); e->bImBeingRendered = true; + PUSH_RENDERGROUP(mi->GetModelName()); RenderFadingAtomic((RpAtomic*)e->m_rwObject, node->item.sort); + POP_RENDERGROUP(); e->bImBeingRendered = false; }else CRenderer::RenderOneNonRoad(e); -- cgit v1.2.3 From 253021866c266d8cf8d18241d3c3f330bff9ed06 Mon Sep 17 00:00:00 2001 From: aap Date: Thu, 18 Feb 2021 13:08:22 +0100 Subject: d3d9 debug render groups --- src/rw/RwHelper.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/rw') diff --git a/src/rw/RwHelper.cpp b/src/rw/RwHelper.cpp index 65e342ed..e98b58f6 100644 --- a/src/rw/RwHelper.cpp +++ b/src/rw/RwHelper.cpp @@ -113,6 +113,30 @@ SetCullMode(uint32 mode) RwRenderStateSet(rwRENDERSTATECULLMODE, (void*)rwCULLMODECULLNONE); } +#ifndef FINAL +void +PushRendergroup(const char *name) +{ +#if defined(RW_OPENGL) + glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, name); +#elif defined(RW_D3D9) + static WCHAR tmp[256]; + MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, -1, tmp, sizeof(tmp)); + D3DPERF_BeginEvent(0xFFFFFFFF, tmp); +#endif +} + +void +PopRendergroup(void) +{ +#if defined(RW_OPENGL) + glPopDebugGroup(); +#elif defined(RW_D3D9) + D3DPERF_EndEvent(); +#endif +} +#endif + RwFrame* GetFirstFrameCallback(RwFrame *child, void *data) { -- cgit v1.2.3 From 6245a17e168822300d7bb1f5a308305872dff2bc Mon Sep 17 00:00:00 2001 From: aap Date: Thu, 18 Feb 2021 20:31:46 +0100 Subject: update librw; render groups only if extension supported --- src/rw/RwHelper.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/rw') diff --git a/src/rw/RwHelper.cpp b/src/rw/RwHelper.cpp index e98b58f6..76749cb1 100644 --- a/src/rw/RwHelper.cpp +++ b/src/rw/RwHelper.cpp @@ -118,7 +118,8 @@ void PushRendergroup(const char *name) { #if defined(RW_OPENGL) - glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, name); + if(GLAD_GL_KHR_debug) + glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, name); #elif defined(RW_D3D9) static WCHAR tmp[256]; MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, -1, tmp, sizeof(tmp)); @@ -130,7 +131,8 @@ void PopRendergroup(void) { #if defined(RW_OPENGL) - glPopDebugGroup(); + if(GLAD_GL_KHR_debug) + glPopDebugGroup(); #elif defined(RW_D3D9) D3DPERF_EndEvent(); #endif -- cgit v1.2.3 From 9a7fa478578beaba947ea867c15a25e411d641d8 Mon Sep 17 00:00:00 2001 From: aap Date: Fri, 19 Feb 2021 18:41:31 +0100 Subject: make debug render groups optional --- src/rw/RwHelper.cpp | 5 +++++ src/rw/RwHelper.h | 1 + 2 files changed, 6 insertions(+) (limited to 'src/rw') diff --git a/src/rw/RwHelper.cpp b/src/rw/RwHelper.cpp index 76749cb1..ef2d1c0f 100644 --- a/src/rw/RwHelper.cpp +++ b/src/rw/RwHelper.cpp @@ -11,6 +11,7 @@ #endif #ifndef FINAL RtCharset *debugCharset; +bool bDebugRenderGroups; #endif #ifdef PS2_ALPHA_TEST @@ -117,6 +118,8 @@ SetCullMode(uint32 mode) void PushRendergroup(const char *name) { + if(!bDebugRenderGroups) + return; #if defined(RW_OPENGL) if(GLAD_GL_KHR_debug) glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, name); @@ -130,6 +133,8 @@ PushRendergroup(const char *name) void PopRendergroup(void) { + if(!bDebugRenderGroups) + return; #if defined(RW_OPENGL) if(GLAD_GL_KHR_debug) glPopDebugGroup(); diff --git a/src/rw/RwHelper.h b/src/rw/RwHelper.h index 1a5f64b1..0e04aece 100644 --- a/src/rw/RwHelper.h +++ b/src/rw/RwHelper.h @@ -1,5 +1,6 @@ #pragma once +extern bool bDebugRenderGroups; extern bool gPS2alphaTest; void OpenCharsetSafe(); -- cgit v1.2.3 From df1ad8e122e43967710470e275844b62c4962e5d Mon Sep 17 00:00:00 2001 From: aap Date: Sun, 28 Feb 2021 15:29:58 +0100 Subject: fix postfx --- src/rw/RwHelper.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/rw') diff --git a/src/rw/RwHelper.cpp b/src/rw/RwHelper.cpp index ef2d1c0f..a633a139 100644 --- a/src/rw/RwHelper.cpp +++ b/src/rw/RwHelper.cpp @@ -6,6 +6,7 @@ #include "Timecycle.h" #include "skeleton.h" #include "Debug.h" +#include "MBlur.h" #if !defined(FINAL) || defined(DEBUGMENU) #include "rtcharse.h" #endif @@ -526,6 +527,13 @@ CameraSize(RwCamera * camera, RwRect * rect, RsGlobal.width = rect->w; RsGlobal.height = rect->h; + +#ifdef FIX_BUGS + if(CMBlur::BlurOn){ + CMBlur::MotionBlurClose(); + CMBlur::MotionBlurOpen(camera); + } +#endif } return; -- cgit v1.2.3 From 77ca9c593f7f04dcc1a1141bdaf197caa398afbf Mon Sep 17 00:00:00 2001 From: aap Date: Sun, 28 Feb 2021 19:03:46 +0100 Subject: fix postfx fix --- src/rw/RwHelper.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/rw') diff --git a/src/rw/RwHelper.cpp b/src/rw/RwHelper.cpp index a633a139..35593722 100644 --- a/src/rw/RwHelper.cpp +++ b/src/rw/RwHelper.cpp @@ -498,6 +498,12 @@ CameraSize(RwCamera * camera, RwRect * rect, raster->width = zRaster->width = rect->w; raster->height = zRaster->height = rect->h; +#endif +#ifdef FIX_BUGS + if(CMBlur::BlurOn){ + CMBlur::MotionBlurClose(); + CMBlur::MotionBlurOpen(camera); + } #endif } @@ -527,13 +533,6 @@ CameraSize(RwCamera * camera, RwRect * rect, RsGlobal.width = rect->w; RsGlobal.height = rect->h; - -#ifdef FIX_BUGS - if(CMBlur::BlurOn){ - CMBlur::MotionBlurClose(); - CMBlur::MotionBlurOpen(camera); - } -#endif } return; -- cgit v1.2.3 From c58d98a39ea3fa5e1f515fbac96eb58350a6de3e Mon Sep 17 00:00:00 2001 From: aap Date: Sun, 28 Feb 2021 19:07:32 +0100 Subject: fix new renderer --- src/rw/VisibilityPlugins.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/rw') diff --git a/src/rw/VisibilityPlugins.cpp b/src/rw/VisibilityPlugins.cpp index 9ea5b11c..7ff5c243 100644 --- a/src/rw/VisibilityPlugins.cpp +++ b/src/rw/VisibilityPlugins.cpp @@ -303,6 +303,8 @@ CVisibilityPlugins::RenderFadingEntities(void) #ifdef EXTRA_MODEL_FLAGS else if(mi->m_bIsTree) SetAlphaRef(128); + if(!e->IsBuilding() || mi->RenderDoubleSided()) + BACKFACE_CULLING_OFF; #endif if(e->bDistanceFade){ @@ -319,6 +321,7 @@ CVisibilityPlugins::RenderFadingEntities(void) #ifdef EXTRA_MODEL_FLAGS if(mi->m_bIsTree) SetAlphaRef(2); + BACKFACE_CULLING_ON; #endif #ifdef FIX_BUGS if(mi->GetModelType() == MITYPE_SIMPLE && mi->m_noZwrite) -- cgit v1.2.3 From 50058371efaf4c5713b7a608db0c7990ec3d78a6 Mon Sep 17 00:00:00 2001 From: aap Date: Sun, 23 May 2021 17:45:07 +0200 Subject: CEntity and C(Vu)Vector fixes and cleanup --- src/rw/VisibilityPlugins.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src/rw') diff --git a/src/rw/VisibilityPlugins.h b/src/rw/VisibilityPlugins.h index f092de5a..5fb87765 100644 --- a/src/rw/VisibilityPlugins.h +++ b/src/rw/VisibilityPlugins.h @@ -117,7 +117,6 @@ public: int32 offset, int32 len); static int32 ms_framePluginOffset; - // Not actually used struct ClumpExt { ClumpVisibilityCB visibilityCB; -- cgit v1.2.3 From 9b5caa190e30131e361e77e0921653d13f5d124f Mon Sep 17 00:00:00 2001 From: erorcun Date: Sat, 26 Jun 2021 00:27:12 +0300 Subject: Pool fixes Mostly for Linux --- src/rw/MemoryMgr.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/rw') diff --git a/src/rw/MemoryMgr.cpp b/src/rw/MemoryMgr.cpp index 2379692c..b9cff043 100644 --- a/src/rw/MemoryMgr.cpp +++ b/src/rw/MemoryMgr.cpp @@ -28,10 +28,10 @@ RwMemoryFunctions memFuncs = { #ifdef USE_CUSTOM_ALLOCATOR // game seems to be using heap directly here, but this is nicer -void *operator new(size_t sz) { return MemoryMgrMalloc(sz); } -void *operator new[](size_t sz) { return MemoryMgrMalloc(sz); } -void operator delete(void *ptr) noexcept { MemoryMgrFree(ptr); } -void operator delete[](void *ptr) noexcept { MemoryMgrFree(ptr); } +void *operator new(size_t sz) throw() { return MemoryMgrMalloc(sz); } +void *operator new[](size_t sz) throw() { return MemoryMgrMalloc(sz); } +void operator delete(void *ptr) throw() { MemoryMgrFree(ptr); } +void operator delete[](void *ptr) throw() { MemoryMgrFree(ptr); } #endif void* -- cgit v1.2.3 From 3c5bae164f54ef3eb21d1f62aabbbb58939f14ab Mon Sep 17 00:00:00 2001 From: aap Date: Thu, 29 Jul 2021 19:43:35 +0200 Subject: CVisibilityPlugins and CRenderer fixes --- src/rw/VisibilityPlugins.cpp | 54 ++++++++++++++++++++++++++++++-------------- src/rw/VisibilityPlugins.h | 3 +++ 2 files changed, 40 insertions(+), 17 deletions(-) (limited to 'src/rw') diff --git a/src/rw/VisibilityPlugins.cpp b/src/rw/VisibilityPlugins.cpp index 7ff5c243..e6d4641d 100644 --- a/src/rw/VisibilityPlugins.cpp +++ b/src/rw/VisibilityPlugins.cpp @@ -155,7 +155,7 @@ CVisibilityPlugins::Initialise(void) m_alphaList.head.item.sort = 0.0f; m_alphaList.tail.item.sort = 100000000.0f; #ifdef ASPECT_RATIO_SCALE - // default 150 if not enough for bigger FOVs + // default 150 is not enough for bigger FOVs m_alphaEntityList.Init(NUMALPHAENTITYLIST * 3); #else m_alphaEntityList.Init(NUMALPHAENTITYLIST); @@ -658,8 +658,7 @@ CVisibilityPlugins::RenderTrainHiDetailAlphaCB(RpAtomic *atomic) return atomic; if(flags & ATOMIC_FLAG_DRAWLAST){ - // sort before clump - if(!InsertAtomicIntoSortedList(atomic, distsq - 0.0001f)) + if(!InsertAtomicIntoSortedList(atomic, distsq)) RENDERCALLBACK(atomic); }else{ if(!InsertAtomicIntoSortedList(atomic, distsq + dot)) @@ -791,16 +790,6 @@ CVisibilityPlugins::DefaultVisibilityCB(RpClump *clump) return true; } -bool -CVisibilityPlugins::MloVisibilityCB(RpClump *clump) -{ - RwFrame *frame = RpClumpGetFrame(clump); - CMloModelInfo *modelInfo = (CMloModelInfo*)GetFrameHierarchyId(frame); - if (sq(modelInfo->field_34) < GetDistanceSquaredFromCamera(frame)) - return false; - return CVisibilityPlugins::FrustumSphereCB(clump); -} - bool CVisibilityPlugins::FrustumSphereCB(RpClump *clump) { @@ -816,12 +805,23 @@ CVisibilityPlugins::FrustumSphereCB(RpClump *clump) return RwCameraFrustumTestSphere(ms_pCamera, &sphere) != rwSPHEREOUTSIDE; } +bool +CVisibilityPlugins::MloVisibilityCB(RpClump *clump) +{ + RwFrame *frame = RpClumpGetFrame(clump); + CMloModelInfo *modelInfo = (CMloModelInfo*)GetFrameHierarchyId(frame); + if (SQR(modelInfo->drawDist) < GetDistanceSquaredFromCamera(frame)) + return false; + return CVisibilityPlugins::FrustumSphereCB(clump); +} + bool CVisibilityPlugins::VehicleVisibilityCB(RpClump *clump) { - if (GetDistanceSquaredFromCamera(RpClumpGetFrame(clump)) <= ms_vehicleLod1Dist) - return FrustumSphereCB(clump); - return false; + RwFrame *frame = RpClumpGetFrame(clump); + if (ms_vehicleLod1Dist < GetDistanceSquaredFromCamera(frame)) + return false; + return FrustumSphereCB(clump); } bool @@ -927,6 +927,12 @@ CVisibilityPlugins::ClearAtomicFlag(RpAtomic *atomic, int f) ATOMICEXT(atomic)->flags &= ~f; } +void +CVisibilityPlugins::SetAtomicId(RpAtomic *atomic, int id) +{ + ATOMICEXT(atomic)->flags = id; +} + int CVisibilityPlugins::GetAtomicId(RpAtomic *atomic) { @@ -1012,7 +1018,9 @@ CVisibilityPlugins::SetClumpModelInfo(RpClump *clump, CClumpModelInfo *modelInfo // Unused switch (modelInfo->GetModelType()) { - // ignore MLO + case MITYPE_MLO: + CLUMPEXT(clump)->visibilityCB = MloVisibilityCB; + break; case MITYPE_VEHICLE: vmi = (CVehicleModelInfo*)modelInfo; if(vmi->m_vehicleType == VEHICLE_TYPE_TRAIN || @@ -1026,6 +1034,12 @@ CVisibilityPlugins::SetClumpModelInfo(RpClump *clump, CClumpModelInfo *modelInfo } } +CClumpModelInfo* +CVisibilityPlugins::GetClumpModelInfo(RpClump *clump) +{ + return (CClumpModelInfo*)GetFrameHierarchyId(RpClumpGetFrame(clump)); +} + void CVisibilityPlugins::SetClumpAlpha(RpClump *clump, int alpha) { @@ -1037,3 +1051,9 @@ CVisibilityPlugins::GetClumpAlpha(RpClump *clump) { return CLUMPEXT(clump)->alpha; } + +bool +CVisibilityPlugins::IsClumpVisible(RpClump *clump) +{ + return CLUMPEXT(clump)->visibilityCB(clump); +} diff --git a/src/rw/VisibilityPlugins.h b/src/rw/VisibilityPlugins.h index 5fb87765..f97fd589 100644 --- a/src/rw/VisibilityPlugins.h +++ b/src/rw/VisibilityPlugins.h @@ -94,6 +94,7 @@ public: static CSimpleModelInfo *GetAtomicModelInfo(RpAtomic *atomic); static void SetAtomicFlag(RpAtomic*, int); static void ClearAtomicFlag(RpAtomic*, int); + static void SetAtomicId(RpAtomic *atomic, int); static int GetAtomicId(RpAtomic *atomic); static void SetAtomicRenderCallback(RpAtomic*, RpAtomicCallBackRender); @@ -123,8 +124,10 @@ public: int alpha; }; static void SetClumpModelInfo(RpClump*, CClumpModelInfo*); + static CClumpModelInfo *GetClumpModelInfo(RpClump*); static void SetClumpAlpha(RpClump*, int); static int GetClumpAlpha(RpClump*); + static bool IsClumpVisible(RpClump*); static void *ClumpConstructor(void *object, int32 offset, int32 len); static void *ClumpDestructor(void *object, int32 offset, int32 len); -- cgit v1.2.3