diff options
Diffstat (limited to 'src/rw')
-rw-r--r-- | src/rw/Lights.cpp | 45 | ||||
-rw-r--r-- | src/rw/RwHelper.cpp | 204 | ||||
-rw-r--r-- | src/rw/RwHelper.h | 7 | ||||
-rw-r--r-- | src/rw/TexRead.cpp | 2 | ||||
-rw-r--r-- | src/rw/VisibilityPlugins.cpp | 368 | ||||
-rw-r--r-- | src/rw/VisibilityPlugins.h | 17 |
6 files changed, 464 insertions, 179 deletions
diff --git a/src/rw/Lights.cpp b/src/rw/Lights.cpp index 5a253854..c5038232 100644 --- a/src/rw/Lights.cpp +++ b/src/rw/Lights.cpp @@ -8,6 +8,7 @@ #include "Weather.h" #include "ZoneCull.h" #include "Frontend.h" +#include "MBlur.h" RpLight *pAmbient; RpLight *pDirect; @@ -22,6 +23,14 @@ RwRGBAReal DirectionalLightColourForFrame; RwRGBAReal AmbientLightColour; RwRGBAReal DirectionalLightColour; +#ifdef EXTENDED_COLOURFILTER +#include "postfx.h" +#define USEBLURCOLORS CPostFX::UseBlurColours() +#else +#define USEBLURCOLORS CMBlur::BlurOn +#endif + +//--MIAMI: done void SetLightsWithTimeOfDayColour(RpWorld *) { @@ -29,17 +38,35 @@ SetLightsWithTimeOfDayColour(RpWorld *) RwMatrix mat; if(pAmbient){ - AmbientLightColourForFrame.red = CTimeCycle::GetAmbientRed() * CCoronas::LightsMult; - AmbientLightColourForFrame.green = CTimeCycle::GetAmbientGreen() * CCoronas::LightsMult; - AmbientLightColourForFrame.blue = CTimeCycle::GetAmbientBlue() * CCoronas::LightsMult; + if(USEBLURCOLORS){ + AmbientLightColourForFrame.red = CTimeCycle::GetAmbientRed_Bl() * CCoronas::LightsMult; + AmbientLightColourForFrame.green = CTimeCycle::GetAmbientGreen_Bl() * CCoronas::LightsMult; + AmbientLightColourForFrame.blue = CTimeCycle::GetAmbientBlue_Bl() * CCoronas::LightsMult; + }else{ + AmbientLightColourForFrame.red = CTimeCycle::GetAmbientRed() * CCoronas::LightsMult; + AmbientLightColourForFrame.green = CTimeCycle::GetAmbientGreen() * CCoronas::LightsMult; + AmbientLightColourForFrame.blue = CTimeCycle::GetAmbientBlue() * CCoronas::LightsMult; + } + + if(USEBLURCOLORS){ + AmbientLightColourForFrame_PedsCarsAndObjects.red = CTimeCycle::GetAmbientRed_Obj_Bl() * CCoronas::LightsMult; + AmbientLightColourForFrame_PedsCarsAndObjects.green = CTimeCycle::GetAmbientGreen_Obj_Bl() * CCoronas::LightsMult; + AmbientLightColourForFrame_PedsCarsAndObjects.blue = CTimeCycle::GetAmbientBlue_Obj_Bl() * CCoronas::LightsMult; + }else{ + AmbientLightColourForFrame_PedsCarsAndObjects.red = CTimeCycle::GetAmbientRed_Obj() * CCoronas::LightsMult; + AmbientLightColourForFrame_PedsCarsAndObjects.green = CTimeCycle::GetAmbientGreen_Obj() * CCoronas::LightsMult; + AmbientLightColourForFrame_PedsCarsAndObjects.blue = CTimeCycle::GetAmbientBlue_Obj() * CCoronas::LightsMult; + } + if(CWeather::LightningFlash && !CCullZones::CamNoRain()){ AmbientLightColourForFrame.red = 1.0f; AmbientLightColourForFrame.green = 1.0f; AmbientLightColourForFrame.blue = 1.0f; + + AmbientLightColourForFrame_PedsCarsAndObjects.red = 1.0f; + AmbientLightColourForFrame_PedsCarsAndObjects.green = 1.0f; + AmbientLightColourForFrame_PedsCarsAndObjects.blue = 1.0f; } - AmbientLightColourForFrame_PedsCarsAndObjects.red = Min(1.0f, AmbientLightColourForFrame.red*1.3f); - AmbientLightColourForFrame_PedsCarsAndObjects.green = Min(1.0f, AmbientLightColourForFrame.green*1.3f); - AmbientLightColourForFrame_PedsCarsAndObjects.blue = Min(1.0f, AmbientLightColourForFrame.blue*1.3f); RpLightSetColor(pAmbient, &AmbientLightColourForFrame); } @@ -66,9 +93,9 @@ SetLightsWithTimeOfDayColour(RpWorld *) RwFrameTransform(RpLightGetFrame(pDirect), &mat, rwCOMBINEREPLACE); } - if(CMenuManager::m_PrefsBrightness > 256){ - float f1 = 2.0f * (CMenuManager::m_PrefsBrightness/256.0f - 1.0f) * 0.6f + 1.0f; - float f2 = 3.0f * (CMenuManager::m_PrefsBrightness/256.0f - 1.0f) * 0.6f + 1.0f; + if(FrontEndMenuManager.m_PrefsBrightness > 256){ + float f1 = 2.0f * (FrontEndMenuManager.m_PrefsBrightness/256.0f - 1.0f) * 0.6f + 1.0f; + float f2 = 3.0f * (FrontEndMenuManager.m_PrefsBrightness/256.0f - 1.0f) * 0.6f + 1.0f; AmbientLightColourForFrame.red = Min(1.0f, AmbientLightColourForFrame.red * f2); AmbientLightColourForFrame.green = Min(1.0f, AmbientLightColourForFrame.green * f2); diff --git a/src/rw/RwHelper.cpp b/src/rw/RwHelper.cpp index f568532a..58791ce2 100644 --- a/src/rw/RwHelper.cpp +++ b/src/rw/RwHelper.cpp @@ -16,6 +16,7 @@ bool gPS2alphaTest = true; #else bool gPS2alphaTest = false; #endif +bool gBackfaceCulling; #ifndef FINAL static bool charsetOpen; @@ -111,7 +112,7 @@ DefinedState(void) RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE); RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); - RwRenderStateSet(rwRENDERSTATEALPHAPRIMITIVEBUFFER, (void*)FALSE); + //RwRenderStateSet(rwRENDERSTATEALPHAPRIMITIVEBUFFER, (void*)FALSE); RwRenderStateSet(rwRENDERSTATEBORDERCOLOR, (void*)RWRGBALONG(0, 0, 0, 255)); RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE); RwRenderStateSet(rwRENDERSTATEFOGCOLOR, @@ -131,6 +132,15 @@ DefinedState(void) #endif } +void +SetCullMode(uint32 mode) +{ + if(gBackfaceCulling) + RwRenderStateSet(rwRENDERSTATECULLMODE, (void*)mode); + else + RwRenderStateSet(rwRENDERSTATECULLMODE, (void*)rwCULLMODECULLNONE); +} + RwFrame* GetFirstFrameCallback(RwFrame *child, void *data) { @@ -352,9 +362,9 @@ AtomicRemoveAnimFromSkinCB(RpAtomic *atomic, void *data) hier->interpolator->currentAnim = nil; } #else - if(hier && hier->pCurrentAnim){ - RpHAnimAnimationDestroy(hier->pCurrentAnim); - hier->pCurrentAnim = nil; + if(hier && hier->currentAnim){ + RpHAnimAnimationDestroy(hier->currentAnim->pCurrentAnim); + hier->currentAnim = nil; } #endif } @@ -389,6 +399,125 @@ RenderSkeleton(RpHAnimHierarchy *hier) } #endif + +RwBool Im2DRenderQuad(RwReal x1, RwReal y1, RwReal x2, RwReal y2, RwReal z, RwReal recipCamZ, RwReal uvOffset) +{ + RwIm2DVertex vx[4]; + + /* + * Render an opaque white 2D quad at the given coordinates and + * spanning a whole texture. + */ + + RwIm2DVertexSetScreenX(&vx[0], x1); + RwIm2DVertexSetScreenY(&vx[0], y1); + RwIm2DVertexSetScreenZ(&vx[0], z); + RwIm2DVertexSetIntRGBA(&vx[0], 255, 255, 255, 255); + RwIm2DVertexSetRecipCameraZ(&vx[0], recipCamZ); + RwIm2DVertexSetU(&vx[0], uvOffset, recipCamZ); + RwIm2DVertexSetV(&vx[0], uvOffset, recipCamZ); + + RwIm2DVertexSetScreenX(&vx[1], x1); + RwIm2DVertexSetScreenY(&vx[1], y2); + RwIm2DVertexSetScreenZ(&vx[1], z); + RwIm2DVertexSetIntRGBA(&vx[1], 255, 255, 255, 255); + RwIm2DVertexSetRecipCameraZ(&vx[1], recipCamZ); + RwIm2DVertexSetU(&vx[1], uvOffset, recipCamZ); + RwIm2DVertexSetV(&vx[1], 1.0f + uvOffset, recipCamZ); + + RwIm2DVertexSetScreenX(&vx[2], x2); + RwIm2DVertexSetScreenY(&vx[2], y1); + RwIm2DVertexSetScreenZ(&vx[2], z); + RwIm2DVertexSetIntRGBA(&vx[2], 255, 255, 255, 255); + RwIm2DVertexSetRecipCameraZ(&vx[2], recipCamZ); + RwIm2DVertexSetU(&vx[2], 1.0f + uvOffset, recipCamZ); + RwIm2DVertexSetV(&vx[2], uvOffset, recipCamZ); + + RwIm2DVertexSetScreenX(&vx[3], x2); + RwIm2DVertexSetScreenY(&vx[3], y2); + RwIm2DVertexSetScreenZ(&vx[3], z); + RwIm2DVertexSetIntRGBA(&vx[3], 255, 255, 255, 255); + RwIm2DVertexSetRecipCameraZ(&vx[3], recipCamZ); + RwIm2DVertexSetU(&vx[3], 1.0f + uvOffset, recipCamZ); + RwIm2DVertexSetV(&vx[3], 1.0f + uvOffset, recipCamZ); + + RwIm2DRenderPrimitive(rwPRIMTYPETRISTRIP, vx, 4); + + return TRUE; +} + +bool b_cbsUseLTM = true; + +RpAtomic *cbsCalcMeanBSphereRadiusCB(RpAtomic *atomic, void *data) +{ + RwV3d atomicPos; + + if ( b_cbsUseLTM ) + RwV3dTransformPoints(&atomicPos, &RpAtomicGetBoundingSphere(atomic)->center, 1, RwFrameGetLTM(RpClumpGetFrame(atomic->clump))); + else + RwV3dTransformPoints(&atomicPos, &RpAtomicGetBoundingSphere(atomic)->center, 1, RwFrameGetMatrix(RpClumpGetFrame(atomic->clump))); + + RwV3d temp; + RwV3dSub(&temp, &atomicPos, &((RwSphere *)data)->center); + RwReal radius = RwV3dLength(&temp) + RpAtomicGetBoundingSphere(atomic)->radius; + + if ( ((RwSphere *)data)->radius < radius ) + ((RwSphere *)data)->radius = radius; + + return atomic; +} + +RpAtomic *cbsCalcMeanBSphereCenterCB(RpAtomic *atomic, void *data) +{ + RwV3d atomicPos; + + if ( b_cbsUseLTM ) + RwV3dTransformPoints(&atomicPos, &RpAtomicGetBoundingSphere(atomic)->center, 1, RwFrameGetLTM(RpClumpGetFrame(atomic->clump))); + else + RwV3dTransformPoints(&atomicPos, &RpAtomicGetBoundingSphere(atomic)->center, 1, RwFrameGetMatrix(RpClumpGetFrame(atomic->clump))); + + RwV3dAdd(&((RwSphere *)data)->center, &((RwSphere *)data)->center, &atomicPos); + + return atomic; +} + +RpClump *RpClumpGetBoundingSphere(RpClump *clump, RwSphere *sphere, bool useLTM) +{ + RwMatrix matrix; + RwSphere result = { 0.0f, 0.0f, 0.0f, 0.0f }; + + b_cbsUseLTM = useLTM; + + if ( clump == nil || sphere == nil ) + return nil; + + sphere->radius = 0.0f; + sphere->center.x = 0.0f; + sphere->center.y = 0.0f; + sphere->center.z = 0.0f; + + RwInt32 numAtomics = RpClumpGetNumAtomics(clump); + if ( numAtomics < 1.0f ) + return nil; + + RpClumpForAllAtomics(clump, cbsCalcMeanBSphereCenterCB, &result); + + RwV3dScale(&result.center, &result.center, 1.0f/numAtomics); + + RpClumpForAllAtomics(clump, cbsCalcMeanBSphereRadiusCB, &result); + + if ( b_cbsUseLTM ) + RwMatrixInvert(&matrix, RwFrameGetLTM(RpClumpGetFrame(clump))); + else + RwMatrixInvert(&matrix, RwFrameGetMatrix(RpClumpGetFrame(clump))); + + RwV3dTransformPoints(&result.center, &result.center, 1, &matrix); + + *sphere = result; + + return clump; +} + void CameraSize(RwCamera * camera, RwRect * rect, RwReal viewWindow, RwReal aspectRatio) @@ -616,6 +745,73 @@ WRAPPER void _TexturePoolsInitialise() { EAXJMP(0x598B10); } WRAPPER void _TexturePoolsShutdown() { EAXJMP(0x598B30); } #endif +#ifdef LIBRW +#include <rpmatfx.h> +#include "VehicleModelInfo.h" + +int32 +findPlatform(rw::Atomic *a) +{ + rw::Geometry *g = a->geometry; + if(g->instData) + return g->instData->platform; + return 0; +} + +// Game doesn't read atomic extensions so we never get any other than the default pipe, +// but we need it for uninstancing +void +attachPipe(rw::Atomic *atomic) +{ + if(RpSkinGeometryGetSkin(RpAtomicGetGeometry(atomic))) + atomic->pipeline = rw::skinGlobals.pipelines[rw::platform]; + else{ + int fx = rpMATFXEFFECTNULL; + RpGeometryForAllMaterials(RpAtomicGetGeometry(atomic), CVehicleModelInfo::GetMatFXEffectMaterialCB, &fx); + if(fx != rpMATFXEFFECTNULL) + RpMatFXAtomicEnableEffects(atomic); + } +} + +// Attach pipes for the platform we have native data for so we can uninstance +void +switchPipes(rw::Atomic *a, int32 platform) +{ + if(a->pipeline && a->pipeline->platform != platform){ + uint32 plgid = a->pipeline->pluginID; + switch(plgid){ + // assume default pipe won't be attached explicitly + case rw::ID_SKIN: + a->pipeline = rw::skinGlobals.pipelines[platform]; + break; + case rw::ID_MATFX: + a->pipeline = rw::matFXGlobals.pipelines[platform]; + break; + } + } +} + +RpAtomic* +ConvertPlatformAtomic(RpAtomic *atomic, void *data) +{ + int32 driver = rw::platform; + int32 platform = findPlatform(atomic); + if(platform != 0 && platform != driver){ + attachPipe(atomic); // kludge + rw::ObjPipeline *origPipe = atomic->pipeline; + rw::platform = platform; + switchPipes(atomic, rw::platform); + if(atomic->geometry->flags & rw::Geometry::NATIVE) + atomic->uninstance(); + // no ADC in this game + //rw::ps2::unconvertADC(atomic->geometry); + rw::platform = driver; + atomic->pipeline = origPipe; + } + return atomic; +} +#endif + #if defined(FIX_BUGS) && defined(GTA_PC) RwUInt32 saved_alphafunc, saved_alpharef; diff --git a/src/rw/RwHelper.h b/src/rw/RwHelper.h index eceaee07..3f1a3d19 100644 --- a/src/rw/RwHelper.h +++ b/src/rw/RwHelper.h @@ -1,6 +1,7 @@ #pragma once extern bool gPS2alphaTest; +extern bool gBackfaceCulling; void *RwMallocAlign(RwUInt32 size, RwUInt32 align); void RwFreeAlign(void *mem); @@ -11,6 +12,7 @@ void DestroyDebugFont(); void ObrsPrintfString(const char *str, short x, short y); void FlushObrsPrintfs(); void DefinedState(void); +void SetCullMode(uint32 mode); RwFrame *GetFirstChild(RwFrame *frame); RwObject *GetFirstObject(RwFrame *frame); RpAtomic *GetFirstAtomic(RpClump *clump); @@ -27,6 +29,9 @@ RpAtomic *AtomicRemoveAnimFromSkinCB(RpAtomic *atomic, void *data); void RenderSkeleton(RpHAnimHierarchy *hier); #endif +RwBool Im2DRenderQuad(RwReal x1, RwReal y1, RwReal x2, RwReal y2, RwReal z, RwReal recipCamZ, RwReal uvOffset); +RpClump *RpClumpGetBoundingSphere(RpClump *clump, RwSphere *sphere, bool useLTM); + RwTexDictionary *RwTexDictionaryGtaStreamRead(RwStream *stream); RwTexDictionary *RwTexDictionaryGtaStreamRead1(RwStream *stream); RwTexDictionary *RwTexDictionaryGtaStreamRead2(RwStream *stream, RwTexDictionary *texDict); @@ -54,6 +59,8 @@ RwCamera *CameraCreate(RwInt32 width, void _TexturePoolsInitialise(); void _TexturePoolsShutdown(); +RpAtomic *ConvertPlatformAtomic(RpAtomic *atomic, void *data); + #if defined(FIX_BUGS) && defined (GTA_PC) void SetAlphaTest(RwUInt32 alpharef); void RestoreAlphaTest(); diff --git a/src/rw/TexRead.cpp b/src/rw/TexRead.cpp index 0ef260b1..0c07b9f5 100644 --- a/src/rw/TexRead.cpp +++ b/src/rw/TexRead.cpp @@ -233,7 +233,7 @@ ConvertingTexturesScreen(uint32 num, uint32 count, const char *text) CFont::SetJustifyOff(); CFont::SetColor(CRGBA(255, 217, 106, 255)); CFont::SetBackGroundOnlyTextOff(); - CFont::SetFontStyle(FONT_BANK); + CFont::SetFontStyle(FONT_STANDARD); CFont::PrintString(SCREEN_SCALE_X(170.0f), SCREEN_SCALE_Y(160.0f), TheText.Get(text)); CFont::DrawFonts(); DoRWStuffEndOfFrame(); diff --git a/src/rw/VisibilityPlugins.cpp b/src/rw/VisibilityPlugins.cpp index b2e252a0..36a60117 100644 --- a/src/rw/VisibilityPlugins.cpp +++ b/src/rw/VisibilityPlugins.cpp @@ -4,16 +4,21 @@ #include "Entity.h" #include "ModelInfo.h" #include "Lights.h" +#include "RwHelper.h" #include "Renderer.h" #include "Camera.h" #include "VisibilityPlugins.h" #include "World.h" #include "custompipes.h" +//--MIAMI: file done + #define FADE_DISTANCE 20.0f CLinkList<CVisibilityPlugins::AlphaObjectInfo> CVisibilityPlugins::m_alphaList; +CLinkList<CVisibilityPlugins::AlphaObjectInfo> CVisibilityPlugins::m_alphaBoatAtomicList; CLinkList<CVisibilityPlugins::AlphaObjectInfo> CVisibilityPlugins::m_alphaEntityList; +CLinkList<CVisibilityPlugins::AlphaObjectInfo> CVisibilityPlugins::m_alphaUnderwaterEntityList; int32 CVisibilityPlugins::ms_atomicPluginOffset = -1; int32 CVisibilityPlugins::ms_framePluginOffset = -1; @@ -27,7 +32,6 @@ float CVisibilityPlugins::ms_vehicleLod1Dist; float CVisibilityPlugins::ms_vehicleFadeDist; float CVisibilityPlugins::ms_bigVehicleLod0Dist; float CVisibilityPlugins::ms_bigVehicleLod1Dist; -float CVisibilityPlugins::ms_pedLod0Dist; float CVisibilityPlugins::ms_pedLod1Dist; float CVisibilityPlugins::ms_pedFadeDist; @@ -37,6 +41,11 @@ CVisibilityPlugins::Initialise(void) m_alphaList.Init(NUMALPHALIST); m_alphaList.head.item.sort = 0.0f; m_alphaList.tail.item.sort = 100000000.0f; + + m_alphaBoatAtomicList.Init(NUMBOATALPHALIST); + m_alphaBoatAtomicList.head.item.sort = 0.0f; + m_alphaBoatAtomicList.tail.item.sort = 100000000.0f; + #ifdef ASPECT_RATIO_SCALE // default 150 if not enough for bigger FOVs m_alphaEntityList.Init(NUMALPHAENTITYLIST * 3); @@ -45,19 +54,28 @@ CVisibilityPlugins::Initialise(void) #endif // ASPECT_RATIO_SCALE m_alphaEntityList.head.item.sort = 0.0f; m_alphaEntityList.tail.item.sort = 100000000.0f; + + m_alphaUnderwaterEntityList.Init(NUMALPHAUNTERWATERENTITYLIST); + m_alphaUnderwaterEntityList.head.item.sort = 0.0f; + m_alphaUnderwaterEntityList.tail.item.sort = 100000000.0f; + } void CVisibilityPlugins::Shutdown(void) { m_alphaList.Shutdown(); + m_alphaBoatAtomicList.Shutdown(); m_alphaEntityList.Shutdown(); + m_alphaUnderwaterEntityList.Shutdown(); } void CVisibilityPlugins::InitAlphaEntityList(void) { m_alphaEntityList.Clear(); + m_alphaBoatAtomicList.Clear(); + m_alphaUnderwaterEntityList.Clear(); } bool @@ -66,10 +84,9 @@ CVisibilityPlugins::InsertEntityIntoSortedList(CEntity *e, float dist) AlphaObjectInfo item; item.entity = e; item.sort = dist; - bool ret = !!m_alphaEntityList.InsertSorted(item); -// if(!ret) -// printf("list full %d\n", m_alphaEntityList.Count()); - return ret; + if(e->bUnderwater && m_alphaUnderwaterEntityList.InsertSorted(item)) + return true; + return !!m_alphaEntityList.InsertSorted(item); } void @@ -84,10 +101,16 @@ CVisibilityPlugins::InsertAtomicIntoSortedList(RpAtomic *a, float dist) AlphaObjectInfo item; item.atomic = a; item.sort = dist; - bool ret = !!m_alphaList.InsertSorted(item); -// if(!ret) -// printf("list full %d\n", m_alphaList.Count()); - return ret; + return !!m_alphaList.InsertSorted(item); +} + +bool +CVisibilityPlugins::InsertAtomicIntoBoatSortedList(RpAtomic *a, float dist) +{ + AlphaObjectInfo item; + item.atomic = a; + item.sort = dist; + return !!m_alphaBoatAtomicList.InsertSorted(item); } void @@ -107,11 +130,25 @@ CVisibilityPlugins::SetRenderWareCamera(RwCamera *camera) ms_vehicleFadeDist = sq(100.0f * TheCamera.GenerationDistMultiplier); ms_bigVehicleLod0Dist = sq(60.0f * TheCamera.GenerationDistMultiplier); ms_bigVehicleLod1Dist = sq(150.0f * TheCamera.GenerationDistMultiplier); - ms_pedLod0Dist = sq(25.0f * TheCamera.LODDistMultiplier); ms_pedLod1Dist = sq(60.0f * TheCamera.LODDistMultiplier); ms_pedFadeDist = sq(70.0f * TheCamera.LODDistMultiplier); } +static float DistToCameraSq; +static float PitchToCamera; + +void +CVisibilityPlugins::SetupVehicleVariables(RpClump *vehicle) +{ + if (RwObjectGetType((RwObject*)vehicle) != rpCLUMP) + return; + DistToCameraSq = GetDistanceSquaredFromCamera(RpClumpGetFrame(vehicle)); + RwV3d distToCam; + RwV3dSub(&distToCam, ms_pCameraPosn, &RwFrameGetMatrix(RpClumpGetFrame(vehicle))->pos); + float dist2d = Sqrt(SQR(distToCam.x) + SQR(distToCam.y)); + PitchToCamera = Atan2(distToCam.z, dist2d); +} + RpMaterial* SetAlphaCB(RpMaterial *material, void *data) { @@ -127,23 +164,33 @@ SetTextureCB(RpMaterial *material, void *data) } void -CVisibilityPlugins::RenderAlphaAtomics(void) +CVisibilityPlugins::RenderAtomicList(CLinkList<AlphaObjectInfo> &list) { CLink<AlphaObjectInfo> *node; - for(node = m_alphaList.tail.prev; - node != &m_alphaList.head; - node = node->prev) + for(node = list.tail.prev; node != &list.head; node = node->prev) AtomicDefaultRenderCallBack(node->item.atomic); } void -CVisibilityPlugins::RenderFadingEntities(void) +CVisibilityPlugins::RenderAlphaAtomics(void) +{ + RenderAtomicList(m_alphaList); +} + +void +CVisibilityPlugins::RenderBoatAlphaAtomics(void) +{ + SetCullMode(rwCULLMODECULLNONE); + RenderAtomicList(m_alphaBoatAtomicList); + SetCullMode(rwCULLMODECULLBACK); +} + +void +CVisibilityPlugins::RenderFadingEntities(CLinkList<AlphaObjectInfo> &list) { CLink<AlphaObjectInfo> *node; CSimpleModelInfo *mi; - for(node = m_alphaEntityList.tail.prev; - node != &m_alphaEntityList.head; - node = node->prev){ + for(node = list.tail.prev; node != &list.head; node = node->prev){ CEntity *e = node->item.entity; if(e->m_rwObject == nil) continue; @@ -152,11 +199,7 @@ CVisibilityPlugins::RenderFadingEntities(void) continue; #endif mi = (CSimpleModelInfo *)CModelInfo::GetModelInfo(e->GetModelIndex()); -#ifdef FIX_BUGS if(mi->GetModelType() == MITYPE_SIMPLE && mi->m_noZwrite) -#else - if(mi->m_noZwrite) -#endif RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, FALSE); if(e->bDistanceFade){ @@ -168,29 +211,34 @@ CVisibilityPlugins::RenderFadingEntities(void) }else CRenderer::RenderOneNonRoad(e); -#ifdef FIX_BUGS if(mi->GetModelType() == MITYPE_SIMPLE && mi->m_noZwrite) -#else - if(mi->m_noZwrite) -#endif RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE); } } +void +CVisibilityPlugins::RenderFadingEntities(void) +{ + RenderFadingEntities(m_alphaEntityList); + RenderBoatAlphaAtomics(); +} + +void +CVisibilityPlugins::RenderFadingUnderwaterEntities(void) +{ + RenderFadingEntities(m_alphaUnderwaterEntityList); +} + RpAtomic* CVisibilityPlugins::RenderWheelAtomicCB(RpAtomic *atomic) { RpAtomic *lodatm; - RwMatrix *m; - RwV3d view; float len; CSimpleModelInfo *mi; mi = GetAtomicModelInfo(atomic); - m = RwFrameGetLTM(RpAtomicGetFrame(atomic)); - RwV3dSub(&view, RwMatrixGetPos(m), ms_pCameraPosn); - len = RwV3dLength(&view); - lodatm = mi->GetAtomicFromDistance(len); + len = Sqrt(DistToCameraSq); + lodatm = mi->GetAtomicFromDistance(len * TheCamera.LODDistMultiplier / TheCamera.GenerationDistMultiplier); if(lodatm){ if(RpAtomicGetGeometry(lodatm) != RpAtomicGetGeometry(atomic)) RpAtomicSetGeometry(atomic, RpAtomicGetGeometry(lodatm), rpATOMICSAMEBOUNDINGSPHERE); @@ -232,6 +280,24 @@ CVisibilityPlugins::RenderAlphaAtomic(RpAtomic *atomic, int alpha) } RpAtomic* +CVisibilityPlugins::RenderWeaponCB(RpAtomic *atomic) +{ + RwMatrix *m; + RwV3d view; + float maxdist, distsq; + CSimpleModelInfo *mi; + + mi = GetAtomicModelInfo(atomic); + m = RwFrameGetLTM(RpAtomicGetFrame(atomic)); + RwV3dSub(&view, RwMatrixGetPos(m), ms_pCameraPosn); + maxdist = mi->GetLodDistance(0); + distsq = RwV3dDotProduct(&view, &view); + if(distsq < maxdist*maxdist) + AtomicDefaultRenderCallBack(atomic); + return atomic; +} + +RpAtomic* CVisibilityPlugins::RenderFadingAtomic(RpAtomic *atomic, float camdist) { RpAtomic *lodatm; @@ -241,29 +307,30 @@ CVisibilityPlugins::RenderFadingAtomic(RpAtomic *atomic, float camdist) mi = GetAtomicModelInfo(atomic); lodatm = mi->GetAtomicFromDistance(camdist - FADE_DISTANCE); - if(mi->m_additive){ - RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE); + if(mi->m_additive) AtomicDefaultRenderCallBack(atomic); - RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); - }else{ - fadefactor = (mi->GetLargestLodDistance() - (camdist - FADE_DISTANCE))/FADE_DISTANCE; - if(fadefactor > 1.0f) - fadefactor = 1.0f; - alpha = mi->m_alpha * fadefactor; - if(alpha == 255) - AtomicDefaultRenderCallBack(atomic); - else{ - RpGeometry *geo = RpAtomicGetGeometry(lodatm); - uint32 flags = RpGeometryGetFlags(geo); - RpGeometrySetFlags(geo, flags | rpGEOMETRYMODULATEMATERIALCOLOR); - RpGeometryForAllMaterials(geo, SetAlphaCB, (void*)alpha); - if(geo != RpAtomicGetGeometry(atomic)) - RpAtomicSetGeometry(atomic, geo, rpATOMICSAMEBOUNDINGSPHERE); // originally 5 (mistake?) - AtomicDefaultRenderCallBack(atomic); - RpGeometryForAllMaterials(geo, SetAlphaCB, (void*)255); - RpGeometrySetFlags(geo, flags); - } + + fadefactor = (mi->GetLargestLodDistance() - (camdist - FADE_DISTANCE))/FADE_DISTANCE; + if(fadefactor > 1.0f) + fadefactor = 1.0f; + alpha = mi->m_alpha * fadefactor; + if(alpha == 255) + AtomicDefaultRenderCallBack(atomic); + else{ + RpGeometry *geo = RpAtomicGetGeometry(lodatm); + uint32 flags = RpGeometryGetFlags(geo); + RpGeometrySetFlags(geo, flags | rpGEOMETRYMODULATEMATERIALCOLOR); + RpGeometryForAllMaterials(geo, SetAlphaCB, (void*)alpha); + if(geo != RpAtomicGetGeometry(atomic)) + RpAtomicSetGeometry(atomic, geo, rpATOMICSAMEBOUNDINGSPHERE); // originally 5 (mistake?) + AtomicDefaultRenderCallBack(atomic); + RpGeometryForAllMaterials(geo, SetAlphaCB, (void*)255); + RpGeometrySetFlags(geo, flags); } + + if(mi->m_additive) + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); + return atomic; } @@ -273,17 +340,16 @@ RpAtomic* CVisibilityPlugins::RenderVehicleHiDetailCB(RpAtomic *atomic) { RwFrame *clumpframe; - float distsq, dot; + float dot; uint32 flags; clumpframe = RpClumpGetFrame(RpAtomicGetClump(atomic)); - distsq = GetDistanceSquaredFromCamera(clumpframe); - if(distsq < ms_vehicleLod0Dist){ + if(DistToCameraSq < ms_vehicleLod0Dist){ flags = GetAtomicId(atomic); - if(distsq > ms_cullCompsDist && (flags & ATOMIC_FLAG_NOCULL) == 0){ + if(DistToCameraSq > ms_cullCompsDist && (flags & ATOMIC_FLAG_NOCULL) == 0 && PitchToCamera < 0.2f){ dot = GetDotProductWithCameraVector(RwFrameGetLTM(RpAtomicGetFrame(atomic)), RwFrameGetLTM(clumpframe), flags); - if(dot > 0.0f && ((flags & ATOMIC_FLAG_ANGLECULL) || 0.1f*distsq < dot*dot)) + if(dot > 0.0f && ((flags & ATOMIC_FLAG_ANGLECULL) || 0.1f*DistToCameraSq < dot*dot)) return atomic; } AtomicDefaultRenderCallBack(atomic); @@ -295,25 +361,24 @@ RpAtomic* CVisibilityPlugins::RenderVehicleHiDetailAlphaCB(RpAtomic *atomic) { RwFrame *clumpframe; - float distsq, dot; + float dot; uint32 flags; clumpframe = RpClumpGetFrame(RpAtomicGetClump(atomic)); - distsq = GetDistanceSquaredFromCamera(clumpframe); - if(distsq < ms_vehicleLod0Dist){ + if(DistToCameraSq < ms_vehicleLod0Dist){ flags = GetAtomicId(atomic); dot = GetDotProductWithCameraVector(RwFrameGetLTM(RpAtomicGetFrame(atomic)), RwFrameGetLTM(clumpframe), flags); - if(distsq > ms_cullCompsDist && (flags & ATOMIC_FLAG_NOCULL) == 0) - if(dot > 0.0f && ((flags & ATOMIC_FLAG_ANGLECULL) || 0.1f*distsq < dot*dot)) + if(DistToCameraSq > ms_cullCompsDist && (flags & ATOMIC_FLAG_NOCULL) == 0 && PitchToCamera < 0.2f) + if(dot > 0.0f && ((flags & ATOMIC_FLAG_ANGLECULL) || 0.1f*DistToCameraSq < dot*dot)) return atomic; if(flags & ATOMIC_FLAG_DRAWLAST){ // sort before clump - if(!InsertAtomicIntoSortedList(atomic, distsq - 0.0001f)) + if(!InsertAtomicIntoSortedList(atomic, DistToCameraSq - 0.0001f)) AtomicDefaultRenderCallBack(atomic); }else{ - if(!InsertAtomicIntoSortedList(atomic, distsq + dot)) + if(!InsertAtomicIntoSortedList(atomic, DistToCameraSq + dot)) AtomicDefaultRenderCallBack(atomic); } } @@ -324,14 +389,13 @@ RpAtomic* CVisibilityPlugins::RenderVehicleHiDetailCB_BigVehicle(RpAtomic *atomic) { RwFrame *clumpframe; - float distsq, dot; + float dot; uint32 flags; clumpframe = RpClumpGetFrame(RpAtomicGetClump(atomic)); - distsq = GetDistanceSquaredFromCamera(clumpframe); - if(distsq < ms_bigVehicleLod0Dist){ + if(DistToCameraSq < ms_bigVehicleLod0Dist){ flags = GetAtomicId(atomic); - if(distsq > ms_cullCompsDist && (flags & ATOMIC_FLAG_NOCULL) == 0){ + if(DistToCameraSq > ms_cullCompsDist && (flags & ATOMIC_FLAG_NOCULL) == 0 && PitchToCamera < 0.2f){ dot = GetDotProductWithCameraVector(RwFrameGetLTM(RpAtomicGetFrame(atomic)), RwFrameGetLTM(clumpframe), flags); if(dot > 0.0f) @@ -346,20 +410,19 @@ RpAtomic* CVisibilityPlugins::RenderVehicleHiDetailAlphaCB_BigVehicle(RpAtomic *atomic) { RwFrame *clumpframe; - float distsq, dot; + float dot; uint32 flags; clumpframe = RpClumpGetFrame(RpAtomicGetClump(atomic)); - distsq = GetDistanceSquaredFromCamera(clumpframe); - if(distsq < ms_bigVehicleLod0Dist){ + if(DistToCameraSq < ms_bigVehicleLod0Dist){ flags = GetAtomicId(atomic); dot = GetDotProductWithCameraVector(RwFrameGetLTM(RpAtomicGetFrame(atomic)), RwFrameGetLTM(clumpframe), flags); - if(dot > 0.0f) - if(distsq > ms_cullCompsDist && (flags & ATOMIC_FLAG_NOCULL) == 0) + if(DistToCameraSq > ms_cullCompsDist && (flags & ATOMIC_FLAG_NOCULL) == 0 && PitchToCamera < 0.2f) + if(dot > 0.0f && ((flags & ATOMIC_FLAG_ANGLECULL) || 0.1f*DistToCameraSq < dot*dot)) return atomic; - if(!InsertAtomicIntoSortedList(atomic, distsq + dot)) + if(!InsertAtomicIntoSortedList(atomic, DistToCameraSq + dot)) AtomicDefaultRenderCallBack(atomic); } return atomic; @@ -368,29 +431,36 @@ CVisibilityPlugins::RenderVehicleHiDetailAlphaCB_BigVehicle(RpAtomic *atomic) RpAtomic* CVisibilityPlugins::RenderVehicleHiDetailCB_Boat(RpAtomic *atomic) { - RwFrame *clumpframe; - float distsq; - - clumpframe = RpClumpGetFrame(RpAtomicGetClump(atomic)); - distsq = GetDistanceSquaredFromCamera(clumpframe); - if(distsq < ms_bigVehicleLod1Dist) + if(DistToCameraSq < ms_bigVehicleLod1Dist) AtomicDefaultRenderCallBack(atomic); return atomic; } RpAtomic* +CVisibilityPlugins::RenderVehicleHiDetailAlphaCB_Boat(RpAtomic *atomic) +{ + if(DistToCameraSq < ms_vehicleLod0Dist){ + if(GetAtomicId(atomic) & ATOMIC_FLAG_DRAWLAST){ + if(!InsertAtomicIntoBoatSortedList(atomic, DistToCameraSq)) + AtomicDefaultRenderCallBack(atomic); + }else + AtomicDefaultRenderCallBack(atomic); + } + return atomic; +} + +RpAtomic* CVisibilityPlugins::RenderVehicleLowDetailCB_BigVehicle(RpAtomic *atomic) { RwFrame *clumpframe; - float distsq, dot; + float dot; uint32 flags; clumpframe = RpClumpGetFrame(RpAtomicGetClump(atomic)); - distsq = GetDistanceSquaredFromCamera(clumpframe); - if(distsq >= ms_bigVehicleLod0Dist && - distsq < ms_bigVehicleLod1Dist){ + if(DistToCameraSq >= ms_bigVehicleLod0Dist && + DistToCameraSq < ms_bigVehicleLod1Dist){ flags = GetAtomicId(atomic); - if(distsq > ms_cullCompsDist && (flags & ATOMIC_FLAG_NOCULL) == 0){ + if(DistToCameraSq > ms_cullCompsDist && (flags & ATOMIC_FLAG_NOCULL) == 0 && PitchToCamera < 0.2f){ dot = GetDotProductWithCameraVector(RwFrameGetLTM(RpAtomicGetFrame(atomic)), RwFrameGetLTM(clumpframe), flags); if(dot > 0.0f) @@ -405,21 +475,20 @@ RpAtomic* CVisibilityPlugins::RenderVehicleLowDetailAlphaCB_BigVehicle(RpAtomic *atomic) { RwFrame *clumpframe; - float distsq, dot; + float dot; uint32 flags; clumpframe = RpClumpGetFrame(RpAtomicGetClump(atomic)); - distsq = GetDistanceSquaredFromCamera(clumpframe); - if(distsq >= ms_bigVehicleLod0Dist && - distsq < ms_bigVehicleLod1Dist){ + if(DistToCameraSq >= ms_bigVehicleLod0Dist && + DistToCameraSq < ms_bigVehicleLod1Dist){ flags = GetAtomicId(atomic); dot = GetDotProductWithCameraVector(RwFrameGetLTM(RpAtomicGetFrame(atomic)), RwFrameGetLTM(clumpframe), flags); if(dot > 0.0f) - if(distsq > ms_cullCompsDist && (flags & ATOMIC_FLAG_NOCULL) == 0) + if(DistToCameraSq > ms_cullCompsDist && (flags & ATOMIC_FLAG_NOCULL) == 0 && PitchToCamera < 0.2f) return atomic; - if(!InsertAtomicIntoSortedList(atomic, distsq + dot)) + if(!InsertAtomicIntoSortedList(atomic, DistToCameraSq + dot)) AtomicDefaultRenderCallBack(atomic); } return atomic; @@ -429,12 +498,10 @@ RpAtomic* CVisibilityPlugins::RenderVehicleReallyLowDetailCB(RpAtomic *atomic) { RpClump *clump; - float dist; int32 alpha; clump = RpAtomicGetClump(atomic); - dist = GetDistanceSquaredFromCamera(RpClumpGetFrame(clump)); - if(dist >= ms_vehicleLod0Dist){ + if(DistToCameraSq >= ms_vehicleLod0Dist){ alpha = GetClumpAlpha(clump); if(alpha == 255) AtomicDefaultRenderCallBack(atomic); @@ -448,12 +515,7 @@ CVisibilityPlugins::RenderVehicleReallyLowDetailCB(RpAtomic *atomic) RpAtomic* CVisibilityPlugins::RenderVehicleReallyLowDetailCB_BigVehicle(RpAtomic *atomic) { - RwFrame *clumpframe; - float distsq; - - clumpframe = RpClumpGetFrame(RpAtomicGetClump(atomic)); - distsq = GetDistanceSquaredFromCamera(clumpframe); - if(distsq >= ms_bigVehicleLod1Dist) + if(DistToCameraSq >= ms_bigVehicleLod1Dist) AtomicDefaultRenderCallBack(atomic); return atomic; } @@ -462,17 +524,16 @@ RpAtomic* CVisibilityPlugins::RenderTrainHiDetailCB(RpAtomic *atomic) { RwFrame *clumpframe; - float distsq, dot; + float dot; uint32 flags; clumpframe = RpClumpGetFrame(RpAtomicGetClump(atomic)); - distsq = GetDistanceSquaredFromCamera(clumpframe); - if(distsq < ms_bigVehicleLod1Dist){ + if(DistToCameraSq < ms_bigVehicleLod1Dist){ flags = GetAtomicId(atomic); - if(distsq > ms_cullCompsDist && (flags & ATOMIC_FLAG_NOCULL) == 0){ + if(DistToCameraSq > ms_cullCompsDist && (flags & ATOMIC_FLAG_NOCULL) == 0 && PitchToCamera < 0.2f){ dot = GetDotProductWithCameraVector(RwFrameGetLTM(RpAtomicGetFrame(atomic)), RwFrameGetLTM(clumpframe), flags); - if(dot > 0.0f && ((flags & ATOMIC_FLAG_ANGLECULL) || 0.1f*distsq < dot*dot)) + if(dot > 0.0f && ((flags & ATOMIC_FLAG_ANGLECULL) || 0.1f*DistToCameraSq < dot*dot)) return atomic; } AtomicDefaultRenderCallBack(atomic); @@ -484,25 +545,24 @@ RpAtomic* CVisibilityPlugins::RenderTrainHiDetailAlphaCB(RpAtomic *atomic) { RwFrame *clumpframe; - float distsq, dot; + float dot; uint32 flags; clumpframe = RpClumpGetFrame(RpAtomicGetClump(atomic)); - distsq = GetDistanceSquaredFromCamera(clumpframe); - if(distsq < ms_bigVehicleLod1Dist){ + if(DistToCameraSq < ms_bigVehicleLod1Dist){ flags = GetAtomicId(atomic); dot = GetDotProductWithCameraVector(RwFrameGetLTM(RpAtomicGetFrame(atomic)), RwFrameGetLTM(clumpframe), flags); - if(distsq > ms_cullCompsDist && (flags & ATOMIC_FLAG_NOCULL) == 0) - if(dot > 0.0f && ((flags & ATOMIC_FLAG_ANGLECULL) || 0.1f*distsq < dot*dot)) + if(DistToCameraSq > ms_cullCompsDist && (flags & ATOMIC_FLAG_NOCULL) == 0 && PitchToCamera < 0.2f) + if(dot > 0.0f && ((flags & ATOMIC_FLAG_ANGLECULL) || 0.1f*DistToCameraSq < dot*dot)) return atomic; if(flags & ATOMIC_FLAG_DRAWLAST){ // sort before clump - if(!InsertAtomicIntoSortedList(atomic, distsq - 0.0001f)) + if(!InsertAtomicIntoSortedList(atomic, DistToCameraSq - 0.0001f)) AtomicDefaultRenderCallBack(atomic); }else{ - if(!InsertAtomicIntoSortedList(atomic, distsq + dot)) + if(!InsertAtomicIntoSortedList(atomic, DistToCameraSq + dot)) AtomicDefaultRenderCallBack(atomic); } } @@ -510,54 +570,49 @@ CVisibilityPlugins::RenderTrainHiDetailAlphaCB(RpAtomic *atomic) } RpAtomic* -CVisibilityPlugins::RenderPlayerCB(RpAtomic *atomic) +CVisibilityPlugins::RenderVehicleRotorAlphaCB(RpAtomic *atomic) { - if(CWorld::Players[0].m_pSkinTexture) - RpGeometryForAllMaterials(RpAtomicGetGeometry(atomic), SetTextureCB, CWorld::Players[0].m_pSkinTexture); - AtomicDefaultRenderCallBack(atomic); + RwFrame *clumpframe; + float dot; + RwV3d cam2atm; + + clumpframe = RpClumpGetFrame(RpAtomicGetClump(atomic)); + if(DistToCameraSq < ms_bigVehicleLod1Dist){ + RwV3dSub(&cam2atm, &RwFrameGetLTM(RpAtomicGetFrame(atomic))->pos, ms_pCameraPosn); + dot = RwV3dDotProduct(&cam2atm, &RwFrameGetLTM(clumpframe)->at); + if(!InsertAtomicIntoSortedList(atomic, DistToCameraSq + dot*20.0f)) + AtomicDefaultRenderCallBack(atomic); + } return atomic; } RpAtomic* -CVisibilityPlugins::RenderPedLowDetailCB(RpAtomic *atomic) +CVisibilityPlugins::RenderVehicleTailRotorAlphaCB(RpAtomic *atomic) { - RpClump *clump; - float dist; - int32 alpha; + RwMatrix *clumpMat, *atmMat; + float dot; + RwV3d cam2atm; - clump = RpAtomicGetClump(atomic); - dist = GetDistanceSquaredFromCamera(RpClumpGetFrame(clump)); - if(dist >= ms_pedLod0Dist){ - alpha = GetClumpAlpha(clump); - if(alpha == 255) + if(DistToCameraSq < ms_bigVehicleLod0Dist){ + atmMat = RwFrameGetLTM(RpAtomicGetFrame(atomic)); + clumpMat = RwFrameGetLTM(RpClumpGetFrame(RpAtomicGetClump(atomic))); + RwV3dSub(&cam2atm, &atmMat->pos, ms_pCameraPosn); + dot = RwV3dDotProduct(&cam2atm, &clumpMat->up) + RwV3dDotProduct(&cam2atm, &clumpMat->right); + if(!InsertAtomicIntoSortedList(atomic, DistToCameraSq - dot)) AtomicDefaultRenderCallBack(atomic); - else - RenderAlphaAtomic(atomic, alpha); } return atomic; } RpAtomic* -CVisibilityPlugins::RenderPedHiDetailCB(RpAtomic *atomic) +CVisibilityPlugins::RenderPlayerCB(RpAtomic *atomic) { - RpClump *clump; - float dist; - int32 alpha; - - clump = RpAtomicGetClump(atomic); - dist = GetDistanceSquaredFromCamera(RpClumpGetFrame(clump)); - if(dist < ms_pedLod0Dist){ - alpha = GetClumpAlpha(clump); - if(alpha == 255) - AtomicDefaultRenderCallBack(atomic); - else - RenderAlphaAtomic(atomic, alpha); - } + if(CWorld::Players[0].m_pSkinTexture) + RpGeometryForAllMaterials(RpAtomicGetGeometry(atomic), SetTextureCB, CWorld::Players[0].m_pSkinTexture); + AtomicDefaultRenderCallBack(atomic); return atomic; } -// This is needed for peds with only one clump, i.e. skinned models -// strangely even the xbox version has no such thing RpAtomic* CVisibilityPlugins::RenderPedCB(RpAtomic *atomic) { @@ -576,6 +631,14 @@ CVisibilityPlugins::RenderPedCB(RpAtomic *atomic) } float +CVisibilityPlugins::GetDistanceSquaredFromCamera(RwV3d *pos) +{ + RwV3d dist; + RwV3dSub(&dist, pos, ms_pCameraPosn); + return RwV3dDotProduct(&dist, &dist); +} + +float CVisibilityPlugins::GetDistanceSquaredFromCamera(RwFrame *frame) { RwMatrix *m; @@ -632,16 +695,6 @@ CVisibilityPlugins::DefaultVisibilityCB(RpClump *clump) } 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) { RwSphere sphere; @@ -735,13 +788,6 @@ CVisibilityPlugins::SetAtomicModelInfo(RpAtomic *atomic, { AtomicExt *ext = ATOMICEXT(atomic); ext->modelInfo = modelInfo; - switch (modelInfo->GetModelType()) { - case MITYPE_SIMPLE: - case MITYPE_TIME: - if(modelInfo->m_normalCull) - SetAtomicRenderCallback(atomic, RenderObjNormalAtomic); - default: break; - } } CSimpleModelInfo* diff --git a/src/rw/VisibilityPlugins.h b/src/rw/VisibilityPlugins.h index dd02f2e1..f277565d 100644 --- a/src/rw/VisibilityPlugins.h +++ b/src/rw/VisibilityPlugins.h @@ -21,7 +21,9 @@ public: }; static CLinkList<AlphaObjectInfo> m_alphaList; + static CLinkList<AlphaObjectInfo> m_alphaBoatAtomicList; static CLinkList<AlphaObjectInfo> m_alphaEntityList; + static CLinkList<AlphaObjectInfo> m_alphaUnderwaterEntityList; static RwCamera *ms_pCamera; static RwV3d *ms_pCameraPosn; static float ms_cullCompsDist; @@ -30,7 +32,6 @@ public: static float ms_vehicleFadeDist; static float ms_bigVehicleLod0Dist; static float ms_bigVehicleLod1Dist; - static float ms_pedLod0Dist; static float ms_pedLod1Dist; static float ms_pedFadeDist; @@ -40,12 +41,15 @@ public: static bool InsertEntityIntoSortedList(CEntity *e, float dist); static void InitAlphaAtomicList(void); static bool InsertAtomicIntoSortedList(RpAtomic *a, float dist); + static bool InsertAtomicIntoBoatSortedList(RpAtomic *a, float dist); static void SetRenderWareCamera(RwCamera *camera); + static void SetupVehicleVariables(RpClump *vehicle); static RpAtomic *RenderWheelAtomicCB(RpAtomic *atomic); static RpAtomic *RenderObjNormalAtomic(RpAtomic *atomic); static RpAtomic *RenderAlphaAtomic(RpAtomic *atomic, int alpha); + static RpAtomic *RenderWeaponCB(RpAtomic *atomic); static RpAtomic *RenderFadingAtomic(RpAtomic *atm, float dist); static RpAtomic *RenderVehicleHiDetailCB(RpAtomic *atomic); @@ -53,28 +57,33 @@ public: static RpAtomic *RenderVehicleHiDetailCB_BigVehicle(RpAtomic *atomic); static RpAtomic *RenderVehicleHiDetailAlphaCB_BigVehicle(RpAtomic *atomic); static RpAtomic *RenderVehicleHiDetailCB_Boat(RpAtomic *atomic); + static RpAtomic *RenderVehicleHiDetailAlphaCB_Boat(RpAtomic *atomic); static RpAtomic *RenderVehicleLowDetailCB_BigVehicle(RpAtomic *atomic); static RpAtomic *RenderVehicleLowDetailAlphaCB_BigVehicle(RpAtomic *atomic); static RpAtomic *RenderVehicleReallyLowDetailCB(RpAtomic *atomic); static RpAtomic *RenderVehicleReallyLowDetailCB_BigVehicle(RpAtomic *atomic); static RpAtomic *RenderTrainHiDetailCB(RpAtomic *atomic); static RpAtomic *RenderTrainHiDetailAlphaCB(RpAtomic *atomic); + static RpAtomic *RenderVehicleRotorAlphaCB(RpAtomic *atomic); + static RpAtomic *RenderVehicleTailRotorAlphaCB(RpAtomic *atomic); static RpAtomic *RenderPlayerCB(RpAtomic *atomic); - static RpAtomic *RenderPedLowDetailCB(RpAtomic *atomic); - static RpAtomic *RenderPedHiDetailCB(RpAtomic *atomic); static RpAtomic *RenderPedCB(RpAtomic *atomic); // for skinned models with only one clump + static void RenderAtomicList(CLinkList<AlphaObjectInfo> &list); static void RenderAlphaAtomics(void); + static void RenderBoatAlphaAtomics(void); + static void RenderFadingEntities(CLinkList<AlphaObjectInfo> &list); static void RenderFadingEntities(void); + static void RenderFadingUnderwaterEntities(void); // All actually unused static bool DefaultVisibilityCB(RpClump *clump); static bool FrustumSphereCB(RpClump *clump); - static bool MloVisibilityCB(RpClump *clump); static bool VehicleVisibilityCB(RpClump *clump); static bool VehicleVisibilityCB_BigVehicle(RpClump *clump); + static float GetDistanceSquaredFromCamera(RwV3d *pos); static float GetDistanceSquaredFromCamera(RwFrame *frame); static float GetDotProductWithCameraVector(RwMatrix *atomicMat, RwMatrix *clumpMat, uint32 flags); |