diff --git a/Build/Scripting/ZDoom_DECORATE.cfg b/Build/Scripting/ZDoom_DECORATE.cfg index 24bfcfb08801fc21c1f080784816d461a486f412..3497a3cfba01586a4eb2d052eecc0851b3fb0e1e 100644 --- a/Build/Scripting/ZDoom_DECORATE.cfg +++ b/Build/Scripting/ZDoom_DECORATE.cfg @@ -572,6 +572,7 @@ properties Decal; StencilColor; FloatBobPhase; + DistanceCheck; //Obituaries HitObituary; Obituary; diff --git a/Source/Core/Config/ThingTypeInfo.cs b/Source/Core/Config/ThingTypeInfo.cs index 739f4c8c20763cea539bce6530534419e36862da..376824f10ba91b65cde16a3b46bb07138e2f6c8e 100644 --- a/Source/Core/Config/ThingTypeInfo.cs +++ b/Source/Core/Config/ThingTypeInfo.cs @@ -68,6 +68,7 @@ namespace CodeImp.DoomBuilder.Config private bool arrow; private float radius; private float height; + private int distancechecksq; //mxd. Contains squared value or int.MaxValue when not set private bool hangs; private int blocking; private int errorcheck; @@ -105,6 +106,7 @@ namespace CodeImp.DoomBuilder.Config public bool Arrow { get { return arrow; } } public float Radius { get { return radius; } } public float Height { get { return height; } } + public int DistanceCheckSq { get { return distancechecksq; } } //mxd public bool Hangs { get { return hangs; } } public int Blocking { get { return blocking; } } public int ErrorCheck { get { return errorcheck; } } @@ -148,6 +150,7 @@ namespace CodeImp.DoomBuilder.Config this.arrow = true; this.radius = 10f; this.height = 20f; + this.distancechecksq = int.MaxValue; //mxd this.hangs = false; this.blocking = 0; this.errorcheck = 0; @@ -177,6 +180,7 @@ namespace CodeImp.DoomBuilder.Config this.isknown = true; this.actor = null; this.bright = false; //mxd + this.distancechecksq = int.MaxValue; //mxd // Read properties this.title = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".title", "<" + key + ">"); @@ -225,6 +229,7 @@ namespace CodeImp.DoomBuilder.Config this.classname = string.Empty; //mxd this.isknown = true; this.bright = false; //mxd + this.distancechecksq = int.MaxValue; //mxd this.args = new ArgumentInfo[Linedef.NUM_ARGS]; for(int i = 0; i < Linedef.NUM_ARGS; i++) this.args[i] = new ArgumentInfo(i); @@ -268,6 +273,7 @@ namespace CodeImp.DoomBuilder.Config this.classname = actor.ClassName; //mxd this.isknown = true; this.bright = false; //mxd + this.distancechecksq = int.MaxValue; //mxd this.args = new ArgumentInfo[Linedef.NUM_ARGS]; for(int i = 0; i < Linedef.NUM_ARGS; i++) this.args[i] = new ArgumentInfo(i); @@ -312,6 +318,7 @@ namespace CodeImp.DoomBuilder.Config this.classname = actor.ClassName; //mxd this.isknown = true; this.bright = false; //mxd + this.distancechecksq = int.MaxValue; //mxd this.args = new ArgumentInfo[Linedef.NUM_ARGS]; for(int i = 0; i < Linedef.NUM_ARGS; i++) this.args[i] = new ArgumentInfo(i); @@ -372,6 +379,7 @@ namespace CodeImp.DoomBuilder.Config this.arrow = other.arrow; this.radius = other.radius; this.height = other.height; + this.distancechecksq = other.distancechecksq; //mxd this.hangs = other.hangs; this.blocking = other.blocking; this.errorcheck = other.errorcheck; @@ -467,6 +475,13 @@ namespace CodeImp.DoomBuilder.Config if(actor.HasPropertyWithValue("radius")) radius = actor.GetPropertyValueInt("radius", 0); if(actor.HasPropertyWithValue("height")) height = actor.GetPropertyValueInt("height", 0); + //mxd. DistanceCheck. We'll need squared value + if(actor.HasPropertyWithValue("distancecheck")) + { + distancechecksq = actor.GetPropertyValueInt("distancecheck", 0); + distancechecksq = (distancechecksq == 0 ? int.MaxValue : distancechecksq * distancechecksq); + } + //mxd. Renderstyle if(actor.HasPropertyWithValue("renderstyle") && !actor.HasProperty("$ignorerenderstyle")) renderstyle = actor.GetPropertyValueString("renderstyle", 0, true).ToLower(); diff --git a/Source/Core/Rendering/Renderer3D.cs b/Source/Core/Rendering/Renderer3D.cs index 7c6dd991f539a1466a11487c851cd1c65b19ab74..be2a15074761173ee52d43844edbe155330ca90c 100644 --- a/Source/Core/Rendering/Renderer3D.cs +++ b/Source/Core/Rendering/Renderer3D.cs @@ -842,6 +842,10 @@ namespace CodeImp.DoomBuilder.Rendering // Update buffer if needed t.Update(); + //mxd. Check 3D distance + if(t.Info.DistanceCheckSq < int.MaxValue && (t.Thing.Position - cameraposition).GetLengthSq() > t.Info.DistanceCheckSq) + continue; + // Only do this sector when a vertexbuffer is created if(t.GeometryBuffer != null) { @@ -1107,6 +1111,13 @@ namespace CodeImp.DoomBuilder.Rendering // Render things collected foreach(VisualThing t in thingspass) { + // Update buffer if needed + t.Update(); + + //mxd. Check 3D distance + if(t.Info.DistanceCheckSq < int.MaxValue && (t.Thing.Position - cameraposition).GetLengthSq() > t.Info.DistanceCheckSq) + continue; + t.UpdateSpriteFrame(); // Set correct texture, geobuffer and triangles count if(t.Texture is UnknownImage) continue; @@ -1145,9 +1156,6 @@ namespace CodeImp.DoomBuilder.Rendering curtexturename = t.Texture.LongName; } - // Update buffer if needed - t.Update(); - // Only do this sector when a vertexbuffer is created if(t.GeometryBuffer != null) { @@ -1368,7 +1376,7 @@ namespace CodeImp.DoomBuilder.Rendering graphics.Device.SetRenderState(RenderState.BlendOperation, BlendOperation.Add); } - //mxd. render models + //mxd. Render models private void RenderModels() { int shaderpass = (fullbrightness ? 1 : 4); @@ -1382,7 +1390,12 @@ namespace CodeImp.DoomBuilder.Rendering { foreach(VisualThing t in group.Value) { + // Update buffer if needed t.Update(); + + // Check 3D distance + if(t.Info.DistanceCheckSq < int.MaxValue && (t.Thing.Position - cameraposition).GetLengthSq() > t.Info.DistanceCheckSq) + continue; Color4 vertexcolor = new Color4(t.VertexColor); @@ -1395,7 +1408,7 @@ namespace CodeImp.DoomBuilder.Rendering // Determine the shader pass we want to use for this object int wantedshaderpass = ((((t == highlighted) && showhighlight) || (t.Selected && showselection)) ? highshaderpass : shaderpass); - //mxd. if fog is enagled, switch to shader, which calculates it + // If fog is enagled, switch to shader, which calculates it if(General.Settings.GZDrawFog && !fullbrightness && t.Thing.Sector != null && t.Thing.Sector.FogMode != SectorFogMode.NONE) wantedshaderpass += 8; @@ -1420,7 +1433,7 @@ namespace CodeImp.DoomBuilder.Rendering world = General.Map.Data.ModeldefEntries[t.Thing.Type].Transform * modelscale * modelrotation * t.Position; ApplyMatrices3D(); - //mxd. Set variables for fog rendering + // Set variables for fog rendering if(wantedshaderpass > 7) { graphics.Shaders.World3D.World = world; @@ -1476,7 +1489,13 @@ namespace CodeImp.DoomBuilder.Rendering currentpass = t.RenderPass; } + // Update buffer if needed t.Update(); + + // Check 3D distance + if(t.Info.DistanceCheckSq < int.MaxValue && (t.Thing.Position - cameraposition).GetLengthSq() > t.Info.DistanceCheckSq) + continue; + Color4 vertexcolor = new Color4(t.VertexColor); // Check if model is affected by dynamic lights and set color accordingly @@ -1488,7 +1507,7 @@ namespace CodeImp.DoomBuilder.Rendering // Determine the shader pass we want to use for this object int wantedshaderpass = ((((t == highlighted) && showhighlight) || (t.Selected && showselection)) ? highshaderpass : shaderpass); - //mxd. if fog is enagled, switch to shader, which calculates it + // If fog is enagled, switch to shader, which calculates it if(General.Settings.GZDrawFog && !fullbrightness && t.Thing.Sector != null && t.Thing.Sector.FogMode != SectorFogMode.NONE) wantedshaderpass += 8; @@ -1513,7 +1532,7 @@ namespace CodeImp.DoomBuilder.Rendering world = General.Map.Data.ModeldefEntries[t.Thing.Type].Transform * modelscale * modelrotation * t.Position; ApplyMatrices3D(); - //mxd. Set variables for fog rendering + // Set variables for fog rendering if(wantedshaderpass > 7) { graphics.Shaders.World3D.World = world; diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs index 617b9ed99db79d487866b7a6c9395a38b6c5be54..35fd26df74df673d155daed1bd3c1db8a3b71362 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs @@ -513,6 +513,11 @@ namespace CodeImp.DoomBuilder.BuilderModes // This performs a fast test in object picking public override bool PickFastReject(Vector3D from, Vector3D to, Vector3D dir) { + //mxd. Don't highlight when thing sprite is not rendered and thing cages are disabled + if(!General.Map.Renderer3D.DrawThingCages && info.DistanceCheckSq < int.MaxValue + && (Thing.Position - General.Map.VisualCamera.Position).GetLengthSq() > info.DistanceCheckSq) + return false; + float distance2 = Line2D.GetDistanceToLineSq(from, to, pos2d, false); return (distance2 <= cageradius2); }