@ Fixed immediate update of target sector lighting when control sector of ExtraFloor_LightOnly effect is changed.

Fixed some inaccuracy problems with the Edit Selection mode.
This commit is contained in:
codeimp 2010-09-16 17:07:30 +00:00
parent c3c4ffcc7b
commit 6c68a5635e
3 changed files with 96 additions and 11 deletions

View file

@ -613,6 +613,42 @@ namespace CodeImp.DoomBuilder.BuilderModes
return p;
}
// This applies the current rotation and resize to a point
private Vector2D TransformedPointNoScale(Vector2D p)
{
// Rotate
Vector2D center = baseoffset + size * 0.5f;
Vector2D po = p - center;
p = po.GetRotated(rotation);
p += center;
// Translate
p += offset - baseoffset;
return p;
}
// This applies the current rotation and resize to a point
private Vector2D TransformedPointNoRotate(Vector2D p)
{
// Resize
p = (p - baseoffset) * (size / basesize) + baseoffset;
// Translate
p += offset - baseoffset;
return p;
}
// This applies the current rotation and resize to a point
private Vector2D TransformedPointNoRotateNoScale(Vector2D p)
{
// Translate
p += offset - baseoffset;
return p;
}
// This checks if a point is in a rect
private bool PointInRectF(RectangleF rect, Vector2D point)
{
@ -629,19 +665,68 @@ namespace CodeImp.DoomBuilder.BuilderModes
// This moves all things and vertices to match the current transformation
private void UpdateGeometry()
{
// We use optimized versions of the TransformedPoint depending on what needs to be done.
// This is mainly done because 0.0 rotation and 1.0 scale may still give slight inaccuracies.
bool norotate = Math.Abs(rotation) < 0.0001f;
bool noscale = Math.Abs(size.x - basesize.x) + Math.Abs(size.y - basesize.y) < 0.0001f;
if(norotate && noscale)
{
int index = 0;
foreach(Vertex v in selectedvertices)
{
v.Move(TransformedPointNoRotateNoScale(vertexpos[index++]));
}
index = 0;
foreach(Thing t in selectedthings)
{
t.Rotate(Angle2D.Normalized(thingangle[index] + rotation));
t.Move(TransformedPointNoRotateNoScale(thingpos[index++]));
}
}
else if(norotate)
{
int index = 0;
foreach(Vertex v in selectedvertices)
{
v.Move(TransformedPointNoRotate(vertexpos[index++]));
}
index = 0;
foreach(Thing t in selectedthings)
{
t.Rotate(Angle2D.Normalized(thingangle[index] + rotation));
t.Move(TransformedPointNoRotate(thingpos[index++]));
}
}
else if(noscale)
{
int index = 0;
foreach(Vertex v in selectedvertices)
{
v.Move(TransformedPointNoScale(vertexpos[index++]));
}
index = 0;
foreach(Thing t in selectedthings)
{
t.Rotate(Angle2D.Normalized(thingangle[index] + rotation));
t.Move(TransformedPointNoScale(thingpos[index++]));
}
}
else
{
int index = 0;
foreach(Vertex v in selectedvertices)
{
v.Move(TransformedPoint(vertexpos[index++]));
}
index = 0;
foreach(Thing t in selectedthings)
{
t.Rotate(Angle2D.Normalized(thingangle[index] + rotation));
t.Move(TransformedPoint(thingpos[index++]));
}
}
// This checks if the lines should be flipped
bool shouldbeflipped = (size.x < 0.0f) ^ (size.y < 0.0f);

View file

@ -901,7 +901,7 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
Sector.Sector.UpdateCache();
// Rebuild sector
Sector.Changed = true;
Sector.UpdateSectorGeometry(false);
// Go for all things in this sector
foreach(Thing t in General.Map.Map.Things)

View file

@ -40,7 +40,7 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
{
SectorData sd = data.Mode.GetSectorData(linedef.Front.Sector);
if(!sd.Updated) sd.Update();
data.AddUpdateSector(linedef.Front.Sector, false);
sd.AddUpdateSector(data.Sector, false);
if(level == null)
{