Skip to content
This repository has been archived by the owner on Feb 11, 2024. It is now read-only.

Support for heavily scaled brushes. #23 #65

Merged
merged 3 commits into from
Mar 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Scripts/Brushes/PrimitiveBrush.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ public override Polygon[] GenerateTransformedPolygons()

Vector3 center = transform.position;
Quaternion rotation = transform.rotation;
Vector3 scale = transform.localScale;
Vector3 scale = transform.lossyScale;

for (int i = 0; i < polygons.Length; i++)
{
Expand Down Expand Up @@ -887,7 +887,11 @@ public GameObject Duplicate()
GameObject newObject = Instantiate(this.gameObject);

newObject.name = this.gameObject.name;
newObject.transform.parent = this.transform.parent;

// copy the scale with checks for scaled parents and being of a scaled child.
newObject.transform.parent = null;
newObject.transform.localScale = this.transform.lossyScale;
newObject.transform.parent = this.transform.parent;

// copy the world position as compound brush children brushes have position 0,0,0.
// once parented they will end up at world position 0,0,0 if this step isn't done.
Expand Down
2 changes: 2 additions & 0 deletions Scripts/CSGModelBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ public bool HasBrushBeenBuilt(Brush candidateBrush)
brushObject = new GameObject("AppliedBrush");
}

brushObject.transform.localScale = this.transform.lossyScale;
brushObject.transform.parent = this.transform;
brushObject.transform.localPosition = localPosition;
if(localRotation != default(Quaternion))
Expand Down Expand Up @@ -606,6 +607,7 @@ public bool HasBrushBeenBuilt(Brush candidateBrush)
brushObject = new GameObject(compoundBrushType.Name);
}

brushObject.transform.localScale = this.transform.lossyScale;
brushObject.transform.parent = this.transform;
brushObject.transform.localPosition = localPosition;
if(localRotation != default(Quaternion))
Expand Down