Skip to content

Commit 18757fb

Browse files
committed
- fix cell object Y flipping between D1 and D2
1 parent 0837463 commit 18757fb

5 files changed

Lines changed: 15 additions & 10 deletions

File tree

DriverLevelTool/driver_routines/regions_d2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ bool CDriver2LevelMap::UnpackCellObject(CELL_OBJECT& co, PACKED_CELL_OBJECT* pco
655655
co.pos.vz = nearCell.z + (((pco->pos.vz - nearCell.z) << 0x10) >> 0x10);
656656

657657
// cell height should be negated
658-
co.pos.vy = -((pco->pos.vy << 0x10) >> 0x11);
658+
co.pos.vy = ((pco->pos.vy << 0x10) >> 0x11);
659659

660660
co.yang = pco->value & 0x3f;
661661
co.type = (pco->value >> 6) | ((pco->pos.vy & 1) << 10);

DriverLevelTool/exporter/export_regions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ int ExportRegionDriver1(CDriver1LevelRegion* region, IVirtualStream* levelFileSt
7171

7272
while(co)
7373
{
74-
Vector3D absCellPosition(co->pos.vx * -EXPORT_SCALING, co->pos.vy * -EXPORT_SCALING, co->pos.vz * EXPORT_SCALING);
74+
Vector3D absCellPosition(co->pos.vx * -EXPORT_SCALING, -co->pos.vy * -EXPORT_SCALING, co->pos.vz * EXPORT_SCALING);
7575
float cellRotationRad = co->yang / 64.0f * PI_F * 2.0f;
7676

7777
ModelRef_t* ref = g_levModels.GetModelByIndex(co->type);
@@ -139,7 +139,7 @@ int ExportRegionDriver2(CDriver2LevelRegion* region, IVirtualStream* levelFileSt
139139
CELL_OBJECT co;
140140
CDriver2LevelMap::UnpackCellObject(co, pco, ci.nearCell);
141141

142-
Vector3D absCellPosition(co.pos.vx * -EXPORT_SCALING, co.pos.vy * EXPORT_SCALING, co.pos.vz * EXPORT_SCALING);
142+
Vector3D absCellPosition(co.pos.vx * -EXPORT_SCALING, -co.pos.vy * EXPORT_SCALING, co.pos.vz * EXPORT_SCALING);
143143
float cellRotationRad = co.yang / 64.0f * PI_F * 2.0f;
144144

145145
ModelRef_t* ref = g_levModels.GetModelByIndex(co.type);

DriverLevelTool/viewer/renderlevel.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ extern int g_cellsDrawDistance;
3232

3333
//-----------------------------------------------------------------
3434

35-
const float MODEL_LOD_HIGH_MIN_DISTANCE = 5.0f;
36-
const float MODEL_LOD_LOW_MIN_DISTANCE = 40.0f;
35+
const float MODEL_LOD_HIGH_MIN_DISTANCE = 1.0f;
36+
const float MODEL_LOD_LOW_MIN_DISTANCE = 5.0f;
3737

3838
//-------------------------------------------------------
3939
// returns specific model or LOD model
@@ -49,13 +49,13 @@ ModelRef_t* GetModelCheckLods(int index, float distSqr)
4949
ModelRef_t* retRef = baseRef;
5050
if (baseRef->highDetailId != 0xFFFF)
5151
{
52-
if (distSqr < MODEL_LOD_HIGH_MIN_DISTANCE)
52+
if (distSqr < MODEL_LOD_HIGH_MIN_DISTANCE * MODEL_LOD_HIGH_MIN_DISTANCE)
5353
return g_levModels.GetModelByIndex(baseRef->highDetailId);
5454
}
5555

5656
if (baseRef->lowDetailId != 0xFFFF)
5757
{
58-
if (distSqr > MODEL_LOD_HIGH_MIN_DISTANCE)
58+
if (distSqr > MODEL_LOD_LOW_MIN_DISTANCE * MODEL_LOD_LOW_MIN_DISTANCE)
5959
return g_levModels.GetModelByIndex(baseRef->lowDetailId);
6060
}
6161

@@ -242,6 +242,7 @@ void DrawLevelDriver2(const Vector3D& cameraPos, float cameraAngleY, const Volum
242242
}
243243

244244
Vector3D absCellPosition = FromFixedVector(co.pos);
245+
absCellPosition.y *= -1.0f;
245246

246247
float distanceFromCamera = lengthSqr(absCellPosition - cameraPos);
247248

@@ -408,6 +409,8 @@ void DrawLevelDriver1(const Vector3D& cameraPos, float cameraAngleY, const Volum
408409
}
409410

410411
Vector3D absCellPosition = FromFixedVector(pco->pos);
412+
absCellPosition.y *= -1.0f;
413+
411414
float distanceFromCamera = lengthSqr(absCellPosition - cameraPos);
412415

413416
ModelRef_t* ref = GetModelCheckLods(pco->type, distanceFromCamera);
@@ -436,9 +439,9 @@ void DrawLevelDriver1(const Vector3D& cameraPos, float cameraAngleY, const Volum
436439
GR_UpdateMatrixUniforms();
437440

438441
if (g_nightMode)
439-
CRenderModel::SetupLightingProperties(0.45f, 0.0f);
442+
CRenderModel::SetupLightingProperties(0.25f, 0.0f);
440443
else
441-
CRenderModel::SetupLightingProperties(1.0f, 1.0f);
444+
CRenderModel::SetupLightingProperties(0.55f, 0.55f);
442445

443446
CRenderModel* renderModel = (CRenderModel*)ref->userData;
444447

DriverLevelTool/viewer/rendermodel.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ void CRenderModel::DrawModelCollisionBox(ModelRef_t* ref, const VECTOR_NOPAD& po
424424
float objRotationRad = -rotation / 64.0f * PI_F * 2.0f;
425425

426426
Vector3D offset = FromFixedVector(position);
427+
offset.y *= -1.0f;
427428
Matrix4x4 world = translate(offset) * rotateY4(objRotationRad);
428429

429430
MODEL* model = ref->model;

DriverLevelTool/viewer/viewer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ void RenderLevelView()
224224
Volume frustumVolume;
225225

226226
// setup standard camera
227+
CRenderModel::SetupModelShader();
227228
SetupCameraViewAndMatrices(g_cameraPosition, g_cameraAngles, frustumVolume);
228229

229230
GR_SetDepth(1);
@@ -250,9 +251,9 @@ void RenderModelView()
250251
AngleVectors(g_cameraAngles, &forward, &right);
251252

252253
// setup orbital camera
254+
CRenderModel::SetupModelShader();
253255
SetupCameraViewAndMatrices(-forward * g_cameraDistance, g_cameraAngles, frustumVolume);
254256

255-
CRenderModel::SetupModelShader();
256257
CRenderModel::SetupLightingProperties(0.5f, 0.5f);
257258

258259
GR_SetDepth(1);

0 commit comments

Comments
 (0)