From 90689a171720550892ce7a9807193699569981a9 Mon Sep 17 00:00:00 2001 From: Fire-Head Date: Mon, 3 Aug 2020 01:25:29 +0300 Subject: shadow fixes --- src/render/Shadows.cpp | 59 +++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 29 deletions(-) (limited to 'src/render/Shadows.cpp') diff --git a/src/render/Shadows.cpp b/src/render/Shadows.cpp index c169c351..9d6193b3 100644 --- a/src/render/Shadows.cpp +++ b/src/render/Shadows.cpp @@ -458,7 +458,7 @@ CShadows::StoreShadowForCar(CAutomobile *pCar) if ( CTimeCycle::GetShadowStrength() != 0 ) { CVector CarPos = pCar->GetPosition(); - float fDistToCamSqr = (CarPos - TheCamera.GetPosition()).MagnitudeSqr(); + float fDistToCamSqr = (CarPos - TheCamera.GetPosition()).MagnitudeSqr2D(); if ( CCutsceneMgr::IsRunning() ) fDistToCamSqr /= SQR(TheCamera.LODDistMultiplier) * 4.0f; @@ -1578,40 +1578,41 @@ CStaticShadow::Free(void) void CShadows::CalcPedShadowValues(CVector vecLightDir, - float *pfDisplacementX, float *pfDisplacementY, float *pfFrontX, float *pfFrontY, - float *pfSideX, float *pfSideY) + float *pfSideX, float *pfSideY, + float *pfDisplacementX, float *pfDisplacementY) { - ASSERT(pfDisplacementX != NULL); - ASSERT(pfDisplacementY != NULL); - ASSERT(pfFrontX != NULL); - ASSERT(pfFrontY != NULL); - ASSERT(pfSideX != NULL); - ASSERT(pfSideY != NULL); + ASSERT(pfFrontX != nil); + ASSERT(pfFrontY != nil); + ASSERT(pfSideX != nil); + ASSERT(pfSideY != nil); + ASSERT(pfDisplacementX != nil); + ASSERT(pfDisplacementY != nil); - *pfDisplacementX = -vecLightDir.x; - *pfDisplacementY = -vecLightDir.y; + *pfFrontX = -vecLightDir.x; + *pfFrontY = -vecLightDir.y; - float fDist = Sqrt(*pfDisplacementY * *pfDisplacementY + *pfDisplacementX * *pfDisplacementX); + float fDist = Sqrt(*pfFrontY * *pfFrontY + *pfFrontX * *pfFrontX); float fMult = (fDist + 1.0f) / fDist; - *pfDisplacementX *= fMult; - *pfDisplacementY *= fMult; - - *pfFrontX = -vecLightDir.y / fDist; - *pfFrontY = vecLightDir.x / fDist; + *pfFrontX *= fMult; + *pfFrontY *= fMult; - *pfSideX = -vecLightDir.x; - *pfSideY = -vecLightDir.y; + *pfSideX = -vecLightDir.y / fDist; + *pfSideY = vecLightDir.x / fDist; - *pfDisplacementX /= 2; - *pfDisplacementY /= 2; + *pfDisplacementX = -vecLightDir.x; + *pfDisplacementY = -vecLightDir.y; *pfFrontX /= 2; *pfFrontY /= 2; *pfSideX /= 2; *pfSideY /= 2; + + *pfDisplacementX /= 2; + *pfDisplacementY /= 2; + } void @@ -1656,22 +1657,22 @@ CShadows::RenderExtraPlayerShadows(void) vecLight.y *= fInv; vecLight.z *= fInv; - float fDisplacementX, fDisplacementY, fFrontX, fFrontY, fSideX, fSideY; + float fFrontX, fFrontY, fSideX, fSideY, fDisplacementX, fDisplacementY; CalcPedShadowValues(vecLight, - &fDisplacementX, &fDisplacementY, - &fFrontX, &fFrontY, - &fSideX, &fSideY); + &fFrontX, &fFrontY, + &fSideX, &fSideY, + &fDisplacementX, &fDisplacementY); CVector shadowPos = FindPlayerCoors(); - shadowPos.x += fSideX; - shadowPos.y += fSideY; + shadowPos.x += fDisplacementX; + shadowPos.y += fDisplacementY; StoreShadowToBeRendered(SHADOWTYPE_DARK, gpShadowPedTex, &shadowPos, - fDisplacementX, fDisplacementY, fFrontX, fFrontY, + fSideX, fSideY, nColorStrength, 0, 0, 0, 4.0f, false, 1.0f); } @@ -1768,7 +1769,7 @@ CShadows::RenderIndicatorShadow(uint32 nID, uint8 ShadowType, RwTexture *pTextur { ASSERT(pPosn != NULL); - C3dMarkers::PlaceMarkerSet(nID, _TODOCONST(4), *pPosn, Max(fFrontX, -fSideY), + C3dMarkers::PlaceMarkerSet(nID, MARKERTYPE_CYLINDER, *pPosn, Max(fFrontX, -fSideY), 0, 128, 255, 128, 2048, 0.2f, 0); } -- cgit v1.2.3 From abb640c6b6b1c4c1b699d18509c8a344e2be2dd5 Mon Sep 17 00:00:00 2001 From: aap Date: Mon, 3 Aug 2020 12:58:37 +0200 Subject: VU0 collision --- src/render/Shadows.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/render/Shadows.cpp') diff --git a/src/render/Shadows.cpp b/src/render/Shadows.cpp index c169c351..9980d678 100644 --- a/src/render/Shadows.cpp +++ b/src/render/Shadows.cpp @@ -1027,7 +1027,9 @@ CShadows::CastShadowEntity(CEntity *pEntity, float fStartX, float fStartY, floa CColTrianglePlane *pColTriPlanes = pCol->trianglePlanes; ASSERT(pColTriPlanes != NULL); - if ( Abs(pColTriPlanes[i].normal.z) > 0.1f ) + CVector normal; + pColTriPlanes[i].GetNormal(normal); + if ( Abs(normal.z) > 0.1f ) { CColTriangle *pColTri = pCol->triangles; ASSERT(pColTri != NULL); -- cgit v1.2.3