Skip to content

Commit

Permalink
Selection now only allowed if there is a backing NOS for the object
Browse files Browse the repository at this point in the history
fixes #1376
  • Loading branch information
vchelaru committed Mar 13, 2024
1 parent 5305bb2 commit 80e24a7
Showing 1 changed file with 29 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,40 +74,47 @@ public static void GetItemsOver(List<INameable> currentEntities, List<INameable>
}

IEnumerable<PositionedObject> availableItems = null;
IEnumerable<NamedObjectSave> allNamedObjects = null;

if (objectOver == null)
{
availableItems = GetAvailableObjects(elementEditingMode);

if (availableItems != null)
{
allNamedObjects = GlueState.Self.CurrentElement.GetAllNamedObjectsRecurisvely();
// here we sort every frame. This could be slow if we have a lot of objects so we may need to cache this somehow
foreach (var objectAtI in availableItems.OrderByDescending(item => item.Z))
{
if (IsSelectable(objectAtI))
{
if (IsRayIntersecting(objectAtI, ray))
{
var allNamedObjects = GlueState.Self.CurrentElement.GetAllNamedObjectsRecurisvely();
var nos = allNamedObjects.FirstOrDefault(item => item.InstanceName == objectAtI.Name);

// don't select it if it is locked
var isLocked = nos?.IsEditingLocked == true;

var isEditingLocked = nos != null &&
ObjectFinder.Self.GetPropertyValueRecursively<bool>(
nos, nameof(nos.IsEditingLocked));
if (!isEditingLocked)
// why do we allow selecting if there is no NOS? It can't be edited...
// and this allows the selection of items inside an entity.
if(nos != null)
{
if (punchThrough)
{
tempPunchThroughList.Add(objectAtI);
}
else
// don't select it if it is locked
var isLocked = nos?.IsEditingLocked == true;

var isEditingLocked = nos != null &&
ObjectFinder.Self.GetPropertyValueRecursively<bool>(
nos, nameof(nos.IsEditingLocked));
if (!isEditingLocked)
{
objectOver = objectAtI;
break;
if (punchThrough)
{
tempPunchThroughList.Add(objectAtI);
}
else
{
objectOver = objectAtI;
break;
}
}

}
}
}
Expand Down Expand Up @@ -146,11 +153,15 @@ public static void GetItemsOver(List<INameable> currentEntities, List<INameable>

if (PerformedRectangleSelection && availableItems != null)
{
foreach (var item in availableItems)
foreach (var positionedObject in availableItems)
{
if (IsSelectable(item) && IsRectangleSelectionOver(item))
if (IsSelectable(positionedObject) && IsRectangleSelectionOver(positionedObject))
{
itemsOverToFill.Add(item);
var nos = allNamedObjects.FirstOrDefault(item => item.InstanceName == positionedObject.Name);
if(nos?.IsEditingLocked == false)
{
itemsOverToFill.Add(positionedObject);
}
}
}
}
Expand Down

0 comments on commit 80e24a7

Please sign in to comment.