2006-02-24 04:48:15 +00:00
|
|
|
/*
|
|
|
|
** a_decals.cpp
|
|
|
|
** Implements the actor that represents decals in the level
|
|
|
|
**
|
|
|
|
**---------------------------------------------------------------------------
|
2006-04-12 01:50:09 +00:00
|
|
|
** Copyright 1998-2006 Randy Heit
|
2006-02-24 04:48:15 +00:00
|
|
|
** All rights reserved.
|
|
|
|
**
|
|
|
|
** Redistribution and use in source and binary forms, with or without
|
|
|
|
** modification, are permitted provided that the following conditions
|
|
|
|
** are met:
|
|
|
|
**
|
|
|
|
** 1. Redistributions of source code must retain the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer.
|
|
|
|
** 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer in the
|
|
|
|
** documentation and/or other materials provided with the distribution.
|
|
|
|
** 3. The name of the author may not be used to endorse or promote products
|
|
|
|
** derived from this software without specific prior written permission.
|
|
|
|
**
|
|
|
|
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "actor.h"
|
|
|
|
#include "a_sharedglobal.h"
|
|
|
|
#include "r_defs.h"
|
|
|
|
#include "p_local.h"
|
|
|
|
#include "v_video.h"
|
|
|
|
#include "p_trace.h"
|
|
|
|
#include "decallib.h"
|
|
|
|
#include "statnums.h"
|
|
|
|
#include "c_dispatch.h"
|
2008-09-14 23:54:38 +00:00
|
|
|
#include "d_net.h"
|
|
|
|
#include "colormatcher.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-04-12 01:50:09 +00:00
|
|
|
static fixed_t DecalWidth, DecalLeft, DecalRight;
|
|
|
|
static fixed_t SpreadZ;
|
|
|
|
static const DBaseDecal *SpreadSource;
|
|
|
|
static const FDecalTemplate *SpreadTemplate;
|
|
|
|
static TArray<side_t *> SpreadStack;
|
|
|
|
|
|
|
|
static int ImpactCount;
|
|
|
|
|
|
|
|
CVAR (Bool, cl_spreaddecals, true, CVAR_ARCHIVE)
|
|
|
|
|
2008-03-12 02:56:11 +00:00
|
|
|
IMPLEMENT_POINTY_CLASS (DBaseDecal)
|
|
|
|
DECLARE_POINTER(WallNext)
|
|
|
|
END_POINTERS
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-04-12 01:50:09 +00:00
|
|
|
IMPLEMENT_CLASS (DImpactDecal)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-04-12 01:50:09 +00:00
|
|
|
DBaseDecal::DBaseDecal ()
|
|
|
|
: DThinker(STAT_DECAL),
|
2006-04-13 02:01:40 +00:00
|
|
|
WallNext(0), WallPrev(0), LeftDistance(0), Z(0), ScaleX(FRACUNIT), ScaleY(FRACUNIT), Alpha(FRACUNIT),
|
2008-06-15 18:36:26 +00:00
|
|
|
AlphaColor(0), Translation(0), RenderFlags(0)
|
2006-04-12 01:50:09 +00:00
|
|
|
{
|
- Updated lempar.c to v1.31.
- Added .txt files to the list of types (wad, zip, and pk3) that can be
loaded without listing them after -file.
- Fonts that are created by the ACS setfont command to wrap a texture now
support animated textures.
- FON2 fonts can now use their full palette for CR_UNTRANSLATED when drawn
with the hardware 2D path instead of being restricted to the game palette.
- Fixed: Toggling vid_vsync would reset the displayed fullscreen gamma to 1
on a Radeon 9000.
- Added back the off-by-one palette handling, but in a much more limited
scope than before. The skipped entry is assumed to always be at 248, and
it is assumed that all Shader Model 1.4 cards suffer from this. That's
because all SM1.4 cards are based on variants of the ATI R200 core, and the
RV250 in a Radeon 9000 craps up like this. I see no reason to assume that
other flavors of the R200 are any different. (Interesting note: With the
Radeon 9000, D3DTADDRESS_CLAMP is an invalid address mode when using the
debug Direct3D 9 runtime, but it works perfectly fine with the retail
Direct3D 9 runtime.) (Insight: The R200 probably uses bytes for all its
math inside pixel shaders. That would explain perfectly why I can't use
constants greater than 1 with PS1.4 and why it can't do an exact mapping to
every entry in the color palette.
- Fixed: The software shaded drawer did not work for 2D, because its selected
"color"map was replaced with the identitymap before being used.
- Fixed: I cannot use Printf to output messages before the framebuffer was
completely setup, meaning that Shader Model 1.4 cards could not change
resolution.
- I have decided to let remap palettes specify variable alpha values for
their colors. D3DFB no longer forces them to 255.
- Updated re2c to version 0.12.3.
- Fixed: A_Wander used threshold as a timer, when it should have used
reactiontime.
- Fixed: A_CustomRailgun would not fire at all for actors without a target
when the aim parameter was disabled.
- Made the warp command work in multiplayer, again courtesy of Karate Chris.
- Fixed: Trying to spawn a bot while not in a game made for a crashing time.
(Patch courtesy of Karate Chris.)
- Removed some floating point math from hu_scores.cpp that somebody's GCC
gave warnings for (not mine, though).
- Fixed: The SBarInfo drawbar command crashed if the sprite image was
unavailable.
- Fixed: FString::operator=(const char *) did not release its old buffer when
being assigned to the null string.
- The scanner no longer has an upper limit on the length of strings it
accepts, though short strings will be faster than long ones.
- Moved all the text scanning functions into a class. Mainly, this means that
multiple script scanner states can be stored without being forced to do so
recursively. I think I might be taking advantage of that in the near
future. Possibly. Maybe.
- Removed some potential buffer overflows from the decal parser.
- Applied Blzut3's SBARINFO update #9:
* Fixed: When using even length values in drawnumber it would cap to a 98
value instead of a 99 as intended.
* The SBarInfo parser can now accept negatives for coordinates. This
doesn't allow much right now, but later I plan to add better fullscreen
hud support in which the negatives will be more useful. This also cleans
up the source a bit since all calls for (x, y) coordinates are with the
function getCoordinates().
- Added support for stencilling actors.
- Added support for non-black colors specified with DTA_ColorOverlay to the
software renderer.
- Fixed: The inverse, gold, red, and green fixed colormaps each allocated
space for 32 different colormaps, even though each only used the first one.
- Added two new blending flags to make reverse subtract blending more useful:
STYLEF_InvertSource and STYLEF_InvertOverlay. These invert the color that
gets blended with the background, since that seems like a good idea for
reverse subtraction. They also work with the other two blending operations.
- Added subtract and reverse subtract blending operations to the renderer.
Since the ERenderStyle enumeration was getting rather unwieldy, I converted
it into a new FRenderStyle structure that lets each parameter of the
blending equation be set separately. This simplified the set up for the
blend quite a bit, and it means a number of new combinations are available
by setting the parameters properly.
SVN r710 (trunk)
2008-01-25 23:57:44 +00:00
|
|
|
RenderStyle = STYLE_None;
|
2008-06-15 18:36:26 +00:00
|
|
|
PicNum.SetInvalid();
|
2006-04-12 01:50:09 +00:00
|
|
|
}
|
|
|
|
|
2006-04-13 02:01:40 +00:00
|
|
|
DBaseDecal::DBaseDecal (fixed_t z)
|
2006-04-12 01:50:09 +00:00
|
|
|
: DThinker(STAT_DECAL),
|
2006-04-13 02:01:40 +00:00
|
|
|
WallNext(0), WallPrev(0), LeftDistance(0), Z(z), ScaleX(FRACUNIT), ScaleY(FRACUNIT), Alpha(FRACUNIT),
|
2008-06-15 18:36:26 +00:00
|
|
|
AlphaColor(0), Translation(0), RenderFlags(0)
|
2006-04-13 02:01:40 +00:00
|
|
|
{
|
- Updated lempar.c to v1.31.
- Added .txt files to the list of types (wad, zip, and pk3) that can be
loaded without listing them after -file.
- Fonts that are created by the ACS setfont command to wrap a texture now
support animated textures.
- FON2 fonts can now use their full palette for CR_UNTRANSLATED when drawn
with the hardware 2D path instead of being restricted to the game palette.
- Fixed: Toggling vid_vsync would reset the displayed fullscreen gamma to 1
on a Radeon 9000.
- Added back the off-by-one palette handling, but in a much more limited
scope than before. The skipped entry is assumed to always be at 248, and
it is assumed that all Shader Model 1.4 cards suffer from this. That's
because all SM1.4 cards are based on variants of the ATI R200 core, and the
RV250 in a Radeon 9000 craps up like this. I see no reason to assume that
other flavors of the R200 are any different. (Interesting note: With the
Radeon 9000, D3DTADDRESS_CLAMP is an invalid address mode when using the
debug Direct3D 9 runtime, but it works perfectly fine with the retail
Direct3D 9 runtime.) (Insight: The R200 probably uses bytes for all its
math inside pixel shaders. That would explain perfectly why I can't use
constants greater than 1 with PS1.4 and why it can't do an exact mapping to
every entry in the color palette.
- Fixed: The software shaded drawer did not work for 2D, because its selected
"color"map was replaced with the identitymap before being used.
- Fixed: I cannot use Printf to output messages before the framebuffer was
completely setup, meaning that Shader Model 1.4 cards could not change
resolution.
- I have decided to let remap palettes specify variable alpha values for
their colors. D3DFB no longer forces them to 255.
- Updated re2c to version 0.12.3.
- Fixed: A_Wander used threshold as a timer, when it should have used
reactiontime.
- Fixed: A_CustomRailgun would not fire at all for actors without a target
when the aim parameter was disabled.
- Made the warp command work in multiplayer, again courtesy of Karate Chris.
- Fixed: Trying to spawn a bot while not in a game made for a crashing time.
(Patch courtesy of Karate Chris.)
- Removed some floating point math from hu_scores.cpp that somebody's GCC
gave warnings for (not mine, though).
- Fixed: The SBarInfo drawbar command crashed if the sprite image was
unavailable.
- Fixed: FString::operator=(const char *) did not release its old buffer when
being assigned to the null string.
- The scanner no longer has an upper limit on the length of strings it
accepts, though short strings will be faster than long ones.
- Moved all the text scanning functions into a class. Mainly, this means that
multiple script scanner states can be stored without being forced to do so
recursively. I think I might be taking advantage of that in the near
future. Possibly. Maybe.
- Removed some potential buffer overflows from the decal parser.
- Applied Blzut3's SBARINFO update #9:
* Fixed: When using even length values in drawnumber it would cap to a 98
value instead of a 99 as intended.
* The SBarInfo parser can now accept negatives for coordinates. This
doesn't allow much right now, but later I plan to add better fullscreen
hud support in which the negatives will be more useful. This also cleans
up the source a bit since all calls for (x, y) coordinates are with the
function getCoordinates().
- Added support for stencilling actors.
- Added support for non-black colors specified with DTA_ColorOverlay to the
software renderer.
- Fixed: The inverse, gold, red, and green fixed colormaps each allocated
space for 32 different colormaps, even though each only used the first one.
- Added two new blending flags to make reverse subtract blending more useful:
STYLEF_InvertSource and STYLEF_InvertOverlay. These invert the color that
gets blended with the background, since that seems like a good idea for
reverse subtraction. They also work with the other two blending operations.
- Added subtract and reverse subtract blending operations to the renderer.
Since the ERenderStyle enumeration was getting rather unwieldy, I converted
it into a new FRenderStyle structure that lets each parameter of the
blending equation be set separately. This simplified the set up for the
blend quite a bit, and it means a number of new combinations are available
by setting the parameters properly.
SVN r710 (trunk)
2008-01-25 23:57:44 +00:00
|
|
|
RenderStyle = STYLE_None;
|
2008-06-15 18:36:26 +00:00
|
|
|
PicNum.SetInvalid();
|
2006-04-13 02:01:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DBaseDecal::DBaseDecal (int statnum, fixed_t z)
|
|
|
|
: DThinker(statnum),
|
|
|
|
WallNext(0), WallPrev(0), LeftDistance(0), Z(z), ScaleX(FRACUNIT), ScaleY(FRACUNIT), Alpha(FRACUNIT),
|
2008-06-15 18:36:26 +00:00
|
|
|
AlphaColor(0), Translation(0), RenderFlags(0)
|
2006-04-12 01:50:09 +00:00
|
|
|
{
|
- Updated lempar.c to v1.31.
- Added .txt files to the list of types (wad, zip, and pk3) that can be
loaded without listing them after -file.
- Fonts that are created by the ACS setfont command to wrap a texture now
support animated textures.
- FON2 fonts can now use their full palette for CR_UNTRANSLATED when drawn
with the hardware 2D path instead of being restricted to the game palette.
- Fixed: Toggling vid_vsync would reset the displayed fullscreen gamma to 1
on a Radeon 9000.
- Added back the off-by-one palette handling, but in a much more limited
scope than before. The skipped entry is assumed to always be at 248, and
it is assumed that all Shader Model 1.4 cards suffer from this. That's
because all SM1.4 cards are based on variants of the ATI R200 core, and the
RV250 in a Radeon 9000 craps up like this. I see no reason to assume that
other flavors of the R200 are any different. (Interesting note: With the
Radeon 9000, D3DTADDRESS_CLAMP is an invalid address mode when using the
debug Direct3D 9 runtime, but it works perfectly fine with the retail
Direct3D 9 runtime.) (Insight: The R200 probably uses bytes for all its
math inside pixel shaders. That would explain perfectly why I can't use
constants greater than 1 with PS1.4 and why it can't do an exact mapping to
every entry in the color palette.
- Fixed: The software shaded drawer did not work for 2D, because its selected
"color"map was replaced with the identitymap before being used.
- Fixed: I cannot use Printf to output messages before the framebuffer was
completely setup, meaning that Shader Model 1.4 cards could not change
resolution.
- I have decided to let remap palettes specify variable alpha values for
their colors. D3DFB no longer forces them to 255.
- Updated re2c to version 0.12.3.
- Fixed: A_Wander used threshold as a timer, when it should have used
reactiontime.
- Fixed: A_CustomRailgun would not fire at all for actors without a target
when the aim parameter was disabled.
- Made the warp command work in multiplayer, again courtesy of Karate Chris.
- Fixed: Trying to spawn a bot while not in a game made for a crashing time.
(Patch courtesy of Karate Chris.)
- Removed some floating point math from hu_scores.cpp that somebody's GCC
gave warnings for (not mine, though).
- Fixed: The SBarInfo drawbar command crashed if the sprite image was
unavailable.
- Fixed: FString::operator=(const char *) did not release its old buffer when
being assigned to the null string.
- The scanner no longer has an upper limit on the length of strings it
accepts, though short strings will be faster than long ones.
- Moved all the text scanning functions into a class. Mainly, this means that
multiple script scanner states can be stored without being forced to do so
recursively. I think I might be taking advantage of that in the near
future. Possibly. Maybe.
- Removed some potential buffer overflows from the decal parser.
- Applied Blzut3's SBARINFO update #9:
* Fixed: When using even length values in drawnumber it would cap to a 98
value instead of a 99 as intended.
* The SBarInfo parser can now accept negatives for coordinates. This
doesn't allow much right now, but later I plan to add better fullscreen
hud support in which the negatives will be more useful. This also cleans
up the source a bit since all calls for (x, y) coordinates are with the
function getCoordinates().
- Added support for stencilling actors.
- Added support for non-black colors specified with DTA_ColorOverlay to the
software renderer.
- Fixed: The inverse, gold, red, and green fixed colormaps each allocated
space for 32 different colormaps, even though each only used the first one.
- Added two new blending flags to make reverse subtract blending more useful:
STYLEF_InvertSource and STYLEF_InvertOverlay. These invert the color that
gets blended with the background, since that seems like a good idea for
reverse subtraction. They also work with the other two blending operations.
- Added subtract and reverse subtract blending operations to the renderer.
Since the ERenderStyle enumeration was getting rather unwieldy, I converted
it into a new FRenderStyle structure that lets each parameter of the
blending equation be set separately. This simplified the set up for the
blend quite a bit, and it means a number of new combinations are available
by setting the parameters properly.
SVN r710 (trunk)
2008-01-25 23:57:44 +00:00
|
|
|
RenderStyle = STYLE_None;
|
2008-06-15 18:36:26 +00:00
|
|
|
PicNum.SetInvalid();
|
2006-04-12 01:50:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DBaseDecal::DBaseDecal (const AActor *basis)
|
|
|
|
: DThinker(STAT_DECAL),
|
2006-11-14 16:54:02 +00:00
|
|
|
WallNext(0), WallPrev(0), LeftDistance(0), Z(basis->z), ScaleX(basis->scaleX), ScaleY(basis->scaleY),
|
- Updated lempar.c to v1.31.
- Added .txt files to the list of types (wad, zip, and pk3) that can be
loaded without listing them after -file.
- Fonts that are created by the ACS setfont command to wrap a texture now
support animated textures.
- FON2 fonts can now use their full palette for CR_UNTRANSLATED when drawn
with the hardware 2D path instead of being restricted to the game palette.
- Fixed: Toggling vid_vsync would reset the displayed fullscreen gamma to 1
on a Radeon 9000.
- Added back the off-by-one palette handling, but in a much more limited
scope than before. The skipped entry is assumed to always be at 248, and
it is assumed that all Shader Model 1.4 cards suffer from this. That's
because all SM1.4 cards are based on variants of the ATI R200 core, and the
RV250 in a Radeon 9000 craps up like this. I see no reason to assume that
other flavors of the R200 are any different. (Interesting note: With the
Radeon 9000, D3DTADDRESS_CLAMP is an invalid address mode when using the
debug Direct3D 9 runtime, but it works perfectly fine with the retail
Direct3D 9 runtime.) (Insight: The R200 probably uses bytes for all its
math inside pixel shaders. That would explain perfectly why I can't use
constants greater than 1 with PS1.4 and why it can't do an exact mapping to
every entry in the color palette.
- Fixed: The software shaded drawer did not work for 2D, because its selected
"color"map was replaced with the identitymap before being used.
- Fixed: I cannot use Printf to output messages before the framebuffer was
completely setup, meaning that Shader Model 1.4 cards could not change
resolution.
- I have decided to let remap palettes specify variable alpha values for
their colors. D3DFB no longer forces them to 255.
- Updated re2c to version 0.12.3.
- Fixed: A_Wander used threshold as a timer, when it should have used
reactiontime.
- Fixed: A_CustomRailgun would not fire at all for actors without a target
when the aim parameter was disabled.
- Made the warp command work in multiplayer, again courtesy of Karate Chris.
- Fixed: Trying to spawn a bot while not in a game made for a crashing time.
(Patch courtesy of Karate Chris.)
- Removed some floating point math from hu_scores.cpp that somebody's GCC
gave warnings for (not mine, though).
- Fixed: The SBarInfo drawbar command crashed if the sprite image was
unavailable.
- Fixed: FString::operator=(const char *) did not release its old buffer when
being assigned to the null string.
- The scanner no longer has an upper limit on the length of strings it
accepts, though short strings will be faster than long ones.
- Moved all the text scanning functions into a class. Mainly, this means that
multiple script scanner states can be stored without being forced to do so
recursively. I think I might be taking advantage of that in the near
future. Possibly. Maybe.
- Removed some potential buffer overflows from the decal parser.
- Applied Blzut3's SBARINFO update #9:
* Fixed: When using even length values in drawnumber it would cap to a 98
value instead of a 99 as intended.
* The SBarInfo parser can now accept negatives for coordinates. This
doesn't allow much right now, but later I plan to add better fullscreen
hud support in which the negatives will be more useful. This also cleans
up the source a bit since all calls for (x, y) coordinates are with the
function getCoordinates().
- Added support for stencilling actors.
- Added support for non-black colors specified with DTA_ColorOverlay to the
software renderer.
- Fixed: The inverse, gold, red, and green fixed colormaps each allocated
space for 32 different colormaps, even though each only used the first one.
- Added two new blending flags to make reverse subtract blending more useful:
STYLEF_InvertSource and STYLEF_InvertOverlay. These invert the color that
gets blended with the background, since that seems like a good idea for
reverse subtraction. They also work with the other two blending operations.
- Added subtract and reverse subtract blending operations to the renderer.
Since the ERenderStyle enumeration was getting rather unwieldy, I converted
it into a new FRenderStyle structure that lets each parameter of the
blending equation be set separately. This simplified the set up for the
blend quite a bit, and it means a number of new combinations are available
by setting the parameters properly.
SVN r710 (trunk)
2008-01-25 23:57:44 +00:00
|
|
|
Alpha(basis->alpha), AlphaColor(basis->fillcolor), Translation(basis->Translation), PicNum(basis->picnum),
|
2006-04-13 02:01:40 +00:00
|
|
|
RenderFlags(basis->renderflags), RenderStyle(basis->RenderStyle)
|
2006-04-12 01:50:09 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
DBaseDecal::DBaseDecal (const DBaseDecal *basis)
|
|
|
|
: DThinker(STAT_DECAL),
|
2006-04-13 02:01:40 +00:00
|
|
|
WallNext(0), WallPrev(0), LeftDistance(basis->LeftDistance), Z(basis->Z), ScaleX(basis->ScaleX),
|
|
|
|
ScaleY(basis->ScaleY), Alpha(basis->Alpha), AlphaColor(basis->AlphaColor), Translation(basis->Translation),
|
|
|
|
PicNum(basis->PicNum), RenderFlags(basis->RenderFlags), RenderStyle(basis->RenderStyle)
|
2006-04-12 01:50:09 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void DBaseDecal::Destroy ()
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
Remove ();
|
|
|
|
Super::Destroy ();
|
|
|
|
}
|
|
|
|
|
2006-04-12 01:50:09 +00:00
|
|
|
void DBaseDecal::Remove ()
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-04-12 01:50:09 +00:00
|
|
|
DBaseDecal **prev = WallPrev;
|
|
|
|
DBaseDecal *next = WallNext;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (prev && (*prev = next))
|
2006-04-12 01:50:09 +00:00
|
|
|
next->WallPrev = prev;
|
|
|
|
WallPrev = NULL;
|
|
|
|
WallNext = NULL;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-04-12 01:50:09 +00:00
|
|
|
void DBaseDecal::Serialize (FArchive &arc)
|
|
|
|
{
|
|
|
|
Super::Serialize (arc);
|
2006-04-13 02:01:40 +00:00
|
|
|
arc << LeftDistance
|
|
|
|
<< Z
|
|
|
|
<< ScaleX << ScaleY
|
|
|
|
<< Alpha
|
2006-04-12 01:50:09 +00:00
|
|
|
<< AlphaColor
|
|
|
|
<< Translation
|
|
|
|
<< PicNum
|
|
|
|
<< RenderFlags
|
2006-04-13 02:01:40 +00:00
|
|
|
<< RenderStyle;
|
2006-04-12 01:50:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DBaseDecal::SerializeChain (FArchive &arc, DBaseDecal **first)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
DWORD numInChain;
|
2006-04-12 01:50:09 +00:00
|
|
|
DBaseDecal *fresh;
|
|
|
|
DBaseDecal **firstptr = first;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (arc.IsLoading ())
|
|
|
|
{
|
|
|
|
numInChain = arc.ReadCount ();
|
|
|
|
|
|
|
|
while (numInChain--)
|
|
|
|
{
|
|
|
|
arc << fresh;
|
|
|
|
*firstptr = fresh;
|
2006-04-12 01:50:09 +00:00
|
|
|
fresh->WallPrev = firstptr;
|
|
|
|
firstptr = &fresh->WallNext;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
numInChain = 0;
|
|
|
|
fresh = *firstptr;
|
|
|
|
while (fresh != NULL)
|
|
|
|
{
|
2006-04-12 01:50:09 +00:00
|
|
|
fresh = fresh->WallNext;
|
2006-02-24 04:48:15 +00:00
|
|
|
++numInChain;
|
|
|
|
}
|
|
|
|
arc.WriteCount (numInChain);
|
|
|
|
fresh = *firstptr;
|
|
|
|
while (numInChain--)
|
|
|
|
{
|
|
|
|
arc << fresh;
|
2006-04-12 01:50:09 +00:00
|
|
|
fresh = fresh->WallNext;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-13 02:01:40 +00:00
|
|
|
void DBaseDecal::GetXY (side_t *wall, fixed_t &ox, fixed_t &oy) const
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
line_t *line = &lines[wall->linenum];
|
2006-04-12 03:03:58 +00:00
|
|
|
DWORD wallnum = DWORD(wall - sides);
|
2006-02-24 04:48:15 +00:00
|
|
|
vertex_t *v1, *v2;
|
|
|
|
|
|
|
|
if (line->sidenum[0] == wallnum)
|
|
|
|
{
|
|
|
|
v1 = line->v1;
|
|
|
|
v2 = line->v2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
v1 = line->v2;
|
|
|
|
v2 = line->v1;
|
|
|
|
}
|
|
|
|
|
|
|
|
fixed_t dx = v2->x - v1->x;
|
|
|
|
fixed_t dy = v2->y - v1->y;
|
|
|
|
|
2006-04-13 02:01:40 +00:00
|
|
|
ox = v1->x + MulScale30 (LeftDistance, dx);
|
|
|
|
oy = v1->y + MulScale30 (LeftDistance, dy);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-04-12 01:50:09 +00:00
|
|
|
void DBaseDecal::SetShade (DWORD rgb)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-04-12 01:50:09 +00:00
|
|
|
PalEntry *entry = (PalEntry *)&rgb;
|
|
|
|
AlphaColor = rgb | (ColorMatcher.Pick (entry->r, entry->g, entry->b) << 24);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-04-12 01:50:09 +00:00
|
|
|
void DBaseDecal::SetShade (int r, int g, int b)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-04-12 01:50:09 +00:00
|
|
|
AlphaColor = MAKEARGB(ColorMatcher.Pick (r, g, b), r, g, b);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Returns the texture the decal stuck to.
|
2008-06-15 18:36:26 +00:00
|
|
|
FTextureID DBaseDecal::StickToWall (side_t *wall, fixed_t x, fixed_t y)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
// Stick the decal at the end of the chain so it appears on top
|
2006-04-12 01:50:09 +00:00
|
|
|
DBaseDecal *next, **prev;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-04-12 01:50:09 +00:00
|
|
|
prev = &wall->AttachedDecals;
|
2006-02-24 04:48:15 +00:00
|
|
|
while (*prev != NULL)
|
|
|
|
{
|
|
|
|
next = *prev;
|
2006-04-12 01:50:09 +00:00
|
|
|
prev = &next->WallNext;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
*prev = this;
|
2006-04-12 01:50:09 +00:00
|
|
|
WallNext = NULL;
|
|
|
|
WallPrev = prev;
|
2006-02-24 04:48:15 +00:00
|
|
|
/*
|
2006-04-12 01:50:09 +00:00
|
|
|
WallNext = wall->AttachedDecals;
|
|
|
|
WallPrev = &wall->AttachedDecals;
|
|
|
|
if (WallNext)
|
|
|
|
WallNext->WallPrev = &WallNext;
|
|
|
|
wall->AttachedDecals = this;
|
2006-02-24 04:48:15 +00:00
|
|
|
*/
|
|
|
|
sector_t *front, *back;
|
|
|
|
line_t *line;
|
2008-06-15 18:36:26 +00:00
|
|
|
FTextureID tex;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
line = &lines[wall->linenum];
|
2006-04-12 03:03:58 +00:00
|
|
|
if (line->sidenum[0] == DWORD(wall - sides))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
front = line->frontsector;
|
|
|
|
back = line->backsector;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
front = line->backsector;
|
|
|
|
back = line->frontsector;
|
|
|
|
}
|
|
|
|
if (back == NULL)
|
|
|
|
{
|
2006-04-12 01:50:09 +00:00
|
|
|
RenderFlags |= RF_RELMID;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (line->flags & ML_DONTPEGBOTTOM)
|
2008-08-16 20:19:35 +00:00
|
|
|
Z -= front->GetPlaneTexZ(sector_t::floor);
|
2006-02-24 04:48:15 +00:00
|
|
|
else
|
2008-08-16 20:19:35 +00:00
|
|
|
Z -= front->GetPlaneTexZ(sector_t::ceiling);
|
2008-03-21 17:35:49 +00:00
|
|
|
tex = wall->GetTexture(side_t::mid);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2006-04-13 02:01:40 +00:00
|
|
|
else if (back->floorplane.ZatPoint (x, y) >= Z)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-04-12 01:50:09 +00:00
|
|
|
RenderFlags |= RF_RELLOWER|RF_CLIPLOWER;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (line->flags & ML_DONTPEGBOTTOM)
|
2008-08-16 20:19:35 +00:00
|
|
|
Z -= front->GetPlaneTexZ(sector_t::ceiling);
|
2006-02-24 04:48:15 +00:00
|
|
|
else
|
2008-08-16 20:19:35 +00:00
|
|
|
Z -= back->GetPlaneTexZ(sector_t::floor);
|
2008-03-21 17:35:49 +00:00
|
|
|
tex = wall->GetTexture(side_t::bottom);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-04-12 01:50:09 +00:00
|
|
|
RenderFlags |= RF_RELUPPER|RF_CLIPUPPER;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (line->flags & ML_DONTPEGTOP)
|
2008-08-16 20:19:35 +00:00
|
|
|
Z -= front->GetPlaneTexZ(sector_t::ceiling);
|
2006-02-24 04:48:15 +00:00
|
|
|
else
|
2008-08-16 20:19:35 +00:00
|
|
|
Z -= back->GetPlaneTexZ(sector_t::ceiling);
|
2008-03-21 17:35:49 +00:00
|
|
|
tex = wall->GetTexture(side_t::top);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-04-13 02:01:40 +00:00
|
|
|
CalcFracPos (wall, x, y);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
return tex;
|
|
|
|
}
|
|
|
|
|
2006-04-12 01:50:09 +00:00
|
|
|
fixed_t DBaseDecal::GetRealZ (const side_t *wall) const
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
const line_t *line = &lines[wall->linenum];
|
|
|
|
const sector_t *front, *back;
|
|
|
|
|
2006-04-12 03:03:58 +00:00
|
|
|
if (line->sidenum[0] == DWORD(wall - sides))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
front = line->frontsector;
|
|
|
|
back = line->backsector;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
front = line->backsector;
|
|
|
|
back = line->frontsector;
|
|
|
|
}
|
|
|
|
if (back == NULL)
|
|
|
|
{
|
|
|
|
back = front;
|
|
|
|
}
|
|
|
|
|
2006-04-12 01:50:09 +00:00
|
|
|
switch (RenderFlags & RF_RELMASK)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
default:
|
2006-04-13 02:01:40 +00:00
|
|
|
return Z;
|
2006-02-24 04:48:15 +00:00
|
|
|
case RF_RELUPPER:
|
|
|
|
if (curline->linedef->flags & ML_DONTPEGTOP)
|
|
|
|
{
|
2008-08-16 20:19:35 +00:00
|
|
|
return Z + front->GetPlaneTexZ(sector_t::ceiling);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-08-16 20:19:35 +00:00
|
|
|
return Z + back->GetPlaneTexZ(sector_t::ceiling);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
case RF_RELLOWER:
|
|
|
|
if (curline->linedef->flags & ML_DONTPEGBOTTOM)
|
|
|
|
{
|
2008-08-16 20:19:35 +00:00
|
|
|
return Z + front->GetPlaneTexZ(sector_t::ceiling);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-08-16 20:19:35 +00:00
|
|
|
return Z + back->GetPlaneTexZ(sector_t::floor);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
case RF_RELMID:
|
|
|
|
if (curline->linedef->flags & ML_DONTPEGBOTTOM)
|
|
|
|
{
|
2008-08-16 20:19:35 +00:00
|
|
|
return Z + front->GetPlaneTexZ(sector_t::floor);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-08-16 20:19:35 +00:00
|
|
|
return Z + front->GetPlaneTexZ(sector_t::ceiling);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-13 02:01:40 +00:00
|
|
|
void DBaseDecal::CalcFracPos (side_t *wall, fixed_t x, fixed_t y)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
line_t *line = &lines[wall->linenum];
|
2006-04-12 03:03:58 +00:00
|
|
|
DWORD wallnum = DWORD(wall - sides);
|
2006-02-24 04:48:15 +00:00
|
|
|
vertex_t *v1, *v2;
|
|
|
|
|
|
|
|
if (line->sidenum[0] == wallnum)
|
|
|
|
{
|
|
|
|
v1 = line->v1;
|
|
|
|
v2 = line->v2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
v1 = line->v2;
|
|
|
|
v2 = line->v1;
|
|
|
|
}
|
|
|
|
|
|
|
|
fixed_t dx = v2->x - v1->x;
|
|
|
|
fixed_t dy = v2->y - v1->y;
|
|
|
|
|
|
|
|
if (abs(dx) > abs(dy))
|
|
|
|
{
|
2006-04-13 02:01:40 +00:00
|
|
|
LeftDistance = SafeDivScale30 (x - v1->x, dx);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else if (dy != 0)
|
|
|
|
{
|
2006-04-13 02:01:40 +00:00
|
|
|
LeftDistance = SafeDivScale30 (y - v1->y, dy);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-04-12 01:50:09 +00:00
|
|
|
LeftDistance = 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void GetWallStuff (side_t *wall, vertex_t *&v1, fixed_t &ldx, fixed_t &ldy)
|
|
|
|
{
|
|
|
|
line_t *line = &lines[wall->linenum];
|
2006-04-12 03:03:58 +00:00
|
|
|
if (line->sidenum[0] == DWORD(wall - sides))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
v1 = line->v1;
|
|
|
|
ldx = line->dx;
|
|
|
|
ldy = line->dy;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
v1 = line->v2;
|
|
|
|
ldx = -line->dx;
|
|
|
|
ldy = -line->dy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static fixed_t Length (fixed_t dx, fixed_t dy)
|
|
|
|
{
|
|
|
|
return (fixed_t)sqrtf ((float)dx*(float)dx+(float)dy*(float)dy);
|
|
|
|
}
|
|
|
|
|
|
|
|
static side_t *NextWall (const side_t *wall)
|
|
|
|
{
|
|
|
|
line_t *line = &lines[wall->linenum];
|
2006-04-12 03:03:58 +00:00
|
|
|
DWORD wallnum = DWORD(wall - sides);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (line->sidenum[0] == wallnum)
|
|
|
|
{
|
|
|
|
if (line->sidenum[1] != NO_SIDE)
|
|
|
|
{
|
|
|
|
return sides + line->sidenum[1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (line->sidenum[1] == wallnum)
|
|
|
|
{
|
|
|
|
return sides + line->sidenum[0];
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-04-12 01:50:09 +00:00
|
|
|
void DBaseDecal::SpreadLeft (fixed_t r, vertex_t *v1, side_t *feelwall)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
fixed_t ldx, ldy;
|
|
|
|
|
|
|
|
SpreadStack.Push (feelwall);
|
|
|
|
|
|
|
|
while (r < 0 && feelwall->LeftSide != NO_SIDE)
|
|
|
|
{
|
|
|
|
fixed_t startr = r;
|
|
|
|
|
|
|
|
fixed_t x = v1->x;
|
|
|
|
fixed_t y = v1->y;
|
|
|
|
|
|
|
|
feelwall = &sides[feelwall->LeftSide];
|
|
|
|
GetWallStuff (feelwall, v1, ldx, ldy);
|
|
|
|
fixed_t wallsize = Length (ldx, ldy);
|
|
|
|
r += DecalLeft;
|
|
|
|
x += Scale (r, ldx, wallsize);
|
|
|
|
y += Scale (r, ldy, wallsize);
|
|
|
|
r = wallsize + startr;
|
2006-04-12 01:50:09 +00:00
|
|
|
SpreadSource->CloneSelf (SpreadTemplate, x, y, SpreadZ, feelwall);
|
2006-02-24 04:48:15 +00:00
|
|
|
SpreadStack.Push (feelwall);
|
|
|
|
|
|
|
|
side_t *nextwall = NextWall (feelwall);
|
|
|
|
if (nextwall != NULL && nextwall->LeftSide != NO_SIDE)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = SpreadStack.Size(); i-- > 0; )
|
|
|
|
{
|
|
|
|
if (SpreadStack[i] == nextwall)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (i == -1)
|
|
|
|
{
|
|
|
|
vertex_t *v2;
|
|
|
|
|
|
|
|
GetWallStuff (nextwall, v2, ldx, ldy);
|
|
|
|
SpreadLeft (startr, v2, nextwall);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-12 01:50:09 +00:00
|
|
|
void DBaseDecal::SpreadRight (fixed_t r, side_t *feelwall, fixed_t wallsize)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
vertex_t *v1;
|
|
|
|
fixed_t x, y, ldx, ldy;
|
|
|
|
|
|
|
|
SpreadStack.Push (feelwall);
|
|
|
|
|
|
|
|
while (r > wallsize && feelwall->RightSide != NO_SIDE)
|
|
|
|
{
|
|
|
|
feelwall = &sides[feelwall->RightSide];
|
|
|
|
|
|
|
|
side_t *nextwall = NextWall (feelwall);
|
|
|
|
if (nextwall != NULL && nextwall->LeftSide != NO_SIDE)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = SpreadStack.Size(); i-- > 0; )
|
|
|
|
{
|
|
|
|
if (SpreadStack[i] == nextwall)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (i == -1)
|
|
|
|
{
|
|
|
|
SpreadRight (r, nextwall, wallsize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
r = DecalWidth - r + wallsize - DecalLeft;
|
|
|
|
GetWallStuff (feelwall, v1, ldx, ldy);
|
|
|
|
x = v1->x;
|
|
|
|
y = v1->y;
|
|
|
|
wallsize = Length (ldx, ldy);
|
|
|
|
x -= Scale (r, ldx, wallsize);
|
|
|
|
y -= Scale (r, ldy, wallsize);
|
|
|
|
r = DecalRight - r;
|
2006-04-12 01:50:09 +00:00
|
|
|
SpreadSource->CloneSelf (SpreadTemplate, x, y, SpreadZ, feelwall);
|
2006-02-24 04:48:15 +00:00
|
|
|
SpreadStack.Push (feelwall);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-13 02:01:40 +00:00
|
|
|
void DBaseDecal::Spread (const FDecalTemplate *tpl, side_t *wall, fixed_t x, fixed_t y, fixed_t z)
|
2006-04-12 01:50:09 +00:00
|
|
|
{
|
|
|
|
FTexture *tex;
|
|
|
|
vertex_t *v1;
|
|
|
|
fixed_t rorg, ldx, ldy;
|
|
|
|
|
|
|
|
GetWallStuff (wall, v1, ldx, ldy);
|
|
|
|
rorg = Length (x - v1->x, y - v1->y);
|
|
|
|
|
|
|
|
tex = TexMan[PicNum];
|
|
|
|
int dwidth = tex->GetWidth ();
|
|
|
|
|
2006-04-13 02:01:40 +00:00
|
|
|
DecalWidth = dwidth * ScaleX;
|
|
|
|
DecalLeft = tex->LeftOffset * ScaleX;
|
2006-04-12 01:50:09 +00:00
|
|
|
DecalRight = DecalWidth - DecalLeft;
|
|
|
|
SpreadSource = this;
|
|
|
|
SpreadTemplate = tpl;
|
2006-04-13 02:01:40 +00:00
|
|
|
SpreadZ = z;
|
2006-04-12 01:50:09 +00:00
|
|
|
|
|
|
|
// Try spreading left first
|
|
|
|
SpreadLeft (rorg - DecalLeft, v1, wall);
|
|
|
|
SpreadStack.Clear ();
|
|
|
|
|
|
|
|
// Then try spreading right
|
|
|
|
SpreadRight (rorg + DecalRight, wall,
|
|
|
|
Length (lines[wall->linenum].dx, lines[wall->linenum].dy));
|
|
|
|
SpreadStack.Clear ();
|
|
|
|
}
|
|
|
|
|
|
|
|
DBaseDecal *DBaseDecal::CloneSelf (const FDecalTemplate *tpl, fixed_t ix, fixed_t iy, fixed_t iz, side_t *wall) const
|
|
|
|
{
|
2006-04-13 02:01:40 +00:00
|
|
|
DBaseDecal *decal = new DBaseDecal(iz);
|
2006-04-12 01:50:09 +00:00
|
|
|
if (decal != NULL)
|
|
|
|
{
|
2006-04-13 02:01:40 +00:00
|
|
|
decal->StickToWall (wall, ix, iy);
|
|
|
|
tpl->ApplyToDecal (decal, wall);
|
2006-04-12 01:50:09 +00:00
|
|
|
decal->AlphaColor = AlphaColor;
|
|
|
|
decal->RenderFlags = (decal->RenderFlags & RF_DECALMASK) |
|
|
|
|
(this->RenderFlags & ~RF_DECALMASK);
|
|
|
|
}
|
|
|
|
return decal;
|
|
|
|
}
|
|
|
|
|
|
|
|
CUSTOM_CVAR (Int, cl_maxdecals, 1024, CVAR_ARCHIVE)
|
|
|
|
{
|
|
|
|
if (self < 0)
|
|
|
|
{
|
|
|
|
self = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while (ImpactCount > self)
|
|
|
|
{
|
2006-04-13 02:01:40 +00:00
|
|
|
DThinker *thinker = DThinker::FirstThinker (STAT_AUTODECAL);
|
|
|
|
if (thinker != NULL)
|
|
|
|
{
|
|
|
|
thinker->Destroy();
|
|
|
|
}
|
2006-04-12 01:50:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Uses: target points to previous impact decal
|
|
|
|
// tracer points to next impact decal
|
|
|
|
//
|
|
|
|
// Note that this means we can't simply serialize an impact decal as-is
|
|
|
|
// because doing so when many are present in a level could result in
|
|
|
|
// a lot of recursion and we would run out of stack. Not nice. So instead,
|
|
|
|
// the save game code calls DImpactDecal::SerializeAll to serialize a
|
|
|
|
// list of impact decals.
|
|
|
|
|
|
|
|
void DImpactDecal::SerializeTime (FArchive &arc)
|
|
|
|
{
|
|
|
|
if (arc.IsLoading ())
|
|
|
|
{
|
|
|
|
ImpactCount = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DImpactDecal::Serialize (FArchive &arc)
|
|
|
|
{
|
|
|
|
Super::Serialize (arc);
|
|
|
|
}
|
|
|
|
|
|
|
|
DImpactDecal::DImpactDecal ()
|
2006-04-13 16:52:24 +00:00
|
|
|
: DBaseDecal (STAT_AUTODECAL, 0)
|
2006-04-12 01:50:09 +00:00
|
|
|
{
|
2006-04-13 02:01:40 +00:00
|
|
|
ImpactCount++;
|
2006-04-12 01:50:09 +00:00
|
|
|
}
|
|
|
|
|
2006-04-13 02:01:40 +00:00
|
|
|
DImpactDecal::DImpactDecal (fixed_t z)
|
|
|
|
: DBaseDecal (STAT_AUTODECAL, z)
|
2006-04-12 01:50:09 +00:00
|
|
|
{
|
2006-04-13 02:01:40 +00:00
|
|
|
ImpactCount++;
|
2006-04-12 01:50:09 +00:00
|
|
|
}
|
|
|
|
|
2006-04-13 02:01:40 +00:00
|
|
|
void DImpactDecal::CheckMax ()
|
2006-04-12 01:50:09 +00:00
|
|
|
{
|
2006-04-13 02:01:40 +00:00
|
|
|
if (ImpactCount >= cl_maxdecals)
|
2006-04-12 01:50:09 +00:00
|
|
|
{
|
2006-04-13 02:01:40 +00:00
|
|
|
DThinker *thinker = DThinker::FirstThinker (STAT_AUTODECAL);
|
|
|
|
if (thinker != NULL)
|
|
|
|
{
|
|
|
|
thinker->Destroy();
|
|
|
|
}
|
2006-04-12 01:50:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DImpactDecal *DImpactDecal::StaticCreate (const char *name, fixed_t x, fixed_t y, fixed_t z, side_t *wall, PalEntry color)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-04-12 01:50:09 +00:00
|
|
|
if (cl_maxdecals > 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-04-12 01:50:09 +00:00
|
|
|
const FDecalTemplate *tpl = DecalLibrary.GetDecalByName (name);
|
|
|
|
|
|
|
|
if (tpl != NULL && (tpl = tpl->GetDecal()) != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-04-12 01:50:09 +00:00
|
|
|
return StaticCreate (tpl, x, y, z, wall, color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
DImpactDecal *DImpactDecal::StaticCreate (const FDecalTemplate *tpl, fixed_t x, fixed_t y, fixed_t z, side_t *wall, PalEntry color)
|
|
|
|
{
|
|
|
|
DImpactDecal *decal = NULL;
|
|
|
|
if (tpl != NULL && cl_maxdecals > 0 && !(wall->Flags & WALLF_NOAUTODECALS))
|
|
|
|
{
|
|
|
|
if (tpl->LowerDecal)
|
|
|
|
{
|
2006-05-04 12:40:39 +00:00
|
|
|
int lowercolor = color;
|
|
|
|
const FDecalTemplate * tpl_low = tpl->LowerDecal->GetDecal();
|
|
|
|
|
|
|
|
// If the default color of the lower decal is the same as the main decal's
|
|
|
|
// apply the custom color as well.
|
|
|
|
if (tpl->ShadeColor == tpl_low->ShadeColor) lowercolor=0;
|
|
|
|
StaticCreate (tpl_low, x, y, z, wall, lowercolor);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2006-04-13 02:01:40 +00:00
|
|
|
DImpactDecal::CheckMax();
|
|
|
|
decal = new DImpactDecal (z);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-06-15 18:36:26 +00:00
|
|
|
FTextureID stickypic = decal->StickToWall (wall, x, y);
|
2006-02-24 04:48:15 +00:00
|
|
|
FTexture *tex = TexMan[stickypic];
|
|
|
|
|
|
|
|
if (tex != NULL && tex->bNoDecals)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-04-12 01:50:09 +00:00
|
|
|
if (decal == NULL)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-04-13 02:01:40 +00:00
|
|
|
tpl->ApplyToDecal (decal, wall);
|
2006-04-12 01:50:09 +00:00
|
|
|
if (color != 0)
|
|
|
|
{
|
|
|
|
decal->SetShade (color.r, color.g, color.b);
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-06-15 18:36:26 +00:00
|
|
|
if (!cl_spreaddecals || !decal->PicNum.isValid())
|
2006-04-12 01:50:09 +00:00
|
|
|
{
|
|
|
|
return decal;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-04-12 01:50:09 +00:00
|
|
|
// Spread decal to nearby walls if it does not all fit on this one
|
2006-04-13 02:01:40 +00:00
|
|
|
decal->Spread (tpl, wall, x, y, z);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2006-04-12 01:50:09 +00:00
|
|
|
return decal;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-04-12 01:50:09 +00:00
|
|
|
DBaseDecal *DImpactDecal::CloneSelf (const FDecalTemplate *tpl, fixed_t ix, fixed_t iy, fixed_t iz, side_t *wall) const
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-04-13 02:01:40 +00:00
|
|
|
DImpactDecal::CheckMax();
|
|
|
|
DImpactDecal *decal = new DImpactDecal(iz);
|
2006-04-12 01:50:09 +00:00
|
|
|
if (decal != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-04-13 02:01:40 +00:00
|
|
|
decal->StickToWall (wall, ix, iy);
|
|
|
|
tpl->ApplyToDecal (decal, wall);
|
2006-04-12 01:50:09 +00:00
|
|
|
decal->AlphaColor = AlphaColor;
|
|
|
|
decal->RenderFlags = (decal->RenderFlags & RF_DECALMASK) |
|
|
|
|
(this->RenderFlags & ~RF_DECALMASK);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2006-04-12 01:50:09 +00:00
|
|
|
return decal;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-04-12 01:50:09 +00:00
|
|
|
void DImpactDecal::Destroy ()
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
ImpactCount--;
|
|
|
|
Super::Destroy ();
|
|
|
|
}
|
|
|
|
|
|
|
|
CCMD (countdecals)
|
|
|
|
{
|
|
|
|
Printf ("%d impact decals\n", ImpactCount);
|
|
|
|
}
|
|
|
|
|
|
|
|
CCMD (countdecalsreal)
|
|
|
|
{
|
2006-04-13 02:01:40 +00:00
|
|
|
TThinkerIterator<DImpactDecal> iterator (STAT_AUTODECAL);
|
2006-02-24 04:48:15 +00:00
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
while (iterator.Next())
|
|
|
|
count++;
|
|
|
|
|
|
|
|
Printf ("Counted %d impact decals\n", count);
|
|
|
|
}
|
|
|
|
|
|
|
|
CCMD (spray)
|
|
|
|
{
|
- Added the ACS commands
ReplaceTextures (str old_texture, str new_texture, optional bool not_lower,
optional bool not_mid, optional bool not_upper, optional bool not_floor,
optional bool not_ceiling); and
SectorDamage (int tag, int amount, str type, bool players_only, bool in_air,
str protection_item, bool subclasses_okay);
- Added the vid_nowidescreen cvar to disable widescreen aspect ratio
correction. When this is enabled, the only display ratio available is 4:3
(and 5:4 if vid_tft is set).
- Added support for setting an actor's damage property to an expression
through decorate. Just enclose it within parentheses, and the expression
will be evaluated exactly as-is without the normal Doom damage calculation.
So if you want something that does exactly 6 damage, use a "Damage (6)"
property. To deal normal Doom missile damage, you can use
"Damage (random(1,8)*6)" instead of "Damage 6".
- Moved InvFirst and InvSel into APlayerPawn so that they can be consistantly
maintained by ObtainInventory.
SVN r288 (trunk)
2006-08-12 02:30:57 +00:00
|
|
|
if (who == NULL || argv.argc() < 2)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
Printf ("Usage: spray <decal>\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-04-21 05:44:21 +00:00
|
|
|
Net_WriteByte (DEM_SPRAY);
|
|
|
|
Net_WriteString (argv[1]);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2006-04-12 01:50:09 +00:00
|
|
|
|
|
|
|
class ADecal : public AActor
|
|
|
|
{
|
2008-08-08 22:52:04 +00:00
|
|
|
DECLARE_CLASS (ADecal, AActor);
|
2006-04-12 01:50:09 +00:00
|
|
|
public:
|
|
|
|
void BeginPlay ();
|
|
|
|
};
|
|
|
|
|
2008-08-08 22:52:04 +00:00
|
|
|
IMPLEMENT_CLASS (ADecal)
|
2006-04-12 01:50:09 +00:00
|
|
|
|
|
|
|
void ADecal::BeginPlay ()
|
|
|
|
{
|
2006-04-13 02:01:40 +00:00
|
|
|
const FDecalTemplate *tpl;
|
|
|
|
FTraceResults trace;
|
|
|
|
DBaseDecal *decal;
|
|
|
|
side_t *wall;
|
2006-04-12 01:50:09 +00:00
|
|
|
|
2006-04-13 02:01:40 +00:00
|
|
|
Super::BeginPlay ();
|
2006-04-12 01:50:09 +00:00
|
|
|
|
2008-05-11 21:16:32 +00:00
|
|
|
int decalid = args[0] + (args[1] << 8); // [KS] High byte for decals.
|
|
|
|
|
2006-04-13 02:01:40 +00:00
|
|
|
// If no decal is specified, don't try to create one.
|
2008-05-11 21:16:32 +00:00
|
|
|
if (decalid != 0 && (tpl = DecalLibrary.GetDecalByNum (decalid)) != 0)
|
2006-04-12 01:50:09 +00:00
|
|
|
{
|
2008-06-15 18:36:26 +00:00
|
|
|
if (!tpl->PicNum.Exists())
|
2006-04-13 02:01:40 +00:00
|
|
|
{
|
2006-09-14 00:02:31 +00:00
|
|
|
Printf("Decal actor at (%d,%d) does not have a valid texture\n", x>>FRACBITS, y>>FRACBITS);
|
2006-06-21 20:45:19 +00:00
|
|
|
|
2006-04-13 02:01:40 +00:00
|
|
|
}
|
|
|
|
else
|
2006-04-12 01:50:09 +00:00
|
|
|
{
|
2006-06-21 20:45:19 +00:00
|
|
|
// Look for a wall within 64 units behind the actor. If none can be
|
|
|
|
// found, then no decal is created, and this actor is destroyed
|
|
|
|
// without effectively doing anything.
|
|
|
|
Trace (x, y, z, Sector,
|
|
|
|
finecosine[(angle+ANGLE_180)>>ANGLETOFINESHIFT],
|
|
|
|
finesine[(angle+ANGLE_180)>>ANGLETOFINESHIFT], 0,
|
|
|
|
64*FRACUNIT, 0, 0, NULL, trace, TRACE_NoSky);
|
|
|
|
|
|
|
|
if (trace.HitType == TRACE_HitWall)
|
|
|
|
{
|
|
|
|
decal = new DBaseDecal (this);
|
|
|
|
wall = sides + trace.Line->sidenum[trace.Side];
|
|
|
|
decal->StickToWall (wall, trace.X, trace.Y);
|
|
|
|
tpl->ApplyToDecal (decal, wall);
|
|
|
|
// Spread decal to nearby walls if it does not all fit on this one
|
|
|
|
if (cl_spreaddecals)
|
|
|
|
{
|
|
|
|
decal->Spread (tpl, wall, trace.X, trace.Y, z);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-09-14 00:02:31 +00:00
|
|
|
DPrintf ("Could not find a wall to stick decal to at (%d,%d)\n", x>>FRACBITS, y>>FRACBITS);
|
2006-06-21 20:45:19 +00:00
|
|
|
}
|
2006-04-12 01:50:09 +00:00
|
|
|
}
|
|
|
|
}
|
2006-04-13 02:01:40 +00:00
|
|
|
else
|
2006-04-12 01:50:09 +00:00
|
|
|
{
|
2006-09-14 00:02:31 +00:00
|
|
|
DPrintf ("Decal actor at (%d,%d) does not have a good template\n", x>>FRACBITS, y>>FRACBITS);
|
2006-04-12 01:50:09 +00:00
|
|
|
}
|
2006-04-13 02:01:40 +00:00
|
|
|
// This actor doesn't need to stick around anymore.
|
|
|
|
Destroy();
|
2006-04-12 01:50:09 +00:00
|
|
|
}
|