Collisions editing progress

This commit is contained in:
dexy 2020-01-06 22:17:51 +11:00
parent 0d066679cb
commit 33dc83c0e0
13 changed files with 1390 additions and 216 deletions

View File

@ -62,5 +62,17 @@ namespace CodeWalker.GameFiles
return data;
}
public bool RemoveBounds(Bounds b)
{
return false;
}
public bool RemovePoly(BoundPolygon p)
{
return false;
}
}
}

View File

@ -3516,7 +3516,7 @@ namespace CodeWalker.GameFiles
}
public void TestYbns()
{
bool savetest = false;
bool savetest = true;
var errorfiles = new List<RpfEntry>();
foreach (RpfFile file in AllRpfs)
{
@ -3674,7 +3674,8 @@ namespace CodeWalker.GameFiles
}
public void TestYdrs()
{
bool savetest = false;
bool savetest = true;
bool boundsonly = true;
var errorfiles = new List<RpfEntry>();
foreach (RpfFile file in AllRpfs)
{
@ -3701,6 +3702,9 @@ namespace CodeWalker.GameFiles
if (fentry == null)
{ continue; } //shouldn't happen
if (boundsonly && (ydr.Drawable.Bound == null))
{ continue; }
var bytes = ydr.Save();
string origlen = TextUtil.GetBytesReadable(fentry.FileSize);
@ -3783,7 +3787,7 @@ namespace CodeWalker.GameFiles
}
public void TestYfts()
{
bool savetest = false;
bool savetest = true;
var errorfiles = new List<RpfEntry>();
foreach (RpfFile file in AllRpfs)
{

File diff suppressed because it is too large Load Diff

View File

@ -648,6 +648,11 @@ namespace CodeWalker.GameFiles
this.Unknown_140h_Pointer // offset
);
if (Bound != null)
{
Bound.Owner = this;
}
if (Unknown_70h?.data_items?.Length > 0)
{ }
if (Unknown_80h?.data_items?.Length > 0)
@ -1132,6 +1137,11 @@ namespace CodeWalker.GameFiles
this.BoundPointer // offset
);
if (Bound != null)
{
Bound.Owner = this;
}
}
/// <summary>

View File

@ -2768,6 +2768,12 @@ namespace CodeWalker.GameFiles
this.Bound = reader.ReadBlockAt<Bounds>(
this.BoundPointer // offset
);
if (Bound != null)
{
Bound.Owner = this;
}
}
catch (Exception ex) //sometimes error here for loading particles! different drawable type? base only?
{

View File

@ -453,6 +453,11 @@ namespace CodeWalker.GameFiles
FragMatrices = reader.ReadStructsAt<Matrix>(FragMatricesPointer, FragMatricesCount);
Name = reader.ReadStringAt(NamePointer);
if (Bound != null)
{
Bound.Owner = this;
}
if ((Count3 != Count4)&&(Count4!=1)&&(Count3!=0))
{ }
if (FragMatricesInds != null)
@ -1272,6 +1277,11 @@ namespace CodeWalker.GameFiles
}
}
}
if (Bound != null)
{
Bound.Owner = this;
}
}
/// <summary>
@ -2123,6 +2133,11 @@ namespace CodeWalker.GameFiles
this.Bound = reader.ReadBlockAt<Bounds>(
this.BoundPointer // offset
);
if (Bound != null)
{
Bound.Owner = this;
}
}
/// <summary>

View File

@ -828,7 +828,7 @@ namespace CodeWalker.GameFiles
public uint EntriesCapacity { get; private set; }
// reference data
public T[] data_items { get; private set; }
public T[] data_items { get; set; }
private ResourceSystemStructBlock<T> data_block;//used for saving.

View File

@ -40,16 +40,38 @@ namespace CodeWalker
}
}
public static Vector3 Floor(this Vector3 v)
{
return new Vector3((float)Math.Floor(v.X), (float)Math.Floor(v.Y), (float)Math.Floor(v.Z));
}
public static Vector3 Ceiling(this Vector3 v)
{
return new Vector3((float)Math.Ceiling(v.X), (float)Math.Ceiling(v.Y), (float)Math.Ceiling(v.Z));
}
public static Vector3 Abs(this Vector3 v)
{
return new Vector3(Math.Abs(v.X), Math.Abs(v.Y), Math.Abs(v.Z));
}
public static int CompareTo(this Vector3 a, Vector3 b)
{
int c;
c = a.X.CompareTo(b.X); if (c != 0) return c;
c = a.Y.CompareTo(b.Y); if (c != 0) return c;
c = a.Z.CompareTo(b.Z); if (c != 0) return c;
return 0;
}
public static Vector4 Floor(this Vector4 v)
{
return new Vector4((float)Math.Floor(v.X), (float)Math.Floor(v.Y), (float)Math.Floor(v.Z), (float)Math.Floor(v.W));
}
public static Vector4 Ceiling(this Vector4 v)
{
return new Vector4((float)Math.Ceiling(v.X), (float)Math.Ceiling(v.Y), (float)Math.Ceiling(v.Z), (float)Math.Ceiling(v.W));
}
public static Vector4 Abs(this Vector4 v)
{

View File

@ -91,6 +91,9 @@
this.MatColourUpDown = new System.Windows.Forms.NumericUpDown();
this.label25 = new System.Windows.Forms.Label();
this.MatFlagsCheckedListBox = new System.Windows.Forms.CheckedListBox();
this.UpdateSharedMaterialCheckBox = new System.Windows.Forms.CheckBox();
this.DeleteButton = new System.Windows.Forms.Button();
this.AddToProjectButton = new System.Windows.Forms.Button();
this.PolyTabControl.SuspendLayout();
this.TriangleTabPage.SuspendLayout();
this.SphereTabPage.SuspendLayout();
@ -118,10 +121,10 @@
this.PolyTabControl.Controls.Add(this.CapsuleTabPage);
this.PolyTabControl.Controls.Add(this.BoxTabPage);
this.PolyTabControl.Controls.Add(this.CylinderTabPage);
this.PolyTabControl.Location = new System.Drawing.Point(0, 0);
this.PolyTabControl.Location = new System.Drawing.Point(0, 12);
this.PolyTabControl.Name = "PolyTabControl";
this.PolyTabControl.SelectedIndex = 0;
this.PolyTabControl.Size = new System.Drawing.Size(564, 216);
this.PolyTabControl.Size = new System.Drawing.Size(564, 213);
this.PolyTabControl.TabIndex = 0;
//
// TriangleTabPage
@ -146,7 +149,7 @@
this.TriangleTabPage.Location = new System.Drawing.Point(4, 22);
this.TriangleTabPage.Name = "TriangleTabPage";
this.TriangleTabPage.Padding = new System.Windows.Forms.Padding(3);
this.TriangleTabPage.Size = new System.Drawing.Size(556, 190);
this.TriangleTabPage.Size = new System.Drawing.Size(556, 187);
this.TriangleTabPage.TabIndex = 0;
this.TriangleTabPage.Text = "Triangle";
this.TriangleTabPage.UseVisualStyleBackColor = true;
@ -160,7 +163,7 @@
this.SphereTabPage.Location = new System.Drawing.Point(4, 22);
this.SphereTabPage.Name = "SphereTabPage";
this.SphereTabPage.Padding = new System.Windows.Forms.Padding(3);
this.SphereTabPage.Size = new System.Drawing.Size(556, 190);
this.SphereTabPage.Size = new System.Drawing.Size(556, 185);
this.SphereTabPage.TabIndex = 1;
this.SphereTabPage.Text = "Sphere";
this.SphereTabPage.UseVisualStyleBackColor = true;
@ -175,7 +178,7 @@
this.CapsuleTabPage.Controls.Add(this.label12);
this.CapsuleTabPage.Location = new System.Drawing.Point(4, 22);
this.CapsuleTabPage.Name = "CapsuleTabPage";
this.CapsuleTabPage.Size = new System.Drawing.Size(556, 190);
this.CapsuleTabPage.Size = new System.Drawing.Size(556, 185);
this.CapsuleTabPage.TabIndex = 2;
this.CapsuleTabPage.Text = "Capsule";
this.CapsuleTabPage.UseVisualStyleBackColor = true;
@ -192,7 +195,7 @@
this.BoxTabPage.Controls.Add(this.label19);
this.BoxTabPage.Location = new System.Drawing.Point(4, 22);
this.BoxTabPage.Name = "BoxTabPage";
this.BoxTabPage.Size = new System.Drawing.Size(556, 190);
this.BoxTabPage.Size = new System.Drawing.Size(556, 185);
this.BoxTabPage.TabIndex = 3;
this.BoxTabPage.Text = "Box";
this.BoxTabPage.UseVisualStyleBackColor = true;
@ -207,7 +210,7 @@
this.CylinderTabPage.Controls.Add(this.label15);
this.CylinderTabPage.Location = new System.Drawing.Point(4, 22);
this.CylinderTabPage.Name = "CylinderTabPage";
this.CylinderTabPage.Size = new System.Drawing.Size(556, 190);
this.CylinderTabPage.Size = new System.Drawing.Size(556, 185);
this.CylinderTabPage.TabIndex = 4;
this.CylinderTabPage.Text = "Cylinder";
this.CylinderTabPage.UseVisualStyleBackColor = true;
@ -408,14 +411,15 @@
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.MaterialTabControl.Controls.Add(this.MaterialTabPage);
this.MaterialTabControl.Location = new System.Drawing.Point(0, 218);
this.MaterialTabControl.Location = new System.Drawing.Point(0, 225);
this.MaterialTabControl.Name = "MaterialTabControl";
this.MaterialTabControl.SelectedIndex = 0;
this.MaterialTabControl.Size = new System.Drawing.Size(564, 286);
this.MaterialTabControl.Size = new System.Drawing.Size(564, 279);
this.MaterialTabControl.TabIndex = 1;
//
// MaterialTabPage
//
this.MaterialTabPage.Controls.Add(this.UpdateSharedMaterialCheckBox);
this.MaterialTabPage.Controls.Add(this.MatFlagsCheckedListBox);
this.MaterialTabPage.Controls.Add(this.MatColourUpDown);
this.MaterialTabPage.Controls.Add(this.label25);
@ -432,7 +436,7 @@
this.MaterialTabPage.Location = new System.Drawing.Point(4, 22);
this.MaterialTabPage.Name = "MaterialTabPage";
this.MaterialTabPage.Padding = new System.Windows.Forms.Padding(3);
this.MaterialTabPage.Size = new System.Drawing.Size(556, 260);
this.MaterialTabPage.Size = new System.Drawing.Size(556, 253);
this.MaterialTabPage.TabIndex = 0;
this.MaterialTabPage.Text = "Material";
this.MaterialTabPage.UseVisualStyleBackColor = true;
@ -668,7 +672,7 @@
// MatTypeCombo
//
this.MatTypeCombo.FormattingEnabled = true;
this.MatTypeCombo.Location = new System.Drawing.Point(92, 9);
this.MatTypeCombo.Location = new System.Drawing.Point(92, 6);
this.MatTypeCombo.Name = "MatTypeCombo";
this.MatTypeCombo.Size = new System.Drawing.Size(195, 21);
this.MatTypeCombo.TabIndex = 20;
@ -677,7 +681,7 @@
// label20
//
this.label20.AutoSize = true;
this.label20.Location = new System.Drawing.Point(39, 12);
this.label20.Location = new System.Drawing.Point(39, 9);
this.label20.Name = "label20";
this.label20.Size = new System.Drawing.Size(47, 13);
this.label20.TabIndex = 19;
@ -685,7 +689,7 @@
//
// MatUnkUpDown
//
this.MatUnkUpDown.Location = new System.Drawing.Point(92, 140);
this.MatUnkUpDown.Location = new System.Drawing.Point(92, 137);
this.MatUnkUpDown.Maximum = new decimal(new int[] {
65535,
0,
@ -699,7 +703,7 @@
// label21
//
this.label21.AutoSize = true;
this.label21.Location = new System.Drawing.Point(56, 142);
this.label21.Location = new System.Drawing.Point(56, 139);
this.label21.Name = "label21";
this.label21.Size = new System.Drawing.Size(30, 13);
this.label21.TabIndex = 29;
@ -707,7 +711,7 @@
//
// MatPedDensityUpDown
//
this.MatPedDensityUpDown.Location = new System.Drawing.Point(92, 114);
this.MatPedDensityUpDown.Location = new System.Drawing.Point(92, 111);
this.MatPedDensityUpDown.Maximum = new decimal(new int[] {
255,
0,
@ -721,7 +725,7 @@
// label22
//
this.label22.AutoSize = true;
this.label22.Location = new System.Drawing.Point(19, 116);
this.label22.Location = new System.Drawing.Point(19, 113);
this.label22.Name = "label22";
this.label22.Size = new System.Drawing.Size(67, 13);
this.label22.TabIndex = 27;
@ -729,7 +733,7 @@
//
// MatRoomIDUpDown
//
this.MatRoomIDUpDown.Location = new System.Drawing.Point(92, 88);
this.MatRoomIDUpDown.Location = new System.Drawing.Point(92, 85);
this.MatRoomIDUpDown.Maximum = new decimal(new int[] {
255,
0,
@ -743,7 +747,7 @@
// label23
//
this.label23.AutoSize = true;
this.label23.Location = new System.Drawing.Point(34, 90);
this.label23.Location = new System.Drawing.Point(34, 87);
this.label23.Name = "label23";
this.label23.Size = new System.Drawing.Size(52, 13);
this.label23.TabIndex = 25;
@ -751,7 +755,7 @@
//
// MatProceduralIDUpDown
//
this.MatProceduralIDUpDown.Location = new System.Drawing.Point(92, 62);
this.MatProceduralIDUpDown.Location = new System.Drawing.Point(92, 59);
this.MatProceduralIDUpDown.Maximum = new decimal(new int[] {
255,
0,
@ -765,7 +769,7 @@
// label24
//
this.label24.AutoSize = true;
this.label24.Location = new System.Drawing.Point(11, 64);
this.label24.Location = new System.Drawing.Point(11, 61);
this.label24.Name = "label24";
this.label24.Size = new System.Drawing.Size(75, 13);
this.label24.TabIndex = 23;
@ -773,7 +777,7 @@
//
// MatColourUpDown
//
this.MatColourUpDown.Location = new System.Drawing.Point(92, 36);
this.MatColourUpDown.Location = new System.Drawing.Point(92, 33);
this.MatColourUpDown.Maximum = new decimal(new int[] {
255,
0,
@ -787,7 +791,7 @@
// label25
//
this.label25.AutoSize = true;
this.label25.Location = new System.Drawing.Point(6, 38);
this.label25.Location = new System.Drawing.Point(6, 35);
this.label25.Name = "label25";
this.label25.Size = new System.Drawing.Size(80, 13);
this.label25.TabIndex = 21;
@ -816,17 +820,51 @@
"13 - Too Steep for Player",
"14 - No Network Spawn",
"15 - No Cam Collision Allow Clipping"});
this.MatFlagsCheckedListBox.Location = new System.Drawing.Point(326, 9);
this.MatFlagsCheckedListBox.Location = new System.Drawing.Point(326, 6);
this.MatFlagsCheckedListBox.Name = "MatFlagsCheckedListBox";
this.MatFlagsCheckedListBox.Size = new System.Drawing.Size(223, 244);
this.MatFlagsCheckedListBox.TabIndex = 31;
this.MatFlagsCheckedListBox.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.MatFlagsCheckedListBox_ItemCheck);
//
// UpdateSharedMaterialCheckBox
//
this.UpdateSharedMaterialCheckBox.AutoSize = true;
this.UpdateSharedMaterialCheckBox.Location = new System.Drawing.Point(92, 172);
this.UpdateSharedMaterialCheckBox.Name = "UpdateSharedMaterialCheckBox";
this.UpdateSharedMaterialCheckBox.Size = new System.Drawing.Size(170, 17);
this.UpdateSharedMaterialCheckBox.TabIndex = 32;
this.UpdateSharedMaterialCheckBox.Text = "Update shared material on edit";
this.UpdateSharedMaterialCheckBox.UseVisualStyleBackColor = true;
//
// DeleteButton
//
this.DeleteButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.DeleteButton.Location = new System.Drawing.Point(458, 7);
this.DeleteButton.Name = "DeleteButton";
this.DeleteButton.Size = new System.Drawing.Size(95, 23);
this.DeleteButton.TabIndex = 38;
this.DeleteButton.Text = "Delete Polygon";
this.DeleteButton.UseVisualStyleBackColor = true;
this.DeleteButton.Click += new System.EventHandler(this.DeleteButton_Click);
//
// AddToProjectButton
//
this.AddToProjectButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.AddToProjectButton.Location = new System.Drawing.Point(357, 7);
this.AddToProjectButton.Name = "AddToProjectButton";
this.AddToProjectButton.Size = new System.Drawing.Size(95, 23);
this.AddToProjectButton.TabIndex = 37;
this.AddToProjectButton.Text = "Add to Project";
this.AddToProjectButton.UseVisualStyleBackColor = true;
this.AddToProjectButton.Click += new System.EventHandler(this.AddToProjectButton_Click);
//
// EditYbnBoundPolyPanel
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(565, 505);
this.Controls.Add(this.DeleteButton);
this.Controls.Add(this.AddToProjectButton);
this.Controls.Add(this.MaterialTabControl);
this.Controls.Add(this.PolyTabControl);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
@ -922,5 +960,8 @@
private System.Windows.Forms.NumericUpDown MatColourUpDown;
private System.Windows.Forms.Label label25;
private System.Windows.Forms.CheckedListBox MatFlagsCheckedListBox;
private System.Windows.Forms.CheckBox UpdateSharedMaterialCheckBox;
private System.Windows.Forms.Button DeleteButton;
private System.Windows.Forms.Button AddToProjectButton;
}
}

View File

@ -81,6 +81,8 @@ namespace CodeWalker.Project.Panels
{
if (CollisionPoly == null)
{
AddToProjectButton.Enabled = false;
DeleteButton.Enabled = false;
PolyTabControl.TabPages.Clear();
TriVertex1TextBox.Text = string.Empty;
TriVertex2TextBox.Text = string.Empty;
@ -192,6 +194,10 @@ namespace CodeWalker.Project.Panels
MatUnkUpDown.Value = m.Unk4;
SetCheckedListBoxValues(MatFlagsCheckedListBox, (ushort)m.Flags);
var ybn = CollisionPoly.Owner?.GetRootYbn();
AddToProjectButton.Enabled = (ybn != null) ? !ProjectForm.YbnExistsInProject(ybn) : false;
DeleteButton.Enabled = !AddToProjectButton.Enabled;
populatingui = false;
}
}
@ -226,6 +232,29 @@ namespace CodeWalker.Project.Panels
}
private void UpdatePolyMaterial(BoundMaterial_s mat)
{
if (CollisionPoly == null) return;
var shared = UpdateSharedMaterialCheckBox.Checked && (CollisionPoly.Owner != null);
lock (ProjectForm.ProjectSyncRoot)
{
if (shared)
{
CollisionPoly.Owner.SetMaterial(CollisionPoly.Index, mat);
}
else
{
CollisionPoly.Material = mat;
}
ProjectForm.SetYbnHasChanged(true);
}
if ((ProjectForm.WorldForm != null) && (CollisionPoly.Owner != null))
{
ProjectForm.WorldForm.UpdateCollisionBoundsGraphics(CollisionPoly.Owner);
}
}
private void TriVertex1TextBox_TextChanged(object sender, EventArgs e)
{
@ -561,49 +590,103 @@ namespace CodeWalker.Project.Panels
{
if (CollisionPoly == null) return;
if (populatingui) return;
var mat = CollisionPoly.Material;
var v = (byte)MatTypeCombo.SelectedIndex;
if (mat.Type != v)
{
mat.Type = v;
UpdatePolyMaterial(mat);
}
}
private void MatColourUpDown_ValueChanged(object sender, EventArgs e)
{
if (CollisionPoly == null) return;
if (populatingui) return;
var mat = CollisionPoly.Material;
var v = (byte)MatColourUpDown.Value;
if (mat.MaterialColorIndex != v)
{
mat.MaterialColorIndex = v;
UpdatePolyMaterial(mat);
}
}
private void MatProceduralIDUpDown_ValueChanged(object sender, EventArgs e)
{
if (CollisionPoly == null) return;
if (populatingui) return;
var mat = CollisionPoly.Material;
var v = (byte)MatProceduralIDUpDown.Value;
if (mat.ProceduralId != v)
{
mat.ProceduralId = v;
UpdatePolyMaterial(mat);
}
}
private void MatRoomIDUpDown_ValueChanged(object sender, EventArgs e)
{
if (CollisionPoly == null) return;
if (populatingui) return;
var mat = CollisionPoly.Material;
var v = (byte)MatRoomIDUpDown.Value;
if (mat.RoomId != v)
{
mat.RoomId = v;
UpdatePolyMaterial(mat);
}
}
private void MatPedDensityUpDown_ValueChanged(object sender, EventArgs e)
{
if (CollisionPoly == null) return;
if (populatingui) return;
var mat = CollisionPoly.Material;
var v = (byte)MatPedDensityUpDown.Value;
if (mat.PedDensity != v)
{
mat.PedDensity = v;
UpdatePolyMaterial(mat);
}
}
private void MatUnkUpDown_ValueChanged(object sender, EventArgs e)
{
if (CollisionPoly == null) return;
if (populatingui) return;
var mat = CollisionPoly.Material;
var v = (ushort)MatUnkUpDown.Value;
if (mat.Unk4 != v)
{
mat.Unk4 = v;
UpdatePolyMaterial(mat);
}
}
private void MatFlagsCheckedListBox_ItemCheck(object sender, ItemCheckEventArgs e)
{
if (CollisionPoly == null) return;
if (populatingui) return;
var mat = CollisionPoly.Material;
var v = (EBoundMaterialFlags)GetCheckedListBoxValues(MatFlagsCheckedListBox, e);
if (mat.Flags != v)
{
mat.Flags = v;
UpdatePolyMaterial(mat);
}
}
private void AddToProjectButton_Click(object sender, EventArgs e)
{
ProjectForm.SetProjectItem(CollisionPoly);
ProjectForm.AddCollisionPolyToProject();
}
private void DeleteButton_Click(object sender, EventArgs e)
{
ProjectForm.SetProjectItem(CollisionPoly);
ProjectForm.DeleteCollisionPoly();
}
}
}

View File

@ -64,16 +64,18 @@
this.label11 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.GeometryTabPage = new System.Windows.Forms.TabPage();
this.CenterGeomTextBox = new System.Windows.Forms.TextBox();
this.label17 = new System.Windows.Forms.Label();
this.QuantumTextBox = new System.Windows.Forms.TextBox();
this.label18 = new System.Windows.Forms.Label();
this.UnkFloat1TextBox = new System.Windows.Forms.TextBox();
this.label19 = new System.Windows.Forms.Label();
this.PolyCountLabel = new System.Windows.Forms.Label();
this.VertexCountLabel = new System.Windows.Forms.Label();
this.UnkFloat2TextBox = new System.Windows.Forms.TextBox();
this.label20 = new System.Windows.Forms.Label();
this.VertexCountLabel = new System.Windows.Forms.Label();
this.PolyCountLabel = new System.Windows.Forms.Label();
this.UnkFloat1TextBox = new System.Windows.Forms.TextBox();
this.label19 = new System.Windows.Forms.Label();
this.QuantumTextBox = new System.Windows.Forms.TextBox();
this.label18 = new System.Windows.Forms.Label();
this.CenterGeomTextBox = new System.Windows.Forms.TextBox();
this.label17 = new System.Windows.Forms.Label();
this.DeleteButton = new System.Windows.Forms.Button();
this.AddToProjectButton = new System.Windows.Forms.Button();
this.BoundsTabControl.SuspendLayout();
this.BoundsTabPage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.UnkTypeUpDown)).BeginInit();
@ -99,6 +101,8 @@
//
// BoundsTabPage
//
this.BoundsTabPage.Controls.Add(this.DeleteButton);
this.BoundsTabPage.Controls.Add(this.AddToProjectButton);
this.BoundsTabPage.Controls.Add(this.MaterialCombo);
this.BoundsTabPage.Controls.Add(this.UnkTypeUpDown);
this.BoundsTabPage.Controls.Add(this.label16);
@ -483,62 +487,23 @@
this.GeometryTabPage.Text = "Geometry";
this.GeometryTabPage.UseVisualStyleBackColor = true;
//
// CenterGeomTextBox
// PolyCountLabel
//
this.CenterGeomTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.CenterGeomTextBox.Location = new System.Drawing.Point(91, 6);
this.CenterGeomTextBox.Name = "CenterGeomTextBox";
this.CenterGeomTextBox.Size = new System.Drawing.Size(458, 20);
this.CenterGeomTextBox.TabIndex = 4;
this.CenterGeomTextBox.TextChanged += new System.EventHandler(this.CenterGeomTextBox_TextChanged);
this.PolyCountLabel.AutoSize = true;
this.PolyCountLabel.Location = new System.Drawing.Point(88, 144);
this.PolyCountLabel.Name = "PolyCountLabel";
this.PolyCountLabel.Size = new System.Drawing.Size(58, 13);
this.PolyCountLabel.TabIndex = 12;
this.PolyCountLabel.Text = "0 polygons";
//
// label17
// VertexCountLabel
//
this.label17.AutoSize = true;
this.label17.Location = new System.Drawing.Point(13, 9);
this.label17.Name = "label17";
this.label17.Size = new System.Drawing.Size(72, 13);
this.label17.TabIndex = 3;
this.label17.Text = "Geom Center:";
//
// QuantumTextBox
//
this.QuantumTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.QuantumTextBox.Location = new System.Drawing.Point(91, 32);
this.QuantumTextBox.Name = "QuantumTextBox";
this.QuantumTextBox.Size = new System.Drawing.Size(458, 20);
this.QuantumTextBox.TabIndex = 6;
this.QuantumTextBox.TextChanged += new System.EventHandler(this.QuantumTextBox_TextChanged);
//
// label18
//
this.label18.AutoSize = true;
this.label18.Location = new System.Drawing.Point(32, 35);
this.label18.Name = "label18";
this.label18.Size = new System.Drawing.Size(53, 13);
this.label18.TabIndex = 5;
this.label18.Text = "Quantum:";
//
// UnkFloat1TextBox
//
this.UnkFloat1TextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.UnkFloat1TextBox.Location = new System.Drawing.Point(91, 58);
this.UnkFloat1TextBox.Name = "UnkFloat1TextBox";
this.UnkFloat1TextBox.Size = new System.Drawing.Size(458, 20);
this.UnkFloat1TextBox.TabIndex = 8;
this.UnkFloat1TextBox.TextChanged += new System.EventHandler(this.UnkFloat1TextBox_TextChanged);
//
// label19
//
this.label19.AutoSize = true;
this.label19.Location = new System.Drawing.Point(20, 61);
this.label19.Name = "label19";
this.label19.Size = new System.Drawing.Size(65, 13);
this.label19.TabIndex = 7;
this.label19.Text = "Unk Float 1:";
this.VertexCountLabel.AutoSize = true;
this.VertexCountLabel.Location = new System.Drawing.Point(88, 124);
this.VertexCountLabel.Name = "VertexCountLabel";
this.VertexCountLabel.Size = new System.Drawing.Size(53, 13);
this.VertexCountLabel.TabIndex = 11;
this.VertexCountLabel.Text = "0 vertices";
//
// UnkFloat2TextBox
//
@ -559,23 +524,84 @@
this.label20.TabIndex = 9;
this.label20.Text = "Unk Float 2:";
//
// VertexCountLabel
// UnkFloat1TextBox
//
this.VertexCountLabel.AutoSize = true;
this.VertexCountLabel.Location = new System.Drawing.Point(88, 124);
this.VertexCountLabel.Name = "VertexCountLabel";
this.VertexCountLabel.Size = new System.Drawing.Size(53, 13);
this.VertexCountLabel.TabIndex = 11;
this.VertexCountLabel.Text = "0 vertices";
this.UnkFloat1TextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.UnkFloat1TextBox.Location = new System.Drawing.Point(91, 58);
this.UnkFloat1TextBox.Name = "UnkFloat1TextBox";
this.UnkFloat1TextBox.Size = new System.Drawing.Size(458, 20);
this.UnkFloat1TextBox.TabIndex = 8;
this.UnkFloat1TextBox.TextChanged += new System.EventHandler(this.UnkFloat1TextBox_TextChanged);
//
// PolyCountLabel
// label19
//
this.PolyCountLabel.AutoSize = true;
this.PolyCountLabel.Location = new System.Drawing.Point(88, 144);
this.PolyCountLabel.Name = "PolyCountLabel";
this.PolyCountLabel.Size = new System.Drawing.Size(58, 13);
this.PolyCountLabel.TabIndex = 12;
this.PolyCountLabel.Text = "0 polygons";
this.label19.AutoSize = true;
this.label19.Location = new System.Drawing.Point(20, 61);
this.label19.Name = "label19";
this.label19.Size = new System.Drawing.Size(65, 13);
this.label19.TabIndex = 7;
this.label19.Text = "Unk Float 1:";
//
// QuantumTextBox
//
this.QuantumTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.QuantumTextBox.Location = new System.Drawing.Point(91, 32);
this.QuantumTextBox.Name = "QuantumTextBox";
this.QuantumTextBox.Size = new System.Drawing.Size(458, 20);
this.QuantumTextBox.TabIndex = 6;
this.QuantumTextBox.TextChanged += new System.EventHandler(this.QuantumTextBox_TextChanged);
//
// label18
//
this.label18.AutoSize = true;
this.label18.Location = new System.Drawing.Point(32, 35);
this.label18.Name = "label18";
this.label18.Size = new System.Drawing.Size(53, 13);
this.label18.TabIndex = 5;
this.label18.Text = "Quantum:";
//
// CenterGeomTextBox
//
this.CenterGeomTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.CenterGeomTextBox.Location = new System.Drawing.Point(91, 6);
this.CenterGeomTextBox.Name = "CenterGeomTextBox";
this.CenterGeomTextBox.Size = new System.Drawing.Size(458, 20);
this.CenterGeomTextBox.TabIndex = 4;
this.CenterGeomTextBox.TextChanged += new System.EventHandler(this.CenterGeomTextBox_TextChanged);
//
// label17
//
this.label17.AutoSize = true;
this.label17.Location = new System.Drawing.Point(13, 9);
this.label17.Name = "label17";
this.label17.Size = new System.Drawing.Size(72, 13);
this.label17.TabIndex = 3;
this.label17.Text = "Geom Center:";
//
// DeleteButton
//
this.DeleteButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.DeleteButton.Location = new System.Drawing.Point(454, 238);
this.DeleteButton.Name = "DeleteButton";
this.DeleteButton.Size = new System.Drawing.Size(95, 23);
this.DeleteButton.TabIndex = 36;
this.DeleteButton.Text = "Delete Bounds";
this.DeleteButton.UseVisualStyleBackColor = true;
this.DeleteButton.Click += new System.EventHandler(this.DeleteButton_Click);
//
// AddToProjectButton
//
this.AddToProjectButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.AddToProjectButton.Location = new System.Drawing.Point(353, 238);
this.AddToProjectButton.Name = "AddToProjectButton";
this.AddToProjectButton.Size = new System.Drawing.Size(95, 23);
this.AddToProjectButton.TabIndex = 35;
this.AddToProjectButton.Text = "Add to Project";
this.AddToProjectButton.UseVisualStyleBackColor = true;
this.AddToProjectButton.Click += new System.EventHandler(this.AddToProjectButton_Click);
//
// EditYbnBoundsPanel
//
@ -649,5 +675,7 @@
private System.Windows.Forms.Label label19;
private System.Windows.Forms.Label PolyCountLabel;
private System.Windows.Forms.Label VertexCountLabel;
private System.Windows.Forms.Button DeleteButton;
private System.Windows.Forms.Button AddToProjectButton;
}
}

View File

@ -74,6 +74,8 @@ namespace CodeWalker.Project.Panels
var b = CollisionBounds;
if (b == null)
{
AddToProjectButton.Enabled = false;
DeleteButton.Enabled = false;
BBMinTextBox.Text = string.Empty;
BBMaxTextBox.Text = string.Empty;
BBCenterTextBox.Text = string.Empty;
@ -144,6 +146,10 @@ namespace CodeWalker.Project.Panels
PolyCountLabel.Text = "0 polygons";
}
var ybn = b.GetRootYbn();
AddToProjectButton.Enabled = (ybn != null) ? !ProjectForm.YbnExistsInProject(ybn) : false;
DeleteButton.Enabled = !AddToProjectButton.Enabled;
populatingui = false;
}
}
@ -447,5 +453,17 @@ namespace CodeWalker.Project.Panels
}
}
}
private void AddToProjectButton_Click(object sender, EventArgs e)
{
ProjectForm.SetProjectItem(CollisionBounds);
ProjectForm.AddCollisionBoundsToProject();
}
private void DeleteButton_Click(object sender, EventArgs e)
{
ProjectForm.SetProjectItem(CollisionBounds);
ProjectForm.DeleteCollisionBounds();
}
}
}

View File

@ -3048,6 +3048,157 @@ namespace CodeWalker.Project
return CurrentProjectFile.ContainsYbn(ybn);
}
public void NewCollisionBounds(BoundsType type, Bounds copy = null)
{
if (CurrentYbnFile == null) return;
//////// TODO!!
}
public void AddCollisionBoundsToProject()
{
try
{
if (CurrentCollisionBounds == null) return;
CurrentYbnFile = CurrentCollisionBounds.GetRootYbn();
if (CurrentYbnFile == null)
{
MessageBox.Show("Sorry, only YBN collisions can currently be added to the project. Embedded collisions TODO!");
return;
}
if (!YbnExistsInProject(CurrentYbnFile))
{
var b = CurrentCollisionBounds;
CurrentYbnFile.HasChanged = true;
AddYbnToProject(CurrentYbnFile);
CurrentCollisionBounds = b; //bug fix for some reason the treeview selects the project node here.
CurrentYbnFile = b.GetRootYbn();
ProjectExplorer?.TrySelectCollisionBoundsTreeNode(b);
}
}
catch
{ }
}
public bool DeleteCollisionBounds()
{
if (CurrentCollisionBounds == null) return false;
if (CurrentYbnFile == null) return false;
if (CurrentCollisionBounds.GetRootYbn() != CurrentYbnFile) return false;
if (MessageBox.Show("Are you sure you want to delete this collision bounds?\n" + CurrentCollisionBounds.ToString() + "\n\nThis operation cannot be undone. Continue?", "Confirm delete", MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return true;
}
bool res = false;
if (WorldForm != null)
{
lock (WorldForm.RenderSyncRoot) //don't try to do this while rendering...
{
res = CurrentYbnFile.RemoveBounds(CurrentCollisionBounds);
//WorldForm.SelectItem(null, null, null);
}
}
else
{
res = CurrentYbnFile.RemoveBounds(CurrentCollisionBounds);
}
if (!res)
{
MessageBox.Show("Unable to delete the collision bounds. This shouldn't happen!");
}
var delb = CurrentCollisionBounds;
ProjectExplorer?.RemoveCollisionBoundsTreeNode(CurrentCollisionBounds);
ProjectExplorer?.SetYbnHasChanged(CurrentYbnFile, true);
ClosePanel((EditYbnBoundsPanel p) => { return p.Tag == delb; });
CurrentCollisionBounds = null;
return true;
}
public void NewCollisionPoly(BoundPolygonType type, BoundPolygon copy = null)
{
if (CurrentYbnFile == null) return;
//////// TODO!!
}
public void AddCollisionPolyToProject()
{
try
{
if (CurrentCollisionPoly == null) return;
CurrentYbnFile = CurrentCollisionPoly.Owner?.GetRootYbn();
if (CurrentYbnFile == null)
{
MessageBox.Show("Sorry, only YBN collisions can currently be added to the project. Embedded collisions TODO!");
return;
}
if (!YbnExistsInProject(CurrentYbnFile))
{
var p = CurrentCollisionPoly;
CurrentYbnFile.HasChanged = true;
AddYbnToProject(CurrentYbnFile);
CurrentCollisionPoly = p; //bug fix for some reason the treeview selects the project node here.
CurrentCollisionBounds = p.Owner;
CurrentYbnFile = p.Owner?.GetRootYbn();
ProjectExplorer?.TrySelectCollisionPolyTreeNode(p);
}
}
catch
{ }
}
public bool DeleteCollisionPoly()
{
if (CurrentCollisionBounds == null) return false;
if (CurrentCollisionPoly == null) return false;
if (CurrentYbnFile == null) return false;
if (CurrentCollisionPoly.Owner != CurrentCollisionBounds) return false;
if (MessageBox.Show("Are you sure you want to delete this collision poly?\n" + CurrentCollisionPoly.ToString() + "\n\nThis operation cannot be undone. Continue?", "Confirm delete", MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return true;
}
bool res = false;
if (WorldForm != null)
{
lock (WorldForm.RenderSyncRoot) //don't try to do this while rendering...
{
res = CurrentYbnFile.RemovePoly(CurrentCollisionPoly);
//WorldForm.SelectItem(null, null, null);
}
}
else
{
res = CurrentYbnFile.RemovePoly(CurrentCollisionPoly);
}
if (!res)
{
MessageBox.Show("Unable to delete the collision poly. This shouldn't happen!");
}
var delp = CurrentCollisionPoly;
//ProjectExplorer?.RemoveCollisionPolyTreeNode(CurrentCollisionPoly);
ProjectExplorer?.SetYbnHasChanged(CurrentYbnFile, true);
ClosePanel((EditYbnBoundPolyPanel p) => { return p.Tag == delp; });
CurrentCollisionPoly = null;
return true;
}