Newer
Older
foreach(int tag in s.Tags)
if(tag == 0) continue;
if(!sectortags.ContainsKey(tag)) sectortags[tag] = new List<Sector>();
sectortags[tag].Add(s);
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
// ========== Thing vertex slope, vertices with UDMF vertex offsets ==========
if (s.Sidedefs.Count == 3)
{
if (General.Map.UDMF) GetSectorData(s).AddEffectVertexOffset(); //mxd
List<Thing> slopeceilingthings = new List<Thing>(3);
List<Thing> slopefloorthings = new List<Thing>(3);
foreach (Sidedef sd in s.Sidedefs)
{
Vertex v = sd.IsFront ? sd.Line.End : sd.Line.Start;
// Check if a thing is at this vertex
foreach (VisualBlockEntry block in blockmap.GetBlocks(v.Position))
{
foreach (Thing t in block.Things)
{
if ((Vector2D)t.Position == v.Position)
{
switch (t.Type)
{
case 1504: slopefloorthings.Add(t); break;
case 1505: slopeceilingthings.Add(t); break;
}
}
}
}
}
// Slope any floor vertices?
if (slopefloorthings.Count > 0)
{
SectorData sd = GetSectorData(s);
sd.AddEffectThingVertexSlope(slopefloorthings, true);
}
// Slope any ceiling vertices?
if (slopeceilingthings.Count > 0)
{
SectorData sd = GetSectorData(s);
sd.AddEffectThingVertexSlope(slopeceilingthings, false);
}
}
// Find interesting things (such as sector slopes)
// Pass one of slope things, and determine which one are for pass two
//TODO: unfuck this because UDB decided to overhaul this...
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
foreach (Thing t in General.Map.Map.Things)
{
// SRB2
if (t.Type == 750)
{
if (!thingtags.ContainsKey(t.Tag)) thingtags[t.Tag] = new List<Thing>();
thingtags[t.Tag].Add(t);
}
continue;
switch (t.Type)
{
// ========== Copy slope ==========
case 9511:
case 9510:
slopethingpass[1].Add(t);
break;
// ========== Thing line slope ==========
case 9501:
case 9500:
if (linetags.ContainsKey(t.Args[0]))
{
// Only slope each sector once, even when multiple lines of the same sector are tagged. See https://github.com/jewalky/UltimateDoomBuilder/issues/491
List<Sector> slopedsectors = new List<Sector>();
foreach (Linedef ld in linetags[t.Args[0]])
{
if (ld.Line.GetSideOfLine(t.Position) < 0.0f)
{
if (ld.Front != null && !slopedsectors.Contains(ld.Front.Sector))
{
GetSectorData(ld.Front.Sector).AddEffectThingLineSlope(t, ld.Front);
slopedsectors.Add(ld.Front.Sector);
}
}
else if (ld.Back != null && !slopedsectors.Contains(ld.Back.Sector))
{
GetSectorData(ld.Back.Sector).AddEffectThingLineSlope(t, ld.Back);
slopedsectors.Add(ld.Back.Sector);
}
}
}
break;
// ========== Thing slope ==========
case 9503:
case 9502:
t.DetermineSector(blockmap);
if (t.Sector != null)
{
SectorData sd = GetSectorData(t.Sector);
sd.AddEffectThingSlope(t);
}
break;
}
}
// Find interesting linedefs (such as line slopes)
// This also determines which slope lines belong to pass one and pass two. See https://zdoom.org/wiki/Slope
foreach (Linedef l in General.Map.Map.Linedefs)
// Builds a cache of linedef ids/tags. Used for slope things. Use linedef tags in UDMF
if(General.Map.UDMF)
{
foreach(int tag in l.Tags)
{
if (!linetags.ContainsKey(tag)) linetags[tag] = new List<Linedef>();
linetags[tag].Add(l);
}
}
//mxd. Rewritten to use action ID instead of number
if (l.Action == 0 || !General.Map.Config.LinedefActions.ContainsKey(l.Action)) continue;
switch(General.Map.Config.LinedefActions[l.Action].Id.ToLowerInvariant())
// ========== Line Set Identification (121) (see https://zdoom.org/wiki/Line_SetIdentification) ==========
// Builds a cache of linedef ids/tags. Used for slope things. Only used for Hexen format
case "line_setidentification":
int tag = l.Args[0] + l.Args[4] * 256;
if (!linetags.ContainsKey(tag)) linetags[tag] = new List<Linedef>();
linetags[tag].Add(l);
break;
// ========== Plane Align (181) (see http://zdoom.org/wiki/Plane_Align) ==========
case "plane_align":
slopelinedefpass[0].Add(l);
MaxED
committed
break;
// ========== Plane Copy (118) (mxd) (see http://zdoom.org/wiki/Plane_Copy) ==========
case "plane_copy":
slopelinedefpass[1].Add(l);
MaxED
committed
break;
case "srb2_vertexslope":
{
List<Thing> sourcethings = new List<Thing>();
if (!thingtags.ContainsKey(l.Args[1]) || thingtags[l.Args[1]].Count == 0)
break;
foreach (Thing thing in thingtags[l.Args[1]])
{
if (sourcethings.Contains(thing))
continue;
sourcethings.Add(thing);
break;
}
if (!thingtags.ContainsKey(l.Args[2]) || thingtags[l.Args[2]].Count == 0)
break;
foreach (Thing thing in thingtags[l.Args[2]])
{
if (sourcethings.Contains(thing))
continue;
sourcethings.Add(thing);
break;
}
if (!thingtags.ContainsKey(l.Args[3]) || thingtags[l.Args[3]].Count == 0)
break;
foreach (Thing thing in thingtags[l.Args[3]])
{
if (sourcethings.Contains(thing))
continue;
sourcethings.Add(thing);
break;
}
SectorData sd = GetSectorData((l.Args[0] < 2) ? l.Front.Sector : l.Back.Sector);
sd.AddEffectSRB2ThingVertexSlope(sourcethings, (l.Args[0] & 1) != 1);
break;
}
// ========== Sector 3D floor (160) (see http://zdoom.org/wiki/Sector_Set3dFloor) ==========
case "sector_set3dfloor":
MaxED
committed
if(l.Front != null)
MaxED
committed
//mxd. Added hi-tag/line ID check
int sectortag = (General.Map.UDMF || (l.Args[1] & (int)Effect3DFloor.FloorTypes.HiTagIsLineID) != 0) ? l.Args[0] : l.Args[0] + (l.Args[4] << 8);
MaxED
committed
if(sectortags.ContainsKey(sectortag))
{
List<Sector> sectors = sectortags[sectortag];
foreach(Sector s in sectors)
{
SectorData sd = GetSectorData(s);
sd.AddEffect3DFloor(l);
}
}
break;
case "srb2_fofsolid":
case "srb2_fofwater":
case "srb2_fofsolidopaque":
case "srb2_fofcrumbling":
case "srb2_fofintangible":
case "srb2_fofbustable":
case "srb2_foflaser":
case "srb2_fofcustom":
if (l.Front != null && sectortags.ContainsKey(l.Args[0]))
List<Sector> sectors = sectortags[l.Args[0]];
foreach (Sector s in sectors)
SectorData sd = GetSectorData(s);
sd.AddEffect3DFloor(l);
}
}
break;
case "srb2_foflight":
case "srb2_foffog":
case "srb2_fofintangibleinvisible":
if (l.Front != null && sectortags.ContainsKey(l.Args[0]))
{
List<Sector> sectors = sectortags[l.Args[0]];
foreach (Sector s in sectors)
{
SectorData sd = GetSectorData(s);
//sd.AddEffectBrightnessLevel(l);
sd.AddEffect3DFloor(l);
MaxED
committed
break;
// ========== Transfer Brightness (50) (see http://zdoom.org/wiki/ExtraFloor_LightOnly) =========
case "extrafloor_lightonly":
MaxED
committed
if(l.Front != null && sectortags.ContainsKey(l.Args[0]))
MaxED
committed
List<Sector> sectors = sectortags[l.Args[0]];
foreach(Sector s in sectors)
{
SectorData sd = GetSectorData(s);
sd.AddEffectBrightnessLevel(l);
}
MaxED
committed
break;
// ========== mxd. Transfer Floor Brightness (210) (see http://www.zdoom.org/w/index.php?title=Transfer_FloorLight) =========
case "transfer_floorlight":
MaxED
committed
if(l.Front != null && sectortags.ContainsKey(l.Args[0]))
{
List<Sector> sectors = sectortags[l.Args[0]];
foreach(Sector s in sectors)
{
SectorData sd = GetSectorData(s);
sd.AddEffectTransferFloorBrightness(l);
}
}
break;
// ========== mxd. Transfer Ceiling Brightness (211) (see http://www.zdoom.org/w/index.php?title=Transfer_CeilingLight) =========
case "transfer_ceilinglight":
MaxED
committed
if(l.Front != null && sectortags.ContainsKey(l.Args[0]))
{
List<Sector> sectors = sectortags[l.Args[0]];
foreach(Sector s in sectors)
{
SectorData sd = GetSectorData(s);
sd.AddEffectTransferCeilingBrightness(l);
}
}
break;
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
// ========== mxd. BOOM: Set Tagged Floor Lighting to Lighting on 1st Sidedef's Sector (213) =========
case "boom_transfer_floorlight":
if(l.Front != null && sectortags.ContainsKey(l.Tag))
{
List<Sector> sectors = sectortags[l.Tag];
foreach(Sector s in sectors)
{
SectorData sd = GetSectorData(s);
sd.AddEffectTransferFloorBrightness(l);
}
}
break;
// ========== mxd. BOOM: Set Tagged Ceiling Lighting to Lighting on 1st Sidedef's Sector (261) =========
case "boom_transfer_ceilinglight":
if(l.Front != null && sectortags.ContainsKey(l.Tag))
{
List<Sector> sectors = sectortags[l.Tag];
foreach(Sector s in sectors)
{
SectorData sd = GetSectorData(s);
sd.AddEffectTransferCeilingBrightness(l);
}
}
break;
}
}
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
// Pass one for linedefs
foreach (Linedef l in slopelinedefpass[0])
{
//mxd. Rewritten to use action ID instead of number
if (l.Action == 0 || !General.Map.Config.LinedefActions.ContainsKey(l.Action)) continue;
switch (General.Map.Config.LinedefActions[l.Action].Id.ToLowerInvariant())
{
// ========== Plane Align (181) (see http://zdoom.org/wiki/Plane_Align) ==========
case "plane_align":
if (((l.Args[0] == 1) || (l.Args[1] == 1)) && (l.Front != null))
{
SectorData sd = GetSectorData(l.Front.Sector);
sd.AddEffectLineSlope(l);
}
if (((l.Args[0] == 2) || (l.Args[1] == 2)) && (l.Back != null))
{
SectorData sd = GetSectorData(l.Back.Sector);
sd.AddEffectLineSlope(l);
}
break;
}
}
// Pass two of slope things
//TODO: unfuck this because UDB decided to overhaul this...
foreach (Thing t in slopethingpass[1])
{
switch (t.Type)
{
// ========== Copy slope ==========
case 9511:
case 9510:
t.DetermineSector(blockmap);
if (t.Sector != null)
SectorData sd = GetSectorData(t.Sector);
sd.AddEffectCopySlope(t);
}
}
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
// Pass two for linedefs
foreach (Linedef l in slopelinedefpass[1])
{
if (l.Action == 0 || !General.Map.Config.LinedefActions.ContainsKey(l.Action)) continue;
switch (General.Map.Config.LinedefActions[l.Action].Id.ToLowerInvariant())
{
// ========== Plane Copy (118) (mxd) (see http://zdoom.org/wiki/Plane_Copy) ==========
case "plane_copy":
{
//check the flags...
bool floorCopyToBack = false;
bool floorCopyToFront = false;
bool ceilingCopyToBack = false;
bool ceilingCopyToFront = false;
if (l.Args[4] > 0 && l.Args[4] != 3 && l.Args[4] != 12)
{
floorCopyToBack = (l.Args[4] & 1) == 1;
floorCopyToFront = (l.Args[4] & 2) == 2;
ceilingCopyToBack = (l.Args[4] & 4) == 4;
ceilingCopyToFront = (l.Args[4] & 8) == 8;
}
// Copy slope to front sector
if (l.Front != null)
{
if ((l.Args[0] > 0 || l.Args[1] > 0) || (l.Back != null && (floorCopyToFront || ceilingCopyToFront)))
{
SectorData sd = GetSectorData(l.Front.Sector);
sd.AddEffectPlaneClopySlope(l, true);
}
}
// Copy slope to back sector
if (l.Back != null)
{
if ((l.Args[2] > 0 || l.Args[3] > 0) || (l.Front != null && (floorCopyToBack || ceilingCopyToBack)))
{
SectorData sd = GetSectorData(l.Back.Sector);
sd.AddEffectPlaneClopySlope(l, false);
}
}
}
break;
}
}
// Visual slope handles
foreach (KeyValuePair<Sector, List<VisualSlope>> kvp in allslopehandles)
{
foreach (VisualSlope handle in kvp.Value)
biwa
committed
if (handle != null && handle.Selected)
if (handle is BaseVisualSlope)
RemoveSelectedObject((BaseVisualSlope)handle);
usedslopehandles.Clear();
biwa
committed
sidedefslopehandles.Clear();
vertexslopehandles.Clear();
BuildSlopeHandles(General.Map.Map.Sectors.ToList());
}
private void BuildSlopeHandles(List<Sector> sectors)
{
biwa
committed
if (!General.Map.UDMF)
return;
foreach (Sector s in sectors)
biwa
committed
if (s.IsDisposed)
continue;
SectorData sectordata = GetSectorData(s);
sectordata.Update();
// Clear old data
if (allslopehandles.ContainsKey(s)) allslopehandles.Remove(s);
if (sidedefslopehandles.ContainsKey(s)) sidedefslopehandles.Remove(s);
if (vertexslopehandles.ContainsKey(s)) vertexslopehandles.Remove(s);
// Create visual sidedef slope handles
foreach (Sidedef sidedef in s.Sidedefs)
biwa
committed
// Create handles for the regular floor and ceiling
CreateVisualSlopeHandle(sectordata.Floor, sidedef, true);
CreateVisualSlopeHandle(sectordata.Ceiling, sidedef, false);
// Create handles for 3D floors
if (sectordata.ExtraFloors.Count > 0)
{
biwa
committed
foreach (Effect3DFloor floor in sectordata.ExtraFloors)
{
CreateVisualSlopeHandle(floor.Floor, sidedef, false);
CreateVisualSlopeHandle(floor.Ceiling, sidedef, true);
}
}
biwa
committed
}
}
biwa
committed
// Create visual vertex slope handles
foreach(Vertex v in General.Map.Map.Vertices)
{
if (v.IsDisposed || v.Linedefs.Count == 0)
continue;
HashSet<Sector> vertexsectors = new HashSet<Sector>();
// Find all sectors that have lines connected to this vertex
foreach(Linedef ld in v.Linedefs)
{
if (ld.IsDisposed)
continue;
if (ld.Front != null && ld.Front.Sector != null && !ld.Front.Sector.IsDisposed) vertexsectors.Add(ld.Front.Sector);
if (ld.Back != null && ld.Back.Sector != null && !ld.Back.Sector.IsDisposed) vertexsectors.Add(ld.Back.Sector);
biwa
committed
}
biwa
committed
foreach(Sector s in vertexsectors)
{
SectorData sectordata = GetSectorData(s);
biwa
committed
// Create handles for the regular floor and ceiling
CreateVisualSlopeHandle(sectordata.Floor, v, s, true);
CreateVisualSlopeHandle(sectordata.Ceiling, v, s, false);
biwa
committed
// Create handles for 3D floors
if (sectordata.ExtraFloors.Count > 0)
biwa
committed
foreach (Effect3DFloor floor in sectordata.ExtraFloors)
biwa
committed
CreateVisualSlopeHandle(floor.Floor, v, s, false);
CreateVisualSlopeHandle(floor.Ceiling, v, s, true);
}
#endregion
#region ================== Events
// Help!
public override void OnHelp()
{
General.ShowHelp("e_visual.html");
}
codeimp
committed
// When entering this mode
public override void OnEngage()
{
//mxd
useSelectionFromClassicMode = BuilderPlug.Me.SyncSelection ? !General.Interface.ShiftState : General.Interface.ShiftState;
if(useSelectionFromClassicMode) UpdateSelectionInfo();
// Read settings
cameraflooroffset = General.Map.Config.ReadSetting("cameraflooroffset", cameraflooroffset);
cameraceilingoffset = General.Map.Config.ReadSetting("cameraceilingoffset", cameraceilingoffset);
//mxd. Update fog color (otherwise FogBoundaries won't be setup correctly)
foreach (Sector s in General.Map.Map.Sectors)
s.UpdateFogColor();
// biwa. We need a blockmap for the slope things. Can't wait until it's built in base.OnEngage
// This was the root cause for issue #160
FillBlockMap();
// (Re)create special effects
RebuildElementData();
// Objects are only selected when they are created, so for objects that are selected we have to make sure
// that they are created immediately. Otherwise the selection order will not be correct, or the objects
// will not be selected at all if they are out of the user's camera range when entering visual mode
// See https://github.com/jewalky/UltimateDoomBuilder/issues/938
if (useSelectionFromClassicMode)
{
foreach (Sector s in General.Map.Map.GetSelectedSectors(true))
{
BaseVisualSector bvs = CreateBaseVisualSector(s);
bvs.Ceiling.PerformAutoSelection();
bvs.Floor.PerformAutoSelection();
}
// Things are automatically selected on creation
foreach (Thing t in General.Map.Map.GetSelectedThings(true))
allthings[t] = CreateVisualThing(t);
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
// For linedefs it's a bit more complicated...
foreach (Linedef ld in General.Map.Map.GetSelectedLinedefs(true))
{
foreach (Sidedef sd in new Sidedef[] { ld.Front, ld.Back })
{
if (sd != null)
{
if (!allsectors.ContainsKey(sd.Sector))
CreateBaseVisualSector(sd.Sector).Rebuild(); // We have to rebuild the sector so that potential 3D floors get created
VisualSidedefParts vsp = ((BaseVisualSector)allsectors[sd.Sector]).Sides[sd];
vsp.upper?.PerformAutoSelection();
vsp.middlesingle?.PerformAutoSelection();
vsp.middledouble?.PerformAutoSelection();
vsp.lower?.PerformAutoSelection();
if (vsp.middle3d != null)
foreach (VisualMiddle3D vm in vsp.middle3d)
vm.PerformAutoSelection();
if (vsp.middleback != null)
foreach (VisualMiddleBack vm in vsp.middleback)
vm.PerformAutoSelection();
}
}
}
}
//mxd. Update event lines
renderer.SetEventLines(LinksCollector.GetHelperShapes(General.Map.ThingsFilter.VisibleThings, blockmap));
ZZYZX
committed
// [ZZ] this enables calling of this object from the outside world. Only after properly initialized pls.
base.OnEngage();
}
codeimp
committed
// When returning to another mode
public override void OnDisengage()
{
base.OnDisengage();
if(BuilderPlug.Me.SyncSelection ? !General.Interface.ShiftState : General.Interface.ShiftState)
{
//clear previously selected stuff
General.Map.Map.ClearAllSelected();
//refill selection
List<int> selectedsectorindices = new List<int>();
List<int> selectedlineindices = new List<int>();
List<int> selectedvertexindices = new List<int>();
foreach(IVisualEventReceiver obj in selectedobjects)
{
if(obj is BaseVisualThing)
{
}
else if(obj is VisualFloor || obj is VisualCeiling)
{
VisualGeometry vg = (VisualGeometry)obj;
if(vg.Sector != null && vg.Sector.Sector != null && !selectedsectorindices.Contains(vg.Sector.Sector.Index))
{
selectedsectorindices.Add(vg.Sector.Sector.Index);
vg.Sector.Sector.Selected = true;
}
}
else if(obj is VisualLower || obj is VisualUpper || obj is VisualMiddleDouble
|| obj is VisualMiddleSingle || obj is VisualMiddle3D)
{
VisualGeometry vg = (VisualGeometry)obj;
if(vg.Sidedef != null && !selectedlineindices.Contains(vg.Sidedef.Line.Index))
{
selectedlineindices.Add(vg.Sidedef.Line.Index);
vg.Sidedef.Line.Selected = true;
}
else if(obj is VisualVertex)
{
VisualVertex v = (VisualVertex)obj;
if(!selectedvertexindices.Contains(v.Vertex.Index))
{
selectedvertexindices.Add(v.Vertex.Index);
v.Vertex.Selected = true;
}
}
codeimp
committed
General.Map.Map.Update();
}
public override void OnProcess(long deltatime)
long pickinterval = PICK_INTERVAL; // biwa
// Process things?
base.ProcessThings = (BuilderPlug.Me.ShowVisualThings != 0);
// Setup the move multiplier depending on gravity
biwa
committed
Vector3D movemultiplier = new Vector3D(1.0, 1.0, 1.0);
if(BuilderPlug.Me.UseGravity) movemultiplier.z = 0.0;
General.Map.VisualCamera.MoveMultiplier = movemultiplier;
// Apply gravity?
if(BuilderPlug.Me.UseGravity && (General.Map.VisualCamera.Sector != null))
{
SectorData sd = GetSectorData(General.Map.VisualCamera.Sector);
if(!sd.Updated) sd.Update();
// Camera below floor level?
Vector3D feetposition = General.Map.VisualCamera.Position;
SectorLevel floorlevel = sd.GetFloorBelow(feetposition) ?? sd.Floor;
double floorheight = floorlevel.plane.GetZ(General.Map.VisualCamera.Position);
biwa
committed
if(General.Map.VisualCamera.Position.z < (floorheight + cameraflooroffset + 0.1))
{
// Stay above floor
biwa
committed
gravity = new Vector3D(0.0, 0.0, 0.0);
General.Map.VisualCamera.Position = new Vector3D(General.Map.VisualCamera.Position.x,
General.Map.VisualCamera.Position.y,
floorheight + cameraflooroffset);
}
else
{
// Fall down
MaxED
committed
gravity.z += GRAVITY * General.Map.VisualCamera.Gravity * deltatime;
biwa
committed
if(gravity.z > 3.0) gravity.z = 3.0;
// Test if we don't go through a floor
biwa
committed
if((General.Map.VisualCamera.Position.z + gravity.z) < (floorheight + cameraflooroffset + 0.1))
{
// Stay above floor
biwa
committed
gravity = new Vector3D(0.0, 0.0, 0.0);
General.Map.VisualCamera.Position = new Vector3D(General.Map.VisualCamera.Position.x,
General.Map.VisualCamera.Position.y,
floorheight + cameraflooroffset);
}
else
{
// Apply gravity vector
General.Map.VisualCamera.Position += gravity;
}
// Camera above ceiling?
biwa
committed
feetposition = General.Map.VisualCamera.Position - new Vector3D(0, 0, cameraflooroffset - 7.0);
SectorLevel ceillevel = sd.GetCeilingAbove(feetposition) ?? sd.Ceiling;
double ceilheight = ceillevel.plane.GetZ(General.Map.VisualCamera.Position);
biwa
committed
if(General.Map.VisualCamera.Position.z > (ceilheight - cameraceilingoffset - 0.01))
{
// Stay below ceiling
General.Map.VisualCamera.Position = new Vector3D(General.Map.VisualCamera.Position.x,
General.Map.VisualCamera.Position.y,
ceilheight - cameraceilingoffset);
}
}
else
{
biwa
committed
gravity = new Vector3D(0.0, 0.0, 0.0);
}
// Do processing
base.OnProcess(deltatime);
// Process visible geometry
foreach(IVisualEventReceiver g in visiblegeometry)
{
g.OnProcess(deltatime);
}
// biwa. Use a lower pick interval for paint selection, to make it more reliable
if (paintselectpressed)
pickinterval = PICK_INTERVAL_PAINT_SELECT;
// Time to pick a new target?
if(Clock.CurrentTime > (lastpicktime + pickinterval))
{
PickTargetUnlocked();
lastpicktime = Clock.CurrentTime;
}
// The mouse is always in motion
MouseEventArgs args = new MouseEventArgs(General.Interface.MouseButtons, 0, 0, 0, 0);
OnMouseMove(args);
}
MaxED
committed
//mxd
public override void OnClockReset()
{
base.OnClockReset();
lastpicktime = 0;
}
// This draws a frame
public override void OnRedrawDisplay()
{
renderer.SetClassicLightingColorMap(General.Map.Data.MainColorMap);
// Start drawing
if(renderer.Start())
{
// Use fog!
renderer.SetFogMode(true);
// Set target for highlighting
renderer.ShowSelection = General.Settings.GZOldHighlightMode || General.Settings.UseHighlight; //mxd
if(General.Settings.UseHighlight)
renderer.SetHighlightedObject(target.picked);
// Begin with geometry
renderer.StartGeometry();
// Render all visible sectors
foreach(VisualGeometry g in visiblegeometry)
renderer.AddSectorGeometry(g);
if(BuilderPlug.Me.ShowVisualThings != 0)
{
// Render things in cages?
renderer.DrawThingCages = ((BuilderPlug.Me.ShowVisualThings & 2) != 0);
// Render all visible things
foreach(VisualThing t in visiblethings)
renderer.AddThingGeometry(t);
}
if(General.Map.UDMF && General.Map.Config.VertexHeightSupport && General.Settings.GZShowVisualVertices && vertices.Count > 0)
MaxED
committed
{
List<VisualVertex> verts = new List<VisualVertex>();
foreach(KeyValuePair<Vertex, VisualVertexPair> pair in vertices)
verts.AddRange(pair.Value.Vertices);
renderer.SetVisualVertices(verts);
renderer.SetVisualSlopeHandles(usedslopehandles);
// Done rendering geometry
renderer.FinishGeometry();
// Render crosshair
renderer.RenderCrosshair();
// Present!
renderer.Finish();
}
}
// After resources were reloaded
protected override void ResourcesReloaded()
{
base.ResourcesReloaded();
RebuildElementData();
UpdateChangedObjects(); //mxd
PickTarget();
}
// This usually happens when geometry is changed by undo, redo, cut or paste actions
// and uses the marks to check what needs to be reloaded.
protected override void ResourcesReloadedPartial()
{
// Let the core do this (it will just dispose the sectors that were changed)
base.ResourcesReloadedPartial();
if (General.Map.UndoRedo.GeometryChanged)
{
// The base doesn't know anything about slobe handles, so we have to clear them up ourself
if (General.Map.UDMF)
{
List<Sector> removedsectors = new List<Sector>();
// Get the sectors that were disposed...
foreach(Sector s in allslopehandles.Keys)
{
if (s.IsDisposed)
removedsectors.Add(s);
}
// ... so that we can remove their slope handles
foreach(Sector s in removedsectors)
{
allslopehandles[s].Clear();
allslopehandles.Remove(s);
biwa
committed
sidedefslopehandles[s].Clear();
sidedefslopehandles.Remove(s);
vertexslopehandles[s].Clear();
vertexslopehandles.Remove(s);
}
// Rebuild slope handles for the changed sectors
BuildSlopeHandles(General.Map.Map.GetMarkedSectors(true));
}
bool sectorsmarked = false;
// Neighbour sectors must be updated as well
foreach (Sector s in General.Map.Map.Sectors)
{
if(s.Marked)
{
sectorsmarked = true;
foreach(Sidedef sd in s.Sidedefs)
{
sd.Marked = true;
if(sd.Other != null) sd.Other.Marked = true;
}
}
}
// Go for all sidedefs to update
foreach(Sidedef sd in General.Map.Map.Sidedefs)
{
if(sd.Marked && VisualSectorExists(sd.Sector))
BaseVisualSector vs = (BaseVisualSector)GetVisualSector(sd.Sector);
VisualSidedefParts parts = vs.GetSidedefParts(sd);
parts.SetupAllParts();
}
}
// Go for all sectors to update
foreach(Sector s in General.Map.Map.Sectors)
{
if(s.Marked)
SectorData sd = GetSectorDataEx(s);
if(sd != null)
sd.Reset(false); //mxd (changed Reset implementation)
// UpdateSectorGeometry for associated sectors (sd.UpdateAlso) as well!
foreach(KeyValuePair<Sector, bool> us in sd.UpdateAlso)
if(VisualSectorExists(us.Key))
{
BaseVisualSector vs = (BaseVisualSector)GetVisualSector(us.Key);
vs.UpdateSectorGeometry(us.Value);
}
}
}
// And update for this sector ofcourse
if(VisualSectorExists(s))
{
BaseVisualSector vs = (BaseVisualSector)GetVisualSector(s);
vs.UpdateSectorGeometry(false);
}
}
}
if(!sectorsmarked)
{
// No sectors or geometry changed. So we only have
// to update things when they have changed.
HashSet<Thing> toremove = new HashSet<Thing>(); //mxd
ZZYZX
committed
foreach(KeyValuePair<Thing, VisualThing> vt in allthings)
{
ZZYZX
committed
if((vt.Value != null) && vt.Key.Marked)
{
if(vt.Key.IsDisposed) toremove.Add(vt.Key); //mxd. Disposed things will cause problems
else ((BaseVisualThing)vt.Value).Rebuild();
}
}
//mxd. Remove disposed things
foreach(Thing t in toremove)
{
ZZYZX
committed
if(allthings[t] != null) allthings[t].Dispose();
allthings.Remove(t);
}
}
else
{
// Things depend on the sector they are in and because we can't
// easily determine which ones changed, we dispose all things
ZZYZX
committed
foreach(KeyValuePair<Thing, VisualThing> vt in allthings)
if(vt.Value != null) vt.Value.Dispose();
// Apply new lists
allthings = new Dictionary<Thing, VisualThing>(allthings.Count);
}
// Clear visibility collections
visiblesectors.Clear();
visibleblocks.Clear();
visiblegeometry.Clear();
visiblethings.Clear();
// Make new blockmap
if(sectorsmarked || General.Map.UndoRedo.PopulationChanged || General.Map.IsChanged)
codeimp
committed
FillBlockMap();
RebuildElementData();
UpdateChangedObjects();
// Visibility culling (this re-creates the needed resources)
DoCulling();
}
// Determine what we're aiming at now
PickTarget();
}
// Mouse moves
public override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
IVisualEventReceiver o = GetTargetEventReceiver(true);
o.OnMouseMove(e);
//mxd. Show hints!
if(o.GetType() != lasthighlighttype)
{
if(General.Interface.ActiveDockerTabName == "Help")
{
if(o is BaseVisualGeometrySidedef)
{
General.Hints.ShowHints(this.GetType(), "sidedefs");
}
else if(o is BaseVisualGeometrySector)
{
General.Hints.ShowHints(this.GetType(), "sectors");
}
else if(o is BaseVisualThing)
{
General.Hints.ShowHints(this.GetType(), "things");
}
else if(o is BaseVisualVertex)
{
General.Hints.ShowHints(this.GetType(), "vertices");
}
else
{
General.Hints.ShowHints(this.GetType(), HintsManager.GENERAL);
}
}
lasthighlighttype = o.GetType();
}
// biwa
if (o is NullVisualEventReceiver)
highlighted = null;
else if (o is VisualGeometry)
highlighted = (VisualGeometry)o;
else if (o is VisualThing)
highlighted = (VisualThing)o;
// Undo performed
public override void OnUndoEnd()
{
base.OnUndoEnd();