mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-23 04:12:12 +00:00
"Export to Wavefront .obj" action should work much faster now.
Things mode: selection info was not updated when selection was cleared.
This commit is contained in:
parent
871776e319
commit
ab4d8c2776
6 changed files with 40 additions and 39 deletions
|
@ -491,26 +491,26 @@ namespace CodeImp.DoomBuilder.Map
|
|||
float right = float.MinValue;
|
||||
float bottom = float.MinValue;
|
||||
|
||||
List<Vertex> processed = new List<Vertex>(); //mxd
|
||||
Dictionary<Vertex, bool> processed = new Dictionary<Vertex, bool>(); //mxd
|
||||
|
||||
//mxd. This way bbox will be created even if triangulation failed (sector with 2 or less sidedefs and 2 vertices)
|
||||
foreach (Sidedef s in sidedefs) {
|
||||
//start...
|
||||
if (!processed.Contains(s.Line.Start)) {
|
||||
if (!processed.ContainsKey(s.Line.Start)) {
|
||||
if (s.Line.Start.Position.x < left) left = s.Line.Start.Position.x;
|
||||
if (s.Line.Start.Position.x > right) right = s.Line.Start.Position.x;
|
||||
if (s.Line.Start.Position.y < top) top = s.Line.Start.Position.y;
|
||||
if (s.Line.Start.Position.y > bottom) bottom = s.Line.Start.Position.y;
|
||||
processed.Add(s.Line.Start);
|
||||
processed.Add(s.Line.Start, false);
|
||||
}
|
||||
|
||||
//end...
|
||||
if(!processed.Contains(s.Line.End)) {
|
||||
if(!processed.ContainsKey(s.Line.End)) {
|
||||
if(s.Line.End.Position.x < left) left = s.Line.End.Position.x;
|
||||
if(s.Line.End.Position.x > right) right = s.Line.End.Position.x;
|
||||
if(s.Line.End.Position.y < top) top = s.Line.End.Position.y;
|
||||
if(s.Line.End.Position.y > bottom) bottom = s.Line.End.Position.y;
|
||||
processed.Add(s.Line.End);
|
||||
processed.Add(s.Line.End, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -850,7 +850,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Clear selection
|
||||
General.Map.Map.ClearAllSelected();
|
||||
|
||||
//mxd
|
||||
//mxd. Clear selection info
|
||||
General.Interface.DisplayStatus(StatusType.Selection, string.Empty);
|
||||
|
||||
// Redraw
|
||||
|
|
|
@ -1776,7 +1776,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Clear selection
|
||||
General.Map.Map.ClearAllSelected();
|
||||
|
||||
General.Interface.DisplayStatus(StatusType.Selection, string.Empty); //mxd
|
||||
//mxd. Clear selection info
|
||||
General.Interface.DisplayStatus(StatusType.Selection, string.Empty);
|
||||
|
||||
// Clear labels
|
||||
foreach(TextLabel[] labelarray in labels.Values)
|
||||
|
|
|
@ -730,6 +730,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Clear selection
|
||||
General.Map.Map.ClearAllSelected();
|
||||
|
||||
//mxd. Clear selection info
|
||||
General.Interface.DisplayStatus(StatusType.Selection, string.Empty);
|
||||
|
||||
// Redraw
|
||||
General.Interface.RedrawDisplay();
|
||||
}
|
||||
|
|
|
@ -739,7 +739,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Clear selection
|
||||
General.Map.Map.ClearAllSelected();
|
||||
|
||||
//mxd
|
||||
//mxd. Clear selection info
|
||||
General.Interface.DisplayStatus(StatusType.Selection, string.Empty);
|
||||
|
||||
// Redraw
|
||||
|
|
|
@ -290,12 +290,15 @@ namespace CodeImp.DoomBuilder.BuilderModes.IO
|
|||
StringBuilder obj = new StringBuilder();
|
||||
const string vertexFormatter = "{0} {2} {1}\n";
|
||||
|
||||
List<Vector3D> uniqueVerts = new List<Vector3D>();
|
||||
List<Vector3D> uniqueNormals = new List<Vector3D>();
|
||||
List<PointF> uniqueUVs = new List<PointF>();
|
||||
Dictionary<Vector3D, int> uniqueVerts = new Dictionary<Vector3D, int>();
|
||||
Dictionary<Vector3D, int> uniqueNormals = new Dictionary<Vector3D, int>();
|
||||
Dictionary<PointF, int> uniqueUVs = new Dictionary<PointF, int>();
|
||||
|
||||
Dictionary<string, Dictionary<WorldVertex, VertexIndices>> vertexDataByTexture = new Dictionary<string, Dictionary<WorldVertex, VertexIndices>>();
|
||||
int ni, pi, uvi;
|
||||
int ni;
|
||||
int pc = 0;
|
||||
int nc = 0;
|
||||
int uvc = 0;
|
||||
|
||||
//optimize geometry
|
||||
foreach(KeyValuePair<string, List<WorldVertex[]>> group in geometryByTexture) {
|
||||
|
@ -303,12 +306,11 @@ namespace CodeImp.DoomBuilder.BuilderModes.IO
|
|||
foreach(WorldVertex[] verts in group.Value) {
|
||||
//vertex normals
|
||||
Vector3D n = new Vector3D(verts[0].nx, verts[0].ny, verts[0].nz).GetNormal();
|
||||
ni = uniqueNormals.IndexOf(n);
|
||||
if (ni == -1) {
|
||||
uniqueNormals.Add(n);
|
||||
ni = uniqueNormals.Count;
|
||||
if(uniqueNormals.ContainsKey(n)) {
|
||||
ni = uniqueNormals[n];
|
||||
} else {
|
||||
ni++;
|
||||
uniqueNormals.Add(n, ++nc);
|
||||
ni = nc;
|
||||
}
|
||||
|
||||
foreach(WorldVertex v in verts){
|
||||
|
@ -318,27 +320,22 @@ namespace CodeImp.DoomBuilder.BuilderModes.IO
|
|||
|
||||
//vertex coords
|
||||
Vector3D vc = new Vector3D(v.x, v.y, v.z);
|
||||
pi = uniqueVerts.IndexOf(vc);
|
||||
if (pi == -1) {
|
||||
uniqueVerts.Add(vc);
|
||||
pi = uniqueVerts.Count;
|
||||
if(uniqueVerts.ContainsKey(vc)) {
|
||||
indices.PositionIndex = uniqueVerts[vc];
|
||||
} else {
|
||||
pi++;
|
||||
uniqueVerts.Add(vc, ++pc);
|
||||
indices.PositionIndex = pc;
|
||||
}
|
||||
|
||||
//uv
|
||||
PointF uv = new PointF(v.u, v.v);
|
||||
uvi = uniqueUVs.IndexOf(uv);
|
||||
if(uvi == -1) {
|
||||
uniqueUVs.Add(uv);
|
||||
uvi = uniqueUVs.Count;
|
||||
} else {
|
||||
uvi++;
|
||||
if(uniqueUVs.ContainsKey(uv)) {
|
||||
indices.UVIndex = uniqueUVs[uv];
|
||||
}else{
|
||||
uniqueUVs.Add(uv, ++uvc);
|
||||
indices.UVIndex = uvc;
|
||||
}
|
||||
|
||||
indices.PositionIndex = pi;
|
||||
indices.UVIndex = uvi;
|
||||
|
||||
vertsData.Add(v, indices);
|
||||
}
|
||||
}
|
||||
|
@ -349,20 +346,20 @@ namespace CodeImp.DoomBuilder.BuilderModes.IO
|
|||
//write geometry
|
||||
//write vertices
|
||||
if(data.FixScale) {
|
||||
foreach(Vector3D v in uniqueVerts)
|
||||
obj.Append(string.Format(CultureInfo.InvariantCulture, "v " + vertexFormatter, -v.x * data.Scale, v.y * data.Scale, v.z * data.Scale * 1.2f));
|
||||
foreach(KeyValuePair<Vector3D, int> group in uniqueVerts)
|
||||
obj.Append(string.Format(CultureInfo.InvariantCulture, "v " + vertexFormatter, -group.Key.x * data.Scale, group.Key.y * data.Scale, group.Key.z * data.Scale * 1.2f));
|
||||
} else {
|
||||
foreach(Vector3D v in uniqueVerts)
|
||||
obj.Append(string.Format(CultureInfo.InvariantCulture, "v " + vertexFormatter, -v.x * data.Scale, v.y * data.Scale, v.z * data.Scale));
|
||||
foreach(KeyValuePair<Vector3D, int> group in uniqueVerts)
|
||||
obj.Append(string.Format(CultureInfo.InvariantCulture, "v " + vertexFormatter, -group.Key.x * data.Scale, group.Key.y * data.Scale, group.Key.z * data.Scale));
|
||||
}
|
||||
|
||||
//write normals
|
||||
foreach(Vector3D v in uniqueNormals)
|
||||
obj.Append(string.Format(CultureInfo.InvariantCulture, "vn " + vertexFormatter, v.x, v.y, v.z));
|
||||
foreach(KeyValuePair<Vector3D, int> group in uniqueNormals)
|
||||
obj.Append(string.Format(CultureInfo.InvariantCulture, "vn " + vertexFormatter, group.Key.x, group.Key.y, group.Key.z));
|
||||
|
||||
//write UV coords
|
||||
foreach(PointF p in uniqueUVs)
|
||||
obj.Append(string.Format(CultureInfo.InvariantCulture, "vt {0} {1}\n", p.X, -p.Y));
|
||||
foreach(KeyValuePair<PointF, int> group in uniqueUVs)
|
||||
obj.Append(string.Format(CultureInfo.InvariantCulture, "vt {0} {1}\n", group.Key.X, -group.Key.Y));
|
||||
|
||||
//write material library
|
||||
obj.Append("mtllib ").Append(data.ObjName + ".mtl").Append("\n");
|
||||
|
|
Loading…
Reference in a new issue