diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/World.cpp | 251 | ||||
-rw-r--r-- | src/core/World.h | 20 | ||||
-rw-r--r-- | src/core/Zones.cpp | 16 | ||||
-rw-r--r-- | src/core/config.h | 1 | ||||
-rw-r--r-- | src/core/main.cpp | 149 | ||||
-rw-r--r-- | src/core/main.h | 5 | ||||
-rw-r--r-- | src/core/re3.cpp | 24 |
7 files changed, 372 insertions, 94 deletions
diff --git a/src/core/World.cpp b/src/core/World.cpp index 14c06a81..4c700f10 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -15,6 +15,7 @@ #include "Object.h" #include "ParticleObject.h" #include "Ped.h" +#include "Pickups.h" #include "PlayerPed.h" #include "Population.h" #include "ProjectileInfo.h" @@ -28,6 +29,7 @@ #include "WaterLevel.h" #include "World.h" +// --MIAMI: file done #define OBJECT_REPOSITION_OFFSET_Z 2.0f @@ -157,6 +159,7 @@ CWorld::ClearExcitingStuffFromArea(const CVector &pos, float radius, bool bRemov CProjectileInfo::RemoveAllProjectiles(); CShadows::TidyUpShadows(); } + CPickups::RemoveUnnecessaryPickups(pos, radius); } bool @@ -333,11 +336,24 @@ CWorld::ProcessLineOfSightSectorList(CPtrList &list, const CColLine &line, CColP { bool deadPeds = false; bool bikers = false; + bool carTyres = false; float mindist = dist; CPtrNode *node; CEntity *e; CColModel *colmodel; - + CColModel tyreCol; + CColSphere tyreSpheres[6]; + CColPoint tyreColPoint; + float tyreDist; + + if(bIncludeCarTyres && list.first && ((CEntity*)list.first->item)->IsVehicle()){ + carTyres = true; + tyreCol.numTriangles = 0; + tyreCol.numBoxes = 0; + tyreCol.numLines = 0; + tyreCol.spheres = tyreSpheres; + tyreCol.numSpheres = ARRAY_SIZE(tyreSpheres); + } if(list.first && bIncludeDeadPeds && ((CEntity *)list.first->item)->IsPed()) deadPeds = true; if(list.first && bIncludeBikers && ((CEntity *)list.first->item)->IsPed()) bikers = true; @@ -346,10 +362,11 @@ CWorld::ProcessLineOfSightSectorList(CPtrList &list, const CColLine &line, CColP if(e->m_scanCode != GetCurrentScanCode() && e != pIgnoreEntity && (e->bUsesCollision || deadPeds || bikers) && !(ignoreSomeObjects && CameraToIgnoreThisObject(e))) { colmodel = nil; + tyreDist = mindist; e->m_scanCode = GetCurrentScanCode(); if(e->IsPed()) { - if(e->bUsesCollision || deadPeds && ((CPed *)e)->m_nPedState == PED_DEAD || bikers) { + if(e->bUsesCollision || deadPeds && ((CPed *)e)->m_nPedState == PED_DEAD || bikers && ((CPed*)e)->InVehicle() && (((CPed*)e)->m_pMyVehicle->IsBike() || ((CPed*)e)->m_pMyVehicle->IsBoat())) { colmodel = ((CPedModelInfo *)CModelInfo::GetModelInfo(e->GetModelIndex()))->AnimatePedColModelSkinned(e->GetClump()); } else colmodel = nil; @@ -360,8 +377,18 @@ CWorld::ProcessLineOfSightSectorList(CPtrList &list, const CColLine &line, CColP if(colmodel && CCollision::ProcessLineOfSight(line, e->GetMatrix(), *colmodel, point, dist, ignoreSeeThrough, ignoreShootThrough)) entity = e; + if(carTyres && ((CVehicle*)e)->SetUpWheelColModel(&tyreCol) && CCollision::ProcessLineOfSight(line, e->GetMatrix(), tyreCol, tyreColPoint, tyreDist, false, ignoreShootThrough)){ + float dp1 = DotProduct(line.p1 - line.p0, e->GetRight()); + float dp2 = DotProduct(point.point - e->GetPosition(), e->GetRight()); + if(tyreDist < mindist || dp1 < -0.85f && dp2 > 0.0f || dp1 > 0.85f && dp2 < 0.0f){ + mindist = tyreDist; + point = tyreColPoint; + entity = e; + } + } } } + tyreCol.spheres = nil; if(mindist < dist) { dist = mindist; @@ -695,18 +722,10 @@ CWorld::FindObjectsInRange(Const CVector ¢re, float radius, bool ignoreZ, in if(minY <= 0) minY = 0; int maxX = GetSectorIndexX(centre.x + radius); -#ifdef FIX_BUGS if(maxX >= NUMSECTORS_X) maxX = NUMSECTORS_X - 1; -#else - if(maxX >= NUMSECTORS_X) maxX = NUMSECTORS_X; -#endif int maxY = GetSectorIndexY(centre.y + radius); -#ifdef FIX_BUGS if(maxY >= NUMSECTORS_Y) maxY = NUMSECTORS_Y - 1; -#else - if(maxY >= NUMSECTORS_Y) maxY = NUMSECTORS_Y; -#endif AdvanceCurrentScanCode(); @@ -781,13 +800,18 @@ CWorld::FindObjectsOfTypeInRange(uint32 modelId, const CVector &position, float *nEntitiesFound = 0; const CVector2D vecSectorStartPos(position.x - radius, position.y - radius); const CVector2D vecSectorEndPos(position.x + radius, position.y + radius); - const int32 nStartX = Max(CWorld::GetSectorIndexX(vecSectorStartPos.x), 0); - const int32 nStartY = Max(CWorld::GetSectorIndexY(vecSectorStartPos.y), 0); - const int32 nEndX = Min(CWorld::GetSectorIndexX(vecSectorEndPos.x), NUMSECTORS_X - 1); - const int32 nEndY = Min(CWorld::GetSectorIndexY(vecSectorEndPos.y), NUMSECTORS_Y - 1); + const int32 nStartX = Max(GetSectorIndexX(vecSectorStartPos.x), 0); + const int32 nStartY = Max(GetSectorIndexY(vecSectorStartPos.y), 0); +#ifdef FIX_BUGS + const int32 nEndX = Min(GetSectorIndexX(vecSectorEndPos.x), NUMSECTORS_X - 1); + const int32 nEndY = Min(GetSectorIndexY(vecSectorEndPos.y), NUMSECTORS_Y - 1); +#else + const int32 nEndX = Min(GetSectorIndexX(vecSectorEndPos.x), NUMSECTORS_X); + const int32 nEndY = Min(GetSectorIndexY(vecSectorEndPos.y), NUMSECTORS_Y); +#endif for(int32 y = nStartY; y <= nEndY; y++) { for(int32 x = nStartX; x <= nEndX; x++) { - CSector *pSector = CWorld::GetSector(x, y); + CSector *pSector = GetSector(x, y); if(bBuildings) { CWorld::FindObjectsOfTypeInRangeSectorList( modelId, pSector->m_lists[ENTITYLIST_BUILDINGS], position, radius, bCheck2DOnly, @@ -1050,13 +1074,18 @@ CWorld::FindObjectsKindaColliding(const CVector &position, float radius, bool bC *nCollidingEntities = 0; const CVector2D vecSectorStartPos(position.x - radius, position.y - radius); const CVector2D vecSectorEndPos(position.x + radius, position.y + radius); - const int32 nStartX = Max(CWorld::GetSectorIndexX(vecSectorStartPos.x), 0); - const int32 nStartY = Max(CWorld::GetSectorIndexY(vecSectorStartPos.y), 0); - const int32 nEndX = Min(CWorld::GetSectorIndexX(vecSectorEndPos.x), NUMSECTORS_X - 1); - const int32 nEndY = Min(CWorld::GetSectorIndexY(vecSectorEndPos.y), NUMSECTORS_Y - 1); + const int32 nStartX = Max(GetSectorIndexX(vecSectorStartPos.x), 0); + const int32 nStartY = Max(GetSectorIndexY(vecSectorStartPos.y), 0); +#ifdef FIX_BUGS + const int32 nEndX = Min(GetSectorIndexX(vecSectorEndPos.x), NUMSECTORS_X - 1); + const int32 nEndY = Min(GetSectorIndexY(vecSectorEndPos.y), NUMSECTORS_Y - 1); +#else + const int32 nEndX = Min(GetSectorIndexX(vecSectorEndPos.x), NUMSECTORS_X); + const int32 nEndY = Min(GetSectorIndexY(vecSectorEndPos.y), NUMSECTORS_Y); +#endif for(int32 y = nStartY; y <= nEndY; y++) { for(int32 x = nStartX; x <= nEndX; x++) { - CSector *pSector = CWorld::GetSector(x, y); + CSector *pSector = GetSector(x, y); if(bBuildings) { CWorld::FindObjectsKindaCollidingSectorList( pSector->m_lists[ENTITYLIST_BUILDINGS], position, radius, bCheck2DOnly, @@ -1129,13 +1158,18 @@ CWorld::FindObjectsIntersectingCube(const CVector &vecStartPos, const CVector &v { CWorld::AdvanceCurrentScanCode(); *nIntersecting = 0; - const int32 nStartX = Max(CWorld::GetSectorIndexX(vecStartPos.x), 0); - const int32 nStartY = Max(CWorld::GetSectorIndexY(vecStartPos.y), 0); - const int32 nEndX = Min(CWorld::GetSectorIndexX(vecEndPos.x), NUMSECTORS_X - 1); - const int32 nEndY = Min(CWorld::GetSectorIndexY(vecEndPos.y), NUMSECTORS_Y - 1); + const int32 nStartX = Max(GetSectorIndexX(vecStartPos.x), 0); + const int32 nStartY = Max(GetSectorIndexY(vecStartPos.y), 0); +#ifdef FIX_BUGS + const int32 nEndX = Min(GetSectorIndexX(vecStartPos.x), NUMSECTORS_X - 1); + const int32 nEndY = Min(GetSectorIndexY(vecStartPos.y), NUMSECTORS_Y - 1); +#else + const int32 nEndX = Min(GetSectorIndexX(vecSectorPos.x), NUMSECTORS_X); + const int32 nEndY = Min(GetSectorIndexY(vecSectorPos.y), NUMSECTORS_Y); +#endif for(int32 y = nStartY; y <= nEndY; y++) { for(int32 x = nStartX; x <= nEndX; x++) { - CSector *pSector = CWorld::GetSector(x, y); + CSector *pSector = GetSector(x, y); if(bBuildings) { CWorld::FindObjectsIntersectingCubeSectorList(pSector->m_lists[ENTITYLIST_BUILDINGS], vecStartPos, vecEndPos, nIntersecting, @@ -1210,13 +1244,18 @@ CWorld::FindObjectsIntersectingAngledCollisionBox(const CBox &boundingBox, const { CWorld::AdvanceCurrentScanCode(); *nEntitiesFound = 0; - const int32 nStartX = Max(CWorld::GetSectorIndexX(fStartX), 0); - const int32 nStartY = Max(CWorld::GetSectorIndexY(fStartY), 0); - const int32 nEndX = Min(CWorld::GetSectorIndexX(fEndX), NUMSECTORS_X - 1); - const int32 nEndY = Min(CWorld::GetSectorIndexY(fEndY), NUMSECTORS_Y - 1); + const int32 nStartX = Max(GetSectorIndexX(fStartX), 0); + const int32 nStartY = Max(GetSectorIndexY(fStartY), 0); +#ifdef FIX_BUGS + const int32 nEndX = Min(GetSectorIndexX(fEndX), NUMSECTORS_X - 1); + const int32 nEndY = Min(GetSectorIndexY(fEndY), NUMSECTORS_Y - 1); +#else + const int32 nEndX = Min(GetSectorIndexX(fEndX), NUMSECTORS_X); + const int32 nEndY = Min(GetSectorIndexY(fEndY), NUMSECTORS_Y); +#endif for(int32 y = nStartY; y <= nEndY; y++) { for(int32 x = nStartX; x <= nEndX; x++) { - CSector *pSector = CWorld::GetSector(x, y); + CSector *pSector = GetSector(x, y); if(bBuildings) { CWorld::FindObjectsIntersectingAngledCollisionBoxSectorList( pSector->m_lists[ENTITYLIST_BUILDINGS], boundingBox, matrix, position, @@ -1290,13 +1329,18 @@ CWorld::FindMissionEntitiesIntersectingCube(const CVector &vecStartPos, const CV { CWorld::AdvanceCurrentScanCode(); *nIntersecting = 0; - const int32 nStartX = Max(CWorld::GetSectorIndexX(vecStartPos.x), 0); - const int32 nStartY = Max(CWorld::GetSectorIndexY(vecStartPos.y), 0); - const int32 nEndX = Min(CWorld::GetSectorIndexX(vecEndPos.x), NUMSECTORS_X - 1); - const int32 nEndY = Min(CWorld::GetSectorIndexY(vecEndPos.y), NUMSECTORS_Y - 1); + const int32 nStartX = Max(GetSectorIndexX(vecStartPos.x), 0); + const int32 nStartY = Max(GetSectorIndexY(vecStartPos.y), 0); +#ifdef FIX_BUGS + const int32 nEndX = Min(GetSectorIndexX(vecEndPos.x), NUMSECTORS_X - 1); + const int32 nEndY = Min(GetSectorIndexY(vecEndPos.y), NUMSECTORS_Y - 1); +#else + const int32 nEndX = Min(GetSectorIndexX(vecEndPos.x), NUMSECTORS_X); + const int32 nEndY = Min(GetSectorIndexY(vecEndPos.y), NUMSECTORS_Y); +#endif for(int32 y = nStartY; y <= nEndY; y++) { for(int32 x = nStartX; x <= nEndX; x++) { - CSector *pSector = CWorld::GetSector(x, y); + CSector *pSector = GetSector(x, y); if(bVehicles) { CWorld::FindMissionEntitiesIntersectingCubeSectorList( pSector->m_lists[ENTITYLIST_VEHICLES], vecStartPos, vecEndPos, nIntersecting, @@ -1504,13 +1548,18 @@ CWorld::CallOffChaseForArea(float x1, float y1, float x2, float y2) float fStartY = y1 - 10.0f; float fEndX = x2 + 10.0f; float fEndY = y2 + 10.0f; - const int32 nStartX = Max(CWorld::GetSectorIndexX(fStartX), 0); - const int32 nStartY = Max(CWorld::GetSectorIndexY(fStartY), 0); - const int32 nEndX = Min(CWorld::GetSectorIndexX(fEndX), NUMSECTORS_X - 1); - const int32 nEndY = Min(CWorld::GetSectorIndexY(fEndY), NUMSECTORS_Y - 1); + const int32 nStartX = Max(GetSectorIndexX(fStartX), 0); + const int32 nStartY = Max(GetSectorIndexY(fStartY), 0); +#ifdef FIX_BUGS + const int32 nEndX = Min(GetSectorIndexX(fEndX), NUMSECTORS_X - 1); + const int32 nEndY = Min(GetSectorIndexY(fEndY), NUMSECTORS_Y - 1); +#else + const int32 nEndX = Min(GetSectorIndexX(fEndX), NUMSECTORS_X); + const int32 nEndY = Min(GetSectorIndexY(fEndY), NUMSECTORS_Y); +#endif for(int32 y = nStartY; y <= nEndY; y++) { for(int32 x = nStartX; x <= nEndX; x++) { - CSector *pSector = CWorld::GetSector(x, y); + CSector *pSector = GetSector(x, y); CWorld::CallOffChaseForAreaSectorListVehicles(pSector->m_lists[ENTITYLIST_VEHICLES], x1, y1, x2, y2, fStartX, fStartY, fEndX, fEndY); CWorld::CallOffChaseForAreaSectorListVehicles(pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], x1, @@ -1638,7 +1687,7 @@ CWorld::RemoveFallenCars(void) CVehicle *veh = CPools::GetVehiclePool()->GetSlot(poolIndex); if(veh) { if(veh->GetPosition().z < MAP_Z_LOW_LIMIT) { - if(veh->VehicleCreatedBy == MISSION_VEHICLE || veh == FindPlayerVehicle() || + if(veh->VehicleCreatedBy == MISSION_VEHICLE && !veh->bRenderScorched || veh == FindPlayerVehicle() || (veh->pDriver && veh->pDriver->IsPlayer())) { int closestNode = ThePaths.FindNodeClosestToCoors(veh->GetPosition(), PATH_CAR, 999999.9f, false, false); @@ -1825,37 +1874,55 @@ CWorld::RepositionOneObject(CEntity *pEntity) { int16 modelId = pEntity->GetModelIndex(); if (modelId == MI_PARKINGMETER || modelId == MI_PHONEBOOTH1 || modelId == MI_WASTEBIN || - modelId == MI_BIN || modelId == MI_POSTBOX1 || modelId == MI_NEWSSTAND || modelId == MI_TRAFFICCONE || - modelId == MI_DUMP1 || modelId == MI_ROADWORKBARRIER1 || modelId == MI_BUSSIGN1 || modelId == MI_NOPARKINGSIGN1 || - modelId == MI_PHONESIGN || modelId == MI_FIRE_HYDRANT || modelId == MI_BOLLARDLIGHT || - modelId == MI_PARKTABLE || modelId == MI_PARKINGMETER2 || modelId == MI_TELPOLE02 || - modelId == MI_PARKBENCH || modelId == MI_BARRIER1 || IsTreeModel(modelId) || - IsLightThatNeedsRepositioning(modelId) + modelId == MI_BIN || modelId == MI_POSTBOX1 || modelId == MI_NEWSSTAND || modelId == MI_TRAFFICCONE || + modelId == MI_DUMP1 || modelId == MI_ROADWORKBARRIER1 || modelId == MI_BUSSIGN1 || modelId == MI_NOPARKINGSIGN1 || + modelId == MI_PHONESIGN || modelId == MI_FIRE_HYDRANT || modelId == MI_BOLLARDLIGHT || + modelId == MI_PARKTABLE || modelId == MI_PARKINGMETER2 || modelId == MI_TELPOLE02 || + modelId == MI_PARKBENCH || modelId == MI_BARRIER1 || IsTreeModel(modelId) ) { - CVector &position = pEntity->GetMatrix().GetPosition(); - CColModel *pColModel = pEntity->GetColModel(); + CVector& position = pEntity->GetMatrix().GetPosition(); + CColModel* pColModel = pEntity->GetColModel(); float fBoundingBoxMinZ = pColModel->boundingBox.min.z; float fHeight = pColModel->boundingBox.max.z - pColModel->boundingBox.min.z; - if(fHeight < OBJECT_REPOSITION_OFFSET_Z) fHeight = OBJECT_REPOSITION_OFFSET_Z; + if (fHeight < OBJECT_REPOSITION_OFFSET_Z) fHeight = OBJECT_REPOSITION_OFFSET_Z; position.z = CWorld::FindGroundZFor3DCoord(position.x, position.y, - position.z + fHeight, nil) - - fBoundingBoxMinZ; + position.z + fHeight, nil) - + fBoundingBoxMinZ; pEntity->m_matrix.UpdateRW(); pEntity->UpdateRwFrame(); - } else if(modelId == MI_BUOY) { - float fWaterLevel = 0.0f; + } else if(IsLightThatNeedsRepositioning(modelId)) { + CVector position = pEntity->GetMatrix().GetPosition(); + CColModel* pColModel = pEntity->GetColModel(); + float fBoundingBoxMinZ = pColModel->boundingBox.min.z; + float fHeight = pColModel->boundingBox.max.z - pColModel->boundingBox.min.z; + if (fHeight < OBJECT_REPOSITION_OFFSET_Z) fHeight = OBJECT_REPOSITION_OFFSET_Z; + if (pColModel->numBoxes == 1) + position = pEntity->GetMatrix() * CVector( + (pColModel->boxes[0].min.x + pColModel->boxes[0].max.x) / 2, + (pColModel->boxes[0].min.y + pColModel->boxes[0].max.y) / 2, + pColModel->boxes[0].min.z); + else if (pColModel->numSpheres > 0) { + position.z = 1000.0f; + for (int i = 0; i < pColModel->numSpheres; i++) { + if (pColModel->spheres[i].center.z < position.z) + position = pColModel->spheres[i].center; + } + if (position.z < 1000.0f) + position = pEntity->GetMatrix() * position; + } + pEntity->GetMatrix().GetPosition().z = FindGroundZFor3DCoord(position.x, position.y, pEntity->GetMatrix().GetPosition().z + fHeight, nil) - fBoundingBoxMinZ; + pEntity->GetMatrix().UpdateRW(); + pEntity->UpdateRwFrame(); + + } + if(modelId == MI_BUOY) { bool bFound = true; const CVector &position = pEntity->GetPosition(); float fGroundZ = CWorld::FindGroundZFor3DCoord(position.x, position.y, position.z + OBJECT_REPOSITION_OFFSET_Z, &bFound); - if(CWaterLevel::GetWaterLevelNoWaves(position.x, position.y, position.z + OBJECT_REPOSITION_OFFSET_Z, - &fWaterLevel)) { - if(!bFound || fWaterLevel > fGroundZ) { - CColModel *pColModel = pEntity->GetColModel(); - float fHeight = pColModel->boundingBox.max.z - pColModel->boundingBox.min.z; - pEntity->GetMatrix().GetPosition().z = 0.2f * fHeight + fWaterLevel - 0.5f * fHeight; - } - } + CColModel *pColModel = pEntity->GetColModel(); + float fHeight = pColModel->boundingBox.max.z - pColModel->boundingBox.min.z; + pEntity->GetMatrix().GetPosition().z = 0.2f * fHeight + 6.0f - 0.5f * fHeight; } } @@ -1874,6 +1941,28 @@ CWorld::SetCarsOnFire(float x, float y, float z, float radius, CEntity *reason) } void +CWorld::SetPedsChoking(float x, float y, float z, float radius, CEntity* reason) +{ + int32 poolSize = CPools::GetPedPool()->GetSize(); + for (int32 i = poolSize - 1; i >= 0; i--) { + CPed* pPed = CPools::GetPedPool()->GetSlot(i); + // suspicious copypaste + if (pPed && pPed->m_nPedState != PED_DEAD && !pPed->bInVehicle && !pPed->m_pFire && !pPed->bFireProof && pPed->CharCreatedBy != MISSION_CHAR) { + if (Abs(pPed->GetPosition().z - z) < 5.0f && Abs(pPed->GetPosition().x - x) < radius && + Abs(pPed->GetPosition().y - y) < radius) { + if (!pPed->IsPlayer()) + pPed->SetFlee(CVector2D(x, y), 10000); +#ifdef FIX_BUGS + pPed->InflictDamage(reason, WEAPONTYPE_TEARGAS, 1.0f, PEDPIECE_TORSO, 0); +#else + pPed->InflictDamage(nil, WEAPONTYPE_TEARGAS, 1.0f, PEDPIECE_TORSO, 0); +#endif + } + } + } +} + +void CWorld::SetPedsOnFire(float x, float y, float z, float radius, CEntity *reason) { int32 poolSize = CPools::GetPedPool()->GetSize(); @@ -1925,11 +2014,12 @@ CWorld::Process(void) if(csObj && csObj->m_entryInfoList.first) { if(csObj->m_rwObject && RwObjectGetType(csObj->m_rwObject) == rpCLUMP && RpAnimBlendClumpGetFirstAssociation(csObj->GetClump())) { -// TODO(MIAMI): doRender argument - RpAnimBlendClumpUpdateAnimations(csObj->GetClump(), - 0.02f * (csObj->IsObject() - ? CTimer::GetTimeStepNonClipped() - : CTimer::GetTimeStep())); + if (csObj->IsObject()) + RpAnimBlendClumpUpdateAnimations(csObj->GetClump(), 0.02f * CTimer::GetTimeStepNonClipped()); + else { + csObj->bOffscreen = !csObj->GetIsOnScreen(); + RpAnimBlendClumpUpdateAnimations(csObj->GetClump(), 0.02f * CTimer::GetTimeStep(), !csObj->bOffscreen); + } } csObj->ProcessControl(); csObj->ProcessCollision(); @@ -1949,11 +2039,12 @@ CWorld::Process(void) #endif if(movingEnt->m_rwObject && RwObjectGetType(movingEnt->m_rwObject) == rpCLUMP && RpAnimBlendClumpGetFirstAssociation(movingEnt->GetClump())) { -// TODO(MIAMI): doRender argument - RpAnimBlendClumpUpdateAnimations(movingEnt->GetClump(), - 0.02f * (movingEnt->IsObject() - ? CTimer::GetTimeStepNonClipped() - : CTimer::GetTimeStep())); + if (movingEnt->IsObject()) + RpAnimBlendClumpUpdateAnimations(movingEnt->GetClump(), 0.02f * CTimer::GetTimeStepNonClipped()); + else { + movingEnt->bOffscreen = !movingEnt->GetIsOnScreen(); + RpAnimBlendClumpUpdateAnimations(movingEnt->GetClump(), 0.02f * CTimer::GetTimeStep(), !movingEnt->bOffscreen); + } } } for(CPtrNode *node = ms_listMovingEntityPtrs.first; node; node = node->next) { @@ -2037,7 +2128,7 @@ CWorld::Process(void) movingEnt->bIsStuck = true; if(movingEnt->GetStatus() == STATUS_PLAYER) { printf("STUCK: Final Step: Player Entity %d Is Stuck\n", movingEnt->GetModelIndex()); - movingEnt->m_vecMoveSpeed *= 0.3f; + movingEnt->m_vecMoveSpeed *= Pow(0.707f, CTimer::GetTimeStep()); movingEnt->ApplyMoveSpeed(); movingEnt->ApplyTurnSpeed(); } @@ -2102,13 +2193,13 @@ CWorld::TriggerExplosion(const CVector &position, float fRadius, float fPower, C { CVector2D vecStartPos(position.x - fRadius, position.y - fRadius); CVector2D vecEndPos(position.x + fRadius, position.y + fRadius); - const int32 nStartX = Max(CWorld::GetSectorIndexX(vecStartPos.x), 0); - const int32 nStartY = Max(CWorld::GetSectorIndexY(vecStartPos.y), 0); - const int32 nEndX = Min(CWorld::GetSectorIndexX(vecEndPos.x), NUMSECTORS_X - 1); - const int32 nEndY = Min(CWorld::GetSectorIndexY(vecEndPos.y), NUMSECTORS_Y - 1); + const int32 nStartX = Max(GetSectorIndexX(vecStartPos.x), 0); + const int32 nStartY = Max(GetSectorIndexY(vecStartPos.y), 0); + const int32 nEndX = Min(GetSectorIndexX(vecEndPos.x), NUMSECTORS_X - 1); + const int32 nEndY = Min(GetSectorIndexY(vecEndPos.y), NUMSECTORS_Y - 1); for(int32 y = nStartY; y <= nEndY; y++) { for(int32 x = nStartX; x <= nEndX; x++) { - CSector *pSector = CWorld::GetSector(x, y); + CSector *pSector = GetSector(x, y); CWorld::TriggerExplosionSectorList(pSector->m_lists[ENTITYLIST_VEHICLES], position, fRadius, fPower, pCreator, bProcessVehicleBombTimer); CWorld::TriggerExplosionSectorList(pSector->m_lists[ENTITYLIST_PEDS], position, fRadius, fPower, @@ -2146,7 +2237,7 @@ CWorld::TriggerExplosionSectorList(CPtrList &list, const CVector &position, floa pObject->bHasBeenDamaged) { if(pEntity->IsObject() && modelId != MI_EXPLODINGBARREL && - modelId != MI_PETROLPUMP) + modelId != MI_PETROLPUMP && modelId != MI_PETROLPUMP2) pObject->bHasBeenDamaged = true; } else { CVector pos = pEntity->GetPosition(); @@ -2171,7 +2262,7 @@ CWorld::TriggerExplosionSectorList(CPtrList &list, const CVector &position, floa if(!pEntity->GetIsStatic()) { float fDamageMultiplier = Min((fRadius - fMagnitude) * 2.0f / fRadius, 1.0f); CVector vecForceDir = - vecDistance * (fPower * pEntity->m_fMass * 0.00071429f * fDamageMultiplier / + vecDistance * (fPower * pEntity->m_fMass / 14000.0f * fDamageMultiplier / Max(fMagnitude, 0.01f)); vecForceDir.z = Max(vecForceDir.z, 0.0f); if(pEntity == FindPlayerPed()) vecForceDir.z = Min(vecForceDir.z, 1.0f); diff --git a/src/core/World.h b/src/core/World.h index 606a3466..be32db20 100644 --- a/src/core/World.h +++ b/src/core/World.h @@ -77,7 +77,7 @@ public: static void Remove(CEntity *entity); static void Add(CEntity *entity); - static CSector *GetSector(int x, int y) { return &ms_aSectors[y][x]; } + static CSector *GetSector(int x, int y) { if (x > NUMSECTORS_X - 1 || y > NUMSECTORS_Y - 1) return &ms_aSectors[0][0]; return &ms_aSectors[y][x]; } static CPtrList &GetBigBuildingList(eLevelName i) { return ms_bigBuildingsList[i]; } static CPtrList &GetMovingEntityList(void) { return ms_listMovingEntityPtrs; } static uint16 GetCurrentScanCode(void) { return ms_nCurrentScanCode; } @@ -144,6 +144,7 @@ public: static void SetAllCarsCanBeDamaged(bool); static void ExtinguishAllCarFiresInArea(CVector, float); static void SetCarsOnFire(float x, float y, float z, float radius, CEntity* reason); + static void SetPedsChoking(float x, float y, float z, float radius, CEntity* reason); static void SetPedsOnFire(float x, float y, float z, float radius, CEntity* reason); static void Initialise(); @@ -157,6 +158,23 @@ public: static void TriggerExplosion(const CVector& position, float fRadius, float fPower, CEntity* pCreator, bool bProcessVehicleBombTimer); static void TriggerExplosionSectorList(CPtrList& list, const CVector& position, float fRadius, float fPower, CEntity* pCreator, bool bProcessVehicleBombTimer); static void UseDetonator(CEntity *pEntity); + + // NB: following functions are unused (TODO?) + static void CastShadow(float, float, float, float); + static void CastShadowSectorList(CPtrList&, float, float, float, float); + static void FindLowestZForCoord(float, float); + static void CheckBlockListIntegrity(void); + static void ProcessVerticalLineSectorList_FillGlobeColPoints(CPtrList&, const CColLine&, CEntity*&, bool, CStoredCollPoly*); + static void ProcessVerticalLineSector_FillGlobeColPoints(CSector&, const CColLine&, CEntity*&, bool, bool, bool, bool, bool, bool, CStoredCollPoly*); + static void ProcessVerticalLine_FillGlobeColPoints(const CVector&, float, CEntity*&, bool, bool, bool, bool, bool, bool, CStoredCollPoly*); + static void PrintCarChanges(void); + static void TestForBuildingsOnTopOfEachOther(CPtrList&); + static void TestForBuildingsOnTopOfEachOther(void); + static void TestForUnusedModels(CPtrList&, int*); + static void TestForUnusedModels(void); + static void HandleCollisionZoneChange(eLevelName, eLevelName); + static void DoZoneTestForChaser(class CPhysical*); + static void FindPlayerSlotWithPedPointer(void*); }; extern CColPoint gaTempSphereColPoints[MAX_COLLISION_POINTS]; diff --git a/src/core/Zones.cpp b/src/core/Zones.cpp index 45fe6fff..8abe0f1e 100644 --- a/src/core/Zones.cpp +++ b/src/core/Zones.cpp @@ -532,14 +532,14 @@ CTheZones::SetZonePedInfo(uint16 zoneid, uint8 day, int16 pedDensity, info->gangPedThreshold[8] = gang8Density; info->gangPedThreshold[0] += info->copPedThreshold; - info->gangPedThreshold[1] = info->gangPedThreshold[0]; - info->gangPedThreshold[2] = info->gangPedThreshold[1]; - info->gangPedThreshold[3] = info->gangPedThreshold[2]; - info->gangPedThreshold[4] = info->gangPedThreshold[3]; - info->gangPedThreshold[5] = info->gangPedThreshold[4]; - info->gangPedThreshold[6] = info->gangPedThreshold[5]; - info->gangPedThreshold[7] = info->gangPedThreshold[6]; - info->gangPedThreshold[8] = info->gangPedThreshold[7]; + info->gangPedThreshold[1] += info->gangPedThreshold[0]; + info->gangPedThreshold[2] += info->gangPedThreshold[1]; + info->gangPedThreshold[3] += info->gangPedThreshold[2]; + info->gangPedThreshold[4] += info->gangPedThreshold[3]; + info->gangPedThreshold[5] += info->gangPedThreshold[4]; + info->gangPedThreshold[6] += info->gangPedThreshold[5]; + info->gangPedThreshold[7] += info->gangPedThreshold[6]; + info->gangPedThreshold[8] += info->gangPedThreshold[7]; } //--MIAMI: unused diff --git a/src/core/config.h b/src/core/config.h index 6e0a17f7..822cf83f 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -246,6 +246,7 @@ enum Config { #ifdef LIBRW //#define EXTENDED_COLOURFILTER // more options for colour filter (replaces mblur) //#define EXTENDED_PIPELINES // custom render pipelines (includes Neo) +//#define NEW_RENDERER // leeds-like world rendering, needs librw #endif //#define MULTISAMPLING // adds MSAA option TODO diff --git a/src/core/main.cpp b/src/core/main.cpp index 64b3a63f..48e0ff76 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -107,6 +107,13 @@ void TheGame(void); void DebugMenuPopulate(void); #endif +#ifdef NEW_RENDERER +bool gbNewRenderer; +#define CLEARMODE (rwCAMERACLEARZ | rwCAMERACLEARSTENCIL) +#else +#define CLEARMODE (rwCAMERACLEARZ) +#endif + void ValidateVersion() { @@ -151,7 +158,7 @@ DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomR CDraw::CalculateAspectRatio(); CameraSize(Scene.camera, nil, SCREEN_VIEWWINDOW, SCREEN_ASPECT_RATIO); CVisibilityPlugins::SetRenderWareCamera(Scene.camera); - RwCameraClear(Scene.camera, &TopColor.rwRGBA, rwCAMERACLEARZ); + RwCameraClear(Scene.camera, &TopColor.rwRGBA, CLEARMODE); if(!RsCameraBeginUpdate(Scene.camera)) return false; @@ -170,7 +177,7 @@ DoRWStuffStartOfFrame_Horizon(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 CDraw::CalculateAspectRatio(); CameraSize(Scene.camera, nil, SCREEN_VIEWWINDOW, SCREEN_ASPECT_RATIO); CVisibilityPlugins::SetRenderWareCamera(Scene.camera); - RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ); + RwCameraClear(Scene.camera, &gColourTop, CLEARMODE); if(!RsCameraBeginUpdate(Scene.camera)) return false; @@ -849,9 +856,130 @@ DisplayGameDebugText() } #endif +#ifdef NEW_RENDERER +bool gbRenderRoads = true; +bool gbRenderEverythingBarRoads = true; +bool gbRenderFadingInUnderwaterEntities = true; +bool gbRenderFadingInEntities = true; +bool gbRenderWater = true; +bool gbRenderBoats = true; +bool gbRenderVehicles = true; +bool gbRenderWorld0 = true; +bool gbRenderWorld1 = true; +bool gbRenderWorld2 = true; + +void +MattRenderScene(void) +{ + // this calls CMattRenderer::Render + CWorld::AdvanceCurrentScanCode(); + // CMattRenderer::ResetRenderStates + CRenderer::ClearForFrame(); + // CClock::CalcEnvMapTimeMultiplicator + CWaterLevel::RenderWater(); // actually CMattRenderer::RenderWater + // CClock::ms_EnvMapTimeMultiplicator = 1.0f; + // cWorldStream::ClearDynamics + CRenderer::ConstructRenderList(); +if(gbRenderWorld0) + CRenderer::RenderWorld(0); // roads + // CMattRenderer::ResetRenderStates + CRenderer::PreRender(); + CCoronas::RenderReflections(); +if(gbRenderWorld1) + CRenderer::RenderWorld(1); // opaque +if(gbRenderRoads) + CRenderer::RenderRoads(); + + CRenderer::RenderPeds(); + + // not sure where to put these since LCS has no underwater entities +if(gbRenderBoats) + CRenderer::RenderBoats(); +if(gbRenderFadingInUnderwaterEntities) + CRenderer::RenderFadingInUnderwaterEntities(); +if(gbRenderWater) + CRenderer::RenderTransparentWater(); + +if(gbRenderEverythingBarRoads) + CRenderer::RenderEverythingBarRoads(); + // get env map here? + // moved this: + // CRenderer::RenderFadingInEntities(); +} + +void +RenderScene_new(void) +{ + CClouds::Render(); + DoRWRenderHorizon(); + + MattRenderScene(); + DefinedState(); + // CMattRenderer::ResetRenderStates + // moved CRenderer::RenderBoats to before transparent water +} + +// TODO +bool FredIsInFirstPersonCam(void) { return true; } // this seems to give the best result in all cases + +void +RenderEffects_new(void) +{ + CShadows::RenderStaticShadows(); + // CRenderer::GenerateEnvironmentMap + CShadows::RenderStoredShadows(); + CSkidmarks::Render(); + CRubbish::Render(); + + // these aren't really effects + DefinedState(); + if(FredIsInFirstPersonCam()){ + DefinedState(); + C3dMarkers::Render(); // normally rendered in CSpecialFX::Render() +if(gbRenderWorld2) + CRenderer::RenderWorld(2); // transparent +if(gbRenderVehicles) + CRenderer::RenderVehicles(); + }else{ +if(gbRenderVehicles) + CRenderer::RenderVehicles(); +if(gbRenderWorld2) + CRenderer::RenderWorld(2); // transparent + } + // better render these after transparent world +if(gbRenderFadingInEntities) + CRenderer::RenderFadingInEntities(); + + // actual effects here + CGlass::Render(); + // CMattRenderer::ResetRenderStates + DefinedState(); + CCoronas::RenderSunReflection(); + CWeather::RenderRainStreaks(); + // CWeather::AddSnow + CWaterCannons::Render(); + CAntennas::Render(); + CSpecialFX::Render(); + CRopes::Render(); + CCoronas::Render(); + CParticle::Render(); + CPacManPickups::Render(); + CWeaponEffects::Render(); + CPointLights::RenderFogEffect(); + CMovingThings::Render(); + CRenderer::RenderFirstPersonVehicle(); +} +#endif + void RenderScene(void) { +#ifdef NEW_RENDERER + if(gbNewRenderer){ + RenderScene_new(); + return; + } +#endif CClouds::Render(); DoRWRenderHorizon(); CRenderer::RenderRoads(); @@ -885,6 +1013,12 @@ RenderDebugShit(void) void RenderEffects(void) { +#ifdef NEW_RENDERER + if(gbNewRenderer){ + RenderEffects_new(); + return; + } +#endif CGlass::Render(); CWaterCannons::Render(); CSpecialFX::Render(); @@ -1061,6 +1195,10 @@ Idle(void *arg) pos.y = SCREEN_HEIGHT / 2.0f; RsMouseSetPos(&pos); #endif +#ifdef NEW_RENDERER + if(!gbNewRenderer) +#endif +{ tbStartTimer(0, "CnstrRenderList"); #ifdef PC_WATER CWaterLevel::PreCalcWaterGeometry(); @@ -1071,6 +1209,7 @@ Idle(void *arg) tbStartTimer(0, "PreRender"); CRenderer::PreRender(); tbEndTimer("PreRender"); +} #ifdef FIX_BUGS RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void *)FALSE); // TODO: temp? this fixes OpenGL render but there should be a better place for this @@ -1125,7 +1264,7 @@ Idle(void *arg) CameraSize(Scene.camera, nil, SCREEN_VIEWWINDOW, DEFAULT_ASPECT_RATIO); #endif CVisibilityPlugins::SetRenderWareCamera(Scene.camera); - RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ); + RwCameraClear(Scene.camera, &gColourTop, CLEARMODE); if(!RsCameraBeginUpdate(Scene.camera)) return; } @@ -1174,7 +1313,7 @@ FrontendIdle(void) CameraSize(Scene.camera, nil, SCREEN_VIEWWINDOW, SCREEN_ASPECT_RATIO); CVisibilityPlugins::SetRenderWareCamera(Scene.camera); - RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ); + RwCameraClear(Scene.camera, &gColourTop, CLEARMODE); if(!RsCameraBeginUpdate(Scene.camera)) return; @@ -1450,7 +1589,7 @@ void TheGame(void) { CameraSize(Scene.camera, NULL, SCREEN_VIEWWINDOW, SCREEN_ASPECT_RATIO); CVisibilityPlugins::SetRenderWareCamera(Scene.camera); - RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ); + RwCameraClear(Scene.camera, &gColourTop, CLEARMODE); if (!RsCameraBeginUpdate(Scene.camera)) break; } diff --git a/src/core/main.h b/src/core/main.h index 8bf06c30..f428224e 100644 --- a/src/core/main.h +++ b/src/core/main.h @@ -38,3 +38,8 @@ void ResetLoadingScreenBar(void); #ifndef MASTER void TheModelViewer(void); #endif + +#ifdef NEW_RENDERER +extern bool gbNewRenderer; +bool FredIsInFirstPersonCam(void); +#endif diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 318b1d47..ebfa8de5 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -422,6 +422,30 @@ DebugMenuPopulate(void) DebugMenuAddVarBool8("Render", "Frame limiter", &FrontEndMenuManager.m_PrefsFrameLimiter, nil); DebugMenuAddVarBool8("Render", "VSynch", &FrontEndMenuManager.m_PrefsVsync, nil); DebugMenuAddVar("Render", "Max FPS", &RsGlobal.maxFPS, nil, 1, 1, 1000, nil); +#ifdef NEW_RENDERER + DebugMenuAddVarBool8("Render", "new renderer", &gbNewRenderer, nil); +extern bool gbRenderRoads; +extern bool gbRenderEverythingBarRoads; +extern bool gbRenderFadingInUnderwaterEntities; +extern bool gbRenderFadingInEntities; +extern bool gbRenderWater; +extern bool gbRenderBoats; +extern bool gbRenderVehicles; +extern bool gbRenderWorld0; +extern bool gbRenderWorld1; +extern bool gbRenderWorld2; + DebugMenuAddVarBool8("Render", "gbRenderRoads", &gbRenderRoads, nil); + DebugMenuAddVarBool8("Render", "gbRenderEverythingBarRoads", &gbRenderEverythingBarRoads, nil); + DebugMenuAddVarBool8("Render", "gbRenderFadingInUnderwaterEntities", &gbRenderFadingInUnderwaterEntities, nil); + DebugMenuAddVarBool8("Render", "gbRenderFadingInEntities", &gbRenderFadingInEntities, nil); + DebugMenuAddVarBool8("Render", "gbRenderWater", &gbRenderWater, nil); + DebugMenuAddVarBool8("Render", "gbRenderBoats", &gbRenderBoats, nil); + DebugMenuAddVarBool8("Render", "gbRenderVehicles", &gbRenderVehicles, nil); + DebugMenuAddVarBool8("Render", "gbRenderWorld0", &gbRenderWorld0, nil); + DebugMenuAddVarBool8("Render", "gbRenderWorld1", &gbRenderWorld1, nil); + DebugMenuAddVarBool8("Render", "gbRenderWorld2", &gbRenderWorld2, nil); +#endif + #ifdef EXTENDED_COLOURFILTER static const char *filternames[] = { "None", "Simple", "Normal", "Mobile" }; e = DebugMenuAddVar("Render", "Colourfilter", &CPostFX::EffectSwitch, nil, 1, CPostFX::POSTFX_OFF, CPostFX::POSTFX_MOBILE, filternames); |