@ Slightly improved gravity code so that walking on 3D floors works better.

@ Fixed problem where ceiling or floor height changed too much when having the same 3D floor selected multiple times through different tagged sectors.
This commit is contained in:
codeimp 2010-09-17 06:11:56 +00:00
parent bab0815118
commit 35d2f6fe5d
5 changed files with 42 additions and 5 deletions

View file

@ -312,7 +312,7 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
public virtual void OnChangeTargetHeight(int amount)
{
changed = true;
ChangeHeight(amount);
// Rebuild sector

View file

@ -637,7 +637,7 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
Vector3D feetposition = General.Map.VisualCamera.Position;
SectorLevel floorlevel = sd.GetFloorBelow(feetposition) ?? sd.LightLevels[0];
float floorheight = floorlevel.plane.GetZ(General.Map.VisualCamera.Position);
if(General.Map.VisualCamera.Position.z < (floorheight + cameraflooroffset + 0.01f))
if(General.Map.VisualCamera.Position.z < (floorheight + cameraflooroffset + 0.1f))
{
// Stay above floor
gravity = new Vector3D(0.0f, 0.0f, 0.0f);
@ -652,8 +652,7 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
if(gravity.z > 3.0f) gravity.z = 3.0f;
// Test if we don't go through a floor
SectorLevel newfloorlevel = sd.GetFloorBelow(feetposition + gravity) ?? sd.LightLevels[0];
if(newfloorlevel != floorlevel)
if((General.Map.VisualCamera.Position.z + gravity.z) < (floorheight + cameraflooroffset + 0.1f))
{
// Stay above floor
gravity = new Vector3D(0.0f, 0.0f, 0.0f);

View file

@ -45,12 +45,19 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
private SectorLevel floor;
private SectorLevel ceiling;
// This helps keeping track of changes
// otherwise we update ceiling/floor too much
private bool floorchanged;
private bool ceilingchanged;
#endregion
#region ================== Properties
public Sector Sector { get { return sector; } }
public bool Updated { get { return updated; } }
public bool FloorChanged { get { return floorchanged; } set { floorchanged |= value; } }
public bool CeilingChanged { get { return ceilingchanged; } set { ceilingchanged |= value; } }
public List<SectorLevel> LightLevels { get { return lightlevels; } }
public List<Effect3DFloor> ExtraFloors { get { return extrafloors; } }
public SectorLevel Floor { get { return floor; } }
@ -69,6 +76,8 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
this.mode = mode;
this.sector = s;
this.updated = false;
this.floorchanged = false;
this.ceilingchanged = false;
this.lightlevels = new List<SectorLevel>(2);
this.extrafloors = new List<Effect3DFloor>(1);
this.alleffects = new List<SectorEffect>(1);
@ -243,6 +252,9 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
l.brightnessbelow = pl.brightnessbelow;
}
floorchanged = false;
ceilingchanged = false;
updated = true;
isupdating = false;
}

View file

@ -155,7 +155,20 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
this.Setup();
}
}
// Call to change the height
public override void OnChangeTargetHeight(int amount)
{
// Only do this when not done yet in this call
// Because we may be able to select the same 3D floor multiple times through multiple sectors
SectorData sd = mode.GetSectorData(level.sector);
if(!sd.CeilingChanged)
{
sd.CeilingChanged = true;
base.OnChangeTargetHeight(amount);
}
}
// This changes the height
protected override void ChangeHeight(int amount)
{

View file

@ -155,6 +155,19 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
}
}
// Call to change the height
public override void OnChangeTargetHeight(int amount)
{
// Only do this when not done yet in this call
// Because we may be able to select the same 3D floor multiple times through multiple sectors
SectorData sd = mode.GetSectorData(level.sector);
if(!sd.FloorChanged)
{
sd.FloorChanged = true;
base.OnChangeTargetHeight(amount);
}
}
// This changes the height
protected override void ChangeHeight(int amount)
{