fixed roadblocks

This commit is contained in:
Nikolay Korolev 2020-06-01 12:45:03 +03:00
parent f69313237e
commit 0803c821ae
2 changed files with 53 additions and 54 deletions

View File

@ -404,11 +404,10 @@ CPathFind::PreparePathData(void)
maxX = 0.0f; maxX = 0.0f;
maxY = 0.0f; maxY = 0.0f;
for(j = 0; j < 12; j++){ for(j = 0; j < 12; j++){
k = i*12 + j; k = m_mapObjects[i]->GetModelIndex()*12 + j;
if(InfoForTileCars[k].type == NodeTypeExtern){ if(InfoForTileCars[k].type == NodeTypeExtern){
numExtern++; numExtern++;
if(InfoForTileCars[k].numLeftLanes + InfoForTileCars[k].numRightLanes > numLanes) numLanes = Max(numLanes, InfoForTileCars[k].numLeftLanes + InfoForTileCars[k].numRightLanes);
numLanes = InfoForTileCars[k].numLeftLanes + InfoForTileCars[k].numRightLanes;
maxX = Max(maxX, Abs(InfoForTileCars[k].x)); maxX = Max(maxX, Abs(InfoForTileCars[k].x));
maxY = Max(maxY, Abs(InfoForTileCars[k].y)); maxY = Max(maxY, Abs(InfoForTileCars[k].y));
}else if(InfoForTileCars[k].type == NodeTypeIntern) }else if(InfoForTileCars[k].type == NodeTypeIntern)
@ -417,7 +416,7 @@ CPathFind::PreparePathData(void)
if(numIntern == 1 && numExtern == 2){ if(numIntern == 1 && numExtern == 2){
if(numLanes < 4){ if(numLanes < 4){
if((i & 7) == 4){ // WHAT? if((i & 7) == 4){ // 1/8 probability
m_objectFlags[i] |= UseInRoadBlock; m_objectFlags[i] |= UseInRoadBlock;
if(maxX > maxY) if(maxX > maxY)
m_objectFlags[i] |= ObjectEastWest; m_objectFlags[i] |= ObjectEastWest;

View File

@ -132,7 +132,8 @@ CRoadBlocks::GenerateRoadBlocks(void)
CColModel *pVehicleColModel = CModelInfo::GetModelInfo(vehicleId)->GetColModel(); CColModel *pVehicleColModel = CModelInfo::GetModelInfo(vehicleId)->GetColModel();
float fModelRadius = 2.0f * pVehicleColModel->boundingSphere.radius + 0.25f; float fModelRadius = 2.0f * pVehicleColModel->boundingSphere.radius + 0.25f;
int16 radius = (int16)(fMapObjectRadius / fModelRadius); int16 radius = (int16)(fMapObjectRadius / fModelRadius);
if (radius > 0 && radius < 6) { if (radius >= 6)
continue;
CVector2D vecDistanceToCamera = TheCamera.GetPosition() - mapObject->GetPosition(); CVector2D vecDistanceToCamera = TheCamera.GetPosition() - mapObject->GetPosition();
float fDotProduct = DotProduct2D(vecDistanceToCamera, mapObject->GetForward()); float fDotProduct = DotProduct2D(vecDistanceToCamera, mapObject->GetForward());
float fOffset = 0.5f * fModelRadius * (float)(radius - 1); float fOffset = 0.5f * fModelRadius * (float)(radius - 1);
@ -146,9 +147,9 @@ CRoadBlocks::GenerateRoadBlocks(void)
offsetMatrix.SetRotateZ(((CGeneral::GetRandomNumber() & 0xFF) - 128.0f) * 0.003f - HALFPI); offsetMatrix.SetRotateZ(((CGeneral::GetRandomNumber() & 0xFF) - 128.0f) * 0.003f - HALFPI);
} }
if (ThePaths.m_objectFlags[RoadBlockObjects[nRoadblockNode]] & ObjectEastWest) if (ThePaths.m_objectFlags[RoadBlockObjects[nRoadblockNode]] & ObjectEastWest)
offsetMatrix.GetPosition() = CVector(0.0f, -fOffset, 0.6f); offsetMatrix.GetPosition() = CVector(0.0f, i * fModelRadius - fOffset, 0.6f);
else else
offsetMatrix.GetPosition() = CVector(-fOffset, 0.0f, 0.6f); offsetMatrix.GetPosition() = CVector(i * fModelRadius - fOffset, 0.0f, 0.6f);
CMatrix vehicleMatrix = mapObject->m_matrix * offsetMatrix; CMatrix vehicleMatrix = mapObject->m_matrix * offsetMatrix;
float fModelRadius = CModelInfo::GetModelInfo(vehicleId)->GetColModel()->boundingSphere.radius - 0.25f; float fModelRadius = CModelInfo::GetModelInfo(vehicleId)->GetColModel()->boundingSphere.radius - 0.25f;
int16 colliding = 0; int16 colliding = 0;
@ -188,7 +189,6 @@ CRoadBlocks::GenerateRoadBlocks(void)
} }
} }
} }
}
} else { } else {
InOrOut[nRoadblockNode] = false; InOrOut[nRoadblockNode] = false;
} }