Selectable OccludeModels, also occluder ymap indices now displayed

This commit is contained in:
dexy 2018-12-15 12:12:57 +11:00
parent 3533260884
commit 13a57102a9
3 changed files with 29 additions and 5 deletions

View File

@ -442,6 +442,7 @@ namespace CodeWalker.GameFiles
for (int i = 0; i < CBoxOccluders.Length; i++) for (int i = 0; i < CBoxOccluders.Length; i++)
{ {
BoxOccluders[i] = new YmapBoxOccluder(this, CBoxOccluders[i]); BoxOccluders[i] = new YmapBoxOccluder(this, CBoxOccluders[i]);
BoxOccluders[i].Index = i;
} }
} }
} }
@ -455,7 +456,7 @@ namespace CodeWalker.GameFiles
for (int i = 0; i < COccludeModels.Length; i++) for (int i = 0; i < COccludeModels.Length; i++)
{ {
OccludeModels[i] = new YmapOccludeModel(this, COccludeModels[i]); OccludeModels[i] = new YmapOccludeModel(this, COccludeModels[i]);
OccludeModels[i].Index = i;
OccludeModels[i].Load(Meta); OccludeModels[i].Load(Meta);
} }
@ -2225,6 +2226,7 @@ namespace CodeWalker.GameFiles
public byte[] Data { get; set; } public byte[] Data { get; set; }
public Vector3[] Vertices { get; set; } public Vector3[] Vertices { get; set; }
public byte[] Indices { get; set; } public byte[] Indices { get; set; }
public int Index { get; set; }
public YmapOccludeModel(YmapFile ymap, OccludeModel model) public YmapOccludeModel(YmapFile ymap, OccludeModel model)
{ {
@ -2285,6 +2287,7 @@ namespace CodeWalker.GameFiles
public Vector3 BBMin { get; set; } public Vector3 BBMin { get; set; }
public Vector3 BBMax { get; set; } public Vector3 BBMax { get; set; }
public Quaternion Orientation { get; set; } public Quaternion Orientation { get; set; }
public int Index { get; set; }
public YmapBoxOccluder(YmapFile ymap, BoxOccluder box) public YmapBoxOccluder(YmapFile ymap, BoxOccluder box)

View File

@ -358,11 +358,11 @@ namespace CodeWalker
} }
else if (BoxOccluder != null) else if (BoxOccluder != null)
{ {
name = "BoxOccluder " + (BoxOccluder.Ymap?.Name ?? ""); name = "BoxOccluder " + (BoxOccluder.Ymap?.Name ?? "") + ": " + BoxOccluder.Index.ToString();
} }
else if (OccludeModel != null) else if (OccludeModel != null)
{ {
name = "OccludeModel " + (OccludeModel.Ymap?.Name ?? ""); name = "OccludeModel " + (OccludeModel.Ymap?.Name ?? "") + ": " + OccludeModel.Index.ToString();
} }
else if (CollisionBounds != null) else if (CollisionBounds != null)
{ {
@ -444,11 +444,11 @@ namespace CodeWalker
} }
if (BoxOccluder != null) if (BoxOccluder != null)
{ {
name = "BoxOccluder " + (BoxOccluder.Ymap?.Name ?? ""); name = "BoxOccluder " + (BoxOccluder.Ymap?.Name ?? "") + ": " + BoxOccluder.Index.ToString();
} }
if (OccludeModel != null) if (OccludeModel != null)
{ {
name = "OccludeModel " + (OccludeModel.Ymap?.Name ?? ""); name = "OccludeModel " + (OccludeModel.Ymap?.Name ?? "") + ": " + OccludeModel.Index.ToString();
} }
if (CarGenerator != null) if (CarGenerator != null)
{ {

View File

@ -2728,6 +2728,7 @@ namespace CodeWalker
if (mraytrn.Intersects(ref bbox, out hitdist) && (hitdist < CurMouseHit.HitDist) && (hitdist > 0)) if (mraytrn.Intersects(ref bbox, out hitdist) && (hitdist < CurMouseHit.HitDist) && (hitdist > 0))
{ {
CurMouseHit.BoxOccluder = bo; CurMouseHit.BoxOccluder = bo;
CurMouseHit.OccludeModel = null;
CurMouseHit.HitDist = hitdist; CurMouseHit.HitDist = hitdist;
CurMouseHit.CamRel = mb.CamRelPos; CurMouseHit.CamRel = mb.CamRelPos;
CurMouseHit.AABB = bbox; CurMouseHit.AABB = bbox;
@ -2742,6 +2743,26 @@ namespace CodeWalker
Renderer.RenderBasePath(om); Renderer.RenderBasePath(om);
MapBox mb = new MapBox();
mb.CamRelPos = -camera.Position;
mb.BBMin = om._OccludeModel.bmin;
mb.BBMax = om._OccludeModel.bmax;
mb.Orientation = Quaternion.Identity;// bo.Orientation;
mb.Scale = Vector3.One;
Renderer.BoundingBoxes.Add(mb);
bbox.Minimum = mb.BBMin;
bbox.Maximum = mb.BBMax;
if (mray.Intersects(ref bbox, out hitdist) && (hitdist < CurMouseHit.HitDist) && (hitdist > 0))
{
CurMouseHit.BoxOccluder = null;
CurMouseHit.OccludeModel = om;
CurMouseHit.HitDist = hitdist;
CurMouseHit.CamRel = mb.CamRelPos;
CurMouseHit.AABB = bbox;
}
} }
} }