mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-02-07 08:21:59 +00:00
@ Floor/ceiling textures can now be dragged in GZDoom Visual Mode just like wall textures.
This commit is contained in:
parent
3f6ae23ef9
commit
845b5334d5
4 changed files with 179 additions and 9 deletions
|
@ -19,6 +19,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
@ -41,6 +42,8 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
|
||||||
{
|
{
|
||||||
#region ================== Constants
|
#region ================== Constants
|
||||||
|
|
||||||
|
private const float DRAG_ANGLE_TOLERANCE = 0.06f;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ================== Variables
|
#region ================== Variables
|
||||||
|
@ -56,6 +59,22 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
|
||||||
protected SectorLevel level;
|
protected SectorLevel level;
|
||||||
protected Effect3DFloor extrafloor;
|
protected Effect3DFloor extrafloor;
|
||||||
|
|
||||||
|
// Undo/redo
|
||||||
|
private int undoticket;
|
||||||
|
|
||||||
|
// UV dragging
|
||||||
|
private float dragstartanglexy;
|
||||||
|
private float dragstartanglez;
|
||||||
|
private Vector3D dragorigin;
|
||||||
|
private Vector3D deltaxy;
|
||||||
|
private Vector3D deltaz;
|
||||||
|
private int startoffsetx;
|
||||||
|
private int startoffsety;
|
||||||
|
protected bool uvdragging;
|
||||||
|
private int prevoffsetx; // We have to provide delta offsets, but I don't
|
||||||
|
private int prevoffsety; // want to calculate with delta offsets to prevent
|
||||||
|
// inaccuracy in the dragging.
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ================== Properties
|
#region ================== Properties
|
||||||
|
@ -82,7 +101,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
|
||||||
// This changes the height
|
// This changes the height
|
||||||
protected abstract void ChangeHeight(int amount);
|
protected abstract void ChangeHeight(int amount);
|
||||||
|
|
||||||
|
|
||||||
// This swaps triangles so that the plane faces the other way
|
// This swaps triangles so that the plane faces the other way
|
||||||
protected void SwapTriangleVertices(WorldVertex[] verts)
|
protected void SwapTriangleVertices(WorldVertex[] verts)
|
||||||
{
|
{
|
||||||
|
@ -96,15 +114,36 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is called to update UV dragging
|
||||||
|
protected virtual void UpdateDragUV()
|
||||||
|
{
|
||||||
|
float u_ray = 1.0f;
|
||||||
|
|
||||||
|
// Calculate intersection position
|
||||||
|
this.Level.plane.GetIntersection(General.Map.VisualCamera.Position, General.Map.VisualCamera.Target, ref u_ray);
|
||||||
|
Vector3D intersect = General.Map.VisualCamera.Position + (General.Map.VisualCamera.Target - General.Map.VisualCamera.Position) * u_ray;
|
||||||
|
|
||||||
|
// Calculate offsets
|
||||||
|
Vector3D dragdelta = intersect - dragorigin;
|
||||||
|
float offsetx = dragdelta.x;
|
||||||
|
float offsety = dragdelta.y;
|
||||||
|
|
||||||
|
// Apply offsets
|
||||||
|
int newoffsetx = startoffsetx - (int)Math.Round(offsetx);
|
||||||
|
int newoffsety = startoffsety + (int)Math.Round(offsety);
|
||||||
|
mode.ApplyFlatOffsetChange(prevoffsetx - newoffsetx, prevoffsety - newoffsety);
|
||||||
|
prevoffsetx = newoffsetx;
|
||||||
|
prevoffsety = newoffsety;
|
||||||
|
|
||||||
|
mode.ShowTargetInfo();
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ================== Events
|
#region ================== Events
|
||||||
|
|
||||||
// Unused
|
// Unused
|
||||||
public virtual void OnSelectBegin(){ }
|
|
||||||
public virtual void OnEditBegin() { }
|
public virtual void OnEditBegin() { }
|
||||||
public virtual void OnMouseMove(MouseEventArgs e) { }
|
|
||||||
public virtual void OnChangeTextureOffset(int horizontal, int vertical) { }
|
|
||||||
public virtual void OnTextureAlign(bool alignx, bool aligny) { }
|
public virtual void OnTextureAlign(bool alignx, bool aligny) { }
|
||||||
public virtual void OnToggleUpperUnpegged() { }
|
public virtual void OnToggleUpperUnpegged() { }
|
||||||
public virtual void OnToggleLowerUnpegged() { }
|
public virtual void OnToggleLowerUnpegged() { }
|
||||||
|
@ -116,6 +155,8 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
|
||||||
protected virtual void SetTexture(string texturename) { }
|
protected virtual void SetTexture(string texturename) { }
|
||||||
public virtual void ApplyUpperUnpegged(bool set) { }
|
public virtual void ApplyUpperUnpegged(bool set) { }
|
||||||
public virtual void ApplyLowerUnpegged(bool set) { }
|
public virtual void ApplyLowerUnpegged(bool set) { }
|
||||||
|
protected abstract void MoveTextureOffset(Point xy);
|
||||||
|
protected abstract Point GetTextureOffset();
|
||||||
|
|
||||||
// Setup this plane
|
// Setup this plane
|
||||||
public bool Setup() { return this.Setup(this.level, this.extrafloor); }
|
public bool Setup() { return this.Setup(this.level, this.extrafloor); }
|
||||||
|
@ -126,8 +167,31 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Begin select
|
||||||
|
public virtual void OnSelectBegin()
|
||||||
|
{
|
||||||
|
mode.LockTarget();
|
||||||
|
dragstartanglexy = General.Map.VisualCamera.AngleXY;
|
||||||
|
dragstartanglez = General.Map.VisualCamera.AngleZ;
|
||||||
|
dragorigin = pickintersect;
|
||||||
|
startoffsetx = GetTextureOffset().X;
|
||||||
|
startoffsety = GetTextureOffset().Y;
|
||||||
|
prevoffsetx = GetTextureOffset().X;
|
||||||
|
prevoffsety = GetTextureOffset().Y;
|
||||||
|
}
|
||||||
|
|
||||||
// Select or deselect
|
// Select or deselect
|
||||||
public virtual void OnSelectEnd()
|
public virtual void OnSelectEnd()
|
||||||
|
{
|
||||||
|
mode.UnlockTarget();
|
||||||
|
|
||||||
|
// Was dragging?
|
||||||
|
if(uvdragging)
|
||||||
|
{
|
||||||
|
// Dragging stops now
|
||||||
|
uvdragging = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if(this.selected)
|
if(this.selected)
|
||||||
{
|
{
|
||||||
|
@ -140,6 +204,38 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
|
||||||
mode.AddSelectedObject(this);
|
mode.AddSelectedObject(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Moving the mouse
|
||||||
|
public virtual void OnMouseMove(MouseEventArgs e)
|
||||||
|
{
|
||||||
|
// Dragging UV?
|
||||||
|
if(uvdragging)
|
||||||
|
{
|
||||||
|
UpdateDragUV();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Select button pressed?
|
||||||
|
if(General.Actions.CheckActionActive(General.ThisAssembly, "visualselect"))
|
||||||
|
{
|
||||||
|
// Check if tolerance is exceeded to start UV dragging
|
||||||
|
float deltaxy = General.Map.VisualCamera.AngleXY - dragstartanglexy;
|
||||||
|
float deltaz = General.Map.VisualCamera.AngleZ - dragstartanglez;
|
||||||
|
if((Math.Abs(deltaxy) + Math.Abs(deltaz)) > DRAG_ANGLE_TOLERANCE)
|
||||||
|
{
|
||||||
|
mode.PreAction(UndoGroup.TextureOffsetChange);
|
||||||
|
mode.CreateUndo("Change texture offsets");
|
||||||
|
|
||||||
|
// Start drag now
|
||||||
|
uvdragging = true;
|
||||||
|
mode.Renderer.ShowSelection = false;
|
||||||
|
mode.Renderer.ShowHighlight = false;
|
||||||
|
UpdateDragUV();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Processing
|
// Processing
|
||||||
public virtual void OnProcess(double deltatime)
|
public virtual void OnProcess(double deltatime)
|
||||||
|
@ -341,6 +437,22 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
|
||||||
Sector.UpdateSectorGeometry(false);
|
Sector.UpdateSectorGeometry(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Texture offset change
|
||||||
|
public virtual void OnChangeTextureOffset(int horizontal, int vertical)
|
||||||
|
{
|
||||||
|
if((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket))
|
||||||
|
undoticket = mode.CreateUndo("Change texture offsets");
|
||||||
|
|
||||||
|
// Apply offsets
|
||||||
|
MoveTextureOffset(new Point(-horizontal, -vertical));
|
||||||
|
|
||||||
|
mode.SetActionResult("Changed texture offsets by " + -horizontal + ", " + -vertical + ".");
|
||||||
|
|
||||||
|
// Update sector geometry
|
||||||
|
Sector.UpdateSectorGeometry(false);
|
||||||
|
Sector.Rebuild();
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -920,6 +920,24 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Apply flat offsets
|
||||||
|
public void ApplyFlatOffsetChange(int dx, int dy)
|
||||||
|
{
|
||||||
|
Dictionary<Sector, int> donesectors = new Dictionary<Sector, int>(selectedobjects.Count);
|
||||||
|
List<IVisualEventReceiver> objs = GetSelectedObjects(true, false, false);
|
||||||
|
foreach(IVisualEventReceiver i in objs)
|
||||||
|
{
|
||||||
|
if(i is BaseVisualGeometrySector)
|
||||||
|
{
|
||||||
|
if(!donesectors.ContainsKey((i as BaseVisualGeometrySector).Sector.Sector))
|
||||||
|
{
|
||||||
|
i.OnChangeTextureOffset(dx, dy);
|
||||||
|
donesectors.Add((i as BaseVisualGeometrySector).Sector.Sector, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Apply upper unpegged flag
|
// Apply upper unpegged flag
|
||||||
public void ApplyUpperUnpegged(bool set)
|
public void ApplyUpperUnpegged(bool set)
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,6 +34,7 @@ using CodeImp.DoomBuilder.Data;
|
||||||
using CodeImp.DoomBuilder.Editing;
|
using CodeImp.DoomBuilder.Editing;
|
||||||
using CodeImp.DoomBuilder.IO;
|
using CodeImp.DoomBuilder.IO;
|
||||||
using CodeImp.DoomBuilder.Rendering;
|
using CodeImp.DoomBuilder.Rendering;
|
||||||
|
using CodeImp.DoomBuilder.Types;
|
||||||
using CodeImp.DoomBuilder.VisualModes;
|
using CodeImp.DoomBuilder.VisualModes;
|
||||||
using CodeImp.DoomBuilder.Windows;
|
using CodeImp.DoomBuilder.Windows;
|
||||||
|
|
||||||
|
@ -151,6 +152,25 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
|
||||||
|
|
||||||
#region ================== Methods
|
#region ================== Methods
|
||||||
|
|
||||||
|
// Return texture coordinates
|
||||||
|
protected override Point GetTextureOffset()
|
||||||
|
{
|
||||||
|
Point p = new Point();
|
||||||
|
p.X = (int)Sector.Sector.Fields.GetValue("xpanningceiling", 0.0f);
|
||||||
|
p.Y = (int)Sector.Sector.Fields.GetValue("ypanningceiling", 0.0f);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Move texture coordinates
|
||||||
|
protected override void MoveTextureOffset(Point xy)
|
||||||
|
{
|
||||||
|
Sector.Sector.Fields.BeforeFieldsChange();
|
||||||
|
float oldx = Sector.Sector.Fields.GetValue("xpanningceiling", 0.0f);
|
||||||
|
float oldy = Sector.Sector.Fields.GetValue("ypanningceiling", 0.0f);
|
||||||
|
Sector.Sector.Fields["xpanningceiling"] = new UniValue(UniversalType.Float, oldx + (float)xy.X);
|
||||||
|
Sector.Sector.Fields["ypanningceiling"] = new UniValue(UniversalType.Float, oldy + (float)xy.Y);
|
||||||
|
}
|
||||||
|
|
||||||
// Paste texture
|
// Paste texture
|
||||||
public override void OnPasteTexture()
|
public override void OnPasteTexture()
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,6 +34,7 @@ using CodeImp.DoomBuilder.Data;
|
||||||
using CodeImp.DoomBuilder.Editing;
|
using CodeImp.DoomBuilder.Editing;
|
||||||
using CodeImp.DoomBuilder.IO;
|
using CodeImp.DoomBuilder.IO;
|
||||||
using CodeImp.DoomBuilder.Rendering;
|
using CodeImp.DoomBuilder.Rendering;
|
||||||
|
using CodeImp.DoomBuilder.Types;
|
||||||
using CodeImp.DoomBuilder.VisualModes;
|
using CodeImp.DoomBuilder.VisualModes;
|
||||||
using CodeImp.DoomBuilder.Windows;
|
using CodeImp.DoomBuilder.Windows;
|
||||||
|
|
||||||
|
@ -150,6 +151,25 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
|
||||||
|
|
||||||
#region ================== Methods
|
#region ================== Methods
|
||||||
|
|
||||||
|
// Return texture coordinates
|
||||||
|
protected override Point GetTextureOffset()
|
||||||
|
{
|
||||||
|
Point p = new Point();
|
||||||
|
p.X = (int)Sector.Sector.Fields.GetValue("xpanningfloor", 0.0f);
|
||||||
|
p.Y = (int)Sector.Sector.Fields.GetValue("ypanningfloor", 0.0f);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Move texture coordinates
|
||||||
|
protected override void MoveTextureOffset(Point xy)
|
||||||
|
{
|
||||||
|
Sector.Sector.Fields.BeforeFieldsChange();
|
||||||
|
float oldx = Sector.Sector.Fields.GetValue("xpanningfloor", 0.0f);
|
||||||
|
float oldy = Sector.Sector.Fields.GetValue("ypanningfloor", 0.0f);
|
||||||
|
Sector.Sector.Fields["xpanningfloor"] = new UniValue(UniversalType.Float, oldx + (float)xy.X);
|
||||||
|
Sector.Sector.Fields["ypanningfloor"] = new UniValue(UniversalType.Float, oldy + (float)xy.Y);
|
||||||
|
}
|
||||||
|
|
||||||
// Paste texture
|
// Paste texture
|
||||||
public override void OnPasteTexture()
|
public override void OnPasteTexture()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue