Refactoring selection code

This commit is contained in:
dexy 2020-01-15 17:48:27 +11:00
parent b127029899
commit 95e2a8ec0f
13 changed files with 165 additions and 325 deletions

View File

@ -129,7 +129,7 @@ namespace CodeWalker.Project.Panels
if (ProjectForm.WorldForm != null) if (ProjectForm.WorldForm != null)
{ {
ProjectForm.WorldForm.SelectAudio(CurrentEmitter); ProjectForm.WorldForm.SelectObject(CurrentEmitter);
} }
} }

View File

@ -136,7 +136,7 @@ namespace CodeWalker.Project.Panels
if (ProjectForm.WorldForm != null) if (ProjectForm.WorldForm != null)
{ {
ProjectForm.WorldForm.SelectAudio(CurrentZone); ProjectForm.WorldForm.SelectObject(CurrentZone);
} }
} }

View File

@ -65,7 +65,7 @@ namespace CodeWalker.Project.Panels
{ {
if (ProjectForm.WorldForm != null) if (ProjectForm.WorldForm != null)
{ {
ProjectForm.WorldForm.SelectScenarioNode(CurrentScenarioNode); ProjectForm.WorldForm.SelectObject(CurrentScenarioNode);
} }
} }
} }
@ -465,7 +465,7 @@ namespace CodeWalker.Project.Panels
if (ProjectForm.WorldForm != null) if (ProjectForm.WorldForm != null)
{ {
ProjectForm.WorldForm.SelectScenarioEdge(CurrentScenarioNode, e); ProjectForm.WorldForm.SelectObject(e, CurrentScenarioNode);
} }
} }
} }
@ -681,7 +681,7 @@ namespace CodeWalker.Project.Panels
if (ProjectForm.WorldForm != null) if (ProjectForm.WorldForm != null)
{ {
ProjectForm.WorldForm.UpdateScenarioGraphics(CurrentScenario, false); ProjectForm.WorldForm.UpdateScenarioGraphics(CurrentScenario, false);
ProjectForm.WorldForm.SelectScenarioEdge(CurrentScenarioNode, null); ProjectForm.WorldForm.SelectObject(CurrentScenarioNode);
} }
} }

View File

@ -61,7 +61,7 @@ namespace CodeWalker.Project.Panels
if (ProjectForm.WorldForm != null) if (ProjectForm.WorldForm != null)
{ {
ProjectForm.WorldForm.SelectTrainTrackNode(TrainNode); ProjectForm.WorldForm.SelectObject(TrainNode);
} }
} }
} }

View File

@ -187,7 +187,7 @@ namespace CodeWalker.Project.Panels
populatingui = false; populatingui = false;
ProjectForm.WorldForm?.SelectCollisionBounds(b); ProjectForm.WorldForm?.SelectObject(b);
} }
} }

View File

@ -103,7 +103,7 @@ namespace CodeWalker.Project.Panels
if (ProjectForm.WorldForm != null) if (ProjectForm.WorldForm != null)
{ {
ProjectForm.WorldForm.SelectCarGen(CurrentCarGen); ProjectForm.WorldForm.SelectObject(CurrentCarGen);
} }
////struct CCarGen: ////struct CCarGen:

View File

@ -156,7 +156,7 @@ namespace CodeWalker.Project.Panels
UpdateTabVisibility(); UpdateTabVisibility();
ProjectForm.WorldForm?.SelectEntity(CurrentEntity); //hopefully the drawable is already loaded - this will try get from cache ProjectForm.WorldForm?.SelectObject(CurrentEntity); //hopefully the drawable is already loaded - this will try get from cache
////struct CEntityDef: ////struct CEntityDef:
//MetaHash archetypeName { get; set; } //8 8: Hash: 0: archetypeName //MetaHash archetypeName { get; set; } //8 8: Hash: 0: archetypeName

View File

@ -42,7 +42,7 @@ namespace CodeWalker.Project.Panels
Tag = batch; Tag = batch;
UpdateFormTitle(); UpdateFormTitle();
UpdateControls(); UpdateControls();
ProjectForm.WorldForm?.SelectGrassBatch(batch); ProjectForm.WorldForm?.SelectObject(batch);
} }
private void UpdateControls() private void UpdateControls()

View File

@ -105,7 +105,7 @@ namespace CodeWalker.Project.Panels
if (ProjectForm.WorldForm != null) if (ProjectForm.WorldForm != null)
{ {
ProjectForm.WorldForm.SelectPathNode(CurrentPathNode); ProjectForm.WorldForm.SelectObject(CurrentPathNode);
} }
} }
@ -139,7 +139,7 @@ namespace CodeWalker.Project.Panels
if (ProjectForm.WorldForm != null) if (ProjectForm.WorldForm != null)
{ {
ProjectForm.WorldForm.SelectPathLink(CurrentPathLink); ProjectForm.WorldForm.SelectObject(CurrentPathLink);
} }
} }

View File

@ -24,7 +24,7 @@ namespace CodeWalker.Project.Panels
Tag = room; Tag = room;
UpdateFormTitle(); UpdateFormTitle();
MloInstanceData instance = ProjectForm.TryGetMloInstance(room?.OwnerMlo); MloInstanceData instance = ProjectForm.TryGetMloInstance(room?.OwnerMlo);
ProjectForm.WorldForm?.SelectMloRoom(room, instance); ProjectForm.WorldForm?.SelectObject(room, instance);
UpdateControls(); UpdateControls();
} }

View File

@ -182,7 +182,7 @@ namespace CodeWalker.Project
{ {
Entity?.SetPositionFromWidget(p); Entity?.SetPositionFromWidget(p);
if (Entity != sel.EntityDef) wf.SelectEntity(Entity); if (Entity != sel.EntityDef) wf.SelectObject(Entity);
wf.SetWidgetPosition(Entity.WidgetPosition); wf.SetWidgetPosition(Entity.WidgetPosition);
} }
@ -219,7 +219,7 @@ namespace CodeWalker.Project
{ {
Entity?.SetOrientationFromWidget(q); Entity?.SetOrientationFromWidget(q);
if (Entity != sel.EntityDef) wf.SelectEntity(Entity); if (Entity != sel.EntityDef) wf.SelectObject(Entity);
wf.SetWidgetRotation(q); wf.SetWidgetRotation(q);
} }
@ -257,7 +257,7 @@ namespace CodeWalker.Project
{ {
Entity?.SetScale(s); Entity?.SetScale(s);
if (Entity != sel.EntityDef) wf.SelectEntity(Entity); if (Entity != sel.EntityDef) wf.SelectObject(Entity);
wf.SetWidgetScale(s); wf.SetWidgetScale(s);
} }
@ -297,7 +297,7 @@ namespace CodeWalker.Project
{ {
Entity?.SetPivotPositionFromWidget(p); Entity?.SetPivotPositionFromWidget(p);
if (Entity != sel.EntityDef) wf.SelectEntity(Entity); if (Entity != sel.EntityDef) wf.SelectObject(Entity);
wf.SetWidgetPosition(p); wf.SetWidgetPosition(p);
} }
@ -334,7 +334,7 @@ namespace CodeWalker.Project
{ {
Entity?.SetPivotOrientationFromWidget(q); Entity?.SetPivotOrientationFromWidget(q);
if (Entity != sel.EntityDef) wf.SelectEntity(Entity); if (Entity != sel.EntityDef) wf.SelectObject(Entity);
wf.SetWidgetRotation(q); wf.SetWidgetRotation(q);
} }
@ -374,7 +374,7 @@ namespace CodeWalker.Project
{ {
CarGen?.SetPosition(p); CarGen?.SetPosition(p);
if (CarGen != sel.CarGenerator) wf.SelectCarGen(CarGen); if (CarGen != sel.CarGenerator) wf.SelectObject(CarGen);
wf.SetWidgetPosition(p); wf.SetWidgetPosition(p);
} }
@ -411,7 +411,7 @@ namespace CodeWalker.Project
{ {
CarGen?.SetOrientation(q); CarGen?.SetOrientation(q);
if (CarGen != sel.CarGenerator) wf.SelectCarGen(CarGen); if (CarGen != sel.CarGenerator) wf.SelectObject(CarGen);
wf.SetWidgetRotation(q); wf.SetWidgetRotation(q);
} }
@ -447,7 +447,7 @@ namespace CodeWalker.Project
{ {
CarGen?.SetScale(s); CarGen?.SetScale(s);
if (CarGen != sel.CarGenerator) wf.SelectCarGen(CarGen); if (CarGen != sel.CarGenerator) wf.SelectObject(CarGen);
wf.SetWidgetScale(s); wf.SetWidgetScale(s);
} }
@ -502,7 +502,7 @@ namespace CodeWalker.Project
} }
if (Bounds != sel.CollisionBounds) wf.SelectCollisionBounds(Bounds); if (Bounds != sel.CollisionBounds) wf.SelectObject(Bounds);
wf.SetWidgetPosition(p); wf.SetWidgetPosition(p);
UpdateGraphics(wf); UpdateGraphics(wf);
@ -567,7 +567,7 @@ namespace CodeWalker.Project
} }
} }
if (Bounds != sel.CollisionBounds) wf.SelectCollisionBounds(Bounds); if (Bounds != sel.CollisionBounds) wf.SelectObject(Bounds);
wf.SetWidgetRotation(q); wf.SetWidgetRotation(q);
UpdateGraphics(wf); UpdateGraphics(wf);
@ -618,7 +618,7 @@ namespace CodeWalker.Project
Bounds.Scale = s; Bounds.Scale = s;
} }
if (Bounds != sel.CollisionBounds) wf.SelectCollisionBounds(Bounds); if (Bounds != sel.CollisionBounds) wf.SelectObject(Bounds);
wf.SetWidgetScale(s); wf.SetWidgetScale(s);
UpdateGraphics(wf); UpdateGraphics(wf);
@ -679,7 +679,7 @@ namespace CodeWalker.Project
} }
} }
if (Polygon != sel.CollisionPoly) wf.SelectCollisionPoly(Polygon); if (Polygon != sel.CollisionPoly) wf.SelectObject(Polygon);
wf.SetWidgetPosition(p); wf.SetWidgetPosition(p);
UpdateGraphics(wf); UpdateGraphics(wf);
@ -743,7 +743,7 @@ namespace CodeWalker.Project
} }
} }
if (Polygon != sel.CollisionPoly) wf.SelectCollisionPoly(Polygon); if (Polygon != sel.CollisionPoly) wf.SelectObject(Polygon);
wf.SetWidgetRotation(q); wf.SetWidgetRotation(q);
UpdateGraphics(wf); UpdateGraphics(wf);
@ -794,7 +794,7 @@ namespace CodeWalker.Project
Polygon.Scale = s; Polygon.Scale = s;
} }
if (Polygon != sel.CollisionPoly) wf.SelectCollisionPoly(Polygon); if (Polygon != sel.CollisionPoly) wf.SelectObject(Polygon);
wf.SetWidgetScale(s); wf.SetWidgetScale(s);
UpdateGraphics(wf); UpdateGraphics(wf);
@ -855,7 +855,7 @@ namespace CodeWalker.Project
} }
} }
if (Vertex != sel.CollisionVertex) wf.SelectCollisionVertex(Vertex); if (Vertex != sel.CollisionVertex) wf.SelectObject(Vertex);
wf.SetWidgetPosition(p); wf.SetWidgetPosition(p);
UpdateGraphics(wf); UpdateGraphics(wf);
@ -910,11 +910,11 @@ namespace CodeWalker.Project
{ {
if (sel.PathLink != null) if (sel.PathLink != null)
{ {
wf.SelectPathLink(sel.PathLink); wf.SelectObject(sel.PathLink);
} }
else else
{ {
wf.SelectPathNode(PathNode); wf.SelectObject(PathNode);
} }
} }
wf.SetWidgetPosition(p); wf.SetWidgetPosition(p);
@ -972,7 +972,7 @@ namespace CodeWalker.Project
if (Point != sel.NavPoint) if (Point != sel.NavPoint)
{ {
wf.SelectNavPoint(Point); wf.SelectObject(Point);
} }
wf.SetWidgetPosition(p); wf.SetWidgetPosition(p);
@ -1025,7 +1025,7 @@ namespace CodeWalker.Project
{ {
Point?.SetOrientation(q); Point?.SetOrientation(q);
if (Point != sel.NavPoint) wf.SelectNavPoint(Point); if (Point != sel.NavPoint) wf.SelectObject(Point);
wf.SetWidgetRotation(q); wf.SetWidgetRotation(q);
//UpdateGraphics(wf); //UpdateGraphics(wf);
@ -1078,7 +1078,7 @@ namespace CodeWalker.Project
if (Portal != sel.NavPortal) if (Portal != sel.NavPortal)
{ {
wf.SelectNavPortal(Portal); wf.SelectObject(Portal);
} }
wf.SetWidgetPosition(p); wf.SetWidgetPosition(p);
@ -1131,7 +1131,7 @@ namespace CodeWalker.Project
{ {
Portal?.SetOrientation(q); Portal?.SetOrientation(q);
if (Portal != sel.NavPortal) wf.SelectNavPortal(Portal); if (Portal != sel.NavPortal) wf.SelectObject(Portal);
wf.SetWidgetRotation(q); wf.SetWidgetRotation(q);
//UpdateGraphics(wf); //UpdateGraphics(wf);
@ -1186,7 +1186,7 @@ namespace CodeWalker.Project
if (Node != sel.TrainTrackNode) if (Node != sel.TrainTrackNode)
{ {
wf.SelectTrainTrackNode(Node); wf.SelectObject(Node);
} }
wf.SetWidgetPosition(p); wf.SetWidgetPosition(p);
@ -1241,7 +1241,7 @@ namespace CodeWalker.Project
{ {
ScenarioNode?.SetPosition(p); ScenarioNode?.SetPosition(p);
if (ScenarioNode != sel.ScenarioNode) wf.SelectScenarioNode(ScenarioNode); if (ScenarioNode != sel.ScenarioNode) wf.SelectObject(ScenarioNode);
wf.SetWidgetPosition(p); wf.SetWidgetPosition(p);
UpdateGraphics(wf); UpdateGraphics(wf);
@ -1291,7 +1291,7 @@ namespace CodeWalker.Project
{ {
ScenarioNode?.SetOrientation(q); ScenarioNode?.SetOrientation(q);
if (ScenarioNode != sel.ScenarioNode) wf.SelectScenarioNode(ScenarioNode); if (ScenarioNode != sel.ScenarioNode) wf.SelectObject(ScenarioNode);
wf.SetWidgetRotation(q); wf.SetWidgetRotation(q);
//UpdateGraphics(wf); //UpdateGraphics(wf);
@ -1342,7 +1342,7 @@ namespace CodeWalker.Project
{ {
Audio?.SetPosition(p); Audio?.SetPosition(p);
if (Audio != sel.Audio) wf.SelectAudio(Audio); if (Audio != sel.Audio) wf.SelectObject(Audio);
wf.SetWidgetPosition(p); wf.SetWidgetPosition(p);
} }
@ -1379,7 +1379,7 @@ namespace CodeWalker.Project
{ {
Audio?.SetOrientation(q); Audio?.SetOrientation(q);
if (Audio != sel.Audio) wf.SelectAudio(Audio); if (Audio != sel.Audio) wf.SelectObject(Audio);
wf.SetWidgetRotation(q); wf.SetWidgetRotation(q);
} }

View File

@ -1287,6 +1287,115 @@ namespace CodeWalker
return null; return null;
} }
public static MapSelection FromProjectObject(object o, object parent = null)
{
const float nrad = 0.5f;
var ms = new MapSelection();
if (o is YmapEntityDef entity)
{
ms.EntityDef = entity;
ms.Archetype = entity?.Archetype;
ms.AABB = new BoundingBox(entity.BBMin, entity.BBMax);
if (entity.MloInstance != null)
{
ms.MloEntityDef = entity;
}
}
else if (o is YmapCarGen cargen)
{
ms.CarGenerator = cargen;
ms.AABB = new BoundingBox(cargen.BBMin, cargen.BBMax);
}
else if (o is YmapGrassInstanceBatch batch)
{
ms.GrassBatch = batch;
ms.AABB = new BoundingBox(batch.AABBMin, batch.AABBMax);
}
else if (o is MCMloRoomDef room)
{
if (parent is MloInstanceData instance)
{
ms.MloRoomDef = room;
ms.AABB = new BoundingBox(room.BBMin_CW, room.BBMax_CW);
ms.BBOffset = instance.Owner.Position;
ms.BBOrientation = instance.Owner.Orientation;
}
}
else if (o is Bounds b)
{
ms.CollisionBounds = b;
ms.AABB = new BoundingBox(b.BoxMin, b.BoxMax);
}
else if (o is BoundPolygon p)
{
ms.CollisionPoly = p;
//ms.AABB = new BoundingBox(p.BoundingBoxMin, p.BoundingBoxMax);
}
else if (o is BoundVertex v)
{
ms.CollisionVertex = v;
//ms.AABB = new BoundingBox(p.BoundingBoxMin, p.BoundingBoxMax);
}
else if (o is YnvPoly poly)
{
var cellaabb = poly._RawData.CellAABB;
var sect = poly.Ynv?.Nav?.SectorTree;
ms.NavPoly = poly;
ms.AABB = new BoundingBox(cellaabb.Min, cellaabb.Max);
//if (sect != null)
//{
// ms.AABB = new BoundingBox(sect.AABBMin.XYZ(), sect.AABBMax.XYZ());
//}
}
else if (o is YnvPoint point)
{
ms.NavPoint = point;
ms.AABB = new BoundingBox(new Vector3(-nrad), new Vector3(nrad));
}
else if (o is YnvPortal portal)
{
ms.NavPortal = portal;
ms.AABB = new BoundingBox(new Vector3(-nrad), new Vector3(nrad));
}
else if (o is YndNode node)
{
ms.PathNode = node;
ms.AABB = new BoundingBox(new Vector3(-nrad), new Vector3(nrad));
}
else if (o is YndLink link)
{
ms.PathNode = link.Node1;
ms.PathLink = link;
ms.AABB = new BoundingBox(new Vector3(-nrad), new Vector3(nrad));
}
else if (o is TrainTrackNode tnode)
{
ms.TrainTrackNode = tnode;
ms.AABB = new BoundingBox(new Vector3(-nrad), new Vector3(nrad));
}
else if (o is ScenarioNode snode)
{
ms.ScenarioNode = snode;
ms.AABB = new BoundingBox(new Vector3(-nrad), new Vector3(nrad));
}
else if (o is MCScenarioChainingEdge sedge)
{
if (parent is ScenarioNode enode)
{
ms.ScenarioNode = enode;
ms.ScenarioEdge = sedge;
ms.AABB = new BoundingBox(new Vector3(-nrad), new Vector3(nrad));
}
}
else if (o is AudioPlacement audio)
{
ms.Audio = audio;
ms.AABB = new BoundingBox(audio.HitboxMin, audio.HitboxMax);
ms.BSphere = new BoundingSphere(audio.Position, audio.HitSphereRad);
}
return ms;
}
public override string ToString() public override string ToString()

View File

@ -3265,7 +3265,7 @@ namespace CodeWalker
} }
} }
public void SelectItems(object obj, bool addSelection = false) public void SelectObject(object obj, object parent = null, bool addSelection = false)
{ {
if (obj == null) if (obj == null)
{ {
@ -3277,7 +3277,7 @@ namespace CodeWalker
SelectItem(null, addSelection); SelectItem(null, addSelection);
foreach (var mobj in arr) foreach (var mobj in arr)
{ {
SelectItems(mobj, true); SelectObject(mobj, null, true);
} }
if (!addSelection) if (!addSelection)
{ {
@ -3288,21 +3288,18 @@ namespace CodeWalker
ProjectForm.OnWorldSelectionChanged(SelectedItem); ProjectForm.OnWorldSelectionChanged(SelectedItem);
} }
} }
else if (obj is Bounds bounds) SelectCollisionBounds(bounds, addSelection); else
else if (obj is BoundPolygon cpoly) SelectCollisionPoly(cpoly, addSelection); {
else if (obj is BoundVertex cvert) SelectCollisionVertex(cvert, addSelection); var ms = MapSelection.FromProjectObject(obj, parent);
else if (obj is YmapEntityDef ent) SelectEntity(ent, addSelection); if (!ms.HasValue)
else if (obj is YmapCarGen cargen) SelectCarGen(cargen, addSelection); {
else if (obj is YmapGrassInstanceBatch grass) SelectGrassBatch(grass, addSelection); SelectItem(null, addSelection);
else if (obj is MCMloRoomDef room) SelectMloRoom(room, null, addSelection);//how to get instance? }
else if (obj is YnvPoly npoly) SelectNavPoly(npoly, addSelection); else
else if (obj is YnvPoint npoint) SelectNavPoint(npoint, addSelection); {
else if (obj is YnvPortal nportal) SelectNavPortal(nportal, addSelection); SelectItem(ms, addSelection);
else if (obj is YndNode pnode) SelectPathNode(pnode, addSelection); }
else if (obj is YndLink plink) SelectPathLink(plink, addSelection); }
else if (obj is TrainTrackNode tnode) SelectTrainTrackNode(tnode, addSelection);
else if (obj is ScenarioNode snode) SelectScenarioNode(snode, addSelection);
else if (obj is AudioPlacement audio) SelectAudio(audio, addSelection);
} }
public void SelectItem(MapSelection? mhit = null, bool addSelection = false, bool manualSelection = false) public void SelectItem(MapSelection? mhit = null, bool addSelection = false, bool manualSelection = false)
{ {
@ -3491,272 +3488,6 @@ namespace CodeWalker
} }
} }
} }
public void SelectEntity(YmapEntityDef entity, bool addSelection = false)
{
if (entity == null)
{
SelectItem(null, addSelection);
}
else
{
MapSelection ms = new MapSelection();
ms.EntityDef = entity;
ms.Archetype = entity?.Archetype;
ms.AABB = new BoundingBox(entity.BBMin, entity.BBMax);
if (entity.MloInstance != null)
{
ms.MloEntityDef = entity;
}
SelectItem(ms, addSelection);
}
}
public void SelectCarGen(YmapCarGen cargen, bool addSelection = false)
{
if (cargen == null)
{
SelectItem(null, addSelection);
}
else
{
MapSelection ms = new MapSelection();
ms.CarGenerator = cargen;
ms.AABB = new BoundingBox(cargen.BBMin, cargen.BBMax);
SelectItem(ms, addSelection);
}
}
public void SelectGrassBatch(YmapGrassInstanceBatch batch, bool addSelection = false)
{
if (batch == null)
{
SelectItem(null, addSelection);
}
else
{
MapSelection ms = new MapSelection();
ms.GrassBatch = batch;
ms.AABB = new BoundingBox(batch.AABBMin, batch.AABBMax);
SelectItem(ms, addSelection);
}
}
public void SelectMloRoom(MCMloRoomDef room, MloInstanceData instance, bool addSelection = false)
{
if (room == null)
{
SelectItem(null, addSelection);
}
else if (instance != null)
{
MapSelection ms = new MapSelection();
ms.MloRoomDef = room;
ms.AABB = new BoundingBox(room.BBMin_CW, room.BBMax_CW);
ms.BBOffset = instance.Owner.Position;
ms.BBOrientation = instance.Owner.Orientation;
SelectItem(ms, addSelection);
}
}
public void SelectCollisionBounds(Bounds b, bool addSelection = false)
{
if (b == null)
{
SelectItem(null, addSelection);
}
else
{
MapSelection ms = new MapSelection();
ms.CollisionBounds = b;
ms.AABB = new BoundingBox(b.BoxMin, b.BoxMax);
SelectItem(ms, addSelection);
}
}
public void SelectCollisionPoly(BoundPolygon p, bool addSelection = false)
{
if (p == null)
{
SelectItem(null, addSelection);
}
else
{
MapSelection ms = new MapSelection();
ms.CollisionPoly = p;
//ms.AABB = new BoundingBox(p.BoundingBoxMin, p.BoundingBoxMax);
SelectItem(ms, addSelection);
}
}
public void SelectCollisionVertex(BoundVertex v, bool addSelection = false)
{
if (v == null)
{
SelectItem(null, addSelection);
}
else
{
MapSelection ms = new MapSelection();
ms.CollisionVertex = v;
//ms.AABB = new BoundingBox(p.BoundingBoxMin, p.BoundingBoxMax);
SelectItem(ms, addSelection);
}
}
public void SelectNavPoly(YnvPoly poly, bool addSelection = false)
{
if (poly == null)
{
SelectItem(null, addSelection);
}
else
{
var sect = poly.Ynv?.Nav?.SectorTree;
MapSelection ms = new MapSelection();
ms.NavPoly = poly;
var cellaabb = poly._RawData.CellAABB;
ms.AABB = new BoundingBox(cellaabb.Min, cellaabb.Max);
//if (sect != null)
//{
// ms.AABB = new BoundingBox(sect.AABBMin.XYZ(), sect.AABBMax.XYZ());
//}
SelectItem(ms, addSelection);
}
}
public void SelectNavPoint(YnvPoint point, bool addSelection = false)
{
if (point == null)
{
SelectItem(null, addSelection);
}
else
{
float nrad = 0.5f;
MapSelection ms = new MapSelection();
ms.NavPoint = point;
ms.AABB = new BoundingBox(new Vector3(-nrad), new Vector3(nrad));
SelectItem(ms, addSelection);
}
}
public void SelectNavPortal(YnvPortal portal, bool addSelection = false)
{
if (portal == null)
{
SelectItem(null, addSelection);
}
else
{
float nrad = 0.5f;
MapSelection ms = new MapSelection();
ms.NavPortal = portal;
ms.AABB = new BoundingBox(new Vector3(-nrad), new Vector3(nrad));
SelectItem(ms, addSelection);
}
}
public void SelectPathNode(YndNode node, bool addSelection = false)
{
if (node == null)
{
SelectItem(null, addSelection);
}
else
{
float nrad = 0.5f;
MapSelection ms = new MapSelection();
ms.PathNode = node;
ms.AABB = new BoundingBox(new Vector3(-nrad), new Vector3(nrad));
SelectItem(ms, addSelection);
}
}
public void SelectPathLink(YndLink link, bool addSelection = false)
{
var node = link?.Node1;
if (node == null)
{
SelectItem(null, addSelection);
}
else
{
float nrad = 0.5f;
MapSelection ms = new MapSelection();
ms.PathNode = node;
ms.PathLink = link;
ms.AABB = new BoundingBox(new Vector3(-nrad), new Vector3(nrad));
SelectItem(ms, addSelection);
}
}
public void SelectTrainTrackNode(TrainTrackNode node, bool addSelection = false)
{
if (node == null)
{
SelectItem(null, addSelection);
}
else
{
float nrad = 0.5f;
MapSelection ms = new MapSelection();
ms.TrainTrackNode = node;
ms.AABB = new BoundingBox(new Vector3(-nrad), new Vector3(nrad));
SelectItem(ms, addSelection);
}
}
public void SelectScenarioNode(ScenarioNode node, bool addSelection = false)
{
if (node == null)
{
SelectItem(null, addSelection);
}
else
{
float nrad = 0.5f;
MapSelection ms = new MapSelection();
ms.ScenarioNode = node;
ms.AABB = new BoundingBox(new Vector3(-nrad), new Vector3(nrad));
SelectItem(ms, addSelection);
}
}
public void SelectScenarioEdge(ScenarioNode node, MCScenarioChainingEdge edge, bool addSelection = false)
{
if (node == null)
{
SelectItem(null, addSelection);
}
else
{
float nrad = 0.5f;
MapSelection ms = new MapSelection();
ms.ScenarioNode = node;
ms.ScenarioEdge = edge;
ms.AABB = new BoundingBox(new Vector3(-nrad), new Vector3(nrad));
SelectItem(ms, addSelection);
}
}
public void SelectAudio(AudioPlacement audio, bool addSelection = false)
{
if (audio == null)
{
SelectItem(null, addSelection);
}
else
{
MapSelection ms = new MapSelection();
ms.Audio = audio;
ms.AABB = new BoundingBox(audio.HitboxMin, audio.HitboxMax);
ms.BSphere = new BoundingSphere(audio.Position, audio.HitSphereRad);
SelectItem(ms, addSelection);
}
}
private void SelectMousedItem() private void SelectMousedItem()
{ {
//when clicked, select the currently moused item and update the selection info UI //when clicked, select the currently moused item and update the selection info UI
@ -4245,7 +3976,7 @@ namespace CodeWalker
if (entity == null) return; if (entity == null) return;
ViewModeComboBox.Text = "World view"; ViewModeComboBox.Text = "World view";
GoToPosition(entity.Position); GoToPosition(entity.Position);
SelectEntity(entity); SelectObject(entity);
} }
@ -5200,14 +4931,14 @@ namespace CodeWalker
{ {
if ((ProjectForm != null) && CopiedItem.CanCopyPaste) if ((ProjectForm != null) && CopiedItem.CanCopyPaste)
{ {
SelectItems(ProjectForm.NewObject(CopiedItem, (CopiedItem.MultipleSelectionItems != null))); SelectObject(ProjectForm.NewObject(CopiedItem, (CopiedItem.MultipleSelectionItems != null)));
} }
} }
private void CloneItem() private void CloneItem()
{ {
if ((ProjectForm != null) && SelectedItem.CanCopyPaste) if ((ProjectForm != null) && SelectedItem.CanCopyPaste)
{ {
SelectItems(ProjectForm.NewObject(SelectedItem, true)); SelectObject(ProjectForm.NewObject(SelectedItem, true));
} }
} }
private void DeleteItem() private void DeleteItem()