Skip to content
This repository has been archived by the owner on Sep 16, 2019. It is now read-only.

Commit

Permalink
Fix an issue causing a lot of invalid solids when opening OBJ files
Browse files Browse the repository at this point in the history
  • Loading branch information
LogicAndTrick committed Jun 15, 2014
1 parent 4c56285 commit 6b868aa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Sledge.Editor/Tools/EntityTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ public override void DocumentChanged()

private void BuildMenu()
{
if (_menu != null) foreach (var item in _menu) item.Dispose();
_menu = null;
if (Document == null) return;

var items = new List<ToolStripItem>();
var classes = Document.GameData.Classes.Where(x => x.ClassType != ClassType.Base && x.ClassType != ClassType.Solid).ToList();
var groups = classes.GroupBy(x => x.Name.Split('_')[0]);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Sledge.Providers/Map/ObjProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ private Solid SolidifyFace(DataStructures.MapObjects.Map map, Face face)
solid.Colour = Colour.GetRandomBrushColour();
solid.Faces.Add(face);
face.Parent = solid;
var offset = face.BoundingBox.Center - face.Plane.Normal * 5;
var center = face.Vertices.Aggregate(Coordinate.Zero, (sum, v) => sum + v.Location) / face.Vertices.Count;
var offset = center - face.Plane.Normal * 5;
for (var i = 0; i < face.Vertices.Count; i++)
{
var v1 = face.Vertices[i];
Expand Down

0 comments on commit 6b868aa

Please sign in to comment.