mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-29 18:32:55 +08:00
Refactoring selection code
This commit is contained in:
parent
b127029899
commit
95e2a8ec0f
@ -129,7 +129,7 @@ namespace CodeWalker.Project.Panels
|
||||
|
||||
if (ProjectForm.WorldForm != null)
|
||||
{
|
||||
ProjectForm.WorldForm.SelectAudio(CurrentEmitter);
|
||||
ProjectForm.WorldForm.SelectObject(CurrentEmitter);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ namespace CodeWalker.Project.Panels
|
||||
|
||||
if (ProjectForm.WorldForm != null)
|
||||
{
|
||||
ProjectForm.WorldForm.SelectAudio(CurrentZone);
|
||||
ProjectForm.WorldForm.SelectObject(CurrentZone);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ namespace CodeWalker.Project.Panels
|
||||
{
|
||||
if (ProjectForm.WorldForm != null)
|
||||
{
|
||||
ProjectForm.WorldForm.SelectScenarioNode(CurrentScenarioNode);
|
||||
ProjectForm.WorldForm.SelectObject(CurrentScenarioNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -465,7 +465,7 @@ namespace CodeWalker.Project.Panels
|
||||
|
||||
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)
|
||||
{
|
||||
ProjectForm.WorldForm.UpdateScenarioGraphics(CurrentScenario, false);
|
||||
ProjectForm.WorldForm.SelectScenarioEdge(CurrentScenarioNode, null);
|
||||
ProjectForm.WorldForm.SelectObject(CurrentScenarioNode);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ namespace CodeWalker.Project.Panels
|
||||
|
||||
if (ProjectForm.WorldForm != null)
|
||||
{
|
||||
ProjectForm.WorldForm.SelectTrainTrackNode(TrainNode);
|
||||
ProjectForm.WorldForm.SelectObject(TrainNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ namespace CodeWalker.Project.Panels
|
||||
|
||||
populatingui = false;
|
||||
|
||||
ProjectForm.WorldForm?.SelectCollisionBounds(b);
|
||||
ProjectForm.WorldForm?.SelectObject(b);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ namespace CodeWalker.Project.Panels
|
||||
|
||||
if (ProjectForm.WorldForm != null)
|
||||
{
|
||||
ProjectForm.WorldForm.SelectCarGen(CurrentCarGen);
|
||||
ProjectForm.WorldForm.SelectObject(CurrentCarGen);
|
||||
}
|
||||
|
||||
////struct CCarGen:
|
||||
|
@ -156,7 +156,7 @@ namespace CodeWalker.Project.Panels
|
||||
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:
|
||||
//MetaHash archetypeName { get; set; } //8 8: Hash: 0: archetypeName
|
||||
|
@ -42,7 +42,7 @@ namespace CodeWalker.Project.Panels
|
||||
Tag = batch;
|
||||
UpdateFormTitle();
|
||||
UpdateControls();
|
||||
ProjectForm.WorldForm?.SelectGrassBatch(batch);
|
||||
ProjectForm.WorldForm?.SelectObject(batch);
|
||||
}
|
||||
|
||||
private void UpdateControls()
|
||||
|
@ -105,7 +105,7 @@ namespace CodeWalker.Project.Panels
|
||||
|
||||
if (ProjectForm.WorldForm != null)
|
||||
{
|
||||
ProjectForm.WorldForm.SelectPathNode(CurrentPathNode);
|
||||
ProjectForm.WorldForm.SelectObject(CurrentPathNode);
|
||||
}
|
||||
|
||||
}
|
||||
@ -139,7 +139,7 @@ namespace CodeWalker.Project.Panels
|
||||
|
||||
if (ProjectForm.WorldForm != null)
|
||||
{
|
||||
ProjectForm.WorldForm.SelectPathLink(CurrentPathLink);
|
||||
ProjectForm.WorldForm.SelectObject(CurrentPathLink);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ namespace CodeWalker.Project.Panels
|
||||
Tag = room;
|
||||
UpdateFormTitle();
|
||||
MloInstanceData instance = ProjectForm.TryGetMloInstance(room?.OwnerMlo);
|
||||
ProjectForm.WorldForm?.SelectMloRoom(room, instance);
|
||||
ProjectForm.WorldForm?.SelectObject(room, instance);
|
||||
UpdateControls();
|
||||
}
|
||||
|
||||
|
@ -182,7 +182,7 @@ namespace CodeWalker.Project
|
||||
{
|
||||
Entity?.SetPositionFromWidget(p);
|
||||
|
||||
if (Entity != sel.EntityDef) wf.SelectEntity(Entity);
|
||||
if (Entity != sel.EntityDef) wf.SelectObject(Entity);
|
||||
wf.SetWidgetPosition(Entity.WidgetPosition);
|
||||
}
|
||||
|
||||
@ -219,7 +219,7 @@ namespace CodeWalker.Project
|
||||
{
|
||||
Entity?.SetOrientationFromWidget(q);
|
||||
|
||||
if (Entity != sel.EntityDef) wf.SelectEntity(Entity);
|
||||
if (Entity != sel.EntityDef) wf.SelectObject(Entity);
|
||||
wf.SetWidgetRotation(q);
|
||||
}
|
||||
|
||||
@ -257,7 +257,7 @@ namespace CodeWalker.Project
|
||||
{
|
||||
Entity?.SetScale(s);
|
||||
|
||||
if (Entity != sel.EntityDef) wf.SelectEntity(Entity);
|
||||
if (Entity != sel.EntityDef) wf.SelectObject(Entity);
|
||||
wf.SetWidgetScale(s);
|
||||
}
|
||||
|
||||
@ -297,7 +297,7 @@ namespace CodeWalker.Project
|
||||
{
|
||||
Entity?.SetPivotPositionFromWidget(p);
|
||||
|
||||
if (Entity != sel.EntityDef) wf.SelectEntity(Entity);
|
||||
if (Entity != sel.EntityDef) wf.SelectObject(Entity);
|
||||
wf.SetWidgetPosition(p);
|
||||
}
|
||||
|
||||
@ -334,7 +334,7 @@ namespace CodeWalker.Project
|
||||
{
|
||||
Entity?.SetPivotOrientationFromWidget(q);
|
||||
|
||||
if (Entity != sel.EntityDef) wf.SelectEntity(Entity);
|
||||
if (Entity != sel.EntityDef) wf.SelectObject(Entity);
|
||||
wf.SetWidgetRotation(q);
|
||||
}
|
||||
|
||||
@ -374,7 +374,7 @@ namespace CodeWalker.Project
|
||||
{
|
||||
CarGen?.SetPosition(p);
|
||||
|
||||
if (CarGen != sel.CarGenerator) wf.SelectCarGen(CarGen);
|
||||
if (CarGen != sel.CarGenerator) wf.SelectObject(CarGen);
|
||||
wf.SetWidgetPosition(p);
|
||||
}
|
||||
|
||||
@ -411,7 +411,7 @@ namespace CodeWalker.Project
|
||||
{
|
||||
CarGen?.SetOrientation(q);
|
||||
|
||||
if (CarGen != sel.CarGenerator) wf.SelectCarGen(CarGen);
|
||||
if (CarGen != sel.CarGenerator) wf.SelectObject(CarGen);
|
||||
wf.SetWidgetRotation(q);
|
||||
}
|
||||
|
||||
@ -447,7 +447,7 @@ namespace CodeWalker.Project
|
||||
{
|
||||
CarGen?.SetScale(s);
|
||||
|
||||
if (CarGen != sel.CarGenerator) wf.SelectCarGen(CarGen);
|
||||
if (CarGen != sel.CarGenerator) wf.SelectObject(CarGen);
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
UpdateGraphics(wf);
|
||||
@ -618,7 +618,7 @@ namespace CodeWalker.Project
|
||||
Bounds.Scale = s;
|
||||
}
|
||||
|
||||
if (Bounds != sel.CollisionBounds) wf.SelectCollisionBounds(Bounds);
|
||||
if (Bounds != sel.CollisionBounds) wf.SelectObject(Bounds);
|
||||
wf.SetWidgetScale(s);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
UpdateGraphics(wf);
|
||||
@ -794,7 +794,7 @@ namespace CodeWalker.Project
|
||||
Polygon.Scale = s;
|
||||
}
|
||||
|
||||
if (Polygon != sel.CollisionPoly) wf.SelectCollisionPoly(Polygon);
|
||||
if (Polygon != sel.CollisionPoly) wf.SelectObject(Polygon);
|
||||
wf.SetWidgetScale(s);
|
||||
|
||||
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);
|
||||
|
||||
UpdateGraphics(wf);
|
||||
@ -910,11 +910,11 @@ namespace CodeWalker.Project
|
||||
{
|
||||
if (sel.PathLink != null)
|
||||
{
|
||||
wf.SelectPathLink(sel.PathLink);
|
||||
wf.SelectObject(sel.PathLink);
|
||||
}
|
||||
else
|
||||
{
|
||||
wf.SelectPathNode(PathNode);
|
||||
wf.SelectObject(PathNode);
|
||||
}
|
||||
}
|
||||
wf.SetWidgetPosition(p);
|
||||
@ -972,7 +972,7 @@ namespace CodeWalker.Project
|
||||
|
||||
if (Point != sel.NavPoint)
|
||||
{
|
||||
wf.SelectNavPoint(Point);
|
||||
wf.SelectObject(Point);
|
||||
}
|
||||
wf.SetWidgetPosition(p);
|
||||
|
||||
@ -1025,7 +1025,7 @@ namespace CodeWalker.Project
|
||||
{
|
||||
Point?.SetOrientation(q);
|
||||
|
||||
if (Point != sel.NavPoint) wf.SelectNavPoint(Point);
|
||||
if (Point != sel.NavPoint) wf.SelectObject(Point);
|
||||
wf.SetWidgetRotation(q);
|
||||
|
||||
//UpdateGraphics(wf);
|
||||
@ -1078,7 +1078,7 @@ namespace CodeWalker.Project
|
||||
|
||||
if (Portal != sel.NavPortal)
|
||||
{
|
||||
wf.SelectNavPortal(Portal);
|
||||
wf.SelectObject(Portal);
|
||||
}
|
||||
wf.SetWidgetPosition(p);
|
||||
|
||||
@ -1131,7 +1131,7 @@ namespace CodeWalker.Project
|
||||
{
|
||||
Portal?.SetOrientation(q);
|
||||
|
||||
if (Portal != sel.NavPortal) wf.SelectNavPortal(Portal);
|
||||
if (Portal != sel.NavPortal) wf.SelectObject(Portal);
|
||||
wf.SetWidgetRotation(q);
|
||||
|
||||
//UpdateGraphics(wf);
|
||||
@ -1186,7 +1186,7 @@ namespace CodeWalker.Project
|
||||
|
||||
if (Node != sel.TrainTrackNode)
|
||||
{
|
||||
wf.SelectTrainTrackNode(Node);
|
||||
wf.SelectObject(Node);
|
||||
}
|
||||
wf.SetWidgetPosition(p);
|
||||
|
||||
@ -1241,7 +1241,7 @@ namespace CodeWalker.Project
|
||||
{
|
||||
ScenarioNode?.SetPosition(p);
|
||||
|
||||
if (ScenarioNode != sel.ScenarioNode) wf.SelectScenarioNode(ScenarioNode);
|
||||
if (ScenarioNode != sel.ScenarioNode) wf.SelectObject(ScenarioNode);
|
||||
wf.SetWidgetPosition(p);
|
||||
|
||||
UpdateGraphics(wf);
|
||||
@ -1291,7 +1291,7 @@ namespace CodeWalker.Project
|
||||
{
|
||||
ScenarioNode?.SetOrientation(q);
|
||||
|
||||
if (ScenarioNode != sel.ScenarioNode) wf.SelectScenarioNode(ScenarioNode);
|
||||
if (ScenarioNode != sel.ScenarioNode) wf.SelectObject(ScenarioNode);
|
||||
wf.SetWidgetRotation(q);
|
||||
|
||||
//UpdateGraphics(wf);
|
||||
@ -1342,7 +1342,7 @@ namespace CodeWalker.Project
|
||||
{
|
||||
Audio?.SetPosition(p);
|
||||
|
||||
if (Audio != sel.Audio) wf.SelectAudio(Audio);
|
||||
if (Audio != sel.Audio) wf.SelectObject(Audio);
|
||||
wf.SetWidgetPosition(p);
|
||||
}
|
||||
|
||||
@ -1379,7 +1379,7 @@ namespace CodeWalker.Project
|
||||
{
|
||||
Audio?.SetOrientation(q);
|
||||
|
||||
if (Audio != sel.Audio) wf.SelectAudio(Audio);
|
||||
if (Audio != sel.Audio) wf.SelectObject(Audio);
|
||||
wf.SetWidgetRotation(q);
|
||||
}
|
||||
|
||||
|
@ -1287,6 +1287,115 @@ namespace CodeWalker
|
||||
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()
|
||||
|
303
WorldForm.cs
303
WorldForm.cs
@ -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)
|
||||
{
|
||||
@ -3277,7 +3277,7 @@ namespace CodeWalker
|
||||
SelectItem(null, addSelection);
|
||||
foreach (var mobj in arr)
|
||||
{
|
||||
SelectItems(mobj, true);
|
||||
SelectObject(mobj, null, true);
|
||||
}
|
||||
if (!addSelection)
|
||||
{
|
||||
@ -3288,21 +3288,18 @@ namespace CodeWalker
|
||||
ProjectForm.OnWorldSelectionChanged(SelectedItem);
|
||||
}
|
||||
}
|
||||
else if (obj is Bounds bounds) SelectCollisionBounds(bounds, addSelection);
|
||||
else if (obj is BoundPolygon cpoly) SelectCollisionPoly(cpoly, addSelection);
|
||||
else if (obj is BoundVertex cvert) SelectCollisionVertex(cvert, addSelection);
|
||||
else if (obj is YmapEntityDef ent) SelectEntity(ent, addSelection);
|
||||
else if (obj is YmapCarGen cargen) SelectCarGen(cargen, addSelection);
|
||||
else if (obj is YmapGrassInstanceBatch grass) SelectGrassBatch(grass, 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 if (obj is YnvPoint npoint) SelectNavPoint(npoint, addSelection);
|
||||
else if (obj is YnvPortal nportal) SelectNavPortal(nportal, 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);
|
||||
else
|
||||
{
|
||||
var ms = MapSelection.FromProjectObject(obj, parent);
|
||||
if (!ms.HasValue)
|
||||
{
|
||||
SelectItem(null, addSelection);
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectItem(ms, addSelection);
|
||||
}
|
||||
}
|
||||
}
|
||||
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()
|
||||
{
|
||||
//when clicked, select the currently moused item and update the selection info UI
|
||||
@ -4245,7 +3976,7 @@ namespace CodeWalker
|
||||
if (entity == null) return;
|
||||
ViewModeComboBox.Text = "World view";
|
||||
GoToPosition(entity.Position);
|
||||
SelectEntity(entity);
|
||||
SelectObject(entity);
|
||||
}
|
||||
|
||||
|
||||
@ -5200,14 +4931,14 @@ namespace CodeWalker
|
||||
{
|
||||
if ((ProjectForm != null) && CopiedItem.CanCopyPaste)
|
||||
{
|
||||
SelectItems(ProjectForm.NewObject(CopiedItem, (CopiedItem.MultipleSelectionItems != null)));
|
||||
SelectObject(ProjectForm.NewObject(CopiedItem, (CopiedItem.MultipleSelectionItems != null)));
|
||||
}
|
||||
}
|
||||
private void CloneItem()
|
||||
{
|
||||
if ((ProjectForm != null) && SelectedItem.CanCopyPaste)
|
||||
{
|
||||
SelectItems(ProjectForm.NewObject(SelectedItem, true));
|
||||
SelectObject(ProjectForm.NewObject(SelectedItem, true));
|
||||
}
|
||||
}
|
||||
private void DeleteItem()
|
||||
|
Loading…
Reference in New Issue
Block a user