fixed Visual Mode camera placement with shortcut and changed camera-from-thing positioning logic a bit

This commit is contained in:
codeimp 2009-01-10 01:35:11 +00:00
parent 1f016fc7dc
commit 94c62a34a2
2 changed files with 26 additions and 12 deletions

View file

@ -131,7 +131,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
[BeginAction("placevisualstart")] [BeginAction("placevisualstart")]
public void PlaceVisualStartThing() public void PlaceVisualStartThing()
{ {
bool onefound = false; Thing thingfound = null;
// Not during volatile mode // Not during volatile mode
if(this.Attributes.Volatile) return; if(this.Attributes.Volatile) return;
@ -145,11 +145,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
if(t.Type == General.Map.Config.Start3DModeThingType) if(t.Type == General.Map.Config.Start3DModeThingType)
{ {
if(!onefound) if(thingfound == null)
{ {
// Move this thing // Move this thing
t.Move(mousemappos); t.Move(mousemappos);
onefound = true; thingfound = t;
} }
else else
{ {
@ -160,7 +160,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
} }
// No thing found? // No thing found?
if(!onefound) if(thingfound == null)
{ {
// Make a new one // Make a new one
Thing t = General.Map.Map.CreateThing(); Thing t = General.Map.Map.CreateThing();
@ -168,8 +168,22 @@ namespace CodeImp.DoomBuilder.BuilderModes
t.Move(mousemappos); t.Move(mousemappos);
t.UpdateConfiguration(); t.UpdateConfiguration();
General.Map.ThingsFilter.Update(); General.Map.ThingsFilter.Update();
thingfound = t;
} }
// Make sure that the found thing is between ceiling and floor
thingfound.DetermineSector();
if(thingfound.Position.z < 0.0f) thingfound.Move(thingfound.Position.x, thingfound.Position.y, 0.0f);
if(thingfound.Sector != null)
{
if((thingfound.Position.z + 50.0f) > (thingfound.Sector.CeilHeight - thingfound.Sector.FloorHeight))
thingfound.Move(thingfound.Position.x, thingfound.Position.y,
thingfound.Sector.CeilHeight - thingfound.Sector.FloorHeight - 50.0f);
}
// Update Visual Mode camera
General.Map.VisualCamera.PositionAtThing();
// Redraw display to show changes // Redraw display to show changes
General.Interface.RedrawDisplay(); General.Interface.RedrawDisplay();
} }

View file

@ -94,7 +94,7 @@ namespace CodeImp.DoomBuilder.VisualModes
// This applies the position and angle from the 3D Camera Thing // This applies the position and angle from the 3D Camera Thing
// Returns false when it couldn't find a 3D Camera Thing // Returns false when it couldn't find a 3D Camera Thing
public bool PositionAtThing() public virtual bool PositionAtThing()
{ {
Thing modething = null; Thing modething = null;
@ -105,13 +105,13 @@ namespace CodeImp.DoomBuilder.VisualModes
// Found one? // Found one?
if(modething != null) if(modething != null)
{ {
int z = 0;
if(sector != null)
z = (int)position.z - sector.FloorHeight;
// Position camera here
modething.DetermineSector(); modething.DetermineSector();
position = modething.Position + new Vector3D(0.0f, 0.0f, 96.0f); float z = modething.Position.z;
if(modething.Sector != null)
z = modething.Position.z + (float)modething.Sector.FloorHeight;
// Position camera here
position = new Vector3D(modething.Position.x, modething.Position.y, z + 41.0f);
anglexy = modething.Angle + Angle2D.PI; anglexy = modething.Angle + Angle2D.PI;
anglez = Angle2D.PI; anglez = Angle2D.PI;
return true; return true;
@ -124,7 +124,7 @@ namespace CodeImp.DoomBuilder.VisualModes
// This applies the camera position and angle to the 3D Camera Thing // This applies the camera position and angle to the 3D Camera Thing
// Returns false when it couldn't find a 3D Camera Thing // Returns false when it couldn't find a 3D Camera Thing
public bool ApplyToThing() public virtual bool ApplyToThing()
{ {
Thing modething = null; Thing modething = null;