mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2025-02-05 02:00:34 +03:00
Initial Mapbase MP branch port
This commit is contained in:
parent
54cca19672
commit
9d0253b543
59
mp/src/devtools/gcc9+support.cpp
Normal file
59
mp/src/devtools/gcc9+support.cpp
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
// compatibility with old ABI
|
||||||
|
#if __GNUC__ >= 9
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
extern "C" double __pow_finite(double a, double b)
|
||||||
|
{
|
||||||
|
return pow(a, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" double __log_finite(double a)
|
||||||
|
{
|
||||||
|
return log(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" double __exp_finite(double a)
|
||||||
|
{
|
||||||
|
return exp(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" double __atan2_finite(double a, double b)
|
||||||
|
{
|
||||||
|
return atan2(a, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" double __atan2f_finite(double a, double b)
|
||||||
|
{
|
||||||
|
return atan2f(a, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" float __powf_finite(float a, float b)
|
||||||
|
{
|
||||||
|
return powf(a, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" float __logf_finite(float a)
|
||||||
|
{
|
||||||
|
return logf(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" float __expf_finite(float a)
|
||||||
|
{
|
||||||
|
return expf(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" float __acosf_finite(float a)
|
||||||
|
{
|
||||||
|
return acosf(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" double __asin_finite(double a)
|
||||||
|
{
|
||||||
|
return asin(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" double __acos_finite(double a)
|
||||||
|
{
|
||||||
|
return acos(a);
|
||||||
|
}
|
||||||
|
#endif
|
@ -1,472 +1,15 @@
|
|||||||
#
|
SRCROOT?=..
|
||||||
# Base makefile for Linux.
|
|
||||||
#
|
|
||||||
# !!!!! Note to future editors !!!!!
|
|
||||||
#
|
|
||||||
# before you make changes, make sure you grok:
|
|
||||||
# 1. the difference between =, :=, +=, and ?=
|
|
||||||
# 2. how and when this base makefile gets included in the generated makefile(s)
|
|
||||||
# ( see http://www.gnu.org/software/make/manual/make.html#Flavors )
|
|
||||||
#
|
|
||||||
# Command line prefixes:
|
|
||||||
# - errors are ignored
|
|
||||||
# @ command is not printed to stdout before being executed
|
|
||||||
# + command is executed even if Make is invoked in "do not exec" mode
|
|
||||||
|
|
||||||
OS := $(shell uname)
|
THISFILE:=$(SRCROOT)/devtools/makefile_base_posix.mak
|
||||||
HOSTNAME := $(shell hostname)
|
MAKEFILE_BASE:=$(notdir $(THISFILE))
|
||||||
|
MAKEFILE_LINK:=$(THISFILE).link
|
||||||
|
|
||||||
-include $(SRCROOT)/devtools/steam_def.mak
|
-include $(MAKEFILE_LINK)
|
||||||
-include $(SRCROOT)/devtools/sourcesdk_def.mak
|
|
||||||
|
|
||||||
# To build with clang, set the following in your environment:
|
$(MAKEFILE_LINK): $(shell which $(CC)) $(THISFILE)
|
||||||
# CC = clang
|
if [ "$(shell printf "$(shell $(CC) -dumpversion)\n8" | sort -Vr | head -1)" = 8 ]; then \
|
||||||
# CXX = clang++
|
$(COMPILE.cpp) -o gcc9+support.o gcc9+support.c ;\
|
||||||
ifneq (,$(findstring clang,$(CXX)))
|
ln -sf $(MAKEFILE_BASE).default $@ ;\
|
||||||
CLANG_BUILD = 1
|
else \
|
||||||
endif
|
ln -sf $(MAKEFILE_BASE).gcc8 $@ ;\
|
||||||
|
fi
|
||||||
ifeq ($(OS),Darwin)
|
|
||||||
$(error This file should never be used for Mac - use base.xconfig)
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(CFG), release)
|
|
||||||
# With gcc 4.6.3, engine.so went from 7,383,765 to 8,429,109 when building with -O3.
|
|
||||||
# There also was no speed difference running at 1280x1024. May 2012, mikesart.
|
|
||||||
# tonyp: The size increase was likely caused by -finline-functions and -fipa-cp-clone getting switched on with -O3.
|
|
||||||
# -fno-omit-frame-pointer: need this for stack traces with perf.
|
|
||||||
OptimizerLevel_CompilerSpecific = -O2 -fno-strict-aliasing -ffast-math -fno-omit-frame-pointer -ftree-vectorize
|
|
||||||
ifeq ($(CLANG_BUILD),1)
|
|
||||||
# These aren't supported wit Clang 3.5. Need to remove when we update that.
|
|
||||||
OptimizerLevel_CompilerSpecific += -fpredictive-commoning -funswitch-loops
|
|
||||||
else
|
|
||||||
OptimizerLevel_CompilerSpecific += -fpredictive-commoning -funswitch-loops
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
OptimizerLevel_CompilerSpecific = -O0
|
|
||||||
#-O1 -finline-functions
|
|
||||||
endif
|
|
||||||
|
|
||||||
# CPPFLAGS == "c/c++ *preprocessor* flags" - not "cee-plus-plus flags"
|
|
||||||
ARCH_FLAGS =
|
|
||||||
BUILDING_MULTI_ARCH = 0
|
|
||||||
# Preserve cflags set in environment
|
|
||||||
ENV_CFLAGS := $(CFLAGS)
|
|
||||||
ENV_CXXFLAGS := $(CXXFLAGS)
|
|
||||||
CPPFLAGS = $(DEFINES) $(addprefix -I, $(abspath $(INCLUDEDIRS) ))
|
|
||||||
BASE_CFLAGS = $(ARCH_FLAGS) $(CPPFLAGS) $(WARN_FLAGS) -fvisibility=$(SymbolVisibility) $(OptimizerLevel) -pipe $(GCC_ExtraCompilerFlags) -Usprintf -Ustrncpy -UPROTECTED_THINGS_ENABLE
|
|
||||||
CFLAGS = $(BASE_CFLAGS) $(ENV_CFLAGS)
|
|
||||||
# In -std=gnu++0x mode we get lots of errors about "error: narrowing conversion". -fpermissive
|
|
||||||
# turns these into warnings in gcc, and -Wno-c++11-narrowing suppresses them entirely in clang 3.1+.
|
|
||||||
ifeq ($(CLANG_BUILD),1)
|
|
||||||
CXXFLAGS = $(BASE_CFLAGS) -std=gnu++0x -Wno-c++11-narrowing -Wno-dangling-else $(ENV_CXXFLAGS)
|
|
||||||
else
|
|
||||||
CXXFLAGS = $(BASE_CFLAGS) -std=gnu++0x -fpermissive $(ENV_CXXFLAGS)
|
|
||||||
endif
|
|
||||||
DEFINES += -DVPROF_LEVEL=1 -DGNUC -DNO_HOOK_MALLOC -DNO_MALLOC_OVERRIDE
|
|
||||||
|
|
||||||
## TODO: This cases build errors in cstrike/bin right now. Need to debug.
|
|
||||||
# This causes all filesystem interfaces to default to their 64bit versions on
|
|
||||||
# 32bit systems, which means we don't break on filesystems with inodes > 32bit.
|
|
||||||
# DEFINES += -D_FILE_OFFSET_BITS=64
|
|
||||||
|
|
||||||
LDFLAGS = $(CFLAGS) $(GCC_ExtraLinkerFlags) $(OptimizerLevel)
|
|
||||||
GENDEP_CXXFLAGS = -MMD -MP -MF $(@:.o=.P)
|
|
||||||
MAP_FLAGS =
|
|
||||||
Srv_GAMEOUTPUTFILE =
|
|
||||||
COPY_DLL_TO_SRV = 0
|
|
||||||
|
|
||||||
# We should always specify -Wl,--build-id, as documented at:
|
|
||||||
# http://linux.die.net/man/1/ld and http://fedoraproject.org/wiki/Releases/FeatureBuildId.http://fedoraproject.org/wiki/Releases/FeatureBuildId
|
|
||||||
LDFLAGS += -Wl,--build-id
|
|
||||||
|
|
||||||
#
|
|
||||||
# If we should be running in a chroot, check to see if we are. If not, then prefix everything with the
|
|
||||||
# required chroot
|
|
||||||
#
|
|
||||||
ifdef MAKE_CHROOT
|
|
||||||
export STEAM_RUNTIME_PATH := /usr
|
|
||||||
ifneq ("$(SCHROOT_CHROOT_NAME)", "$(CHROOT_NAME)")
|
|
||||||
$(info '$(SCHROOT_CHROOT_NAME)' is not '$(CHROOT_NAME)')
|
|
||||||
$(error This makefile should be run from within a chroot. 'schroot --chroot $(CHROOT_NAME) -- $(MAKE) $(MAKEFLAGS)')
|
|
||||||
endif
|
|
||||||
GCC_VER = -4.8
|
|
||||||
P4BIN = $(SRCROOT)/devtools/bin/linux/p4
|
|
||||||
CRYPTOPPDIR=ubuntu12_32_gcc48
|
|
||||||
else ifeq ($(USE_VALVE_BINDIR),1)
|
|
||||||
# Using /valve/bin directory.
|
|
||||||
export STEAM_RUNTIME_PATH ?= /valve
|
|
||||||
GCC_VER = -4.6
|
|
||||||
P4BIN = p4
|
|
||||||
CRYPTOPPDIR=linux32
|
|
||||||
else
|
|
||||||
# Not using chroot, use old steam-runtime. (gcc 4.6.3)
|
|
||||||
export STEAM_RUNTIME_PATH ?= /valve/steam-runtime
|
|
||||||
GCC_VER =
|
|
||||||
P4BIN = p4
|
|
||||||
CRYPTOPPDIR=ubuntu12_32
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(TARGET_PLATFORM),linux64)
|
|
||||||
MARCH_TARGET = core2
|
|
||||||
else
|
|
||||||
MARCH_TARGET = pentium4
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(USE_VALVE_BINDIR),1)
|
|
||||||
# On dedicated servers, some plugins depend on global variable symbols in addition to functions.
|
|
||||||
# So symbols like _Z16ClearMultiDamagev should show up when you do "nm server_srv.so" in TF2.
|
|
||||||
STRIP_FLAGS =
|
|
||||||
else
|
|
||||||
# Linux desktop client (or client/dedicated server in chroot).
|
|
||||||
STRIP_FLAGS = -x
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(CLANG_BUILD),1)
|
|
||||||
# Clang does not support -mfpmath=sse because it uses whatever
|
|
||||||
# instruction set extensions are available by default.
|
|
||||||
SSE_GEN_FLAGS = -msse2
|
|
||||||
else
|
|
||||||
SSE_GEN_FLAGS = -msse2 -mfpmath=sse
|
|
||||||
endif
|
|
||||||
|
|
||||||
CCACHE := $(SRCROOT)/devtools/bin/linux/ccache
|
|
||||||
|
|
||||||
ifeq ($(origin AR), default)
|
|
||||||
AR = $(STEAM_RUNTIME_PATH)/bin/ar crs
|
|
||||||
endif
|
|
||||||
ifeq ($(origin CC), default)
|
|
||||||
CC = $(CCACHE) $(STEAM_RUNTIME_PATH)/bin/gcc$(GCC_VER)
|
|
||||||
endif
|
|
||||||
ifeq ($(origin CXX), default)
|
|
||||||
CXX = $(CCACHE) $(STEAM_RUNTIME_PATH)/bin/g++$(GCC_VER)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Support ccache with clang. Add -Qunused-arguments to avoid excessive warnings due to
|
|
||||||
# a ccache quirk. Could also upgrade ccache.
|
|
||||||
# http://petereisentraut.blogspot.com/2011/05/ccache-and-clang.html
|
|
||||||
ifeq ($(CLANG_BUILD),1)
|
|
||||||
CC := $(CCACHE) $(CC) -Qunused-arguments -fcolor-diagnostics
|
|
||||||
CXX := $(CCACHE) $(CXX) -Qunused-arguments -fcolor-diagnostics
|
|
||||||
endif
|
|
||||||
LINK ?= $(CC)
|
|
||||||
|
|
||||||
ifeq ($(STEAM_BRANCH),1)
|
|
||||||
WARN_FLAGS = -Wall -Wextra -Wshadow -Wno-invalid-offsetof
|
|
||||||
else
|
|
||||||
WARN_FLAGS = -Wall -Wno-invalid-offsetof -Wno-multichar -Wno-overloaded-virtual
|
|
||||||
WARN_FLAGS += -Wno-write-strings
|
|
||||||
WARN_FLAGS += -Wno-unused-variable
|
|
||||||
WARN_FLAGS += -Wno-unused-but-set-variable
|
|
||||||
WARN_FLAGS += -Wno-unused-function
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(CLANG_BUILD),1)
|
|
||||||
# Clang specific flags
|
|
||||||
else ifeq ($(GCC_VER),-4.8)
|
|
||||||
WARN_FLAGS += -Wno-unused-local-typedefs
|
|
||||||
WARN_FLAGS += -Wno-unused-result
|
|
||||||
WARN_FLAGS += -Wno-narrowing
|
|
||||||
# WARN_FLAGS += -Wno-unused-function
|
|
||||||
endif
|
|
||||||
|
|
||||||
WARN_FLAGS += -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-value -Wno-missing-field-initializers
|
|
||||||
WARN_FLAGS += -Wno-sign-compare -Wno-reorder -Wno-invalid-offsetof -Wno-float-equal -Werror=return-type
|
|
||||||
WARN_FLAGS += -fdiagnostics-show-option -Wformat -Wformat-security
|
|
||||||
|
|
||||||
ifeq ($(TARGET_PLATFORM),linux64)
|
|
||||||
# nocona = pentium4 + 64bit + MMX, SSE, SSE2, SSE3 - no SSSE3 (that's three s's - added in core2)
|
|
||||||
ARCH_FLAGS += -march=$(MARCH_TARGET) -mtune=core2
|
|
||||||
LD_SO = ld-linux-x86_64.so.2
|
|
||||||
LIBSTDCXX := $(shell $(CXX) -print-file-name=libstdc++.a)
|
|
||||||
LIBSTDCXXPIC := $(shell $(CXX) -print-file-name=libstdc++-pic.a)
|
|
||||||
else
|
|
||||||
# pentium4 = MMX, SSE, SSE2 - no SSE3 (added in prescott) # -msse3 -mfpmath=sse
|
|
||||||
ARCH_FLAGS += -m32 -march=$(MARCH_TARGET) -mtune=core2 $(SSE_GEN_FLAGS)
|
|
||||||
LD_SO = ld-linux.so.2
|
|
||||||
LIBSTDCXX := $(shell $(CXX) $(ARCH_FLAGS) -print-file-name=libstdc++.so)
|
|
||||||
LIBSTDCXXPIC := $(shell $(CXX) $(ARCH_FLAGS) -print-file-name=libstdc++.so)
|
|
||||||
LDFLAGS += -m32
|
|
||||||
endif
|
|
||||||
|
|
||||||
GEN_SYM ?= $(SRCROOT)/devtools/gendbg.sh
|
|
||||||
ifeq ($(CFG),release)
|
|
||||||
STRIP ?= strip $(STRIP_FLAGS) -S
|
|
||||||
# CFLAGS += -ffunction-sections -fdata-sections
|
|
||||||
# LDFLAGS += -Wl,--gc-sections -Wl,--print-gc-sections
|
|
||||||
else
|
|
||||||
STRIP ?= true
|
|
||||||
endif
|
|
||||||
VSIGN ?= true
|
|
||||||
|
|
||||||
ifeq ($(SOURCE_SDK), 1)
|
|
||||||
Srv_GAMEOUTPUTFILE := $(GAMEOUTPUTFILE:.so=_srv.so)
|
|
||||||
COPY_DLL_TO_SRV := 1
|
|
||||||
endif
|
|
||||||
|
|
||||||
LINK_MAP_FLAGS = -Wl,-Map,$(@:.so=).map
|
|
||||||
|
|
||||||
SHLIBLDFLAGS = -shared $(LDFLAGS) -Wl,--no-undefined
|
|
||||||
|
|
||||||
_WRAP := -Xlinker --wrap=
|
|
||||||
PATHWRAP = $(_WRAP)fopen $(_WRAP)freopen $(_WRAP)open $(_WRAP)creat $(_WRAP)access $(_WRAP)__xstat \
|
|
||||||
$(_WRAP)stat $(_WRAP)lstat $(_WRAP)fopen64 $(_WRAP)open64 $(_WRAP)opendir $(_WRAP)__lxstat \
|
|
||||||
$(_WRAP)chmod $(_WRAP)chown $(_WRAP)lchown $(_WRAP)symlink $(_WRAP)link $(_WRAP)__lxstat64 \
|
|
||||||
$(_WRAP)mknod $(_WRAP)utimes $(_WRAP)unlink $(_WRAP)rename $(_WRAP)utime $(_WRAP)__xstat64 \
|
|
||||||
$(_WRAP)mount $(_WRAP)mkfifo $(_WRAP)mkdir $(_WRAP)rmdir $(_WRAP)scandir $(_WRAP)realpath
|
|
||||||
|
|
||||||
LIB_START_EXE = $(PATHWRAP) -static-libgcc -Wl,--start-group
|
|
||||||
LIB_END_EXE = -Wl,--end-group -lm -ldl $(LIBSTDCXX) -lpthread
|
|
||||||
|
|
||||||
LIB_START_SHLIB = $(PATHWRAP) -static-libgcc -Wl,--start-group
|
|
||||||
LIB_END_SHLIB = -Wl,--end-group -lm -ldl $(LIBSTDCXXPIC) -lpthread -l:$(LD_SO) -Wl,--version-script=$(SRCROOT)/devtools/version_script.linux.txt
|
|
||||||
|
|
||||||
#
|
|
||||||
# Profile-directed optimizations.
|
|
||||||
# Note: Last time these were tested 3/5/08, it actually slowed down the server benchmark by 5%!
|
|
||||||
#
|
|
||||||
# First, uncomment these, build, and test. It will generate .gcda and .gcno files where the .o files are.
|
|
||||||
# PROFILE_LINKER_FLAG=-fprofile-arcs
|
|
||||||
# PROFILE_COMPILER_FLAG=-fprofile-arcs
|
|
||||||
#
|
|
||||||
# Then, comment the above flags out again and rebuild with this flag uncommented:
|
|
||||||
# PROFILE_COMPILER_FLAG=-fprofile-use
|
|
||||||
#
|
|
||||||
|
|
||||||
#############################################################################
|
|
||||||
# The compiler command lne for each src code file to compile
|
|
||||||
#############################################################################
|
|
||||||
|
|
||||||
OBJ_DIR = ./obj_$(NAME)_$(TARGET_PLATFORM)$(TARGET_PLATFORM_EXT)/$(CFG)
|
|
||||||
CPP_TO_OBJ = $(CPPFILES:.cpp=.o)
|
|
||||||
CXX_TO_OBJ = $(CPP_TO_OBJ:.cxx=.o)
|
|
||||||
CC_TO_OBJ = $(CXX_TO_OBJ:.cc=.o)
|
|
||||||
MM_TO_OBJ = $(CC_TO_OBJ:.mm=.o)
|
|
||||||
C_TO_OBJ = $(MM_TO_OBJ:.c=.o)
|
|
||||||
OBJS = $(addprefix $(OBJ_DIR)/, $(notdir $(C_TO_OBJ)))
|
|
||||||
|
|
||||||
ifeq ($(MAKE_VERBOSE),1)
|
|
||||||
QUIET_PREFIX =
|
|
||||||
QUIET_ECHO_POSTFIX =
|
|
||||||
else
|
|
||||||
QUIET_PREFIX = @
|
|
||||||
QUIET_ECHO_POSTFIX = > /dev/null
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(MAKE_CC_VERBOSE),1)
|
|
||||||
CC += -v
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(CONFTYPE),lib)
|
|
||||||
LIB_File = $(OUTPUTFILE)
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(CONFTYPE),dll)
|
|
||||||
SO_File = $(OUTPUTFILE)
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(CONFTYPE),exe)
|
|
||||||
EXE_File = $(OUTPUTFILE)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# we generate dependencies as a side-effect of compilation now
|
|
||||||
GEN_DEP_FILE=
|
|
||||||
|
|
||||||
PRE_COMPILE_FILE =
|
|
||||||
|
|
||||||
POST_COMPILE_FILE =
|
|
||||||
|
|
||||||
ifeq ($(BUILDING_MULTI_ARCH),1)
|
|
||||||
SINGLE_ARCH_CXXFLAGS=$(subst -arch x86_64,,$(CXXFLAGS))
|
|
||||||
COMPILE_FILE = \
|
|
||||||
$(QUIET_PREFIX) \
|
|
||||||
echo "---- $(lastword $(subst /, ,$<)) as MULTIARCH----";\
|
|
||||||
mkdir -p $(OBJ_DIR) && \
|
|
||||||
$(CXX) $(SINGLE_ARCH_CXXFLAGS) $(GENDEP_CXXFLAGS) -o $@ -c $< && \
|
|
||||||
$(CXX) $(CXXFLAGS) -o $@ -c $<
|
|
||||||
else
|
|
||||||
COMPILE_FILE = \
|
|
||||||
$(QUIET_PREFIX) \
|
|
||||||
echo "---- $(lastword $(subst /, ,$<)) ----";\
|
|
||||||
mkdir -p $(OBJ_DIR) && \
|
|
||||||
$(CXX) $(CXXFLAGS) $(GENDEP_CXXFLAGS) -o $@ -c $<
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq "$(origin VALVE_NO_AUTO_P4)" "undefined"
|
|
||||||
P4_EDIT_START = chmod -R +w
|
|
||||||
P4_EDIT_END = || true
|
|
||||||
P4_REVERT_START = true
|
|
||||||
P4_REVERT_END =
|
|
||||||
else
|
|
||||||
ifndef P4_EDIT_CHANGELIST
|
|
||||||
# You can use an environment variable to specify what changelist to check the Linux Binaries out into. Normally the default
|
|
||||||
# setting is best, but here is an alternate example:
|
|
||||||
# export P4_EDIT_CHANGELIST_CMD="echo 1424335"
|
|
||||||
# ?= means that if P4_EDIT_CHANGELIST_CMD is already set it won't be changed.
|
|
||||||
P4_EDIT_CHANGELIST_CMD ?= $(P4BIN) changes -c `$(P4BIN) client -o | grep ^Client | cut -f 2` -s pending | fgrep 'POSIX Auto Checkout' | cut -d' ' -f 2 | tail -n 1
|
|
||||||
P4_EDIT_CHANGELIST := $(shell $(P4_EDIT_CHANGELIST_CMD))
|
|
||||||
endif
|
|
||||||
ifeq ($(P4_EDIT_CHANGELIST),)
|
|
||||||
# If we haven't found a changelist to check out to then create one. The name must match the one from a few
|
|
||||||
# lines above or else a new changelist will be created each time.
|
|
||||||
# Warning: the behavior of 'echo' is not consistent. In bash you need the "-e" option in order for \n to be
|
|
||||||
# interpreted as a line-feed, but in dash you do not, and if "-e" is passed along then it is printed, which
|
|
||||||
# confuses p4. So, if you run this command from the bash shell don't forget to add "-e" to the echo command.
|
|
||||||
P4_EDIT_CHANGELIST = $(shell echo -e "Change: new\nDescription: POSIX Auto Checkout" | $(P4BIN) change -i | cut -f 2 -d ' ')
|
|
||||||
endif
|
|
||||||
|
|
||||||
P4_EDIT_START := for f in
|
|
||||||
P4_EDIT_END := ; do if [ -n $$f ]; then if [ -d $$f ]; then find $$f -type f -print | $(P4BIN) -x - edit -c $(P4_EDIT_CHANGELIST); else $(P4BIN) edit -c $(P4_EDIT_CHANGELIST) $$f; fi; fi; done $(QUIET_ECHO_POSTFIX)
|
|
||||||
P4_REVERT_START := for f in
|
|
||||||
P4_REVERT_END := ; do if [ -n $$f ]; then if [ -d $$f ]; then find $$f -type f -print | $(P4BIN) -x - revert; else $(P4BIN) revert $$f; fi; fi; done $(QUIET_ECHO_POSTFIX)
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(CONFTYPE),dll)
|
|
||||||
all: $(OTHER_DEPENDENCIES) $(OBJS) $(GAMEOUTPUTFILE)
|
|
||||||
@echo $(GAMEOUTPUTFILE) $(QUIET_ECHO_POSTFIX)
|
|
||||||
else
|
|
||||||
all: $(OTHER_DEPENDENCIES) $(OBJS) $(OUTPUTFILE)
|
|
||||||
@echo $(OUTPUTFILE) $(QUIET_ECHO_POSTFIX)
|
|
||||||
endif
|
|
||||||
|
|
||||||
.PHONY: clean cleantargets cleanandremove rebuild relink RemoveOutputFile SingleFile
|
|
||||||
|
|
||||||
|
|
||||||
rebuild :
|
|
||||||
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) cleanandremove
|
|
||||||
$(MAKE) -f $(firstword $(MAKEFILE_LIST))
|
|
||||||
|
|
||||||
|
|
||||||
# Use the relink target to force to relink the project.
|
|
||||||
relink: RemoveOutputFile all
|
|
||||||
|
|
||||||
RemoveOutputFile:
|
|
||||||
rm -f $(OUTPUTFILE)
|
|
||||||
|
|
||||||
|
|
||||||
# This rule is so you can say "make SingleFile SingleFilename=/home/myname/valve_main/src/engine/language.cpp" and have it only build that file.
|
|
||||||
# It basically just translates the full filename to create a dependency on the appropriate .o file so it'll build that.
|
|
||||||
SingleFile : RemoveSingleFile $(OBJ_DIR)/$(basename $(notdir $(SingleFilename))).o
|
|
||||||
@echo ""
|
|
||||||
|
|
||||||
RemoveSingleFile:
|
|
||||||
$(QUIET_PREFIX) rm -f $(OBJ_DIR)/$(basename $(notdir $(SingleFilename))).o
|
|
||||||
|
|
||||||
clean:
|
|
||||||
ifneq "$(OBJ_DIR)" ""
|
|
||||||
$(QUIET_PREFIX) echo "rm -rf $(OBJ_DIR)"
|
|
||||||
$(QUIET_PREFIX) rm -rf $(OBJ_DIR)
|
|
||||||
endif
|
|
||||||
ifneq "$(OUTPUTFILE)" ""
|
|
||||||
$(QUIET_PREFIX) if [ -e $(OUTPUTFILE) ]; then \
|
|
||||||
echo "$(P4BIN) revert $(OUTPUTFILE)"; \
|
|
||||||
$(P4_REVERT_START) $(OUTPUTFILE) $(OUTPUTFILE)$(SYM_EXT) $(P4_REVERT_END); \
|
|
||||||
fi;
|
|
||||||
endif
|
|
||||||
ifneq "$(OTHER_DEPENDENCIES)" ""
|
|
||||||
$(QUIET_PREFIX) echo "rm -f $(OTHER_DEPENDENCIES)"
|
|
||||||
$(QUIET_PREFIX) rm -f $(OTHER_DEPENDENCIES)
|
|
||||||
endif
|
|
||||||
ifneq "$(GAMEOUTPUTFILE)" ""
|
|
||||||
$(QUIET_PREFIX) echo "$(P4BIN) revert $(GAMEOUTPUTFILE)"
|
|
||||||
$(QUIET_PREFIX) $(P4_REVERT_START) $(GAMEOUTPUTFILE) $(GAMEOUTPUTFILE)$(SYM_EXT) $(P4_REVERT_END)
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
# Do the above cleaning, except with p4 edit and rm. Reason being ar crs adds and replaces obj files to the
|
|
||||||
# archive. However if you've renamed or deleted a source file, $(AR) won't remove it. This can leave
|
|
||||||
# us with archive files that have extra unused symbols, and also potentially cause compilation errors
|
|
||||||
# when you rename a file and have many duplicate symbols.
|
|
||||||
cleanandremove:
|
|
||||||
ifneq "$(OBJ_DIR)" ""
|
|
||||||
$(QUIET_PREFIX) echo "rm -rf $(OBJ_DIR)"
|
|
||||||
$(QUIET_PREFIX) -rm -rf $(OBJ_DIR)
|
|
||||||
endif
|
|
||||||
ifneq "$(OUTPUTFILE)" ""
|
|
||||||
$(QUIET_PREFIX) if [ -e $(OUTPUTFILE) ]; then \
|
|
||||||
echo "$(P4BIN) edit and rm -f $(OUTPUTFILE) $(OUTPUTFILE)$(SYM_EXT)"; \
|
|
||||||
$(P4_EDIT_START) $(OUTPUTFILE) $(OUTPUTFILE)$(SYM_EXT) $(P4_EDIT_END); \
|
|
||||||
fi;
|
|
||||||
$(QUIET_PREFIX) -rm -f $(OUTPUTFILE) $(OUTPUTFILE)$(SYM_EXT);
|
|
||||||
endif
|
|
||||||
ifneq "$(OTHER_DEPENDENCIES)" ""
|
|
||||||
$(QUIET_PREFIX) echo "rm -f $(OTHER_DEPENDENCIES)"
|
|
||||||
$(QUIET_PREFIX) -rm -f $(OTHER_DEPENDENCIES)
|
|
||||||
endif
|
|
||||||
ifneq "$(GAMEOUTPUTFILE)" ""
|
|
||||||
$(QUIET_PREFIX) echo "$(P4BIN) edit and rm -f $(GAMEOUTPUTFILE) $(GAMEOUTPUTFILE)$(SYM_EXT)"
|
|
||||||
$(QUIET_PREFIX) $(P4_EDIT_START) $(GAMEOUTPUTFILE) $(GAMEOUTPUTFILE)$(SYM_EXT) $(P4_EDIT_END)
|
|
||||||
$(QUIET_PREFIX) -rm -f $(GAMEOUTPUTFILE)
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
# This just deletes the final targets so it'll do a relink next time we build.
|
|
||||||
cleantargets:
|
|
||||||
$(QUIET_PREFIX) rm -f $(OUTPUTFILE) $(GAMEOUTPUTFILE)
|
|
||||||
|
|
||||||
|
|
||||||
$(LIB_File): $(OTHER_DEPENDENCIES) $(OBJS)
|
|
||||||
$(QUIET_PREFIX) -$(P4_EDIT_START) $(LIB_File) $(P4_EDIT_END);
|
|
||||||
$(QUIET_PREFIX) $(AR) $(LIB_File) $(OBJS) $(LIBFILES);
|
|
||||||
|
|
||||||
SO_GameOutputFile = $(GAMEOUTPUTFILE)
|
|
||||||
|
|
||||||
# Remove the target before installing a file over it; this prevents existing
|
|
||||||
# instances of the game from crashing due to the overwrite.
|
|
||||||
$(SO_GameOutputFile): $(SO_File)
|
|
||||||
$(QUIET_PREFIX) \
|
|
||||||
$(P4_EDIT_START) $(GAMEOUTPUTFILE) $(P4_EDIT_END) && \
|
|
||||||
echo "----" $(QUIET_ECHO_POSTFIX);\
|
|
||||||
echo "---- COPYING TO $@ [$(CFG)] ----";\
|
|
||||||
echo "----" $(QUIET_ECHO_POSTFIX);
|
|
||||||
$(QUIET_PREFIX) -$(P4_EDIT_START) $(GAMEOUTPUTFILE) $(P4_EDIT_END);
|
|
||||||
$(QUIET_PREFIX) -mkdir -p `dirname $(GAMEOUTPUTFILE)` > /dev/null;
|
|
||||||
$(QUIET_PREFIX) rm -f $(GAMEOUTPUTFILE) $(QUIET_ECHO_POSTFIX);
|
|
||||||
$(QUIET_PREFIX) cp -v $(OUTPUTFILE) $(GAMEOUTPUTFILE) $(QUIET_ECHO_POSTFIX);
|
|
||||||
$(QUIET_PREFIX) -$(P4_EDIT_START) $(GAMEOUTPUTFILE)$(SYM_EXT) $(P4_EDIT_END);
|
|
||||||
$(QUIET_PREFIX) $(GEN_SYM) $(GAMEOUTPUTFILE);
|
|
||||||
$(QUIET_PREFIX) -$(STRIP) $(GAMEOUTPUTFILE);
|
|
||||||
$(QUIET_PREFIX) $(VSIGN) -signvalve $(GAMEOUTPUTFILE);
|
|
||||||
$(QUIET_PREFIX) if [ "$(COPY_DLL_TO_SRV)" = "1" ]; then\
|
|
||||||
echo "----" $(QUIET_ECHO_POSTFIX);\
|
|
||||||
echo "---- COPYING TO $(Srv_GAMEOUTPUTFILE) ----";\
|
|
||||||
echo "----" $(QUIET_ECHO_POSTFIX);\
|
|
||||||
cp -v $(GAMEOUTPUTFILE) $(Srv_GAMEOUTPUTFILE) $(QUIET_ECHO_POSTFIX);\
|
|
||||||
cp -v $(GAMEOUTPUTFILE)$(SYM_EXT) $(Srv_GAMEOUTPUTFILE)$(SYM_EXT) $(QUIET_ECHO_POSTFIX);\
|
|
||||||
fi;
|
|
||||||
$(QUIET_PREFIX) if [ "$(IMPORTLIBRARY)" != "" ]; then\
|
|
||||||
echo "----" $(QUIET_ECHO_POSTFIX);\
|
|
||||||
echo "---- COPYING TO IMPORT LIBRARY $(IMPORTLIBRARY) ----";\
|
|
||||||
echo "----" $(QUIET_ECHO_POSTFIX);\
|
|
||||||
$(P4_EDIT_START) $(IMPORTLIBRARY) $(P4_EDIT_END) && \
|
|
||||||
mkdir -p `dirname $(IMPORTLIBRARY)` > /dev/null && \
|
|
||||||
cp -v $(OUTPUTFILE) $(IMPORTLIBRARY); \
|
|
||||||
fi;
|
|
||||||
|
|
||||||
|
|
||||||
$(SO_File): $(OTHER_DEPENDENCIES) $(OBJS) $(LIBFILENAMES)
|
|
||||||
$(QUIET_PREFIX) \
|
|
||||||
echo "----" $(QUIET_ECHO_POSTFIX);\
|
|
||||||
echo "---- LINKING $@ [$(CFG)] ----";\
|
|
||||||
echo "----" $(QUIET_ECHO_POSTFIX);\
|
|
||||||
\
|
|
||||||
$(LINK) $(LINK_MAP_FLAGS) $(SHLIBLDFLAGS) $(PROFILE_LINKER_FLAG) -o $(OUTPUTFILE) $(LIB_START_SHLIB) $(OBJS) $(LIBFILES) $(SystemLibraries) $(LIB_END_SHLIB);
|
|
||||||
$(VSIGN) -signvalve $(OUTPUTFILE);
|
|
||||||
|
|
||||||
|
|
||||||
$(EXE_File) : $(OTHER_DEPENDENCIES) $(OBJS) $(LIBFILENAMES)
|
|
||||||
$(QUIET_PREFIX) \
|
|
||||||
echo "----" $(QUIET_ECHO_POSTFIX);\
|
|
||||||
echo "---- LINKING EXE $@ [$(CFG)] ----";\
|
|
||||||
echo "----" $(QUIET_ECHO_POSTFIX);\
|
|
||||||
\
|
|
||||||
$(P4_EDIT_START) $(OUTPUTFILE) $(P4_EDIT_END);\
|
|
||||||
$(LINK) $(LINK_MAP_FLAGS) $(LDFLAGS) $(PROFILE_LINKER_FLAG) -o $(OUTPUTFILE) $(LIB_START_EXE) $(OBJS) $(LIBFILES) $(SystemLibraries) $(LIB_END_EXE);
|
|
||||||
$(QUIET_PREFIX) -$(P4_EDIT_START) $(OUTPUTFILE)$(SYM_EXT) $(P4_EDIT_END);
|
|
||||||
$(QUIET_PREFIX) $(GEN_SYM) $(OUTPUTFILE);
|
|
||||||
$(QUIET_PREFIX) -$(STRIP) $(OUTPUTFILE);
|
|
||||||
$(QUIET_PREFIX) $(VSIGN) -signvalve $(OUTPUTFILE);
|
|
||||||
|
|
||||||
|
|
||||||
tags:
|
|
||||||
etags -a -C -o $(SRCROOT)/TAGS *.cpp *.cxx *.h *.hxx
|
|
||||||
|
509
mp/src/devtools/makefile_base_posix.mak.default
Normal file
509
mp/src/devtools/makefile_base_posix.mak.default
Normal file
@ -0,0 +1,509 @@
|
|||||||
|
#
|
||||||
|
# Base makefile for Linux and OSX
|
||||||
|
#
|
||||||
|
# !!!!! Note to future editors !!!!!
|
||||||
|
#
|
||||||
|
# before you make changes, make sure you grok:
|
||||||
|
# 1. the difference between =, :=, +=, and ?=
|
||||||
|
# 2. how and when this base makefile gets included in the generated makefile(s)
|
||||||
|
# ( see http://www.gnu.org/software/make/manual/make.html#Flavors )
|
||||||
|
#
|
||||||
|
# Command line prefixes:
|
||||||
|
# - errors are ignored
|
||||||
|
# @ command is not printed to stdout before being executed
|
||||||
|
# + command is executed even if Make is invoked in "do not exec" mode
|
||||||
|
|
||||||
|
OS := $(shell uname)
|
||||||
|
HOSTNAME := $(shell hostname)
|
||||||
|
|
||||||
|
-include $(SRCROOT)/devtools/steam_def.mak
|
||||||
|
-include $(SRCROOT)/devtools/sourcesdk_def.mak
|
||||||
|
|
||||||
|
# To build with clang, set the following in your environment:
|
||||||
|
# CC = clang
|
||||||
|
# CXX = clang++
|
||||||
|
|
||||||
|
ifeq ($(CFG), release)
|
||||||
|
# With gcc 4.6.3, engine.so went from 7,383,765 to 8,429,109 when building with -O3.
|
||||||
|
# There also was no speed difference running at 1280x1024. May 2012, mikesart.
|
||||||
|
# tonyp: The size increase was likely caused by -finline-functions and -fipa-cp-clone getting switched on with -O3.
|
||||||
|
# -fno-omit-frame-pointer: need this for stack traces with perf.
|
||||||
|
OptimizerLevel_CompilerSpecific = -O2 -fno-strict-aliasing -ffast-math -fno-omit-frame-pointer -ftree-vectorize -fpredictive-commoning -funswitch-loops
|
||||||
|
else
|
||||||
|
OptimizerLevel_CompilerSpecific = -O0
|
||||||
|
#-O1 -finline-functions
|
||||||
|
endif
|
||||||
|
|
||||||
|
# CPPFLAGS == "c/c++ *preprocessor* flags" - not "cee-plus-plus flags"
|
||||||
|
ARCH_FLAGS =
|
||||||
|
BUILDING_MULTI_ARCH = 0
|
||||||
|
CPPFLAGS = $(DEFINES) $(addprefix -I, $(abspath $(INCLUDEDIRS) ))
|
||||||
|
CFLAGS = $(ARCH_FLAGS) $(CPPFLAGS) $(WARN_FLAGS) -fvisibility=$(SymbolVisibility) $(OptimizerLevel) -pipe $(GCC_ExtraCompilerFlags) -Usprintf -Ustrncpy -UPROTECTED_THINGS_ENABLE
|
||||||
|
# In -std=gnu++0x mode we get lots of errors about "error: narrowing conversion". -fpermissive
|
||||||
|
# turns these into warnings in gcc, and -Wno-c++11-narrowing suppresses them entirely in clang 3.1+.
|
||||||
|
ifeq ($(CXX),clang++)
|
||||||
|
CXXFLAGS = $(CFLAGS) -std=gnu++0x -Wno-c++11-narrowing -Wno-dangling-else
|
||||||
|
else
|
||||||
|
CXXFLAGS = $(CFLAGS) -std=gnu++0x -fpermissive
|
||||||
|
endif
|
||||||
|
DEFINES += -DVPROF_LEVEL=1 -DGNUC -DNO_HOOK_MALLOC -DNO_MALLOC_OVERRIDE
|
||||||
|
LDFLAGS = $(CFLAGS) $(GCC_ExtraLinkerFlags) $(OptimizerLevel)
|
||||||
|
GENDEP_CXXFLAGS = -MD -MP -MF $(@:.o=.P)
|
||||||
|
MAP_FLAGS =
|
||||||
|
Srv_GAMEOUTPUTFILE =
|
||||||
|
COPY_DLL_TO_SRV = 0
|
||||||
|
|
||||||
|
|
||||||
|
ifeq ($(STEAM_BRANCH),1)
|
||||||
|
WARN_FLAGS = -Wall -Wextra -Wshadow -Wno-invalid-offsetof
|
||||||
|
else
|
||||||
|
WARN_FLAGS = -Wno-write-strings -Wno-multichar
|
||||||
|
endif
|
||||||
|
|
||||||
|
WARN_FLAGS += -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-value -Wno-missing-field-initializers -Wno-sign-compare -Wno-reorder -Wno-invalid-offsetof -Wno-float-equal -Werror=return-type -fdiagnostics-show-option -Wformat -Wformat-security
|
||||||
|
|
||||||
|
|
||||||
|
ifeq ($(OS),Linux)
|
||||||
|
# We should always specify -Wl,--build-id, as documented at:
|
||||||
|
# http://linux.die.net/man/1/ld and http://fedoraproject.org/wiki/Releases/FeatureBuildId.http://fedoraproject.org/wiki/Releases/FeatureBuildId
|
||||||
|
LDFLAGS += -Wl,--build-id
|
||||||
|
# Set USE_VALVE_BINDIR to build with /Steam/tools/linux in the /valve/bin path.
|
||||||
|
# Dedicated server uses this.
|
||||||
|
ifeq ($(USE_VALVE_BINDIR),1)
|
||||||
|
# dedicated server flags
|
||||||
|
ifeq ($(TARGET_PLATFORM),linux64)
|
||||||
|
VALVE_BINDIR = /valve/bin64/
|
||||||
|
MARCH_TARGET = nocona
|
||||||
|
else
|
||||||
|
VALVE_BINDIR = /valve/bin/
|
||||||
|
MARCH_TARGET = pentium4
|
||||||
|
endif
|
||||||
|
STRIP_FLAGS =
|
||||||
|
else
|
||||||
|
# linux desktop client flags
|
||||||
|
VALVE_BINDIR =
|
||||||
|
# If the steam-runtime is available, use it. We should just default to using it when
|
||||||
|
# buildbot and everyone has a bit of time to get it installed.
|
||||||
|
ifneq "$(wildcard /valve/steam-runtime/bin/)" ""
|
||||||
|
# The steam-runtime is incompatible with clang at this point, so disable it
|
||||||
|
# if clang is enabled.
|
||||||
|
ifneq ($(CXX),clang++)
|
||||||
|
VALVE_BINDIR = /valve/steam-runtime/bin/
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
GCC_VER =
|
||||||
|
MARCH_TARGET = pentium4
|
||||||
|
# On dedicated servers, some plugins depend on global variable symbols in addition to functions.
|
||||||
|
# So symbols like _Z16ClearMultiDamagev should show up when you do "nm server_srv.so" in TF2.
|
||||||
|
STRIP_FLAGS = -x
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CXX),clang++)
|
||||||
|
# Clang does not support -mfpmath=sse because it uses whatever
|
||||||
|
# instruction set extensions are available by default.
|
||||||
|
SSE_GEN_FLAGS = -msse2
|
||||||
|
else
|
||||||
|
SSE_GEN_FLAGS = -msse2 -mfpmath=sse
|
||||||
|
endif
|
||||||
|
|
||||||
|
CCACHE := $(SRCROOT)/devtools/bin/linux/ccache
|
||||||
|
|
||||||
|
ifeq ($(origin GCC_VER), undefined)
|
||||||
|
GCC_VER=-4.6
|
||||||
|
endif
|
||||||
|
ifeq ($(origin AR), default)
|
||||||
|
AR = $(VALVE_BINDIR)ar crs
|
||||||
|
endif
|
||||||
|
ifeq ($(origin CC),default)
|
||||||
|
CC = $(CCACHE) $(VALVE_BINDIR)gcc$(GCC_VER)
|
||||||
|
endif
|
||||||
|
ifeq ($(origin CXX), default)
|
||||||
|
CXX = $(CCACHE) $(VALVE_BINDIR)g++$(GCC_VER)
|
||||||
|
endif
|
||||||
|
# Support ccache with clang. Add -Qunused-arguments to avoid excessive warnings due to
|
||||||
|
# a ccache quirk. Could also upgrade ccache.
|
||||||
|
# http://petereisentraut.blogspot.com/2011/05/ccache-and-clang.html
|
||||||
|
ifeq ($(CC),clang)
|
||||||
|
CC = $(CCACHE) $(VALVE_BINDIR)clang -Qunused-arguments
|
||||||
|
endif
|
||||||
|
ifeq ($(CXX),clang++)
|
||||||
|
CXX = $(CCACHE) $(VALVE_BINDIR)clang++ -Qunused-arguments
|
||||||
|
endif
|
||||||
|
LINK ?= $(CC)
|
||||||
|
|
||||||
|
ifeq ($(TARGET_PLATFORM),linux64)
|
||||||
|
# nocona = pentium4 + 64bit + MMX, SSE, SSE2, SSE3 - no SSSE3 (that's three s's - added in core2)
|
||||||
|
ARCH_FLAGS += -march=$(MARCH_TARGET) -mtune=core2
|
||||||
|
LD_SO = ld-linux-x86_64.so.2
|
||||||
|
LIBSTDCXX := $(shell $(CXX) -print-file-name=libstdc++.a)
|
||||||
|
LIBSTDCXXPIC := $(shell $(CXX) -print-file-name=libstdc++-pic.a)
|
||||||
|
else
|
||||||
|
# pentium4 = MMX, SSE, SSE2 - no SSE3 (added in prescott) # -msse3 -mfpmath=sse
|
||||||
|
ARCH_FLAGS += -m32 -march=$(MARCH_TARGET) -mtune=core2 $(SSE_GEN_FLAGS)
|
||||||
|
LD_SO = ld-linux.so.2
|
||||||
|
LIBSTDCXX := $(shell $(CXX) $(ARCH_FLAGS) -print-file-name=libstdc++.so)
|
||||||
|
LIBSTDCXXPIC := $(shell $(CXX) $(ARCH_FLAGS) -print-file-name=libstdc++.so)
|
||||||
|
LDFLAGS += -m32
|
||||||
|
endif
|
||||||
|
|
||||||
|
GEN_SYM ?= $(SRCROOT)/devtools/gendbg.sh
|
||||||
|
ifeq ($(CFG),release)
|
||||||
|
STRIP ?= strip $(STRIP_FLAGS) -S
|
||||||
|
# CFLAGS += -ffunction-sections -fdata-sections
|
||||||
|
# LDFLAGS += -Wl,--gc-sections -Wl,--print-gc-sections
|
||||||
|
else
|
||||||
|
STRIP ?= true
|
||||||
|
endif
|
||||||
|
VSIGN ?= true
|
||||||
|
|
||||||
|
ifeq ($(SOURCE_SDK), 1)
|
||||||
|
Srv_GAMEOUTPUTFILE := $(GAMEOUTPUTFILE:.so=_srv.so)
|
||||||
|
COPY_DLL_TO_SRV := 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
LINK_MAP_FLAGS = -Wl,-Map,$(@:.so=).map
|
||||||
|
|
||||||
|
SHLIBLDFLAGS = -shared $(LDFLAGS) -Wl,--no-undefined
|
||||||
|
|
||||||
|
_WRAP := -Xlinker --wrap=
|
||||||
|
PATHWRAP = $(_WRAP)fopen $(_WRAP)freopen $(_WRAP)open $(_WRAP)creat $(_WRAP)access $(_WRAP)__xstat \
|
||||||
|
$(_WRAP)stat $(_WRAP)lstat $(_WRAP)fopen64 $(_WRAP)open64 $(_WRAP)opendir $(_WRAP)__lxstat \
|
||||||
|
$(_WRAP)chmod $(_WRAP)chown $(_WRAP)lchown $(_WRAP)symlink $(_WRAP)link $(_WRAP)__lxstat64 \
|
||||||
|
$(_WRAP)mknod $(_WRAP)utimes $(_WRAP)unlink $(_WRAP)rename $(_WRAP)utime $(_WRAP)__xstat64 \
|
||||||
|
$(_WRAP)mount $(_WRAP)mkfifo $(_WRAP)mkdir $(_WRAP)rmdir $(_WRAP)scandir $(_WRAP)realpath
|
||||||
|
|
||||||
|
LIB_START_EXE = $(PATHWRAP) -static-libgcc -Wl,--start-group
|
||||||
|
LIB_END_EXE = -Wl,--end-group -lm -ldl $(LIBSTDCXX) -lpthread
|
||||||
|
|
||||||
|
LIB_START_SHLIB = $(PATHWRAP) -static-libgcc -Wl,--start-group
|
||||||
|
LIB_END_SHLIB = -Wl,--end-group -lm -ldl $(LIBSTDCXXPIC) -lpthread -l:$(LD_SO) -Wl,--version-script=$(SRCROOT)/devtools/version_script.linux.txt
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(OS),Darwin)
|
||||||
|
CCACHE := $(SRCROOT)/devtools/bin/osx32/ccache
|
||||||
|
MAC_SDK_VER ?= 10.6
|
||||||
|
MAC_SDK := macosx$(MAC_SDK_VER)
|
||||||
|
SYSROOT := $(shell xcodebuild -sdk $(MAC_SDK) -version Path)
|
||||||
|
|
||||||
|
ifneq ($(origin MAC_SDK_VER), file)
|
||||||
|
$(warning Attempting build with SDK version $(MAC_SDK_VER), only 10.6 is supported and recommended!)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(SYSROOT),)
|
||||||
|
FIRSTSDK := $(firstword $(sort $(shell xcodebuild -showsdks | grep macosx | sed 's/.*macosx//')))
|
||||||
|
$(error Could not find SDK version $(MAC_SDK_VER). Install and configure Xcode 4.3, or build with: make MAC_SDK_VER=$(FIRSTSDK))
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(origin CC), default)
|
||||||
|
# Test to see if you have a compiler in the right place, if you
|
||||||
|
# don't abort with an error
|
||||||
|
CLANG := $(shell xcrun -sdk $(MAC_SDK) -find clang)
|
||||||
|
ifeq ($(wildcard $(CLANG)),)
|
||||||
|
$(error Unable to find C compiler, install and configure Xcode 4.3)
|
||||||
|
endif
|
||||||
|
|
||||||
|
CC := $(CCACHE) $(CLANG) -Qunused-arguments
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(origin CXX), default)
|
||||||
|
CXXLANG := $(shell xcrun -sdk $(MAC_SDK) -find clang++)
|
||||||
|
ifeq ($(wildcard $(CXXLANG)),)
|
||||||
|
$(error Unable to find C++ compiler, install and configure Xcode 4.3)
|
||||||
|
endif
|
||||||
|
|
||||||
|
CXX := $(CCACHE) $(CXXLANG) -Qunused-arguments
|
||||||
|
endif
|
||||||
|
LINK ?= $(CXX)
|
||||||
|
|
||||||
|
ifeq ($(origin AR), default)
|
||||||
|
AR := $(shell xcrun -sdk $(MAC_SDK) -find libtool) -static -o
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(TARGET_PLATFORM),osx64)
|
||||||
|
ARCH_FLAGS += -arch x86_64 -m64 -march=core2
|
||||||
|
else ifeq (,$(findstring -arch x86_64,$(GCC_ExtraCompilerFlags)))
|
||||||
|
ARCH_FLAGS += -arch i386 -m32 -march=prescott -momit-leaf-frame-pointer -mtune=core2
|
||||||
|
else
|
||||||
|
# dirty hack to build a universal binary - don't specify the architecture
|
||||||
|
ARCH_FLAGS += -arch i386 -Xarch_i386 -march=prescott -Xarch_i386 -mtune=core2 -Xarch_i386 -momit-leaf-frame-pointer -Xarch_x86_64 -march=core2
|
||||||
|
endif
|
||||||
|
|
||||||
|
GEN_SYM ?= $(shell xcrun -sdk $(MAC_SDK) -find dsymutil)
|
||||||
|
ifeq ($(CFG),release)
|
||||||
|
STRIP ?= strip -S
|
||||||
|
else
|
||||||
|
STRIP ?= true
|
||||||
|
endif
|
||||||
|
ifeq ($(SOURCE_SDK), 1)
|
||||||
|
VSIGN ?= true
|
||||||
|
else
|
||||||
|
VSIGN ?= $(SRCROOT)/devtools/bin/vsign
|
||||||
|
endif
|
||||||
|
|
||||||
|
CPPFLAGS += -I$(SYSROOT)/usr/include/malloc
|
||||||
|
CFLAGS += -isysroot $(SYSROOT) -mmacosx-version-min=10.5 -fasm-blocks
|
||||||
|
|
||||||
|
LIB_START_EXE = -lm -ldl -lpthread
|
||||||
|
LIB_END_EXE =
|
||||||
|
|
||||||
|
LIB_START_SHLIB =
|
||||||
|
LIB_END_SHLIB =
|
||||||
|
|
||||||
|
SHLIBLDFLAGS = $(LDFLAGS) -bundle -flat_namespace -undefined suppress -Wl,-dead_strip -Wl,-no_dead_strip_inits_and_terms
|
||||||
|
|
||||||
|
ifeq (lib,$(findstring lib,$(GAMEOUTPUTFILE)))
|
||||||
|
SHLIBLDFLAGS = $(LDFLAGS) -dynamiclib -current_version 1.0 -compatibility_version 1.0 -install_name @rpath/$(basename $(notdir $(GAMEOUTPUTFILE))).dylib $(SystemLibraries) -Wl,-dead_strip -Wl,-no_dead_strip_inits_and_terms
|
||||||
|
endif
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
#
|
||||||
|
# Profile-directed optimizations.
|
||||||
|
# Note: Last time these were tested 3/5/08, it actually slowed down the server benchmark by 5%!
|
||||||
|
#
|
||||||
|
# First, uncomment these, build, and test. It will generate .gcda and .gcno files where the .o files are.
|
||||||
|
# PROFILE_LINKER_FLAG=-fprofile-arcs
|
||||||
|
# PROFILE_COMPILER_FLAG=-fprofile-arcs
|
||||||
|
#
|
||||||
|
# Then, comment the above flags out again and rebuild with this flag uncommented:
|
||||||
|
# PROFILE_COMPILER_FLAG=-fprofile-use
|
||||||
|
#
|
||||||
|
|
||||||
|
#############################################################################
|
||||||
|
# The compiler command lne for each src code file to compile
|
||||||
|
#############################################################################
|
||||||
|
|
||||||
|
OBJ_DIR = ./obj_$(NAME)_$(TARGET_PLATFORM)$(TARGET_PLATFORM_EXT)/$(CFG)
|
||||||
|
CPP_TO_OBJ = $(CPPFILES:.cpp=.o)
|
||||||
|
CXX_TO_OBJ = $(CPP_TO_OBJ:.cxx=.o)
|
||||||
|
CC_TO_OBJ = $(CXX_TO_OBJ:.cc=.o)
|
||||||
|
MM_TO_OBJ = $(CC_TO_OBJ:.mm=.o)
|
||||||
|
C_TO_OBJ = $(MM_TO_OBJ:.c=.o)
|
||||||
|
OBJS = $(addprefix $(OBJ_DIR)/, $(notdir $(C_TO_OBJ)))
|
||||||
|
|
||||||
|
ifeq ($(MAKE_VERBOSE),1)
|
||||||
|
QUIET_PREFIX =
|
||||||
|
QUIET_ECHO_POSTFIX =
|
||||||
|
else
|
||||||
|
QUIET_PREFIX = @
|
||||||
|
QUIET_ECHO_POSTFIX = > /dev/null
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(MAKE_CC_VERBOSE),1)
|
||||||
|
CC += -v
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFTYPE),lib)
|
||||||
|
LIB_File = $(OUTPUTFILE)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFTYPE),dll)
|
||||||
|
SO_File = $(OUTPUTFILE)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFTYPE),exe)
|
||||||
|
EXE_File = $(OUTPUTFILE)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# we generate dependencies as a side-effect of compilation now
|
||||||
|
GEN_DEP_FILE=
|
||||||
|
|
||||||
|
PRE_COMPILE_FILE =
|
||||||
|
|
||||||
|
POST_COMPILE_FILE =
|
||||||
|
|
||||||
|
ifeq ($(BUILDING_MULTI_ARCH),1)
|
||||||
|
SINGLE_ARCH_CXXFLAGS=$(subst -arch x86_64,,$(CXXFLAGS))
|
||||||
|
COMPILE_FILE = \
|
||||||
|
$(QUIET_PREFIX) \
|
||||||
|
echo "---- $(lastword $(subst /, ,$<)) as MULTIARCH----";\
|
||||||
|
mkdir -p $(OBJ_DIR) && \
|
||||||
|
$(CXX) $(SINGLE_ARCH_CXXFLAGS) $(GENDEP_CXXFLAGS) -o $@ -c $< && \
|
||||||
|
$(CXX) $(CXXFLAGS) -o $@ -c $<
|
||||||
|
else
|
||||||
|
COMPILE_FILE = \
|
||||||
|
$(QUIET_PREFIX) \
|
||||||
|
echo "---- $(lastword $(subst /, ,$<)) ----";\
|
||||||
|
mkdir -p $(OBJ_DIR) && \
|
||||||
|
$(CXX) $(CXXFLAGS) $(GENDEP_CXXFLAGS) -o $@ -c $<
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq "$(origin VALVE_NO_AUTO_P4)" "undefined"
|
||||||
|
P4_EDIT_START = chmod -R +w
|
||||||
|
P4_EDIT_END = || true
|
||||||
|
P4_REVERT_START = true
|
||||||
|
P4_REVERT_END =
|
||||||
|
else
|
||||||
|
ifndef P4_EDIT_CHANGELIST
|
||||||
|
# You can use an environment variable to specify what changelist to check the Linux Binaries out into. Normally the default
|
||||||
|
# setting is best, but here is an alternate example:
|
||||||
|
# export P4_EDIT_CHANGELIST_CMD="echo 1424335"
|
||||||
|
# ?= means that if P4_EDIT_CHANGELIST_CMD is already set it won't be changed.
|
||||||
|
P4_EDIT_CHANGELIST_CMD ?= p4 changes -c `p4 client -o | grep ^Client | cut -f 2` -s pending | fgrep 'POSIX Auto Checkout' | cut -d' ' -f 2 | tail -n 1
|
||||||
|
P4_EDIT_CHANGELIST := $(shell $(P4_EDIT_CHANGELIST_CMD))
|
||||||
|
endif
|
||||||
|
ifeq ($(P4_EDIT_CHANGELIST),)
|
||||||
|
# If we haven't found a changelist to check out to then create one. The name must match the one from a few
|
||||||
|
# lines above or else a new changelist will be created each time.
|
||||||
|
# Warning: the behavior of 'echo' is not consistent. In bash you need the "-e" option in order for \n to be
|
||||||
|
# interpreted as a line-feed, but in dash you do not, and if "-e" is passed along then it is printed, which
|
||||||
|
# confuses p4. So, if you run this command from the bash shell don't forget to add "-e" to the echo command.
|
||||||
|
P4_EDIT_CHANGELIST = $(shell echo "Change: new\nDescription: POSIX Auto Checkout" | p4 change -i | cut -f 2 -d ' ')
|
||||||
|
endif
|
||||||
|
|
||||||
|
P4_EDIT_START := for f in
|
||||||
|
P4_EDIT_END := ; do if [ -n $$f ]; then if [ -d $$f ]; then find $$f -type f -print | p4 -x - edit -c $(P4_EDIT_CHANGELIST); else p4 edit -c $(P4_EDIT_CHANGELIST) $$f; fi; fi; done $(QUIET_ECHO_POSTFIX)
|
||||||
|
P4_REVERT_START := for f in
|
||||||
|
P4_REVERT_END := ; do if [ -n $$f ]; then if [ -d $$f ]; then find $$f -type f -print | p4 -x - revert; else p4 revert $$f; fi; fi; done $(QUIET_ECHO_POSTFIX)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFTYPE),dll)
|
||||||
|
all: $(OTHER_DEPENDENCIES) $(OBJS) $(GAMEOUTPUTFILE)
|
||||||
|
@echo $(GAMEOUTPUTFILE) $(QUIET_ECHO_POSTFIX)
|
||||||
|
else
|
||||||
|
all: $(OTHER_DEPENDENCIES) $(OBJS) $(OUTPUTFILE)
|
||||||
|
@echo $(OUTPUTFILE) $(QUIET_ECHO_POSTFIX)
|
||||||
|
endif
|
||||||
|
|
||||||
|
.PHONY: clean cleantargets cleanandremove rebuild relink RemoveOutputFile SingleFile
|
||||||
|
|
||||||
|
|
||||||
|
rebuild :
|
||||||
|
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) cleanandremove
|
||||||
|
$(MAKE) -f $(firstword $(MAKEFILE_LIST))
|
||||||
|
|
||||||
|
|
||||||
|
# Use the relink target to force to relink the project.
|
||||||
|
relink: RemoveOutputFile all
|
||||||
|
|
||||||
|
RemoveOutputFile:
|
||||||
|
rm -f $(OUTPUTFILE)
|
||||||
|
|
||||||
|
|
||||||
|
# This rule is so you can say "make SingleFile SingleFilename=/home/myname/valve_main/src/engine/language.cpp" and have it only build that file.
|
||||||
|
# It basically just translates the full filename to create a dependency on the appropriate .o file so it'll build that.
|
||||||
|
SingleFile : RemoveSingleFile $(OBJ_DIR)/$(basename $(notdir $(SingleFilename))).o
|
||||||
|
@echo ""
|
||||||
|
|
||||||
|
RemoveSingleFile:
|
||||||
|
$(QUIET_PREFIX) rm -f $(OBJ_DIR)/$(basename $(notdir $(SingleFilename))).o
|
||||||
|
|
||||||
|
clean:
|
||||||
|
ifneq "$(OBJ_DIR)" ""
|
||||||
|
$(QUIET_PREFIX) echo "rm -rf $(OBJ_DIR)"
|
||||||
|
$(QUIET_PREFIX) rm -rf $(OBJ_DIR)
|
||||||
|
endif
|
||||||
|
ifneq "$(OUTPUTFILE)" ""
|
||||||
|
$(QUIET_PREFIX) if [ -e $(OUTPUTFILE) ]; then \
|
||||||
|
echo "p4 revert $(OUTPUTFILE)"; \
|
||||||
|
$(P4_REVERT_START) $(OUTPUTFILE) $(OUTPUTFILE)$(SYM_EXT) $(P4_REVERT_END); \
|
||||||
|
fi;
|
||||||
|
endif
|
||||||
|
ifneq "$(OTHER_DEPENDENCIES)" ""
|
||||||
|
$(QUIET_PREFIX) echo "rm -f $(OTHER_DEPENDENCIES)"
|
||||||
|
$(QUIET_PREFIX) rm -f $(OTHER_DEPENDENCIES)
|
||||||
|
endif
|
||||||
|
ifneq "$(GAMEOUTPUTFILE)" ""
|
||||||
|
$(QUIET_PREFIX) echo "p4 revert $(GAMEOUTPUTFILE)"
|
||||||
|
$(QUIET_PREFIX) $(P4_REVERT_START) $(GAMEOUTPUTFILE) $(GAMEOUTPUTFILE)$(SYM_EXT) $(P4_REVERT_END)
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
# Do the above cleaning, except with p4 edit and rm. Reason being ar crs adds and replaces obj files to the
|
||||||
|
# archive. However if you've renamed or deleted a source file, $(AR) won't remove it. This can leave
|
||||||
|
# us with archive files that have extra unused symbols, and also potentially cause compilation errors
|
||||||
|
# when you rename a file and have many duplicate symbols.
|
||||||
|
cleanandremove:
|
||||||
|
ifneq "$(OBJ_DIR)" ""
|
||||||
|
$(QUIET_PREFIX) echo "rm -rf $(OBJ_DIR)"
|
||||||
|
$(QUIET_PREFIX) -rm -rf $(OBJ_DIR)
|
||||||
|
endif
|
||||||
|
ifneq "$(OUTPUTFILE)" ""
|
||||||
|
$(QUIET_PREFIX) if [ -e $(OUTPUTFILE) ]; then \
|
||||||
|
echo "p4 edit and rm -f $(OUTPUTFILE) $(OUTPUTFILE)$(SYM_EXT)"; \
|
||||||
|
$(P4_EDIT_START) $(OUTPUTFILE) $(OUTPUTFILE)$(SYM_EXT) $(P4_EDIT_END); \
|
||||||
|
fi;
|
||||||
|
$(QUIET_PREFIX) -rm -f $(OUTPUTFILE) $(OUTPUTFILE)$(SYM_EXT);
|
||||||
|
endif
|
||||||
|
ifneq "$(OTHER_DEPENDENCIES)" ""
|
||||||
|
$(QUIET_PREFIX) echo "rm -f $(OTHER_DEPENDENCIES)"
|
||||||
|
$(QUIET_PREFIX) -rm -f $(OTHER_DEPENDENCIES)
|
||||||
|
endif
|
||||||
|
ifneq "$(GAMEOUTPUTFILE)" ""
|
||||||
|
$(QUIET_PREFIX) echo "p4 edit and rm -f $(GAMEOUTPUTFILE) $(GAMEOUTPUTFILE)$(SYM_EXT)"
|
||||||
|
$(QUIET_PREFIX) $(P4_EDIT_START) $(GAMEOUTPUTFILE) $(GAMEOUTPUTFILE)$(SYM_EXT) $(P4_EDIT_END)
|
||||||
|
$(QUIET_PREFIX) -rm -f $(GAMEOUTPUTFILE)
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
# This just deletes the final targets so it'll do a relink next time we build.
|
||||||
|
cleantargets:
|
||||||
|
$(QUIET_PREFIX) rm -f $(OUTPUTFILE) $(GAMEOUTPUTFILE)
|
||||||
|
|
||||||
|
|
||||||
|
$(LIB_File): $(OTHER_DEPENDENCIES) $(OBJS)
|
||||||
|
$(QUIET_PREFIX) -$(P4_EDIT_START) $(LIB_File) $(P4_EDIT_END);
|
||||||
|
$(QUIET_PREFIX) $(AR) $(LIB_File) $(OBJS) $(LIBFILES);
|
||||||
|
|
||||||
|
SO_GameOutputFile = $(GAMEOUTPUTFILE)
|
||||||
|
|
||||||
|
# Remove the target before installing a file over it; this prevents existing
|
||||||
|
# instances of the game from crashing due to the overwrite.
|
||||||
|
$(SO_GameOutputFile): $(SO_File)
|
||||||
|
$(QUIET_PREFIX) \
|
||||||
|
$(P4_EDIT_START) $(GAMEOUTPUTFILE) $(P4_EDIT_END) && \
|
||||||
|
echo "----" $(QUIET_ECHO_POSTFIX);\
|
||||||
|
echo "---- COPYING TO $@ [$(CFG)] ----";\
|
||||||
|
echo "----" $(QUIET_ECHO_POSTFIX);
|
||||||
|
$(QUIET_PREFIX) -$(P4_EDIT_START) $(GAMEOUTPUTFILE) $(P4_EDIT_END);
|
||||||
|
$(QUIET_PREFIX) -mkdir -p `dirname $(GAMEOUTPUTFILE)` > /dev/null;
|
||||||
|
$(QUIET_PREFIX) rm -f $(GAMEOUTPUTFILE) $(QUIET_ECHO_POSTFIX);
|
||||||
|
$(QUIET_PREFIX) cp -v $(OUTPUTFILE) $(GAMEOUTPUTFILE) $(QUIET_ECHO_POSTFIX);
|
||||||
|
$(QUIET_PREFIX) -$(P4_EDIT_START) $(GAMEOUTPUTFILE)$(SYM_EXT) $(P4_EDIT_END);
|
||||||
|
$(QUIET_PREFIX) $(GEN_SYM) $(GAMEOUTPUTFILE);
|
||||||
|
$(QUIET_PREFIX) -$(STRIP) $(GAMEOUTPUTFILE);
|
||||||
|
$(QUIET_PREFIX) $(VSIGN) -signvalve $(GAMEOUTPUTFILE);
|
||||||
|
$(QUIET_PREFIX) if [ "$(COPY_DLL_TO_SRV)" = "1" ]; then\
|
||||||
|
echo "----" $(QUIET_ECHO_POSTFIX);\
|
||||||
|
echo "---- COPYING TO $(Srv_GAMEOUTPUTFILE) ----";\
|
||||||
|
echo "----" $(QUIET_ECHO_POSTFIX);\
|
||||||
|
cp -v $(GAMEOUTPUTFILE) $(Srv_GAMEOUTPUTFILE) $(QUIET_ECHO_POSTFIX);\
|
||||||
|
cp -v $(GAMEOUTPUTFILE)$(SYM_EXT) $(Srv_GAMEOUTPUTFILE)$(SYM_EXT) $(QUIET_ECHO_POSTFIX);\
|
||||||
|
fi;
|
||||||
|
$(QUIET_PREFIX) if [ "$(IMPORTLIBRARY)" != "" ]; then\
|
||||||
|
echo "----" $(QUIET_ECHO_POSTFIX);\
|
||||||
|
echo "---- COPYING TO IMPORT LIBRARY $(IMPORTLIBRARY) ----";\
|
||||||
|
echo "----" $(QUIET_ECHO_POSTFIX);\
|
||||||
|
$(P4_EDIT_START) $(IMPORTLIBRARY) $(P4_EDIT_END) && \
|
||||||
|
mkdir -p `dirname $(IMPORTLIBRARY)` > /dev/null && \
|
||||||
|
cp -v $(OUTPUTFILE) $(IMPORTLIBRARY); \
|
||||||
|
fi;
|
||||||
|
|
||||||
|
|
||||||
|
$(SO_File): $(OTHER_DEPENDENCIES) $(OBJS) $(LIBFILENAMES)
|
||||||
|
$(QUIET_PREFIX) \
|
||||||
|
echo "----" $(QUIET_ECHO_POSTFIX);\
|
||||||
|
echo "---- LINKING $@ [$(CFG)] ----";\
|
||||||
|
echo "----" $(QUIET_ECHO_POSTFIX);\
|
||||||
|
\
|
||||||
|
$(LINK) $(LINK_MAP_FLAGS) $(SHLIBLDFLAGS) $(PROFILE_LINKER_FLAG) -o $(OUTPUTFILE) $(LIB_START_SHLIB) $(OBJS) $(LIBFILES) $(SystemLibraries) $(LIB_END_SHLIB);
|
||||||
|
$(VSIGN) -signvalve $(OUTPUTFILE);
|
||||||
|
|
||||||
|
|
||||||
|
$(EXE_File) : $(OTHER_DEPENDENCIES) $(OBJS) $(LIBFILENAMES)
|
||||||
|
$(QUIET_PREFIX) \
|
||||||
|
echo "----" $(QUIET_ECHO_POSTFIX);\
|
||||||
|
echo "---- LINKING EXE $@ [$(CFG)] ----";\
|
||||||
|
echo "----" $(QUIET_ECHO_POSTFIX);\
|
||||||
|
\
|
||||||
|
$(P4_EDIT_START) $(OUTPUTFILE) $(P4_EDIT_END);\
|
||||||
|
$(LINK) $(LINK_MAP_FLAGS) $(LDFLAGS) $(PROFILE_LINKER_FLAG) -o $(OUTPUTFILE) $(LIB_START_EXE) $(OBJS) $(LIBFILES) $(SystemLibraries) $(LIB_END_EXE);
|
||||||
|
$(QUIET_PREFIX) -$(P4_EDIT_START) $(OUTPUTFILE)$(SYM_EXT) $(P4_EDIT_END);
|
||||||
|
$(QUIET_PREFIX) $(GEN_SYM) $(OUTPUTFILE);
|
||||||
|
$(QUIET_PREFIX) -$(STRIP) $(OUTPUTFILE);
|
||||||
|
$(QUIET_PREFIX) $(VSIGN) -signvalve $(OUTPUTFILE);
|
||||||
|
|
||||||
|
|
||||||
|
tags:
|
||||||
|
etags -a -C -o $(SRCROOT)/TAGS *.cpp *.cxx *.h *.hxx
|
507
mp/src/devtools/makefile_base_posix.mak.gcc8
Normal file
507
mp/src/devtools/makefile_base_posix.mak.gcc8
Normal file
@ -0,0 +1,507 @@
|
|||||||
|
#
|
||||||
|
# Base makefile for Linux and OSX
|
||||||
|
#
|
||||||
|
# !!!!! Note to future editors !!!!!
|
||||||
|
#
|
||||||
|
# before you make changes, make sure you grok:
|
||||||
|
# 1. the difference between =, :=, +=, and ?=
|
||||||
|
# 2. how and when this base makefile gets included in the generated makefile(s)
|
||||||
|
# ( see http://www.gnu.org/software/make/manual/make.html#Flavors )
|
||||||
|
#
|
||||||
|
# Command line prefixes:
|
||||||
|
# - errors are ignored
|
||||||
|
# @ command is not printed to stdout before being executed
|
||||||
|
# + command is executed even if Make is invoked in "do not exec" mode
|
||||||
|
|
||||||
|
OS := $(shell uname)
|
||||||
|
HOSTNAME := $(shell hostname)
|
||||||
|
|
||||||
|
-include $(SRCROOT)/devtools/steam_def.mak
|
||||||
|
-include $(SRCROOT)/devtools/sourcesdk_def.mak
|
||||||
|
|
||||||
|
# To build with clang, set the following in your environment:
|
||||||
|
# CC = clang
|
||||||
|
# CXX = clang++
|
||||||
|
|
||||||
|
ifeq ($(CFG), release)
|
||||||
|
# With gcc 4.6.3, engine.so went from 7,383,765 to 8,429,109 when building with -O3.
|
||||||
|
# There also was no speed difference running at 1280x1024. May 2012, mikesart.
|
||||||
|
# tonyp: The size increase was likely caused by -finline-functions and -fipa-cp-clone getting switched on with -O3.
|
||||||
|
# -fno-omit-frame-pointer: need this for stack traces with perf.
|
||||||
|
OptimizerLevel_CompilerSpecific = -O2 -fno-strict-aliasing -ffast-math -fno-omit-frame-pointer -ftree-vectorize -fpredictive-commoning -funswitch-loops
|
||||||
|
else
|
||||||
|
OptimizerLevel_CompilerSpecific = -Og
|
||||||
|
#-O1 -finline-functions
|
||||||
|
endif
|
||||||
|
|
||||||
|
# CPPFLAGS == "c/c++ *preprocessor* flags" - not "cee-plus-plus flags"
|
||||||
|
ARCH_FLAGS = -fabi-compat-version=2 -fabi-version=2 -fpic -fno-plt -fcf-protection=none -fno-stack-protector -fno-stack-clash-protection
|
||||||
|
BUILDING_MULTI_ARCH = 0
|
||||||
|
CPPFLAGS = $(DEFINES) $(addprefix -I, $(abspath $(INCLUDEDIRS) ))
|
||||||
|
CFLAGS = $(ARCH_FLAGS) $(CPPFLAGS) $(WARN_FLAGS) -fvisibility=$(SymbolVisibility) $(OptimizerLevel) -pipe $(GCC_ExtraCompilerFlags) -Usprintf -Ustrncpy -UPROTECTED_THINGS_ENABLE
|
||||||
|
# In -std=gnu++0x mode we get lots of errors about "error: narrowing conversion". -fpermissive
|
||||||
|
# turns these into warnings in gcc, and -Wno-c++11-narrowing suppresses them entirely in clang 3.1+.
|
||||||
|
ifeq ($(CXX),clang++)
|
||||||
|
CXXFLAGS = $(CFLAGS) -std=gnu++0x -Wno-c++11-narrowing -Wno-dangling-else
|
||||||
|
else
|
||||||
|
CXXFLAGS = $(CFLAGS) -std=gnu++0x -Wno-narrowing -fpermissive
|
||||||
|
endif
|
||||||
|
DEFINES += -DVPROF_LEVEL=1 -DGNUC -DNO_HOOK_MALLOC -DNO_MALLOC_OVERRIDE -D_GLIBCXX_USE_CXX11_ABI=0
|
||||||
|
LDFLAGS = $(CFLAGS) $(GCC_ExtraLinkerFlags) $(OptimizerLevel) -fuse-ld=gold
|
||||||
|
GENDEP_CXXFLAGS = -MD -MP -MF $(@:.o=.P)
|
||||||
|
MAP_FLAGS =
|
||||||
|
Srv_GAMEOUTPUTFILE =
|
||||||
|
COPY_DLL_TO_SRV = 0
|
||||||
|
|
||||||
|
|
||||||
|
ifeq ($(STEAM_BRANCH),1)
|
||||||
|
WARN_FLAGS = -Wall -Wextra -Wshadow -Wno-invalid-offsetof
|
||||||
|
else
|
||||||
|
WARN_FLAGS = -Wno-write-strings -Wno-multichar
|
||||||
|
endif
|
||||||
|
|
||||||
|
WARN_FLAGS += -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-value -Wno-missing-field-initializers -Wno-sign-compare -Wno-reorder -Wno-invalid-offsetof -Wno-float-equal -Werror=return-type -fdiagnostics-show-option -Wformat -Wformat-security
|
||||||
|
|
||||||
|
|
||||||
|
ifeq ($(OS),Linux)
|
||||||
|
# We should always specify -Wl,--build-id, as documented at:
|
||||||
|
# http://linux.die.net/man/1/ld and http://fedoraproject.org/wiki/Releases/FeatureBuildId.http://fedoraproject.org/wiki/Releases/FeatureBuildId
|
||||||
|
LDFLAGS += -Wl,--build-id
|
||||||
|
# Set USE_VALVE_BINDIR to build with /Steam/tools/linux in the /valve/bin path.
|
||||||
|
# Dedicated server uses this.
|
||||||
|
ifeq ($(USE_VALVE_BINDIR),1)
|
||||||
|
# dedicated server flags
|
||||||
|
ifeq ($(TARGET_PLATFORM),linux64)
|
||||||
|
VALVE_BINDIR = /valve/bin64/
|
||||||
|
else
|
||||||
|
VALVE_BINDIR = /valve/bin/
|
||||||
|
endif
|
||||||
|
STRIP_FLAGS =
|
||||||
|
else
|
||||||
|
# linux desktop client flags
|
||||||
|
VALVE_BINDIR =
|
||||||
|
# If the steam-runtime is available, use it. We should just default to using it when
|
||||||
|
# buildbot and everyone has a bit of time to get it installed.
|
||||||
|
ifneq "$(wildcard /valve/steam-runtime/bin/)" ""
|
||||||
|
# The steam-runtime is incompatible with clang at this point, so disable it
|
||||||
|
# if clang is enabled.
|
||||||
|
ifneq ($(CXX),clang++)
|
||||||
|
VALVE_BINDIR = /valve/steam-runtime/bin/
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
GCC_VER =
|
||||||
|
# On dedicated servers, some plugins depend on global variable symbols in addition to functions.
|
||||||
|
# So symbols like _Z16ClearMultiDamagev should show up when you do "nm server_srv.so" in TF2.
|
||||||
|
STRIP_FLAGS = -x
|
||||||
|
endif
|
||||||
|
# nocona = MMX, SSE, SSE2, SSE3
|
||||||
|
MARCH_TARGET = nocona
|
||||||
|
MTUNE_TARGET = generic
|
||||||
|
|
||||||
|
ifeq ($(CXX),clang++)
|
||||||
|
# Clang does not support -mfpmath=sse because it uses whatever
|
||||||
|
# instruction set extensions are available by default.
|
||||||
|
SSE_GEN_FLAGS = -msse2
|
||||||
|
else
|
||||||
|
SSE_GEN_FLAGS = -msse2 -mfpmath=sse
|
||||||
|
endif
|
||||||
|
|
||||||
|
CCACHE := $(SRCROOT)/devtools/bin/linux/ccache
|
||||||
|
|
||||||
|
ifeq ($(origin GCC_VER), undefined)
|
||||||
|
GCC_VER=-4.6
|
||||||
|
endif
|
||||||
|
ifeq ($(origin AR), default)
|
||||||
|
AR = $(VALVE_BINDIR)ar crs
|
||||||
|
endif
|
||||||
|
ifeq ($(origin CC),default)
|
||||||
|
CC = $(CCACHE) $(VALVE_BINDIR)gcc$(GCC_VER)
|
||||||
|
endif
|
||||||
|
ifeq ($(origin CXX), default)
|
||||||
|
CXX = $(CCACHE) $(VALVE_BINDIR)g++$(GCC_VER)
|
||||||
|
endif
|
||||||
|
# Support ccache with clang. Add -Qunused-arguments to avoid excessive warnings due to
|
||||||
|
# a ccache quirk. Could also upgrade ccache.
|
||||||
|
# http://petereisentraut.blogspot.com/2011/05/ccache-and-clang.html
|
||||||
|
ifeq ($(CC),clang)
|
||||||
|
CC = $(CCACHE) $(VALVE_BINDIR)clang -Qunused-arguments
|
||||||
|
endif
|
||||||
|
ifeq ($(CXX),clang++)
|
||||||
|
CXX = $(CCACHE) $(VALVE_BINDIR)clang++ -Qunused-arguments
|
||||||
|
endif
|
||||||
|
LINK ?= $(CC)
|
||||||
|
|
||||||
|
ifeq ($(TARGET_PLATFORM),linux64)
|
||||||
|
ARCH_FLAGS += -march=$(MARCH_TARGET) -mtune=$(MTUNE_TARGET)
|
||||||
|
LD_SO = ld-linux-x86_64.so.2
|
||||||
|
LIBSTDCXX := $(shell $(CXX) -print-file-name=libstdc++.a)
|
||||||
|
LIBSTDCXXPIC := $(shell $(CXX) -print-file-name=libstdc++-pic.a)
|
||||||
|
else
|
||||||
|
ARCH_FLAGS += -m32 -march=$(MARCH_TARGET) -mtune=$(MTUNE_TARGET)
|
||||||
|
LD_SO = ld-linux.so.2
|
||||||
|
LIBSTDCXX := $(shell $(CXX) $(ARCH_FLAGS) -print-file-name=libstdc++.so)
|
||||||
|
LIBSTDCXXPIC := $(shell $(CXX) $(ARCH_FLAGS) -print-file-name=libstdc++.so)
|
||||||
|
LDFLAGS += -m32
|
||||||
|
endif
|
||||||
|
|
||||||
|
GEN_SYM ?= $(SRCROOT)/devtools/gendbg.sh
|
||||||
|
ifeq ($(CFG),release)
|
||||||
|
STRIP ?= strip $(STRIP_FLAGS) -S
|
||||||
|
# CFLAGS += -ffunction-sections -fdata-sections
|
||||||
|
# LDFLAGS += -Wl,--gc-sections -Wl,--print-gc-sections
|
||||||
|
else
|
||||||
|
STRIP ?= true
|
||||||
|
endif
|
||||||
|
VSIGN ?= true
|
||||||
|
|
||||||
|
ifeq ($(SOURCE_SDK), 1)
|
||||||
|
Srv_GAMEOUTPUTFILE := $(GAMEOUTPUTFILE:.so=_srv.so)
|
||||||
|
COPY_DLL_TO_SRV := 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
LINK_MAP_FLAGS = -Wl,-Map,$(@:.so=).map
|
||||||
|
|
||||||
|
SHLIBLDFLAGS = -shared $(LDFLAGS) -Wl,--no-undefined
|
||||||
|
|
||||||
|
_WRAP := -Xlinker --wrap=
|
||||||
|
PATHWRAP = $(_WRAP)fopen $(_WRAP)freopen $(_WRAP)open $(_WRAP)creat $(_WRAP)access $(_WRAP)__xstat \
|
||||||
|
$(_WRAP)stat $(_WRAP)lstat $(_WRAP)fopen64 $(_WRAP)open64 $(_WRAP)opendir $(_WRAP)__lxstat \
|
||||||
|
$(_WRAP)chmod $(_WRAP)chown $(_WRAP)lchown $(_WRAP)symlink $(_WRAP)link $(_WRAP)__lxstat64 \
|
||||||
|
$(_WRAP)mknod $(_WRAP)utimes $(_WRAP)unlink $(_WRAP)rename $(_WRAP)utime $(_WRAP)__xstat64 \
|
||||||
|
$(_WRAP)mount $(_WRAP)mkfifo $(_WRAP)mkdir $(_WRAP)rmdir $(_WRAP)scandir $(_WRAP)realpath
|
||||||
|
|
||||||
|
LIB_START_EXE = $(PATHWRAP) -static-libgcc -Wl,--start-group
|
||||||
|
LIB_END_EXE = -Wl,--end-group -lm -ldl $(LIBSTDCXX) -lpthread
|
||||||
|
|
||||||
|
LIB_START_SHLIB = $(PATHWRAP) -static-libgcc -Wl,--start-group
|
||||||
|
LIB_END_SHLIB = -Wl,--end-group $(SRCROOT)/devtools/gcc9+support.o -lm -ldl $(LIBSTDCXXPIC) -lpthread -l:$(LD_SO) -Wl,--version-script=$(SRCROOT)/devtools/version_script.linux.txt
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(OS),Darwin)
|
||||||
|
CCACHE := $(SRCROOT)/devtools/bin/osx32/ccache
|
||||||
|
MAC_SDK_VER ?= 10.6
|
||||||
|
MAC_SDK := macosx$(MAC_SDK_VER)
|
||||||
|
SYSROOT := $(shell xcodebuild -sdk $(MAC_SDK) -version Path)
|
||||||
|
|
||||||
|
ifneq ($(origin MAC_SDK_VER), file)
|
||||||
|
$(warning Attempting build with SDK version $(MAC_SDK_VER), only 10.6 is supported and recommended!)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(SYSROOT),)
|
||||||
|
FIRSTSDK := $(firstword $(sort $(shell xcodebuild -showsdks | grep macosx | sed 's/.*macosx//')))
|
||||||
|
$(error Could not find SDK version $(MAC_SDK_VER). Install and configure Xcode 4.3, or build with: make MAC_SDK_VER=$(FIRSTSDK))
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(origin CC), default)
|
||||||
|
# Test to see if you have a compiler in the right place, if you
|
||||||
|
# don't abort with an error
|
||||||
|
CLANG := $(shell xcrun -sdk $(MAC_SDK) -find clang)
|
||||||
|
ifeq ($(wildcard $(CLANG)),)
|
||||||
|
$(error Unable to find C compiler, install and configure Xcode 4.3)
|
||||||
|
endif
|
||||||
|
|
||||||
|
CC := $(CCACHE) $(CLANG) -Qunused-arguments
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(origin CXX), default)
|
||||||
|
CXXLANG := $(shell xcrun -sdk $(MAC_SDK) -find clang++)
|
||||||
|
ifeq ($(wildcard $(CXXLANG)),)
|
||||||
|
$(error Unable to find C++ compiler, install and configure Xcode 4.3)
|
||||||
|
endif
|
||||||
|
|
||||||
|
CXX := $(CCACHE) $(CXXLANG) -Qunused-arguments
|
||||||
|
endif
|
||||||
|
LINK ?= $(CXX)
|
||||||
|
|
||||||
|
ifeq ($(origin AR), default)
|
||||||
|
AR := $(shell xcrun -sdk $(MAC_SDK) -find libtool) -static -o
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(TARGET_PLATFORM),osx64)
|
||||||
|
ARCH_FLAGS += -arch x86_64 -m64 -march=core2
|
||||||
|
else ifeq (,$(findstring -arch x86_64,$(GCC_ExtraCompilerFlags)))
|
||||||
|
ARCH_FLAGS += -arch i386 -m32 -march=prescott -momit-leaf-frame-pointer -mtune=core2
|
||||||
|
else
|
||||||
|
# dirty hack to build a universal binary - don't specify the architecture
|
||||||
|
ARCH_FLAGS += -arch i386 -Xarch_i386 -march=prescott -Xarch_i386 -mtune=core2 -Xarch_i386 -momit-leaf-frame-pointer -Xarch_x86_64 -march=core2
|
||||||
|
endif
|
||||||
|
|
||||||
|
GEN_SYM ?= $(shell xcrun -sdk $(MAC_SDK) -find dsymutil)
|
||||||
|
ifeq ($(CFG),release)
|
||||||
|
STRIP ?= strip -S
|
||||||
|
else
|
||||||
|
STRIP ?= true
|
||||||
|
endif
|
||||||
|
ifeq ($(SOURCE_SDK), 1)
|
||||||
|
VSIGN ?= true
|
||||||
|
else
|
||||||
|
VSIGN ?= $(SRCROOT)/devtools/bin/vsign
|
||||||
|
endif
|
||||||
|
|
||||||
|
CPPFLAGS += -I$(SYSROOT)/usr/include/malloc
|
||||||
|
CFLAGS += -isysroot $(SYSROOT) -mmacosx-version-min=10.5 -fasm-blocks
|
||||||
|
|
||||||
|
LIB_START_EXE = -lm -ldl -lpthread
|
||||||
|
LIB_END_EXE =
|
||||||
|
|
||||||
|
LIB_START_SHLIB =
|
||||||
|
LIB_END_SHLIB =
|
||||||
|
|
||||||
|
SHLIBLDFLAGS = $(LDFLAGS) -bundle -flat_namespace -undefined suppress -Wl,-dead_strip -Wl,-no_dead_strip_inits_and_terms
|
||||||
|
|
||||||
|
ifeq (lib,$(findstring lib,$(GAMEOUTPUTFILE)))
|
||||||
|
SHLIBLDFLAGS = $(LDFLAGS) -dynamiclib -current_version 1.0 -compatibility_version 1.0 -install_name @rpath/$(basename $(notdir $(GAMEOUTPUTFILE))).dylib $(SystemLibraries) -Wl,-dead_strip -Wl,-no_dead_strip_inits_and_terms
|
||||||
|
endif
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
#
|
||||||
|
# Profile-directed optimizations.
|
||||||
|
# Note: Last time these were tested 3/5/08, it actually slowed down the server benchmark by 5%!
|
||||||
|
#
|
||||||
|
# First, uncomment these, build, and test. It will generate .gcda and .gcno files where the .o files are.
|
||||||
|
# PROFILE_LINKER_FLAG=-fprofile-arcs
|
||||||
|
# PROFILE_COMPILER_FLAG=-fprofile-arcs
|
||||||
|
#
|
||||||
|
# Then, comment the above flags out again and rebuild with this flag uncommented:
|
||||||
|
# PROFILE_COMPILER_FLAG=-fprofile-use
|
||||||
|
#
|
||||||
|
|
||||||
|
#############################################################################
|
||||||
|
# The compiler command lne for each src code file to compile
|
||||||
|
#############################################################################
|
||||||
|
|
||||||
|
OBJ_DIR = ./obj_$(NAME)_$(TARGET_PLATFORM)$(TARGET_PLATFORM_EXT)/$(CFG)
|
||||||
|
CPP_TO_OBJ = $(CPPFILES:.cpp=.o)
|
||||||
|
CXX_TO_OBJ = $(CPP_TO_OBJ:.cxx=.o)
|
||||||
|
CC_TO_OBJ = $(CXX_TO_OBJ:.cc=.o)
|
||||||
|
MM_TO_OBJ = $(CC_TO_OBJ:.mm=.o)
|
||||||
|
C_TO_OBJ = $(MM_TO_OBJ:.c=.o)
|
||||||
|
OBJS = $(addprefix $(OBJ_DIR)/, $(notdir $(C_TO_OBJ)))
|
||||||
|
|
||||||
|
ifeq ($(MAKE_VERBOSE),1)
|
||||||
|
QUIET_PREFIX =
|
||||||
|
QUIET_ECHO_POSTFIX =
|
||||||
|
else
|
||||||
|
QUIET_PREFIX = @
|
||||||
|
QUIET_ECHO_POSTFIX = > /dev/null
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(MAKE_CC_VERBOSE),1)
|
||||||
|
CC += -v
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFTYPE),lib)
|
||||||
|
LIB_File = $(OUTPUTFILE)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFTYPE),dll)
|
||||||
|
SO_File = $(OUTPUTFILE)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFTYPE),exe)
|
||||||
|
EXE_File = $(OUTPUTFILE)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# we generate dependencies as a side-effect of compilation now
|
||||||
|
GEN_DEP_FILE=
|
||||||
|
|
||||||
|
PRE_COMPILE_FILE =
|
||||||
|
|
||||||
|
POST_COMPILE_FILE =
|
||||||
|
|
||||||
|
ifeq ($(BUILDING_MULTI_ARCH),1)
|
||||||
|
SINGLE_ARCH_CXXFLAGS=$(subst -arch x86_64,,$(CXXFLAGS))
|
||||||
|
COMPILE_FILE = \
|
||||||
|
$(QUIET_PREFIX) \
|
||||||
|
echo "---- $(lastword $(subst /, ,$<)) as MULTIARCH----";\
|
||||||
|
mkdir -p $(OBJ_DIR) && \
|
||||||
|
$(CXX) $(SINGLE_ARCH_CXXFLAGS) $(GENDEP_CXXFLAGS) -o $@ -c $< && \
|
||||||
|
$(CXX) $(CXXFLAGS) -o $@ -c $<
|
||||||
|
else
|
||||||
|
COMPILE_FILE = \
|
||||||
|
$(QUIET_PREFIX) \
|
||||||
|
echo "---- $(lastword $(subst /, ,$<)) ----";\
|
||||||
|
mkdir -p $(OBJ_DIR) && \
|
||||||
|
$(CXX) $(CXXFLAGS) $(GENDEP_CXXFLAGS) -o $@ -c $<
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq "$(origin VALVE_NO_AUTO_P4)" "undefined"
|
||||||
|
P4_EDIT_START = chmod -R +w
|
||||||
|
P4_EDIT_END = || true
|
||||||
|
P4_REVERT_START = true
|
||||||
|
P4_REVERT_END =
|
||||||
|
else
|
||||||
|
ifndef P4_EDIT_CHANGELIST
|
||||||
|
# You can use an environment variable to specify what changelist to check the Linux Binaries out into. Normally the default
|
||||||
|
# setting is best, but here is an alternate example:
|
||||||
|
# export P4_EDIT_CHANGELIST_CMD="echo 1424335"
|
||||||
|
# ?= means that if P4_EDIT_CHANGELIST_CMD is already set it won't be changed.
|
||||||
|
P4_EDIT_CHANGELIST_CMD ?= p4 changes -c `p4 client -o | grep ^Client | cut -f 2` -s pending | fgrep 'POSIX Auto Checkout' | cut -d' ' -f 2 | tail -n 1
|
||||||
|
P4_EDIT_CHANGELIST := $(shell $(P4_EDIT_CHANGELIST_CMD))
|
||||||
|
endif
|
||||||
|
ifeq ($(P4_EDIT_CHANGELIST),)
|
||||||
|
# If we haven't found a changelist to check out to then create one. The name must match the one from a few
|
||||||
|
# lines above or else a new changelist will be created each time.
|
||||||
|
# Warning: the behavior of 'echo' is not consistent. In bash you need the "-e" option in order for \n to be
|
||||||
|
# interpreted as a line-feed, but in dash you do not, and if "-e" is passed along then it is printed, which
|
||||||
|
# confuses p4. So, if you run this command from the bash shell don't forget to add "-e" to the echo command.
|
||||||
|
P4_EDIT_CHANGELIST = $(shell echo "Change: new\nDescription: POSIX Auto Checkout" | p4 change -i | cut -f 2 -d ' ')
|
||||||
|
endif
|
||||||
|
|
||||||
|
P4_EDIT_START := for f in
|
||||||
|
P4_EDIT_END := ; do if [ -n $$f ]; then if [ -d $$f ]; then find $$f -type f -print | p4 -x - edit -c $(P4_EDIT_CHANGELIST); else p4 edit -c $(P4_EDIT_CHANGELIST) $$f; fi; fi; done $(QUIET_ECHO_POSTFIX)
|
||||||
|
P4_REVERT_START := for f in
|
||||||
|
P4_REVERT_END := ; do if [ -n $$f ]; then if [ -d $$f ]; then find $$f -type f -print | p4 -x - revert; else p4 revert $$f; fi; fi; done $(QUIET_ECHO_POSTFIX)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFTYPE),dll)
|
||||||
|
all: $(OTHER_DEPENDENCIES) $(OBJS) $(GAMEOUTPUTFILE)
|
||||||
|
@echo $(GAMEOUTPUTFILE) $(QUIET_ECHO_POSTFIX)
|
||||||
|
else
|
||||||
|
all: $(OTHER_DEPENDENCIES) $(OBJS) $(OUTPUTFILE)
|
||||||
|
@echo $(OUTPUTFILE) $(QUIET_ECHO_POSTFIX)
|
||||||
|
endif
|
||||||
|
|
||||||
|
.PHONY: clean cleantargets cleanandremove rebuild relink RemoveOutputFile SingleFile
|
||||||
|
|
||||||
|
|
||||||
|
rebuild :
|
||||||
|
$(MAKE) -f $(firstword $(MAKEFILE_LIST)) cleanandremove
|
||||||
|
$(MAKE) -f $(firstword $(MAKEFILE_LIST))
|
||||||
|
|
||||||
|
|
||||||
|
# Use the relink target to force to relink the project.
|
||||||
|
relink: RemoveOutputFile all
|
||||||
|
|
||||||
|
RemoveOutputFile:
|
||||||
|
rm -f $(OUTPUTFILE)
|
||||||
|
|
||||||
|
|
||||||
|
# This rule is so you can say "make SingleFile SingleFilename=/home/myname/valve_main/src/engine/language.cpp" and have it only build that file.
|
||||||
|
# It basically just translates the full filename to create a dependency on the appropriate .o file so it'll build that.
|
||||||
|
SingleFile : RemoveSingleFile $(OBJ_DIR)/$(basename $(notdir $(SingleFilename))).o
|
||||||
|
@echo ""
|
||||||
|
|
||||||
|
RemoveSingleFile:
|
||||||
|
$(QUIET_PREFIX) rm -f $(OBJ_DIR)/$(basename $(notdir $(SingleFilename))).o
|
||||||
|
|
||||||
|
clean:
|
||||||
|
ifneq "$(OBJ_DIR)" ""
|
||||||
|
$(QUIET_PREFIX) echo "rm -rf $(OBJ_DIR)"
|
||||||
|
$(QUIET_PREFIX) rm -rf $(OBJ_DIR)
|
||||||
|
endif
|
||||||
|
ifneq "$(OUTPUTFILE)" ""
|
||||||
|
$(QUIET_PREFIX) if [ -e $(OUTPUTFILE) ]; then \
|
||||||
|
echo "p4 revert $(OUTPUTFILE)"; \
|
||||||
|
$(P4_REVERT_START) $(OUTPUTFILE) $(OUTPUTFILE)$(SYM_EXT) $(P4_REVERT_END); \
|
||||||
|
fi;
|
||||||
|
endif
|
||||||
|
ifneq "$(OTHER_DEPENDENCIES)" ""
|
||||||
|
$(QUIET_PREFIX) echo "rm -f $(OTHER_DEPENDENCIES)"
|
||||||
|
$(QUIET_PREFIX) rm -f $(OTHER_DEPENDENCIES)
|
||||||
|
endif
|
||||||
|
ifneq "$(GAMEOUTPUTFILE)" ""
|
||||||
|
$(QUIET_PREFIX) echo "p4 revert $(GAMEOUTPUTFILE)"
|
||||||
|
$(QUIET_PREFIX) $(P4_REVERT_START) $(GAMEOUTPUTFILE) $(GAMEOUTPUTFILE)$(SYM_EXT) $(P4_REVERT_END)
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
# Do the above cleaning, except with p4 edit and rm. Reason being ar crs adds and replaces obj files to the
|
||||||
|
# archive. However if you've renamed or deleted a source file, $(AR) won't remove it. This can leave
|
||||||
|
# us with archive files that have extra unused symbols, and also potentially cause compilation errors
|
||||||
|
# when you rename a file and have many duplicate symbols.
|
||||||
|
cleanandremove:
|
||||||
|
ifneq "$(OBJ_DIR)" ""
|
||||||
|
$(QUIET_PREFIX) echo "rm -rf $(OBJ_DIR)"
|
||||||
|
$(QUIET_PREFIX) -rm -rf $(OBJ_DIR)
|
||||||
|
endif
|
||||||
|
ifneq "$(OUTPUTFILE)" ""
|
||||||
|
$(QUIET_PREFIX) if [ -e $(OUTPUTFILE) ]; then \
|
||||||
|
echo "p4 edit and rm -f $(OUTPUTFILE) $(OUTPUTFILE)$(SYM_EXT)"; \
|
||||||
|
$(P4_EDIT_START) $(OUTPUTFILE) $(OUTPUTFILE)$(SYM_EXT) $(P4_EDIT_END); \
|
||||||
|
fi;
|
||||||
|
$(QUIET_PREFIX) -rm -f $(OUTPUTFILE) $(OUTPUTFILE)$(SYM_EXT);
|
||||||
|
endif
|
||||||
|
ifneq "$(OTHER_DEPENDENCIES)" ""
|
||||||
|
$(QUIET_PREFIX) echo "rm -f $(OTHER_DEPENDENCIES)"
|
||||||
|
$(QUIET_PREFIX) -rm -f $(OTHER_DEPENDENCIES)
|
||||||
|
endif
|
||||||
|
ifneq "$(GAMEOUTPUTFILE)" ""
|
||||||
|
$(QUIET_PREFIX) echo "p4 edit and rm -f $(GAMEOUTPUTFILE) $(GAMEOUTPUTFILE)$(SYM_EXT)"
|
||||||
|
$(QUIET_PREFIX) $(P4_EDIT_START) $(GAMEOUTPUTFILE) $(GAMEOUTPUTFILE)$(SYM_EXT) $(P4_EDIT_END)
|
||||||
|
$(QUIET_PREFIX) -rm -f $(GAMEOUTPUTFILE)
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
# This just deletes the final targets so it'll do a relink next time we build.
|
||||||
|
cleantargets:
|
||||||
|
$(QUIET_PREFIX) rm -f $(OUTPUTFILE) $(GAMEOUTPUTFILE)
|
||||||
|
|
||||||
|
|
||||||
|
$(LIB_File): $(OTHER_DEPENDENCIES) $(OBJS)
|
||||||
|
$(QUIET_PREFIX) -$(P4_EDIT_START) $(LIB_File) $(P4_EDIT_END);
|
||||||
|
$(QUIET_PREFIX) $(AR) $(LIB_File) $(OBJS) $(LIBFILES);
|
||||||
|
|
||||||
|
SO_GameOutputFile = $(GAMEOUTPUTFILE)
|
||||||
|
|
||||||
|
# Remove the target before installing a file over it; this prevents existing
|
||||||
|
# instances of the game from crashing due to the overwrite.
|
||||||
|
$(SO_GameOutputFile): $(SO_File)
|
||||||
|
$(QUIET_PREFIX) \
|
||||||
|
$(P4_EDIT_START) $(GAMEOUTPUTFILE) $(P4_EDIT_END) && \
|
||||||
|
echo "----" $(QUIET_ECHO_POSTFIX);\
|
||||||
|
echo "---- COPYING TO $@ [$(CFG)] ----";\
|
||||||
|
echo "----" $(QUIET_ECHO_POSTFIX);
|
||||||
|
$(QUIET_PREFIX) -$(P4_EDIT_START) $(GAMEOUTPUTFILE) $(P4_EDIT_END);
|
||||||
|
$(QUIET_PREFIX) -mkdir -p `dirname $(GAMEOUTPUTFILE)` > /dev/null;
|
||||||
|
$(QUIET_PREFIX) rm -f $(GAMEOUTPUTFILE) $(QUIET_ECHO_POSTFIX);
|
||||||
|
$(QUIET_PREFIX) cp -v $(OUTPUTFILE) $(GAMEOUTPUTFILE) $(QUIET_ECHO_POSTFIX);
|
||||||
|
$(QUIET_PREFIX) -$(P4_EDIT_START) $(GAMEOUTPUTFILE)$(SYM_EXT) $(P4_EDIT_END);
|
||||||
|
$(QUIET_PREFIX) $(GEN_SYM) $(GAMEOUTPUTFILE);
|
||||||
|
$(QUIET_PREFIX) -$(STRIP) $(GAMEOUTPUTFILE);
|
||||||
|
$(QUIET_PREFIX) $(VSIGN) -signvalve $(GAMEOUTPUTFILE);
|
||||||
|
$(QUIET_PREFIX) if [ "$(COPY_DLL_TO_SRV)" = "1" ]; then\
|
||||||
|
echo "----" $(QUIET_ECHO_POSTFIX);\
|
||||||
|
echo "---- COPYING TO $(Srv_GAMEOUTPUTFILE) ----";\
|
||||||
|
echo "----" $(QUIET_ECHO_POSTFIX);\
|
||||||
|
cp -v $(GAMEOUTPUTFILE) $(Srv_GAMEOUTPUTFILE) $(QUIET_ECHO_POSTFIX);\
|
||||||
|
cp -v $(GAMEOUTPUTFILE)$(SYM_EXT) $(Srv_GAMEOUTPUTFILE)$(SYM_EXT) $(QUIET_ECHO_POSTFIX);\
|
||||||
|
fi;
|
||||||
|
$(QUIET_PREFIX) if [ "$(IMPORTLIBRARY)" != "" ]; then\
|
||||||
|
echo "----" $(QUIET_ECHO_POSTFIX);\
|
||||||
|
echo "---- COPYING TO IMPORT LIBRARY $(IMPORTLIBRARY) ----";\
|
||||||
|
echo "----" $(QUIET_ECHO_POSTFIX);\
|
||||||
|
$(P4_EDIT_START) $(IMPORTLIBRARY) $(P4_EDIT_END) && \
|
||||||
|
mkdir -p `dirname $(IMPORTLIBRARY)` > /dev/null && \
|
||||||
|
cp -v $(OUTPUTFILE) $(IMPORTLIBRARY); \
|
||||||
|
fi;
|
||||||
|
|
||||||
|
|
||||||
|
$(SO_File): $(OTHER_DEPENDENCIES) $(OBJS) $(LIBFILENAMES)
|
||||||
|
$(QUIET_PREFIX) \
|
||||||
|
echo "----" $(QUIET_ECHO_POSTFIX);\
|
||||||
|
echo "---- LINKING $@ [$(CFG)] ----";\
|
||||||
|
echo "----" $(QUIET_ECHO_POSTFIX);\
|
||||||
|
\
|
||||||
|
$(LINK) $(LINK_MAP_FLAGS) $(SHLIBLDFLAGS) $(PROFILE_LINKER_FLAG) -o $(OUTPUTFILE) $(LIB_START_SHLIB) $(OBJS) $(LIBFILES) $(SystemLibraries) $(LIB_END_SHLIB);
|
||||||
|
$(VSIGN) -signvalve $(OUTPUTFILE);
|
||||||
|
|
||||||
|
|
||||||
|
$(EXE_File) : $(OTHER_DEPENDENCIES) $(OBJS) $(LIBFILENAMES)
|
||||||
|
$(QUIET_PREFIX) \
|
||||||
|
echo "----" $(QUIET_ECHO_POSTFIX);\
|
||||||
|
echo "---- LINKING EXE $@ [$(CFG)] ----";\
|
||||||
|
echo "----" $(QUIET_ECHO_POSTFIX);\
|
||||||
|
\
|
||||||
|
$(P4_EDIT_START) $(OUTPUTFILE) $(P4_EDIT_END);\
|
||||||
|
$(LINK) $(LINK_MAP_FLAGS) $(LDFLAGS) $(PROFILE_LINKER_FLAG) -o $(OUTPUTFILE) $(LIB_START_EXE) $(OBJS) $(LIBFILES) $(SystemLibraries) $(LIB_END_EXE);
|
||||||
|
$(QUIET_PREFIX) -$(P4_EDIT_START) $(OUTPUTFILE)$(SYM_EXT) $(P4_EDIT_END);
|
||||||
|
$(QUIET_PREFIX) $(GEN_SYM) $(OUTPUTFILE);
|
||||||
|
$(QUIET_PREFIX) -$(STRIP) $(OUTPUTFILE);
|
||||||
|
$(QUIET_PREFIX) $(VSIGN) -signvalve $(OUTPUTFILE);
|
||||||
|
|
||||||
|
|
||||||
|
tags:
|
||||||
|
etags -a -C -o $(SRCROOT)/TAGS *.cpp *.cxx *.h *.hxx
|
@ -12,6 +12,9 @@
|
|||||||
#include "filesystem_tools.h"
|
#include "filesystem_tools.h"
|
||||||
#include "tier1/strtools.h"
|
#include "tier1/strtools.h"
|
||||||
#include "utlmap.h"
|
#include "utlmap.h"
|
||||||
|
#ifdef MAPBASE
|
||||||
|
#include "fmtstr.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
// memdbgon must be the last include file in a .cpp file!!!
|
// memdbgon must be the last include file in a .cpp file!!!
|
||||||
#include "tier0/memdbgon.h"
|
#include "tier0/memdbgon.h"
|
||||||
@ -579,6 +582,34 @@ GDclass *GameData::BeginInstanceRemap( const char *pszClassName, const char *psz
|
|||||||
return m_InstanceClass;
|
return m_InstanceClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: Sets up for additional instance remap fixes from Mapbase
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void GameData::SetupInstanceRemapParams( int iStartNodes, int iStartBrushSide, bool bRemapVecLines )
|
||||||
|
{
|
||||||
|
// Set the numer of nodes in the level
|
||||||
|
m_InstanceStartAINodes = iStartNodes;
|
||||||
|
|
||||||
|
// If we have a "nodeid" key, set it to ivNodeDest so it's properly recognized
|
||||||
|
// during AI node remapping
|
||||||
|
GDinputvariable *var = m_InstanceClass->VarForName( "nodeid" );
|
||||||
|
if ( var )
|
||||||
|
{
|
||||||
|
var->ForceSetType( ivNodeDest );
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------
|
||||||
|
|
||||||
|
// Set the number of brush sides in the level
|
||||||
|
m_InstanceStartSide = iStartBrushSide;
|
||||||
|
|
||||||
|
//---------------------------------------------
|
||||||
|
|
||||||
|
m_bRemapVecLines = bRemapVecLines;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
enum tRemapOperation
|
enum tRemapOperation
|
||||||
{
|
{
|
||||||
@ -586,6 +617,13 @@ enum tRemapOperation
|
|||||||
REMAP_POSITION,
|
REMAP_POSITION,
|
||||||
REMAP_ANGLE,
|
REMAP_ANGLE,
|
||||||
REMAP_ANGLE_NEGATIVE_PITCH,
|
REMAP_ANGLE_NEGATIVE_PITCH,
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// Remaps the node ID for instance/manifest AI node support
|
||||||
|
REMAP_NODE_ID,
|
||||||
|
|
||||||
|
// Remaps brush sides and sidelists
|
||||||
|
REMAP_SIDES,
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -624,6 +662,12 @@ bool GameData::RemapKeyValue( const char *pszKey, const char *pszInValue, char *
|
|||||||
RemapOperation.Insert( ivOrigin, REMAP_POSITION );
|
RemapOperation.Insert( ivOrigin, REMAP_POSITION );
|
||||||
RemapOperation.Insert( ivAxis, REMAP_ANGLE );
|
RemapOperation.Insert( ivAxis, REMAP_ANGLE );
|
||||||
RemapOperation.Insert( ivAngleNegativePitch, REMAP_ANGLE_NEGATIVE_PITCH );
|
RemapOperation.Insert( ivAngleNegativePitch, REMAP_ANGLE_NEGATIVE_PITCH );
|
||||||
|
#ifdef MAPBASE
|
||||||
|
RemapOperation.Insert( ivNodeDest, REMAP_NODE_ID );
|
||||||
|
RemapOperation.Insert( ivSide, REMAP_SIDES );
|
||||||
|
RemapOperation.Insert( ivSideList, REMAP_SIDES );
|
||||||
|
RemapOperation.Insert( ivVecLine, REMAP_POSITION );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !m_InstanceClass )
|
if ( !m_InstanceClass )
|
||||||
@ -657,6 +701,12 @@ bool GameData::RemapKeyValue( const char *pszKey, const char *pszInValue, char *
|
|||||||
|
|
||||||
case REMAP_POSITION:
|
case REMAP_POSITION:
|
||||||
{
|
{
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// Only remap ivVecLine if the keyvalue is enabled
|
||||||
|
if (KVType == ivVecLine && !m_bRemapVecLines)
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
Vector inPoint( 0.0f, 0.0f, 0.0f ), outPoint;
|
Vector inPoint( 0.0f, 0.0f, 0.0f ), outPoint;
|
||||||
|
|
||||||
sscanf ( pszInValue, "%f %f %f", &inPoint.x, &inPoint.y, &inPoint.z );
|
sscanf ( pszInValue, "%f %f %f", &inPoint.x, &inPoint.y, &inPoint.z );
|
||||||
@ -697,6 +747,54 @@ bool GameData::RemapKeyValue( const char *pszKey, const char *pszInValue, char *
|
|||||||
sprintf( pszOutValue, "%g", -outAngles.x ); // just the pitch
|
sprintf( pszOutValue, "%g", -outAngles.x ); // just the pitch
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
case REMAP_NODE_ID:
|
||||||
|
{
|
||||||
|
int value = atoi( pszInValue );
|
||||||
|
if (value == -1)
|
||||||
|
break;
|
||||||
|
|
||||||
|
//Warning( " %s %s: Remapped %i to %i", m_InstanceClass->GetName(), KVVar->GetName(), value, value + m_InstanceStartAINodes );
|
||||||
|
|
||||||
|
value += m_InstanceStartAINodes;
|
||||||
|
|
||||||
|
sprintf( pszOutValue, "%i", value );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case REMAP_SIDES:
|
||||||
|
{
|
||||||
|
CUtlStringList sideList;
|
||||||
|
V_SplitString( pszInValue, " ", sideList );
|
||||||
|
|
||||||
|
// Convert sides
|
||||||
|
CUtlStringList newSideList;
|
||||||
|
for (int i = 0; i < sideList.Count(); i++)
|
||||||
|
{
|
||||||
|
int iSide = atoi( sideList[i] );
|
||||||
|
|
||||||
|
//Warning( " %s %s: Remapped %i to %i", m_InstanceClass->GetName(), KVVar->GetName(), iSide, iSide + m_InstanceStartSide );
|
||||||
|
|
||||||
|
iSide += m_InstanceStartSide;
|
||||||
|
|
||||||
|
newSideList.AddToTail( const_cast<char*>( CNumStr( iSide ).String() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initial side
|
||||||
|
strcpy( pszOutValue, newSideList[0] );
|
||||||
|
|
||||||
|
// Start at 1 for subsequent sides
|
||||||
|
for (int i = 1; i < newSideList.Count(); i++)
|
||||||
|
{
|
||||||
|
// Any subsequent sides are spaced
|
||||||
|
sprintf( pszOutValue, "%s %s", pszOutValue, newSideList[i] );
|
||||||
|
}
|
||||||
|
|
||||||
|
//Warning("Old side list: \"%s\", new side list: \"%s\"\n", pszInValue, pszOutValue);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return ( strcmpi( pszInValue, pszOutValue ) != 0 );
|
return ( strcmpi( pszInValue, pszOutValue ) != 0 );
|
||||||
|
@ -14,6 +14,104 @@
|
|||||||
#include "c_baseentity.h"
|
#include "c_baseentity.h"
|
||||||
#include "basetypes.h"
|
#include "basetypes.h"
|
||||||
|
|
||||||
|
#ifdef ASW_PROJECTED_TEXTURES
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
class C_EnvProjectedTexture : public C_BaseEntity
|
||||||
|
{
|
||||||
|
DECLARE_CLASS( C_EnvProjectedTexture, C_BaseEntity );
|
||||||
|
public:
|
||||||
|
DECLARE_CLIENTCLASS();
|
||||||
|
|
||||||
|
void SetMaterial( IMaterial *pMaterial );
|
||||||
|
void SetLightColor( byte r, byte g, byte b, byte a );
|
||||||
|
void SetSize( float flSize );
|
||||||
|
void SetRotation( float flRotation );
|
||||||
|
|
||||||
|
virtual void OnDataChanged( DataUpdateType_t updateType );
|
||||||
|
void ShutDownLightHandle( void );
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
virtual void Simulate();
|
||||||
|
#else
|
||||||
|
virtual bool Simulate();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void UpdateLight( void );
|
||||||
|
|
||||||
|
C_EnvProjectedTexture();
|
||||||
|
~C_EnvProjectedTexture();
|
||||||
|
|
||||||
|
static void SetVisibleBBoxMinHeight( float flVisibleBBoxMinHeight ) { m_flVisibleBBoxMinHeight = flVisibleBBoxMinHeight; }
|
||||||
|
static float GetVisibleBBoxMinHeight( void ) { return m_flVisibleBBoxMinHeight; }
|
||||||
|
static C_EnvProjectedTexture *Create( );
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
inline bool IsBBoxVisible( void );
|
||||||
|
bool IsBBoxVisible( Vector vecExtentsMin,
|
||||||
|
Vector vecExtentsMax );
|
||||||
|
|
||||||
|
ClientShadowHandle_t m_LightHandle;
|
||||||
|
bool m_bForceUpdate;
|
||||||
|
|
||||||
|
EHANDLE m_hTargetEntity;
|
||||||
|
#ifdef MAPBASE
|
||||||
|
bool m_bDontFollowTarget;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool m_bState;
|
||||||
|
bool m_bAlwaysUpdate;
|
||||||
|
float m_flLightFOV;
|
||||||
|
#ifdef MAPBASE
|
||||||
|
float m_flLightHorFOV;
|
||||||
|
#endif
|
||||||
|
bool m_bEnableShadows;
|
||||||
|
bool m_bLightOnlyTarget;
|
||||||
|
bool m_bLightWorld;
|
||||||
|
bool m_bCameraSpace;
|
||||||
|
float m_flBrightnessScale;
|
||||||
|
color32 m_LightColor;
|
||||||
|
Vector m_CurrentLinearFloatLightColor;
|
||||||
|
float m_flCurrentLinearFloatLightAlpha;
|
||||||
|
#ifdef MAPBASE
|
||||||
|
float m_flCurrentBrightnessScale;
|
||||||
|
#endif
|
||||||
|
float m_flColorTransitionTime;
|
||||||
|
float m_flAmbient;
|
||||||
|
float m_flNearZ;
|
||||||
|
float m_flFarZ;
|
||||||
|
char m_SpotlightTextureName[ MAX_PATH ];
|
||||||
|
CTextureReference m_SpotlightTexture;
|
||||||
|
int m_nSpotlightTextureFrame;
|
||||||
|
int m_nShadowQuality;
|
||||||
|
#ifdef MAPBASE
|
||||||
|
float m_flConstantAtten;
|
||||||
|
float m_flLinearAtten;
|
||||||
|
float m_flQuadraticAtten;
|
||||||
|
float m_flShadowAtten;
|
||||||
|
|
||||||
|
bool m_bAlwaysDraw;
|
||||||
|
//bool m_bProjectedTextureVersion;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Vector m_vecExtentsMin;
|
||||||
|
Vector m_vecExtentsMax;
|
||||||
|
|
||||||
|
static float m_flVisibleBBoxMinHeight;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool C_EnvProjectedTexture::IsBBoxVisible( void )
|
||||||
|
{
|
||||||
|
return IsBBoxVisible( GetAbsOrigin() + m_vecExtentsMin, GetAbsOrigin() + m_vecExtentsMax );
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose:
|
// Purpose:
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -62,4 +160,6 @@ public:
|
|||||||
|
|
||||||
C_EnvProjectedTexture* GetEnvProjectedTextureList();
|
C_EnvProjectedTexture* GetEnvProjectedTextureList();
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // C_ENVPROJECTEDTEXTURE_H
|
#endif // C_ENVPROJECTEDTEXTURE_H
|
||||||
|
@ -54,6 +54,9 @@
|
|||||||
#include "replay/replay_ragdoll.h"
|
#include "replay/replay_ragdoll.h"
|
||||||
#include "studio_stats.h"
|
#include "studio_stats.h"
|
||||||
#include "tier1/callqueue.h"
|
#include "tier1/callqueue.h"
|
||||||
|
#ifdef MAPBASE
|
||||||
|
#include "viewrender.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef TF_CLIENT_DLL
|
#ifdef TF_CLIENT_DLL
|
||||||
#include "c_tf_player.h"
|
#include "c_tf_player.h"
|
||||||
@ -283,6 +286,31 @@ BEGIN_DATADESC( C_ClientRagdoll )
|
|||||||
|
|
||||||
END_DATADESC()
|
END_DATADESC()
|
||||||
|
|
||||||
|
BEGIN_ENT_SCRIPTDESC( C_BaseAnimating, C_BaseEntity, "Animating models client-side" )
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
DEFINE_SCRIPTFUNC_NAMED( ScriptGetPoseParameter, "GetPoseParameter", "Get the specified pose parameter's value" )
|
||||||
|
#endif
|
||||||
|
DEFINE_SCRIPTFUNC_NAMED( ScriptSetPoseParameter, "SetPoseParameter", "Set the specified pose parameter to the specified value" )
|
||||||
|
DEFINE_SCRIPTFUNC( IsSequenceFinished, "Ask whether the main sequence is done playing" )
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
DEFINE_SCRIPTFUNC( SetBodygroup, "Sets a bodygroup")
|
||||||
|
DEFINE_SCRIPTFUNC( GetBodygroup, "Gets a bodygroup" )
|
||||||
|
DEFINE_SCRIPTFUNC( GetBodygroupName, "Gets a bodygroup name" )
|
||||||
|
DEFINE_SCRIPTFUNC( FindBodygroupByName, "Finds a bodygroup by name" )
|
||||||
|
DEFINE_SCRIPTFUNC( GetBodygroupCount, "Gets the number of models in a bodygroup" )
|
||||||
|
DEFINE_SCRIPTFUNC( GetNumBodyGroups, "Gets the number of bodygroups" )
|
||||||
|
|
||||||
|
DEFINE_SCRIPTFUNC( GetSequence, "Gets the current sequence" )
|
||||||
|
DEFINE_SCRIPTFUNC( SetSequence, "Sets the current sequence" )
|
||||||
|
DEFINE_SCRIPTFUNC( SequenceLoops, "Loops the current sequence" )
|
||||||
|
DEFINE_SCRIPTFUNC( LookupSequence, "Gets the index of the specified sequence name" )
|
||||||
|
DEFINE_SCRIPTFUNC( LookupActivity, "Gets the ID of the specified activity name" )
|
||||||
|
DEFINE_SCRIPTFUNC( GetSequenceName, "Gets the name of the specified sequence index" )
|
||||||
|
DEFINE_SCRIPTFUNC( GetSequenceActivityName, "Gets the activity name of the specified sequence index" )
|
||||||
|
DEFINE_SCRIPTFUNC_NAMED( ScriptGetSequenceActivity, "GetSequenceActivity", "Gets the activity ID of the specified sequence index" )
|
||||||
|
#endif
|
||||||
|
END_SCRIPTDESC();
|
||||||
|
|
||||||
C_ClientRagdoll::C_ClientRagdoll( bool bRestoring )
|
C_ClientRagdoll::C_ClientRagdoll( bool bRestoring )
|
||||||
{
|
{
|
||||||
m_iCurrentFriction = 0;
|
m_iCurrentFriction = 0;
|
||||||
@ -1432,6 +1460,27 @@ float C_BaseAnimating::ClampCycle( float flCycle, bool isLooping )
|
|||||||
return flCycle;
|
return flCycle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
float C_BaseAnimating::ScriptGetPoseParameter( const char* szName )
|
||||||
|
{
|
||||||
|
CStudioHdr* pHdr = GetModelPtr();
|
||||||
|
if (pHdr == NULL)
|
||||||
|
return 0.0f;
|
||||||
|
|
||||||
|
int iPoseParam = LookupPoseParameter( pHdr, szName );
|
||||||
|
return GetPoseParameter( iPoseParam );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void C_BaseAnimating::ScriptSetPoseParameter(const char* szName, float fValue)
|
||||||
|
{
|
||||||
|
CStudioHdr* pHdr = GetModelPtr();
|
||||||
|
if (pHdr == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int iPoseParam = LookupPoseParameter(pHdr, szName);
|
||||||
|
SetPoseParameter(pHdr, iPoseParam, fValue);
|
||||||
|
}
|
||||||
|
|
||||||
void C_BaseAnimating::GetCachedBoneMatrix( int boneIndex, matrix3x4_t &out )
|
void C_BaseAnimating::GetCachedBoneMatrix( int boneIndex, matrix3x4_t &out )
|
||||||
{
|
{
|
||||||
@ -3137,6 +3186,17 @@ int C_BaseAnimating::DrawModel( int flags )
|
|||||||
|
|
||||||
int drawn = 0;
|
int drawn = 0;
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
if (m_iViewHideFlags > 0)
|
||||||
|
{
|
||||||
|
// Hide this entity if it's not supposed to be drawn in this view.
|
||||||
|
if (m_iViewHideFlags & (1 << CurrentViewID()))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef TF_CLIENT_DLL
|
#ifdef TF_CLIENT_DLL
|
||||||
ValidateModelIndex();
|
ValidateModelIndex();
|
||||||
#endif
|
#endif
|
||||||
@ -3604,7 +3664,7 @@ bool C_BaseAnimating::DispatchMuzzleEffect( const char *options, bool isFirstPer
|
|||||||
int weaponType = 0;
|
int weaponType = 0;
|
||||||
|
|
||||||
// Get the first parameter
|
// Get the first parameter
|
||||||
p = nexttoken( token, p, ' ' );
|
p = nexttoken( token, p, ' ' , sizeof(token) );
|
||||||
|
|
||||||
// Find the weapon type
|
// Find the weapon type
|
||||||
if ( token[0] )
|
if ( token[0] )
|
||||||
@ -3648,7 +3708,7 @@ bool C_BaseAnimating::DispatchMuzzleEffect( const char *options, bool isFirstPer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the second parameter
|
// Get the second parameter
|
||||||
p = nexttoken( token, p, ' ' );
|
p = nexttoken( token, p, ' ' , sizeof(token) );
|
||||||
|
|
||||||
int attachmentIndex = -1;
|
int attachmentIndex = -1;
|
||||||
|
|
||||||
@ -3759,7 +3819,7 @@ void C_BaseAnimating::FireEvent( const Vector& origin, const QAngle& angles, int
|
|||||||
|
|
||||||
// Get the particle effect name
|
// Get the particle effect name
|
||||||
const char *p = options;
|
const char *p = options;
|
||||||
p = nexttoken(token, p, ' ');
|
p = nexttoken(token, p, ' ', sizeof(token));
|
||||||
|
|
||||||
const char* mtoken = ModifyEventParticles( token );
|
const char* mtoken = ModifyEventParticles( token );
|
||||||
if ( !mtoken || mtoken[0] == '\0' )
|
if ( !mtoken || mtoken[0] == '\0' )
|
||||||
@ -3767,7 +3827,7 @@ void C_BaseAnimating::FireEvent( const Vector& origin, const QAngle& angles, int
|
|||||||
Q_strncpy( szParticleEffect, mtoken, sizeof(szParticleEffect) );
|
Q_strncpy( szParticleEffect, mtoken, sizeof(szParticleEffect) );
|
||||||
|
|
||||||
// Get the attachment type
|
// Get the attachment type
|
||||||
p = nexttoken(token, p, ' ');
|
p = nexttoken(token, p, ' ', sizeof(token));
|
||||||
|
|
||||||
iAttachType = GetAttachTypeFromString( token );
|
iAttachType = GetAttachTypeFromString( token );
|
||||||
if ( iAttachType == -1 )
|
if ( iAttachType == -1 )
|
||||||
@ -3777,7 +3837,7 @@ void C_BaseAnimating::FireEvent( const Vector& origin, const QAngle& angles, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the attachment point index
|
// Get the attachment point index
|
||||||
p = nexttoken(token, p, ' ');
|
p = nexttoken(token, p, ' ', sizeof(token));
|
||||||
if ( token[0] )
|
if ( token[0] )
|
||||||
{
|
{
|
||||||
iAttachment = atoi(token);
|
iAttachment = atoi(token);
|
||||||
@ -3897,18 +3957,33 @@ void C_BaseAnimating::FireEvent( const Vector& origin, const QAngle& angles, int
|
|||||||
|
|
||||||
// Eject brass
|
// Eject brass
|
||||||
case CL_EVENT_EJECTBRASS1:
|
case CL_EVENT_EJECTBRASS1:
|
||||||
if ( m_Attachments.Count() > 0 )
|
|
||||||
{
|
{
|
||||||
if ( MainViewOrigin().DistToSqr( GetAbsOrigin() ) < (256 * 256) )
|
// Check if we're a weapon, if we belong to the local player, and if the local player is in third person - if all are true, don't do a muzzleflash in this instance, because
|
||||||
|
// we're using the view models dispatch for smoothness.
|
||||||
|
if ( dynamic_cast< C_BaseCombatWeapon *>(this) != NULL )
|
||||||
{
|
{
|
||||||
Vector attachOrigin;
|
C_BaseCombatWeapon *pWeapon = dynamic_cast< C_BaseCombatWeapon *>(this);
|
||||||
QAngle attachAngles;
|
if ( pWeapon && pWeapon->GetOwner() == C_BasePlayer::GetLocalPlayer() && ::input->CAM_IsThirdPerson() )
|
||||||
|
break;
|
||||||
if( GetAttachment( 2, attachOrigin, attachAngles ) )
|
}
|
||||||
|
|
||||||
|
if ( ( prediction->InPrediction() && !prediction->IsFirstTimePredicted() ) )
|
||||||
|
break;
|
||||||
|
|
||||||
|
if ( m_Attachments.Count() > 0 )
|
||||||
|
{
|
||||||
|
if ( MainViewOrigin().DistToSqr( GetAbsOrigin() ) < (256 * 256) )
|
||||||
{
|
{
|
||||||
tempents->EjectBrass( attachOrigin, attachAngles, GetAbsAngles(), atoi( options ) );
|
Vector attachOrigin;
|
||||||
|
QAngle attachAngles;
|
||||||
|
|
||||||
|
if( GetAttachment( 2, attachOrigin, attachAngles ) )
|
||||||
|
{
|
||||||
|
tempents->EjectBrass( attachOrigin, attachAngles, GetAbsAngles(), atoi( options ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -3922,6 +3997,36 @@ void C_BaseAnimating::FireEvent( const Vector& origin, const QAngle& angles, int
|
|||||||
case AE_NPC_MUZZLEFLASH:
|
case AE_NPC_MUZZLEFLASH:
|
||||||
{
|
{
|
||||||
// Send out the effect for an NPC
|
// Send out the effect for an NPC
|
||||||
|
#if defined ( HL2MP ) || defined ( SDK_DLL ) // works for the modified CSS weapons included in the new template sdk.
|
||||||
|
// HL2MP - Make third person muzzleflashes as reliable as the first person ones
|
||||||
|
// while in third person the view model dispatches the muzzleflash event - note: the weapon models dispatch them too, but not frequently.
|
||||||
|
if ( IsViewModel() )
|
||||||
|
{
|
||||||
|
C_BasePlayer *pPlayer = ToBasePlayer( dynamic_cast<C_BaseViewModel *>(this)->GetOwner() );
|
||||||
|
if ( pPlayer && pPlayer == C_BasePlayer::GetLocalPlayer())
|
||||||
|
{
|
||||||
|
if ( ::input->CAM_IsThirdPerson() )
|
||||||
|
{
|
||||||
|
// Dispatch on the weapon - the player model doesn't have the attachments in hl2mp.
|
||||||
|
C_BaseCombatWeapon *pWeapon = pPlayer->GetActiveWeapon();
|
||||||
|
if ( !pWeapon )
|
||||||
|
break;
|
||||||
|
pWeapon->DispatchMuzzleEffect( options, false );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if we're a weapon, if we belong to the local player, and if the local player is in third person - if all are true, don't do a muzzleflash in this instance, because
|
||||||
|
// we're using the view models dispatch for smoothness.
|
||||||
|
if ( dynamic_cast< C_BaseCombatWeapon *>(this) != NULL )
|
||||||
|
{
|
||||||
|
C_BaseCombatWeapon *pWeapon = dynamic_cast< C_BaseCombatWeapon *>(this);
|
||||||
|
if ( pWeapon && pWeapon->GetOwner() == C_BasePlayer::GetLocalPlayer() && ::input->CAM_IsThirdPerson() )
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
DispatchMuzzleEffect( options, false );
|
DispatchMuzzleEffect( options, false );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -3981,11 +4086,11 @@ void C_BaseAnimating::FireEvent( const Vector& origin, const QAngle& angles, int
|
|||||||
const char *p = options;
|
const char *p = options;
|
||||||
|
|
||||||
// Bodygroup Name
|
// Bodygroup Name
|
||||||
p = nexttoken(token, p, ' ');
|
p = nexttoken(token, p, ' ', sizeof(token));
|
||||||
Q_strncpy( szBodygroupName, token, sizeof(szBodygroupName) );
|
Q_strncpy( szBodygroupName, token, sizeof(szBodygroupName) );
|
||||||
|
|
||||||
// Get the desired value
|
// Get the desired value
|
||||||
p = nexttoken(token, p, ' ');
|
p = nexttoken(token, p, ' ', sizeof(token));
|
||||||
value = token[0] ? atoi( token ) : 0;
|
value = token[0] ? atoi( token ) : 0;
|
||||||
|
|
||||||
int index = FindBodygroupByName( szBodygroupName );
|
int index = FindBodygroupByName( szBodygroupName );
|
||||||
@ -4022,13 +4127,13 @@ void C_BaseAnimating::FireObsoleteEvent( const Vector& origin, const QAngle& ang
|
|||||||
|
|
||||||
const char *p = options;
|
const char *p = options;
|
||||||
|
|
||||||
p = nexttoken(token, p, ' ');
|
p = nexttoken(token, p, ' ', sizeof(token));
|
||||||
Q_strncpy( effectFunc, token, sizeof(effectFunc) );
|
Q_strncpy( effectFunc, token, sizeof(effectFunc) );
|
||||||
|
|
||||||
p = nexttoken(token, p, ' ');
|
p = nexttoken(token, p, ' ', sizeof(token));
|
||||||
iAttachment = token[0] ? atoi(token) : -1;
|
iAttachment = token[0] ? atoi(token) : -1;
|
||||||
|
|
||||||
p = nexttoken(token, p, ' ');
|
p = nexttoken(token, p, ' ', sizeof(token));
|
||||||
iParam = token[0] ? atoi(token) : 0;
|
iParam = token[0] ? atoi(token) : 0;
|
||||||
|
|
||||||
if ( iAttachment != -1 && m_Attachments.Count() >= iAttachment )
|
if ( iAttachment != -1 && m_Attachments.Count() >= iAttachment )
|
||||||
@ -4667,6 +4772,14 @@ C_BaseAnimating *C_BaseAnimating::CreateRagdollCopy()
|
|||||||
pRagdoll->m_nForceBone = m_nForceBone;
|
pRagdoll->m_nForceBone = m_nForceBone;
|
||||||
pRagdoll->SetNextClientThink( CLIENT_THINK_ALWAYS );
|
pRagdoll->SetNextClientThink( CLIENT_THINK_ALWAYS );
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
pRagdoll->m_iViewHideFlags = m_iViewHideFlags;
|
||||||
|
|
||||||
|
pRagdoll->m_fadeMinDist = m_fadeMinDist;
|
||||||
|
pRagdoll->m_fadeMaxDist = m_fadeMaxDist;
|
||||||
|
pRagdoll->m_flFadeScale = m_flFadeScale;
|
||||||
|
#endif
|
||||||
|
|
||||||
pRagdoll->SetModelName( AllocPooledString(pModelName) );
|
pRagdoll->SetModelName( AllocPooledString(pModelName) );
|
||||||
pRagdoll->SetModelScale( GetModelScale() );
|
pRagdoll->SetModelScale( GetModelScale() );
|
||||||
return pRagdoll;
|
return pRagdoll;
|
||||||
|
@ -95,6 +95,7 @@ public:
|
|||||||
DECLARE_CLIENTCLASS();
|
DECLARE_CLIENTCLASS();
|
||||||
DECLARE_PREDICTABLE();
|
DECLARE_PREDICTABLE();
|
||||||
DECLARE_INTERPOLATION();
|
DECLARE_INTERPOLATION();
|
||||||
|
DECLARE_ENT_SCRIPTDESC();
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@ -163,6 +164,13 @@ public:
|
|||||||
virtual void FireObsoleteEvent( const Vector& origin, const QAngle& angles, int event, const char *options );
|
virtual void FireObsoleteEvent( const Vector& origin, const QAngle& angles, int event, const char *options );
|
||||||
virtual const char* ModifyEventParticles( const char* token ) { return token; }
|
virtual const char* ModifyEventParticles( const char* token ) { return token; }
|
||||||
|
|
||||||
|
#if defined ( SDK_DLL ) || defined ( HL2MP )
|
||||||
|
virtual void ResetEventsParity() { m_nPrevResetEventsParity = -1; } // used to force animation events to function on players so the muzzleflashes and other events occur
|
||||||
|
// so new functions don't have to be made to parse the models like CSS does in ProcessMuzzleFlashEvent
|
||||||
|
// allows the multiplayer world weapon models to declare the muzzleflashes, and other effects like sp
|
||||||
|
// without the need to script it and add extra parsing code.
|
||||||
|
#endif
|
||||||
|
|
||||||
// Parses and distributes muzzle flash events
|
// Parses and distributes muzzle flash events
|
||||||
virtual bool DispatchMuzzleEffect( const char *options, bool isFirstPerson );
|
virtual bool DispatchMuzzleEffect( const char *options, bool isFirstPerson );
|
||||||
|
|
||||||
@ -447,6 +455,10 @@ public:
|
|||||||
virtual bool IsViewModel() const;
|
virtual bool IsViewModel() const;
|
||||||
virtual void UpdateOnRemove( void );
|
virtual void UpdateOnRemove( void );
|
||||||
|
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
float ScriptGetPoseParameter(const char* szName);
|
||||||
|
#endif
|
||||||
|
void ScriptSetPoseParameter(const char* szName, float fValue);
|
||||||
protected:
|
protected:
|
||||||
// View models scale their attachment positions to account for FOV. To get the unmodified
|
// View models scale their attachment positions to account for FOV. To get the unmodified
|
||||||
// attachment position (like if you're rendering something else during the view model's DrawModel call),
|
// attachment position (like if you're rendering something else during the view model's DrawModel call),
|
||||||
@ -465,6 +477,10 @@ protected:
|
|||||||
|
|
||||||
virtual bool CalcAttachments();
|
virtual bool CalcAttachments();
|
||||||
|
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
int ScriptGetSequenceActivity( int iSequence ) { return GetSequenceActivity( iSequence ); }
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// This method should return true if the bones have changed + SetupBones needs to be called
|
// This method should return true if the bones have changed + SetupBones needs to be called
|
||||||
virtual float LastBoneChangedTime() { return FLT_MAX; }
|
virtual float LastBoneChangedTime() { return FLT_MAX; }
|
||||||
|
@ -16,6 +16,9 @@
|
|||||||
#include "tier1/KeyValues.h"
|
#include "tier1/KeyValues.h"
|
||||||
#include "toolframework/itoolframework.h"
|
#include "toolframework/itoolframework.h"
|
||||||
#include "toolframework_client.h"
|
#include "toolframework_client.h"
|
||||||
|
#ifdef MAPBASE
|
||||||
|
#include "viewrender.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
// memdbgon must be the last include file in a .cpp file!!!
|
// memdbgon must be the last include file in a .cpp file!!!
|
||||||
#include "tier0/memdbgon.h"
|
#include "tier0/memdbgon.h"
|
||||||
@ -82,6 +85,24 @@ static inline bool ShouldDrawLocalPlayerViewModel( void )
|
|||||||
{
|
{
|
||||||
#if defined( PORTAL )
|
#if defined( PORTAL )
|
||||||
return false;
|
return false;
|
||||||
|
#elif MAPBASE
|
||||||
|
// We shouldn't draw the viewmodel externally.
|
||||||
|
C_BasePlayer *localplayer = C_BasePlayer::GetLocalPlayer();
|
||||||
|
if (localplayer)
|
||||||
|
{
|
||||||
|
if (localplayer->m_bDrawPlayerModelExternally)
|
||||||
|
{
|
||||||
|
// If this isn't the main view, draw the weapon.
|
||||||
|
view_id_t viewID = CurrentViewID();
|
||||||
|
if (viewID != VIEW_MAIN && viewID != VIEW_INTRO_CAMERA)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Since we already have the local player, check its own ShouldDrawThisPlayer() to avoid extra checks
|
||||||
|
return !localplayer->ShouldDrawThisPlayer();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
#else
|
#else
|
||||||
return !C_BasePlayer::ShouldDrawLocalPlayer();
|
return !C_BasePlayer::ShouldDrawLocalPlayer();
|
||||||
#endif
|
#endif
|
||||||
@ -156,11 +177,8 @@ void C_BaseCombatWeapon::OnDataChanged( DataUpdateType_t updateType )
|
|||||||
}
|
}
|
||||||
else // weapon carried by other player or not at all
|
else // weapon carried by other player or not at all
|
||||||
{
|
{
|
||||||
int overrideModelIndex = CalcOverrideModelIndex();
|
// See comment below
|
||||||
if( overrideModelIndex != -1 && overrideModelIndex != GetModelIndex() )
|
EnsureCorrectRenderingModel();
|
||||||
{
|
|
||||||
SetModelIndex( overrideModelIndex );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( updateType == DATA_UPDATE_CREATED )
|
if ( updateType == DATA_UPDATE_CREATED )
|
||||||
@ -435,6 +453,12 @@ bool C_BaseCombatWeapon::ShouldDraw( void )
|
|||||||
if ( !ShouldDrawLocalPlayerViewModel() )
|
if ( !ShouldDrawLocalPlayerViewModel() )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// We're drawing this in non-main views, handle it in DrawModel()
|
||||||
|
if ( pLocalPlayer->m_bDrawPlayerModelExternally )
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
|
||||||
// don't draw active weapon if not in some kind of 3rd person mode, the viewmodel will do that
|
// don't draw active weapon if not in some kind of 3rd person mode, the viewmodel will do that
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -483,6 +507,16 @@ int C_BaseCombatWeapon::DrawModel( int flags )
|
|||||||
|
|
||||||
if ( localplayer && localplayer->IsObserver() && GetOwner() )
|
if ( localplayer && localplayer->IsObserver() && GetOwner() )
|
||||||
{
|
{
|
||||||
|
#ifdef MAPBASE
|
||||||
|
if (localplayer->m_bDrawPlayerModelExternally)
|
||||||
|
{
|
||||||
|
// If this isn't the main view, draw the weapon.
|
||||||
|
view_id_t viewID = CurrentViewID();
|
||||||
|
if (viewID != VIEW_MAIN && viewID != VIEW_INTRO_CAMERA)
|
||||||
|
return BaseClass::DrawModel( flags );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// don't draw weapon if chasing this guy as spectator
|
// don't draw weapon if chasing this guy as spectator
|
||||||
// we don't check that in ShouldDraw() since this may change
|
// we don't check that in ShouldDraw() since this may change
|
||||||
// without notification
|
// without notification
|
||||||
@ -517,6 +551,35 @@ int C_BaseCombatWeapon::CalcOverrideModelIndex()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// If the local player is visible (thirdperson mode, tf2 taunts, etc., then make sure that we are using the
|
||||||
|
// w_ (world) model not the v_ (view) model or else the model can flicker, etc.
|
||||||
|
// Otherwise, if we're not the local player, always use the world model
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void C_BaseCombatWeapon::EnsureCorrectRenderingModel()
|
||||||
|
{
|
||||||
|
C_BasePlayer *localplayer = C_BasePlayer::GetLocalPlayer();
|
||||||
|
if ( localplayer &&
|
||||||
|
localplayer == GetOwner() &&
|
||||||
|
!ShouldDrawUsingViewModel() )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// BRJ 10/14/02
|
||||||
|
// FIXME: Remove when Yahn's client-side prediction is done
|
||||||
|
// It's a hacky workaround for the model indices fighting
|
||||||
|
// (GetRenderBounds uses the model index, which is for the view model)
|
||||||
|
SetModelIndex( GetWorldModelIndex() );
|
||||||
|
|
||||||
|
// Validate our current sequence just in case ( in theory the view and weapon models should have the same sequences for sequences that overlap at least )
|
||||||
|
CStudioHdr *pStudioHdr = GetModelPtr();
|
||||||
|
if ( pStudioHdr &&
|
||||||
|
GetSequence() >= pStudioHdr->GetNumSeq() )
|
||||||
|
{
|
||||||
|
SetSequence( 0 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// tool recording
|
// tool recording
|
||||||
|
@ -40,6 +40,14 @@
|
|||||||
#include "cdll_bounded_cvars.h"
|
#include "cdll_bounded_cvars.h"
|
||||||
#include "inetchannelinfo.h"
|
#include "inetchannelinfo.h"
|
||||||
#include "proto_version.h"
|
#include "proto_version.h"
|
||||||
|
#ifdef MAPBASE
|
||||||
|
#include "viewrender.h"
|
||||||
|
#endif
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
#include "vscript_client.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "gamestringpool.h"
|
||||||
|
|
||||||
// memdbgon must be the last include file in a .cpp file!!!
|
// memdbgon must be the last include file in a .cpp file!!!
|
||||||
#include "tier0/memdbgon.h"
|
#include "tier0/memdbgon.h"
|
||||||
@ -420,6 +428,52 @@ BEGIN_RECV_TABLE_NOBASE( C_BaseEntity, DT_AnimTimeMustBeFirst )
|
|||||||
RecvPropInt( RECVINFO(m_flAnimTime), 0, RecvProxy_AnimTime ),
|
RecvPropInt( RECVINFO(m_flAnimTime), 0, RecvProxy_AnimTime ),
|
||||||
END_RECV_TABLE()
|
END_RECV_TABLE()
|
||||||
|
|
||||||
|
BEGIN_ENT_SCRIPTDESC_ROOT( C_BaseEntity, "Root class of all client-side entities" )
|
||||||
|
DEFINE_SCRIPTFUNC_NAMED( GetAbsOrigin, "GetOrigin", "" )
|
||||||
|
DEFINE_SCRIPTFUNC_NAMED( ScriptGetForward, "GetForwardVector", "Get the forward vector of the entity" )
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
DEFINE_SCRIPTFUNC_NAMED( ScriptGetRight, "GetRightVector", "Get the right vector of the entity" )
|
||||||
|
DEFINE_SCRIPTFUNC_NAMED( GetTeamNumber, "GetTeam", "Gets this entity's team" )
|
||||||
|
#endif
|
||||||
|
DEFINE_SCRIPTFUNC_NAMED( ScriptGetLeft, "GetLeftVector", SCRIPT_HIDE )
|
||||||
|
DEFINE_SCRIPTFUNC_NAMED( GetTeamNumber, "GetTeamNumber", SCRIPT_HIDE )
|
||||||
|
|
||||||
|
DEFINE_SCRIPTFUNC_NAMED( ScriptGetUp, "GetUpVector", "Get the up vector of the entity" )
|
||||||
|
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
DEFINE_SCRIPTFUNC( ValidateScriptScope, "Ensure that an entity's script scope has been created" )
|
||||||
|
DEFINE_SCRIPTFUNC( GetScriptScope, "Retrieve the script-side data associated with an entity" )
|
||||||
|
|
||||||
|
DEFINE_SCRIPTFUNC( GetHealth, "" )
|
||||||
|
DEFINE_SCRIPTFUNC( GetMaxHealth, "" )
|
||||||
|
|
||||||
|
DEFINE_SCRIPTFUNC_NAMED( ScriptGetModelName, "GetModelName", "Returns the name of the model" )
|
||||||
|
|
||||||
|
DEFINE_SCRIPTFUNC_NAMED( ScriptEmitSound, "EmitSound", "Plays a sound from this entity." )
|
||||||
|
DEFINE_SCRIPTFUNC_NAMED( VScriptPrecacheScriptSound, "PrecacheSoundScript", "Precache a sound for later playing." )
|
||||||
|
DEFINE_SCRIPTFUNC_NAMED( ScriptSoundDuration, "GetSoundDuration", "Returns float duration of the sound. Takes soundname and optional actormodelname." )
|
||||||
|
|
||||||
|
DEFINE_SCRIPTFUNC( GetClassname, "" )
|
||||||
|
DEFINE_SCRIPTFUNC_NAMED( GetEntityName, "GetName", "" )
|
||||||
|
|
||||||
|
DEFINE_SCRIPTFUNC_NAMED( WorldSpaceCenter, "GetCenter", "Get vector to center of object - absolute coords" )
|
||||||
|
DEFINE_SCRIPTFUNC_NAMED( ScriptEyePosition, "EyePosition", "Get vector to eye position - absolute coords" )
|
||||||
|
DEFINE_SCRIPTFUNC_NAMED( ScriptGetAngles, "GetAngles", "Get entity pitch, yaw, roll as a vector" )
|
||||||
|
|
||||||
|
DEFINE_SCRIPTFUNC_NAMED( ScriptGetBoundingMins, "GetBoundingMins", "Get a vector containing min bounds, centered on object" )
|
||||||
|
DEFINE_SCRIPTFUNC_NAMED( ScriptGetBoundingMaxs, "GetBoundingMaxs", "Get a vector containing max bounds, centered on object" )
|
||||||
|
|
||||||
|
DEFINE_SCRIPTFUNC_NAMED( ScriptGetMoveParent, "GetMoveParent", "If in hierarchy, retrieves the entity's parent" )
|
||||||
|
DEFINE_SCRIPTFUNC_NAMED( ScriptGetRootMoveParent, "GetRootMoveParent", "If in hierarchy, walks up the hierarchy to find the root parent" )
|
||||||
|
DEFINE_SCRIPTFUNC_NAMED( ScriptFirstMoveChild, "FirstMoveChild", "" )
|
||||||
|
DEFINE_SCRIPTFUNC_NAMED( ScriptNextMovePeer, "NextMovePeer", "" )
|
||||||
|
|
||||||
|
DEFINE_SCRIPTFUNC( GetEffects, "Get effects" )
|
||||||
|
DEFINE_SCRIPTFUNC( IsEffectActive, "Check if an effect is active" )
|
||||||
|
|
||||||
|
DEFINE_SCRIPTFUNC_NAMED( GetEntityIndex, "entindex", "" )
|
||||||
|
#endif
|
||||||
|
END_SCRIPTDESC();
|
||||||
|
|
||||||
#ifndef NO_ENTITY_PREDICTION
|
#ifndef NO_ENTITY_PREDICTION
|
||||||
BEGIN_RECV_TABLE_NOBASE( C_BaseEntity, DT_PredictableId )
|
BEGIN_RECV_TABLE_NOBASE( C_BaseEntity, DT_PredictableId )
|
||||||
@ -451,6 +505,9 @@ BEGIN_RECV_TABLE_NOBASE(C_BaseEntity, DT_BaseEntity)
|
|||||||
RecvPropInt(RECVINFO(m_nRenderMode)),
|
RecvPropInt(RECVINFO(m_nRenderMode)),
|
||||||
RecvPropInt(RECVINFO(m_nRenderFX)),
|
RecvPropInt(RECVINFO(m_nRenderFX)),
|
||||||
RecvPropInt(RECVINFO(m_clrRender)),
|
RecvPropInt(RECVINFO(m_clrRender)),
|
||||||
|
#ifdef MAPBASE
|
||||||
|
RecvPropInt(RECVINFO(m_iViewHideFlags)),
|
||||||
|
#endif
|
||||||
RecvPropInt(RECVINFO(m_iTeamNum)),
|
RecvPropInt(RECVINFO(m_iTeamNum)),
|
||||||
RecvPropInt(RECVINFO(m_CollisionGroup)),
|
RecvPropInt(RECVINFO(m_CollisionGroup)),
|
||||||
RecvPropFloat(RECVINFO(m_flElasticity)),
|
RecvPropFloat(RECVINFO(m_flElasticity)),
|
||||||
@ -460,6 +517,8 @@ BEGIN_RECV_TABLE_NOBASE(C_BaseEntity, DT_BaseEntity)
|
|||||||
RecvPropInt( RECVINFO_NAME(m_hNetworkMoveParent, moveparent), 0, RecvProxy_IntToMoveParent ),
|
RecvPropInt( RECVINFO_NAME(m_hNetworkMoveParent, moveparent), 0, RecvProxy_IntToMoveParent ),
|
||||||
RecvPropInt( RECVINFO( m_iParentAttachment ) ),
|
RecvPropInt( RECVINFO( m_iParentAttachment ) ),
|
||||||
|
|
||||||
|
RecvPropString(RECVINFO(m_iName)),
|
||||||
|
|
||||||
RecvPropInt( "movetype", 0, SIZEOF_IGNORE, 0, RecvProxy_MoveType ),
|
RecvPropInt( "movetype", 0, SIZEOF_IGNORE, 0, RecvProxy_MoveType ),
|
||||||
RecvPropInt( "movecollide", 0, SIZEOF_IGNORE, 0, RecvProxy_MoveCollide ),
|
RecvPropInt( "movecollide", 0, SIZEOF_IGNORE, 0, RecvProxy_MoveCollide ),
|
||||||
RecvPropDataTable( RECVINFO_DT( m_Collision ), 0, &REFERENCE_RECV_TABLE(DT_CollisionProperty) ),
|
RecvPropDataTable( RECVINFO_DT( m_Collision ), 0, &REFERENCE_RECV_TABLE(DT_CollisionProperty) ),
|
||||||
@ -1094,6 +1153,8 @@ bool C_BaseEntity::Init( int entnum, int iSerialNum )
|
|||||||
|
|
||||||
m_nCreationTick = gpGlobals->tickcount;
|
m_nCreationTick = gpGlobals->tickcount;
|
||||||
|
|
||||||
|
m_hScriptInstance = NULL;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1171,6 +1232,7 @@ void C_BaseEntity::Term()
|
|||||||
g_Predictables.RemoveFromPredictablesList( GetClientHandle() );
|
g_Predictables.RemoveFromPredictablesList( GetClientHandle() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// If it's play simulated, remove from simulation list if the player still exists...
|
// If it's play simulated, remove from simulation list if the player still exists...
|
||||||
if ( IsPlayerSimulated() && C_BasePlayer::GetLocalPlayer() )
|
if ( IsPlayerSimulated() && C_BasePlayer::GetLocalPlayer() )
|
||||||
{
|
{
|
||||||
@ -1207,6 +1269,12 @@ void C_BaseEntity::Term()
|
|||||||
RemoveFromLeafSystem();
|
RemoveFromLeafSystem();
|
||||||
|
|
||||||
RemoveFromAimEntsList();
|
RemoveFromAimEntsList();
|
||||||
|
|
||||||
|
if ( m_hScriptInstance )
|
||||||
|
{
|
||||||
|
g_pScriptVM->RemoveInstance( m_hScriptInstance );
|
||||||
|
m_hScriptInstance = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1977,6 +2045,17 @@ int C_BaseEntity::DrawModel( int flags )
|
|||||||
return drawn;
|
return drawn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
if (m_iViewHideFlags > 0)
|
||||||
|
{
|
||||||
|
// Hide this entity if it's not supposed to be drawn in this view.
|
||||||
|
if (m_iViewHideFlags & (1 << CurrentViewID()))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int modelType = modelinfo->GetModelType( model );
|
int modelType = modelinfo->GetModelType( model );
|
||||||
switch ( modelType )
|
switch ( modelType )
|
||||||
{
|
{
|
||||||
@ -6447,6 +6526,187 @@ int C_BaseEntity::GetCreationTick() const
|
|||||||
return m_nCreationTick;
|
return m_nCreationTick;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
HSCRIPT C_BaseEntity::GetScriptInstance()
|
||||||
|
{
|
||||||
|
if (!m_hScriptInstance)
|
||||||
|
{
|
||||||
|
if (m_iszScriptId == NULL_STRING)
|
||||||
|
{
|
||||||
|
char* szName = (char*)stackalloc(1024);
|
||||||
|
g_pScriptVM->GenerateUniqueKey((m_iName != NULL_STRING) ? STRING(GetEntityName()) : GetClassname(), szName, 1024);
|
||||||
|
m_iszScriptId = AllocPooledString(szName);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_hScriptInstance = g_pScriptVM->RegisterInstance(GetScriptDesc(), this);
|
||||||
|
g_pScriptVM->SetInstanceUniqeId(m_hScriptInstance, STRING(m_iszScriptId));
|
||||||
|
}
|
||||||
|
return m_hScriptInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Using my edict, cook up a unique VScript scope that's private to me, and
|
||||||
|
// persistent.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
bool C_BaseEntity::ValidateScriptScope()
|
||||||
|
{
|
||||||
|
if (!m_ScriptScope.IsInitialized())
|
||||||
|
{
|
||||||
|
if (scriptmanager == NULL)
|
||||||
|
{
|
||||||
|
ExecuteOnce(DevMsg("Cannot execute script because scripting is disabled (-scripting)\n"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_pScriptVM == NULL)
|
||||||
|
{
|
||||||
|
ExecuteOnce(DevMsg(" Cannot execute script because there is no available VM\n"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Force instance creation
|
||||||
|
GetScriptInstance();
|
||||||
|
|
||||||
|
EHANDLE hThis;
|
||||||
|
hThis.Set(this);
|
||||||
|
|
||||||
|
bool bResult = m_ScriptScope.Init(STRING(m_iszScriptId));
|
||||||
|
|
||||||
|
if (!bResult)
|
||||||
|
{
|
||||||
|
DevMsg("%s couldn't create ScriptScope!\n", GetDebugName());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
g_pScriptVM->SetValue(m_ScriptScope, "self", GetScriptInstance());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Returns true if the function was located and called. false otherwise.
|
||||||
|
// NOTE: Assumes the function takes no parameters at the moment.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
bool C_BaseEntity::CallScriptFunction( const char* pFunctionName, ScriptVariant_t* pFunctionReturn )
|
||||||
|
{
|
||||||
|
if (!ValidateScriptScope())
|
||||||
|
{
|
||||||
|
DevMsg("\n***\nFAILED to create private ScriptScope. ABORTING script\n***\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
HSCRIPT hFunc = m_ScriptScope.LookupFunction(pFunctionName);
|
||||||
|
|
||||||
|
if (hFunc)
|
||||||
|
{
|
||||||
|
m_ScriptScope.Call(hFunc, pFunctionReturn);
|
||||||
|
m_ScriptScope.ReleaseFunction(hFunc);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Gets a function handle
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
HSCRIPT C_BaseEntity::LookupScriptFunction( const char* pFunctionName )
|
||||||
|
{
|
||||||
|
if (!m_ScriptScope.IsInitialized())
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_ScriptScope.LookupFunction(pFunctionName);
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Calls and releases a function handle (ASSUMES SCRIPT SCOPE AND FUNCTION ARE VALID!)
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
bool C_BaseEntity::CallScriptFunctionHandle( HSCRIPT hFunc, ScriptVariant_t* pFunctionReturn )
|
||||||
|
{
|
||||||
|
m_ScriptScope.Call(hFunc, pFunctionReturn);
|
||||||
|
m_ScriptScope.ReleaseFunction(hFunc);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: Load, compile, and run a script file from disk.
|
||||||
|
// Input : *pScriptFile - The filename of the script file.
|
||||||
|
// bUseRootScope - If true, runs this script in the root scope, not
|
||||||
|
// in this entity's private scope.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
bool C_BaseEntity::RunScriptFile( const char* pScriptFile, bool bUseRootScope )
|
||||||
|
{
|
||||||
|
if (!ValidateScriptScope())
|
||||||
|
{
|
||||||
|
DevMsg("\n***\nFAILED to create private ScriptScope. ABORTING script\n***\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bUseRootScope)
|
||||||
|
{
|
||||||
|
return VScriptRunScript(pScriptFile);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return VScriptRunScript(pScriptFile, m_ScriptScope, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: Compile and execute a discrete string of script source code
|
||||||
|
// Input : *pScriptText - A string containing script code to compile and run
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
bool C_BaseEntity::RunScript( const char* pScriptText, const char* pDebugFilename )
|
||||||
|
{
|
||||||
|
if (!ValidateScriptScope())
|
||||||
|
{
|
||||||
|
DevMsg("\n***\nFAILED to create private ScriptScope. ABORTING script\n***\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_ScriptScope.Run(pScriptText, pDebugFilename) == SCRIPT_ERROR)
|
||||||
|
{
|
||||||
|
DevWarning(" Entity %s encountered an error in RunScript()\n", GetDebugName());
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
HSCRIPT C_BaseEntity::ScriptGetMoveParent( void )
|
||||||
|
{
|
||||||
|
return ToHScript( GetMoveParent() );
|
||||||
|
}
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
HSCRIPT C_BaseEntity::ScriptGetRootMoveParent()
|
||||||
|
{
|
||||||
|
return ToHScript( GetRootMoveParent() );
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
HSCRIPT C_BaseEntity::ScriptFirstMoveChild( void )
|
||||||
|
{
|
||||||
|
return ToHScript( FirstMoveChild() );
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
HSCRIPT C_BaseEntity::ScriptNextMovePeer( void )
|
||||||
|
{
|
||||||
|
return ToHScript( NextMovePeer() );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
void CC_CL_Find_Ent( const CCommand& args )
|
void CC_CL_Find_Ent( const CCommand& args )
|
||||||
{
|
{
|
||||||
|
@ -36,6 +36,9 @@
|
|||||||
#include "toolframework/itoolentity.h"
|
#include "toolframework/itoolentity.h"
|
||||||
#include "tier0/threadtools.h"
|
#include "tier0/threadtools.h"
|
||||||
|
|
||||||
|
#include "vscript/ivscript.h"
|
||||||
|
#include "vscript_shared.h"
|
||||||
|
|
||||||
class C_Team;
|
class C_Team;
|
||||||
class IPhysicsObject;
|
class IPhysicsObject;
|
||||||
class IClientVehicle;
|
class IClientVehicle;
|
||||||
@ -184,6 +187,8 @@ public:
|
|||||||
DECLARE_DATADESC();
|
DECLARE_DATADESC();
|
||||||
DECLARE_CLIENTCLASS();
|
DECLARE_CLIENTCLASS();
|
||||||
DECLARE_PREDICTABLE();
|
DECLARE_PREDICTABLE();
|
||||||
|
// script description
|
||||||
|
DECLARE_ENT_SCRIPTDESC();
|
||||||
|
|
||||||
C_BaseEntity();
|
C_BaseEntity();
|
||||||
virtual ~C_BaseEntity();
|
virtual ~C_BaseEntity();
|
||||||
@ -257,6 +262,28 @@ public:
|
|||||||
|
|
||||||
string_t m_iClassname;
|
string_t m_iClassname;
|
||||||
|
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
// VSCRIPT
|
||||||
|
bool ValidateScriptScope();
|
||||||
|
bool CallScriptFunction( const char* pFunctionName, ScriptVariant_t* pFunctionReturn );
|
||||||
|
|
||||||
|
HSCRIPT GetScriptScope() { return m_ScriptScope; }
|
||||||
|
|
||||||
|
HSCRIPT LookupScriptFunction(const char* pFunctionName);
|
||||||
|
bool CallScriptFunctionHandle(HSCRIPT hFunc, ScriptVariant_t* pFunctionReturn);
|
||||||
|
|
||||||
|
bool RunScriptFile( const char* pScriptFile, bool bUseRootScope = false );
|
||||||
|
bool RunScript( const char* pScriptText, const char* pDebugFilename = "C_BaseEntity::RunScript" );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
HSCRIPT GetScriptInstance();
|
||||||
|
|
||||||
|
HSCRIPT m_hScriptInstance;
|
||||||
|
string_t m_iszScriptId;
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
CScriptScope m_ScriptScope;
|
||||||
|
#endif
|
||||||
|
|
||||||
// IClientUnknown overrides.
|
// IClientUnknown overrides.
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -358,6 +385,11 @@ public:
|
|||||||
bool IsMarkedForDeletion( void );
|
bool IsMarkedForDeletion( void );
|
||||||
|
|
||||||
virtual int entindex( void ) const;
|
virtual int entindex( void ) const;
|
||||||
|
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
// "I don't know why but wrapping entindex() works, while calling it directly crashes."
|
||||||
|
inline int C_BaseEntity::GetEntityIndex() const { return entindex(); }
|
||||||
|
#endif
|
||||||
|
|
||||||
// This works for client-only entities and returns the GetEntryIndex() of the entity's handle,
|
// This works for client-only entities and returns the GetEntryIndex() of the entity's handle,
|
||||||
// so the sound system can get an IClientEntity from it.
|
// so the sound system can get an IClientEntity from it.
|
||||||
@ -862,6 +894,7 @@ public:
|
|||||||
void SetSize( const Vector &vecMin, const Vector &vecMax ); // UTIL_SetSize( pev, mins, maxs );
|
void SetSize( const Vector &vecMin, const Vector &vecMax ); // UTIL_SetSize( pev, mins, maxs );
|
||||||
char const *GetClassname( void );
|
char const *GetClassname( void );
|
||||||
char const *GetDebugName( void );
|
char const *GetDebugName( void );
|
||||||
|
virtual const char *GetPlayerName() const { return NULL; }
|
||||||
static int PrecacheModel( const char *name );
|
static int PrecacheModel( const char *name );
|
||||||
static bool PrecacheSound( const char *name );
|
static bool PrecacheSound( const char *name );
|
||||||
static void PrefetchSound( const char *name );
|
static void PrefetchSound( const char *name );
|
||||||
@ -1004,6 +1037,7 @@ public:
|
|||||||
/////////////////
|
/////////////////
|
||||||
|
|
||||||
virtual bool IsPlayer( void ) const { return false; };
|
virtual bool IsPlayer( void ) const { return false; };
|
||||||
|
virtual bool IsBot( void ) const { return ((GetFlags() & FL_FAKECLIENT) == FL_FAKECLIENT) ? true : false; }
|
||||||
virtual bool IsBaseCombatCharacter( void ) { return false; };
|
virtual bool IsBaseCombatCharacter( void ) { return false; };
|
||||||
virtual C_BaseCombatCharacter *MyCombatCharacterPointer( void ) { return NULL; }
|
virtual C_BaseCombatCharacter *MyCombatCharacterPointer( void ) { return NULL; }
|
||||||
virtual bool IsNPC( void ) { return false; }
|
virtual bool IsNPC( void ) { return false; }
|
||||||
@ -1021,6 +1055,11 @@ public:
|
|||||||
virtual Vector EyePosition( void );
|
virtual Vector EyePosition( void );
|
||||||
virtual const QAngle& EyeAngles( void ); // Direction of eyes
|
virtual const QAngle& EyeAngles( void ); // Direction of eyes
|
||||||
virtual const QAngle& LocalEyeAngles( void ); // Direction of eyes in local space (pl.v_angle)
|
virtual const QAngle& LocalEyeAngles( void ); // Direction of eyes in local space (pl.v_angle)
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// Created for script_intro and info_player_view_proxy
|
||||||
|
virtual void GetEyePosition( Vector &vecOrigin, QAngle &angAngles ) { vecOrigin = EyePosition(); angAngles = EyeAngles(); }
|
||||||
|
#endif
|
||||||
|
|
||||||
// position of ears
|
// position of ears
|
||||||
virtual Vector EarPosition( void );
|
virtual Vector EarPosition( void );
|
||||||
@ -1118,6 +1157,34 @@ public:
|
|||||||
virtual int GetBody() { return 0; }
|
virtual int GetBody() { return 0; }
|
||||||
virtual int GetSkin() { return 0; }
|
virtual int GetSkin() { return 0; }
|
||||||
|
|
||||||
|
const Vector& ScriptGetForward(void) { static Vector vecForward; GetVectors(&vecForward, NULL, NULL); return vecForward; }
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
const Vector& ScriptGetRight(void) { static Vector vecRight; GetVectors(NULL, &vecRight, NULL); return vecRight; }
|
||||||
|
#endif
|
||||||
|
const Vector& ScriptGetLeft(void) { static Vector vecRight; GetVectors(NULL, &vecRight, NULL); return vecRight; }
|
||||||
|
|
||||||
|
const Vector& ScriptGetUp(void) { static Vector vecUp; GetVectors(NULL, NULL, &vecUp); return vecUp; }
|
||||||
|
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
const char* ScriptGetModelName( void ) const { return STRING(GetModelName()); }
|
||||||
|
|
||||||
|
void ScriptEmitSound(const char* soundname);
|
||||||
|
float ScriptSoundDuration(const char* soundname, const char* actormodel);
|
||||||
|
|
||||||
|
void VScriptPrecacheScriptSound(const char* soundname);
|
||||||
|
|
||||||
|
const Vector& ScriptEyePosition(void) { static Vector vec; vec = EyePosition(); return vec; }
|
||||||
|
const Vector& ScriptGetAngles(void) { static Vector vec; QAngle qa = GetAbsAngles(); vec.x = qa.x; vec.y = qa.y; vec.z = qa.z; return vec; }
|
||||||
|
|
||||||
|
const Vector& ScriptGetBoundingMins( void ) { return m_Collision.OBBMins(); }
|
||||||
|
const Vector& ScriptGetBoundingMaxs( void ) { return m_Collision.OBBMaxs(); }
|
||||||
|
|
||||||
|
HSCRIPT ScriptGetMoveParent( void );
|
||||||
|
HSCRIPT ScriptGetRootMoveParent();
|
||||||
|
HSCRIPT ScriptFirstMoveChild( void );
|
||||||
|
HSCRIPT ScriptNextMovePeer( void );
|
||||||
|
#endif
|
||||||
|
|
||||||
// Stubs on client
|
// Stubs on client
|
||||||
void NetworkStateManualMode( bool activate ) { }
|
void NetworkStateManualMode( bool activate ) { }
|
||||||
void NetworkStateChanged() { }
|
void NetworkStateChanged() { }
|
||||||
@ -1275,6 +1342,7 @@ public:
|
|||||||
void SetRenderMode( RenderMode_t nRenderMode, bool bForceUpdate = false );
|
void SetRenderMode( RenderMode_t nRenderMode, bool bForceUpdate = false );
|
||||||
RenderMode_t GetRenderMode() const;
|
RenderMode_t GetRenderMode() const;
|
||||||
|
|
||||||
|
const char* GetEntityName();
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Determine what entity this corresponds to
|
// Determine what entity this corresponds to
|
||||||
@ -1289,6 +1357,10 @@ public:
|
|||||||
|
|
||||||
CNetworkColor32( m_clrRender );
|
CNetworkColor32( m_clrRender );
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
int m_iViewHideFlags;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// Model for rendering
|
// Model for rendering
|
||||||
@ -1656,6 +1728,8 @@ private:
|
|||||||
// The owner!
|
// The owner!
|
||||||
EHANDLE m_hOwnerEntity;
|
EHANDLE m_hOwnerEntity;
|
||||||
EHANDLE m_hEffectEntity;
|
EHANDLE m_hEffectEntity;
|
||||||
|
|
||||||
|
char m_iName[MAX_PATH];
|
||||||
|
|
||||||
// This is a random seed used by the networking code to allow client - side prediction code
|
// This is a random seed used by the networking code to allow client - side prediction code
|
||||||
// randon number generators to spit out the same random numbers on both sides for a particular
|
// randon number generators to spit out the same random numbers on both sides for a particular
|
||||||
@ -2211,6 +2285,12 @@ inline bool C_BaseEntity::ShouldRecordInTools() const
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline const char *C_BaseEntity::GetEntityName()
|
||||||
|
{
|
||||||
|
return m_iName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
C_BaseEntity *CreateEntityByName( const char *className );
|
C_BaseEntity *CreateEntityByName( const char *className );
|
||||||
|
|
||||||
#endif // C_BASEENTITY_H
|
#endif // C_BASEENTITY_H
|
||||||
|
@ -1149,7 +1149,9 @@ void C_BaseFlex::SetupWeights( const matrix3x4_t *pBoneToWorld, int nFlexWeightC
|
|||||||
{
|
{
|
||||||
// hack in an initialization
|
// hack in an initialization
|
||||||
LinkToGlobalFlexControllers( GetModelPtr() );
|
LinkToGlobalFlexControllers( GetModelPtr() );
|
||||||
|
#ifndef MAPBASE
|
||||||
m_iBlink = AddGlobalFlexController( "UH" );
|
m_iBlink = AddGlobalFlexController( "UH" );
|
||||||
|
#endif
|
||||||
|
|
||||||
if ( SetupGlobalWeights( pBoneToWorld, nFlexWeightCount, pFlexWeights, pFlexDelayedWeights ) )
|
if ( SetupGlobalWeights( pBoneToWorld, nFlexWeightCount, pFlexWeights, pFlexDelayedWeights ) )
|
||||||
{
|
{
|
||||||
@ -1478,7 +1480,7 @@ bool C_BaseFlex::ClearSceneEvent( CSceneEventInfo *info, bool fastKill, bool can
|
|||||||
// expression -
|
// expression -
|
||||||
// duration -
|
// duration -
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void C_BaseFlex::AddSceneEvent( CChoreoScene *scene, CChoreoEvent *event, CBaseEntity *pTarget, bool bClientSide )
|
void C_BaseFlex::AddSceneEvent( CChoreoScene *scene, CChoreoEvent *event, CBaseEntity *pTarget, bool bClientSide, C_SceneEntity* pSceneEntity)
|
||||||
{
|
{
|
||||||
if ( !scene || !event )
|
if ( !scene || !event )
|
||||||
{
|
{
|
||||||
@ -1503,6 +1505,7 @@ void C_BaseFlex::AddSceneEvent( CChoreoScene *scene, CChoreoEvent *event, CBaseE
|
|||||||
info.m_hTarget = pTarget;
|
info.m_hTarget = pTarget;
|
||||||
info.m_bStarted = false;
|
info.m_bStarted = false;
|
||||||
info.m_bClientSide = bClientSide;
|
info.m_bClientSide = bClientSide;
|
||||||
|
info.m_hSceneEntity = pSceneEntity;
|
||||||
|
|
||||||
if (StartSceneEvent( &info, scene, event, actor, pTarget ))
|
if (StartSceneEvent( &info, scene, event, actor, pTarget ))
|
||||||
{
|
{
|
||||||
|
@ -214,7 +214,7 @@ public:
|
|||||||
virtual bool ClearSceneEvent( CSceneEventInfo *info, bool fastKill, bool canceled );
|
virtual bool ClearSceneEvent( CSceneEventInfo *info, bool fastKill, bool canceled );
|
||||||
|
|
||||||
// Add the event to the queue for this actor
|
// Add the event to the queue for this actor
|
||||||
void AddSceneEvent( CChoreoScene *scene, CChoreoEvent *event, C_BaseEntity *pTarget = NULL, bool bClientSide = false );
|
void AddSceneEvent( CChoreoScene *scene, CChoreoEvent *event, C_BaseEntity *pTarget = NULL, bool bClientSide = false, C_SceneEntity* pSceneEntity = NULL);
|
||||||
|
|
||||||
// Remove the event from the queue for this actor
|
// Remove the event from the queue for this actor
|
||||||
void RemoveSceneEvent( CChoreoScene *scene, CChoreoEvent *event, bool fastKill );
|
void RemoveSceneEvent( CChoreoScene *scene, CChoreoEvent *event, bool fastKill );
|
||||||
|
3894
mp/src/game/client/c_baselesson.cpp
Normal file
3894
mp/src/game/client/c_baselesson.cpp
Normal file
File diff suppressed because it is too large
Load Diff
460
mp/src/game/client/c_baselesson.h
Normal file
460
mp/src/game/client/c_baselesson.h
Normal file
@ -0,0 +1,460 @@
|
|||||||
|
//========= Copyright © 1996-2008, Valve Corporation, All rights reserved. ============//
|
||||||
|
//
|
||||||
|
// Purpose: Client handler for instruction players how to play
|
||||||
|
//
|
||||||
|
//=============================================================================//
|
||||||
|
|
||||||
|
#ifndef _C_BASELESSON_H_
|
||||||
|
#define _C_BASELESSON_H_
|
||||||
|
|
||||||
|
|
||||||
|
#include "GameEventListener.h"
|
||||||
|
#include "hud_locator_target.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define DECLARE_LESSON( _lessonClassName, _baseLessonClassName ) \
|
||||||
|
typedef _baseLessonClassName BaseClass;\
|
||||||
|
typedef _lessonClassName ThisClass;\
|
||||||
|
_lessonClassName( const char *pchName, bool bIsDefaultHolder, bool bIsOpenOpportunity )\
|
||||||
|
: _baseLessonClassName( pchName, bIsDefaultHolder, bIsOpenOpportunity )\
|
||||||
|
{\
|
||||||
|
Init();\
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
enum LessonInstanceType
|
||||||
|
{
|
||||||
|
LESSON_INSTANCE_MULTIPLE,
|
||||||
|
LESSON_INSTANCE_SINGLE_OPEN,
|
||||||
|
LESSON_INSTANCE_FIXED_REPLACE,
|
||||||
|
LESSON_INSTANCE_SINGLE_ACTIVE,
|
||||||
|
|
||||||
|
LESSON_INSTANCE_TYPE_TOTAL
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// This is used to solve a problem where bots can take the place of a player, where on or the other don't have valid entities on the client at the same time
|
||||||
|
#define MAX_DELAYED_PLAYER_SWAPS 8
|
||||||
|
|
||||||
|
struct delayed_player_swap_t
|
||||||
|
{
|
||||||
|
CHandle<C_BaseEntity> *phHandleToChange;
|
||||||
|
int iNewUserID;
|
||||||
|
|
||||||
|
delayed_player_swap_t( void )
|
||||||
|
{
|
||||||
|
phHandleToChange = NULL;
|
||||||
|
iNewUserID = -1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
abstract_class CBaseLesson : public CGameEventListener
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CBaseLesson( const char *pchName, bool bIsDefaultHolder, bool bIsOpenOpportunity );
|
||||||
|
virtual ~CBaseLesson( void );
|
||||||
|
|
||||||
|
void AddPrerequisite( const char *pchLessonName );
|
||||||
|
|
||||||
|
const CGameInstructorSymbol& GetNameSymbol( void ) const { return m_stringName; }
|
||||||
|
const char * GetName( void ) const { return m_stringName.String(); }
|
||||||
|
int GetPriority( void ) const { return m_iPriority; }
|
||||||
|
const char * GetCloseReason( void ) const { return m_stringCloseReason.String(); }
|
||||||
|
void SetCloseReason( const char *pchReason ) { m_stringCloseReason = pchReason; }
|
||||||
|
|
||||||
|
CBaseLesson* GetRoot( void ) const { return m_pRoot; }
|
||||||
|
void SetRoot( CBaseLesson *pRoot );
|
||||||
|
const CUtlVector < CBaseLesson * >* GetChildren( void ) const { return &m_OpenOpportunities; }
|
||||||
|
|
||||||
|
float GetInitTime( void ) { return m_fInitTime; }
|
||||||
|
void SetStartTime( void ) { m_fStartTime = gpGlobals->curtime; }
|
||||||
|
void ResetStartTime( void ) { m_fStartTime = 0.0f; m_bHasPlayedSound = false; }
|
||||||
|
|
||||||
|
bool ShouldShowSpew( void );
|
||||||
|
bool NoPriority( void ) const;
|
||||||
|
bool IsDefaultHolder( void ) const { return m_bIsDefaultHolder; }
|
||||||
|
bool IsOpenOpportunity( void ) const { return m_bIsOpenOpportunity; }
|
||||||
|
bool IsLocked( void ) const;
|
||||||
|
bool CanOpenWhenDead( void ) const { return m_bCanOpenWhenDead; }
|
||||||
|
bool IsInstructing( void ) const { return ( m_fStartTime > 0.0f ); }
|
||||||
|
bool IsLearned( void ) const;
|
||||||
|
bool PrerequisitesHaveBeenMet( void ) const;
|
||||||
|
bool IsTimedOut( void );
|
||||||
|
|
||||||
|
int InstanceType( void ) const { return m_iInstanceType; }
|
||||||
|
const CGameInstructorSymbol& GetReplaceKeySymbol( void ) const { return m_stringReplaceKey; }
|
||||||
|
const char* GetReplaceKey( void ) const { return m_stringReplaceKey.String(); }
|
||||||
|
int GetFixedInstancesMax( void ) const { return m_iFixedInstancesMax; }
|
||||||
|
bool ShouldReplaceOnlyWhenStopped( void ) const { return m_bReplaceOnlyWhenStopped; }
|
||||||
|
void SetInstanceActive( bool bInstanceActive ) { m_bInstanceActive = bInstanceActive; }
|
||||||
|
bool IsInstanceActive( void ) const { return m_bInstanceActive; }
|
||||||
|
|
||||||
|
void ResetDisplaysAndSuccesses( void );
|
||||||
|
bool IncDisplayCount( void );
|
||||||
|
bool IncSuccessCount( void );
|
||||||
|
void SetDisplayCount( int iDisplayCount ) { m_iDisplayCount = iDisplayCount; }
|
||||||
|
void SetSuccessCount( int iSuccessCount ) { m_iSuccessCount = iSuccessCount; }
|
||||||
|
int GetDisplayCount( void ) const { return m_iDisplayCount; }
|
||||||
|
int GetSuccessCount( void ) const { return m_iSuccessCount; }
|
||||||
|
int GetDisplayLimit( void ) const { return m_iDisplayLimit; }
|
||||||
|
int GetSuccessLimit( void ) const { return m_iSuccessLimit; }
|
||||||
|
|
||||||
|
void Init( void ); // NOT virtual, each constructor calls their own
|
||||||
|
virtual void InitPrerequisites( void ) {};
|
||||||
|
virtual void Start( void ) = 0;
|
||||||
|
virtual void Stop( void ) = 0;
|
||||||
|
virtual void OnOpen( void ) {};
|
||||||
|
virtual void Update( void ) {};
|
||||||
|
virtual void UpdateInactive( void ) {};
|
||||||
|
|
||||||
|
virtual bool ShouldDisplay( void ) const { return true; }
|
||||||
|
virtual bool IsVisible( void ) const { return true; }
|
||||||
|
virtual bool WasDisplayed( void ) const { return m_bWasDisplayed ? true : false; }
|
||||||
|
virtual void SwapOutPlayers( int iOldUserID, int iNewUserID ) {}
|
||||||
|
virtual void TakePlaceOf( CBaseLesson *pLesson );
|
||||||
|
|
||||||
|
const char *GetGroup() { return m_szLessonGroup.String(); }
|
||||||
|
void SetEnabled( bool bEnabled ) { m_bDisabled = !bEnabled; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void MarkSucceeded( void );
|
||||||
|
void CloseOpportunity( const char *pchReason );
|
||||||
|
bool DoDelayedPlayerSwaps( void ) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
CBaseLesson *m_pRoot;
|
||||||
|
CUtlVector < CBaseLesson * > m_OpenOpportunities;
|
||||||
|
CUtlVector < const CBaseLesson * > m_Prerequisites;
|
||||||
|
|
||||||
|
CGameInstructorSymbol m_stringCloseReason;
|
||||||
|
CGameInstructorSymbol m_stringName;
|
||||||
|
|
||||||
|
bool m_bInstanceActive : 1;
|
||||||
|
bool m_bSuccessCounted : 1;
|
||||||
|
bool m_bIsDefaultHolder : 1;
|
||||||
|
bool m_bIsOpenOpportunity : 1;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
LessonInstanceType m_iInstanceType;
|
||||||
|
|
||||||
|
int m_iPriority;
|
||||||
|
CGameInstructorSymbol m_stringReplaceKey;
|
||||||
|
int m_iFixedInstancesMax;
|
||||||
|
bool m_bReplaceOnlyWhenStopped;
|
||||||
|
int m_iTeam;
|
||||||
|
bool m_bOnlyKeyboard;
|
||||||
|
bool m_bOnlyGamepad;
|
||||||
|
|
||||||
|
int m_iDisplayLimit;
|
||||||
|
int m_iDisplayCount;
|
||||||
|
bool m_bWasDisplayed;
|
||||||
|
int m_iSuccessLimit;
|
||||||
|
int m_iSuccessCount;
|
||||||
|
|
||||||
|
float m_fLockDuration;
|
||||||
|
float m_fTimeout;
|
||||||
|
float m_fInitTime;
|
||||||
|
float m_fStartTime;
|
||||||
|
float m_fLockTime;
|
||||||
|
float m_fUpdateInterval;
|
||||||
|
bool m_bHasPlayedSound;
|
||||||
|
|
||||||
|
CGameInstructorSymbol m_szStartSound;
|
||||||
|
CGameInstructorSymbol m_szLessonGroup;
|
||||||
|
|
||||||
|
bool m_bCanOpenWhenDead;
|
||||||
|
bool m_bBumpWithTimeoutWhenLearned;
|
||||||
|
bool m_bCanTimeoutWhileInactive;
|
||||||
|
bool m_bDisabled;
|
||||||
|
|
||||||
|
// Right now we can only queue up 4 swaps...
|
||||||
|
// this number can be increased if more entity handle scripted variables are added
|
||||||
|
mutable delayed_player_swap_t m_pDelayedPlayerSwap[ MAX_DELAYED_PLAYER_SWAPS ];
|
||||||
|
mutable int m_iNumDelayedPlayerSwaps;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Colors for console spew in verbose mode
|
||||||
|
static Color m_rgbaVerboseHeader;
|
||||||
|
static Color m_rgbaVerbosePlain;
|
||||||
|
static Color m_rgbaVerboseName;
|
||||||
|
static Color m_rgbaVerboseOpen;
|
||||||
|
static Color m_rgbaVerboseClose;
|
||||||
|
static Color m_rgbaVerboseSuccess;
|
||||||
|
static Color m_rgbaVerboseUpdate;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class CTextLesson : public CBaseLesson
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DECLARE_LESSON( CTextLesson, CBaseLesson );
|
||||||
|
|
||||||
|
void Init( void ); // NOT virtual, each constructor calls their own
|
||||||
|
virtual void Start( void );
|
||||||
|
virtual void Stop( void );
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
CGameInstructorSymbol m_szDisplayText;
|
||||||
|
CGameInstructorSymbol m_szDisplayParamText;
|
||||||
|
CGameInstructorSymbol m_szBinding;
|
||||||
|
CGameInstructorSymbol m_szGamepadBinding;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class CIconLesson : public CTextLesson
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DECLARE_LESSON( CIconLesson, CTextLesson );
|
||||||
|
|
||||||
|
void Init( void ); // NOT virtual, each constructor calls their own
|
||||||
|
virtual void Start( void );
|
||||||
|
virtual void Stop( void );
|
||||||
|
virtual void Update( void );
|
||||||
|
virtual void UpdateInactive( void );
|
||||||
|
|
||||||
|
virtual bool ShouldDisplay( void ) const;
|
||||||
|
virtual bool IsVisible( void ) const;
|
||||||
|
virtual void SwapOutPlayers( int iOldUserID, int iNewUserID );
|
||||||
|
virtual void TakePlaceOf( CBaseLesson *pLesson );
|
||||||
|
|
||||||
|
void SetLocatorBinding( CLocatorTarget * pLocatorTarget );
|
||||||
|
|
||||||
|
const char *GetCaptionColorString() { return m_szCaptionColor.String(); }
|
||||||
|
|
||||||
|
bool IsPresentComplete( void );
|
||||||
|
void PresentStart( void );
|
||||||
|
void PresentEnd( void );
|
||||||
|
|
||||||
|
private:
|
||||||
|
virtual void UpdateLocatorTarget( CLocatorTarget *pLocatorTarget, C_BaseEntity *pIconTarget );
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
Vector GetIconTargetPosition( C_BaseEntity *pIconTarget );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
protected:
|
||||||
|
CHandle<C_BaseEntity> m_hIconTarget;
|
||||||
|
CGameInstructorSymbol m_szVguiTargetName;
|
||||||
|
CGameInstructorSymbol m_szVguiTargetLookup;
|
||||||
|
int m_nVguiTargetEdge;
|
||||||
|
float m_flUpOffset;
|
||||||
|
float m_flRelativeUpOffset;
|
||||||
|
float m_fFixedPositionX;
|
||||||
|
float m_fFixedPositionY;
|
||||||
|
|
||||||
|
int m_hLocatorTarget;
|
||||||
|
int m_iFlags;
|
||||||
|
|
||||||
|
float m_fRange;
|
||||||
|
float m_fCurrentDistance;
|
||||||
|
float m_fOnScreenStartTime;
|
||||||
|
float m_fUpdateDistanceTime;
|
||||||
|
|
||||||
|
CGameInstructorSymbol m_szOnscreenIcon;
|
||||||
|
CGameInstructorSymbol m_szOffscreenIcon;
|
||||||
|
CGameInstructorSymbol m_szCaptionColor;
|
||||||
|
|
||||||
|
bool m_bFixedPosition;
|
||||||
|
bool m_bNoIconTarget;
|
||||||
|
bool m_bAllowNodrawTarget;
|
||||||
|
bool m_bVisible;
|
||||||
|
bool m_bShowWhenOccluded;
|
||||||
|
bool m_bNoOffscreen;
|
||||||
|
bool m_bForceCaption;
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
int m_iIconTargetPos;
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
ICON_TARGET_EYE_POSITION,
|
||||||
|
ICON_TARGET_ORIGIN,
|
||||||
|
ICON_TARGET_CENTER,
|
||||||
|
};
|
||||||
|
|
||||||
|
CGameInstructorSymbol m_szHudHint;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
enum LessonAction
|
||||||
|
{
|
||||||
|
LESSON_ACTION_NONE,
|
||||||
|
|
||||||
|
LESSON_ACTION_SCOPE_IN,
|
||||||
|
LESSON_ACTION_SCOPE_OUT,
|
||||||
|
LESSON_ACTION_CLOSE,
|
||||||
|
LESSON_ACTION_SUCCESS,
|
||||||
|
LESSON_ACTION_LOCK,
|
||||||
|
LESSON_ACTION_PRESENT_COMPLETE,
|
||||||
|
LESSON_ACTION_PRESENT_START,
|
||||||
|
LESSON_ACTION_PRESENT_END,
|
||||||
|
|
||||||
|
LESSON_ACTION_REFERENCE_OPEN,
|
||||||
|
|
||||||
|
LESSON_ACTION_SET,
|
||||||
|
LESSON_ACTION_ADD,
|
||||||
|
LESSON_ACTION_SUBTRACT,
|
||||||
|
LESSON_ACTION_MULTIPLY,
|
||||||
|
LESSON_ACTION_IS,
|
||||||
|
LESSON_ACTION_LESS_THAN,
|
||||||
|
LESSON_ACTION_HAS_PREFIX,
|
||||||
|
LESSON_ACTION_HAS_BIT,
|
||||||
|
LESSON_ACTION_BIT_COUNT_IS,
|
||||||
|
LESSON_ACTION_BIT_COUNT_LESS_THAN,
|
||||||
|
|
||||||
|
LESSON_ACTION_GET_DISTANCE,
|
||||||
|
LESSON_ACTION_GET_ANGULAR_DISTANCE,
|
||||||
|
LESSON_ACTION_GET_PLAYER_DISPLAY_NAME,
|
||||||
|
LESSON_ACTION_CLASSNAME_IS,
|
||||||
|
LESSON_ACTION_MODELNAME_IS,
|
||||||
|
LESSON_ACTION_TEAM_IS,
|
||||||
|
LESSON_ACTION_HEALTH_LESS_THAN,
|
||||||
|
LESSON_ACTION_HEALTH_PERCENTAGE_LESS_THAN,
|
||||||
|
LESSON_ACTION_GET_ACTIVE_WEAPON,
|
||||||
|
LESSON_ACTION_WEAPON_IS,
|
||||||
|
LESSON_ACTION_WEAPON_HAS,
|
||||||
|
LESSON_ACTION_GET_ACTIVE_WEAPON_SLOT,
|
||||||
|
LESSON_ACTION_GET_WEAPON_SLOT,
|
||||||
|
LESSON_ACTION_GET_WEAPON_IN_SLOT,
|
||||||
|
LESSON_ACTION_CLIP_PERCENTAGE_LESS_THAN,
|
||||||
|
LESSON_ACTION_WEAPON_AMMO_LOW,
|
||||||
|
LESSON_ACTION_WEAPON_AMMO_FULL,
|
||||||
|
LESSON_ACTION_WEAPON_AMMO_EMPTY,
|
||||||
|
LESSON_ACTION_WEAPON_CAN_USE,
|
||||||
|
LESSON_ACTION_USE_TARGET_IS,
|
||||||
|
LESSON_ACTION_GET_USE_TARGET,
|
||||||
|
LESSON_ACTION_GET_POTENTIAL_USE_TARGET,
|
||||||
|
|
||||||
|
// Enum continued in Mod_LessonAction
|
||||||
|
LESSON_ACTION_MOD_START,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct LessonElement_t
|
||||||
|
{
|
||||||
|
int iVariable;
|
||||||
|
int iParamVarIndex;
|
||||||
|
int iAction;
|
||||||
|
_fieldtypes paramType;
|
||||||
|
CGameInstructorSymbol szParam;
|
||||||
|
bool bNot : 1;
|
||||||
|
bool bOptionalParam : 1;
|
||||||
|
|
||||||
|
LessonElement_t( int p_iVariable, int p_iAction, bool p_bNot, bool p_bOptionalParam, const char *pchParam, int p_iParamVarIndex, _fieldtypes p_paramType )
|
||||||
|
{
|
||||||
|
iVariable = p_iVariable;
|
||||||
|
iAction = p_iAction;
|
||||||
|
bNot = p_bNot;
|
||||||
|
bOptionalParam = p_bOptionalParam;
|
||||||
|
szParam = pchParam;
|
||||||
|
iParamVarIndex = p_iParamVarIndex;
|
||||||
|
paramType = p_paramType;
|
||||||
|
}
|
||||||
|
|
||||||
|
LessonElement_t( const LessonElement_t &p_LessonElement )
|
||||||
|
{
|
||||||
|
iVariable = p_LessonElement.iVariable;
|
||||||
|
iAction = p_LessonElement.iAction;
|
||||||
|
bNot = p_LessonElement.bNot;
|
||||||
|
bOptionalParam = p_LessonElement.bOptionalParam;
|
||||||
|
szParam = p_LessonElement.szParam;
|
||||||
|
iParamVarIndex = p_LessonElement.iParamVarIndex;
|
||||||
|
paramType = p_LessonElement.paramType;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct LessonEvent_t
|
||||||
|
{
|
||||||
|
CUtlVector< LessonElement_t > elements;
|
||||||
|
CGameInstructorSymbol szEventName;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CScriptedIconLesson : public CIconLesson
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DECLARE_LESSON( CScriptedIconLesson, CIconLesson )
|
||||||
|
|
||||||
|
virtual ~CScriptedIconLesson( void );
|
||||||
|
|
||||||
|
static void PreReadLessonsFromFile( void );
|
||||||
|
static void Mod_PreReadLessonsFromFile( void );
|
||||||
|
|
||||||
|
void Init( void ); // NOT virtual, each constructor calls their own
|
||||||
|
virtual void InitPrerequisites( void );
|
||||||
|
virtual void OnOpen( void );
|
||||||
|
virtual void Update( void );
|
||||||
|
|
||||||
|
virtual void SwapOutPlayers( int iOldUserID, int iNewUserID );
|
||||||
|
|
||||||
|
virtual void FireGameEvent( IGameEvent *event );
|
||||||
|
virtual void ProcessOpenGameEvents( const CScriptedIconLesson *pRootLesson, const char *name, IGameEvent *event );
|
||||||
|
virtual void ProcessCloseGameEvents( const CScriptedIconLesson *pRootLesson, const char *name, IGameEvent *event );
|
||||||
|
virtual void ProcessSuccessGameEvents( const CScriptedIconLesson *pRootLesson, const char *name, IGameEvent *event );
|
||||||
|
|
||||||
|
CUtlVector< LessonEvent_t >& GetOpenEvents( void ) { return m_OpenEvents; }
|
||||||
|
CUtlVector< LessonEvent_t >& GetCloseEvents( void ) { return m_CloseEvents; }
|
||||||
|
CUtlVector< LessonEvent_t >& GetSuccessEvents( void ) { return m_SuccessEvents; }
|
||||||
|
CUtlVector< LessonEvent_t >& GetOnOpenEvents( void ) { return m_OnOpenEvents; }
|
||||||
|
CUtlVector< LessonEvent_t >& GetUpdateEvents( void ) { return m_UpdateEvents; }
|
||||||
|
|
||||||
|
bool ProcessElements( IGameEvent *event, const CUtlVector< LessonElement_t > *pElements );
|
||||||
|
|
||||||
|
private:
|
||||||
|
void InitElementsFromKeys( CUtlVector< LessonElement_t > *pLessonElements, KeyValues *pKey );
|
||||||
|
void InitElementsFromElements( CUtlVector< LessonElement_t > *pLessonElements, const CUtlVector< LessonElement_t > *pLessonElements2 );
|
||||||
|
|
||||||
|
void InitFromKeys( KeyValues *pKey );
|
||||||
|
|
||||||
|
bool ProcessElement( IGameEvent *event, const LessonElement_t *pLessonElement, bool bInFailedScope );
|
||||||
|
|
||||||
|
bool ProcessElementAction( int iAction, bool bNot, const char *pchVarName, float &bVar, const CGameInstructorSymbol *pchParamName, float fParam );
|
||||||
|
bool ProcessElementAction( int iAction, bool bNot, const char *pchVarName, int &bVar, const CGameInstructorSymbol *pchParamName, float fParam );
|
||||||
|
bool ProcessElementAction( int iAction, bool bNot, const char *pchVarName, bool &bVar, const CGameInstructorSymbol *pchParamName, float fParam );
|
||||||
|
bool ProcessElementAction( int iAction, bool bNot, const char *pchVarName, EHANDLE &hVar, const CGameInstructorSymbol *pchParamName, float fParam, C_BaseEntity *pParam, const char *pchParam );
|
||||||
|
bool ProcessElementAction( int iAction, bool bNot, const char *pchVarName, CGameInstructorSymbol *pchVar, const CGameInstructorSymbol *pchParamName, const char *pchParam );
|
||||||
|
|
||||||
|
// Implemented per mod so they can have custom actions
|
||||||
|
bool Mod_ProcessElementAction( int iAction, bool bNot, const char *pchVarName, EHANDLE &hVar, const CGameInstructorSymbol *pchParamName, float fParam, C_BaseEntity *pParam, const char *pchParam, bool &bModHandled );
|
||||||
|
|
||||||
|
LessonEvent_t * AddOpenEvent( void );
|
||||||
|
LessonEvent_t * AddCloseEvent( void );
|
||||||
|
LessonEvent_t * AddSuccessEvent( void );
|
||||||
|
LessonEvent_t * AddOnOpenEvent( void );
|
||||||
|
LessonEvent_t * AddUpdateEvent( void );
|
||||||
|
|
||||||
|
private:
|
||||||
|
static CUtlDict< int, int > CScriptedIconLesson::LessonActionMap;
|
||||||
|
|
||||||
|
EHANDLE m_hLocalPlayer;
|
||||||
|
float m_fOutput;
|
||||||
|
CHandle<C_BaseEntity> m_hEntity1;
|
||||||
|
CHandle<C_BaseEntity> m_hEntity2;
|
||||||
|
CGameInstructorSymbol m_szString1;
|
||||||
|
CGameInstructorSymbol m_szString2;
|
||||||
|
int m_iInteger1;
|
||||||
|
int m_iInteger2;
|
||||||
|
float m_fFloat1;
|
||||||
|
float m_fFloat2;
|
||||||
|
|
||||||
|
CUtlVector< CGameInstructorSymbol > m_PrerequisiteNames;
|
||||||
|
CUtlVector< LessonEvent_t > m_OpenEvents;
|
||||||
|
CUtlVector< LessonEvent_t > m_CloseEvents;
|
||||||
|
CUtlVector< LessonEvent_t > m_SuccessEvents;
|
||||||
|
CUtlVector< LessonEvent_t > m_OnOpenEvents;
|
||||||
|
CUtlVector< LessonEvent_t > m_UpdateEvents;
|
||||||
|
|
||||||
|
float m_fUpdateEventTime;
|
||||||
|
CScriptedIconLesson *m_pDefaultHolder;
|
||||||
|
|
||||||
|
int m_iScopeDepth;
|
||||||
|
|
||||||
|
// Need this to get offsets to scripted variables
|
||||||
|
friend class LessonVariableInfo;
|
||||||
|
friend int LessonActionFromString( const char *pchName );
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _C_BASELESSON_H_
|
@ -54,6 +54,10 @@
|
|||||||
#include "econ_wearable.h"
|
#include "econ_wearable.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
#include "viewrender.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
// NVNT haptics system interface
|
// NVNT haptics system interface
|
||||||
#include "haptics/ihaptics.h"
|
#include "haptics/ihaptics.h"
|
||||||
|
|
||||||
@ -132,6 +136,16 @@ void RecvProxy_LocalVelocityZ( const CRecvProxyData *pData, void *pStruct, void
|
|||||||
void RecvProxy_ObserverTarget( const CRecvProxyData *pData, void *pStruct, void *pOut );
|
void RecvProxy_ObserverTarget( const CRecvProxyData *pData, void *pStruct, void *pOut );
|
||||||
void RecvProxy_ObserverMode ( const CRecvProxyData *pData, void *pStruct, void *pOut );
|
void RecvProxy_ObserverMode ( const CRecvProxyData *pData, void *pStruct, void *pOut );
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// Needs to shift bits back
|
||||||
|
void RecvProxy_ShiftPlayerSpawnflags( const CRecvProxyData *pData, void *pStruct, void *pOut )
|
||||||
|
{
|
||||||
|
C_BasePlayer *pPlayer = (C_BasePlayer *)pStruct;
|
||||||
|
|
||||||
|
pPlayer->m_spawnflags = (pData->m_Value.m_Int) << 16;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------- //
|
// -------------------------------------------------------------------------------- //
|
||||||
// RecvTable for CPlayerState.
|
// RecvTable for CPlayerState.
|
||||||
// -------------------------------------------------------------------------------- //
|
// -------------------------------------------------------------------------------- //
|
||||||
@ -179,6 +193,11 @@ BEGIN_RECV_TABLE_NOBASE( CPlayerLocalData, DT_Local )
|
|||||||
// 3d skybox data
|
// 3d skybox data
|
||||||
RecvPropInt(RECVINFO(m_skybox3d.scale)),
|
RecvPropInt(RECVINFO(m_skybox3d.scale)),
|
||||||
RecvPropVector(RECVINFO(m_skybox3d.origin)),
|
RecvPropVector(RECVINFO(m_skybox3d.origin)),
|
||||||
|
#ifdef MAPBASE
|
||||||
|
RecvPropVector(RECVINFO(m_skybox3d.angles)),
|
||||||
|
RecvPropEHandle(RECVINFO(m_skybox3d.skycamera)),
|
||||||
|
RecvPropInt( RECVINFO( m_skybox3d.skycolor ), 0, RecvProxy_IntToColor32 ),
|
||||||
|
#endif
|
||||||
RecvPropInt(RECVINFO(m_skybox3d.area)),
|
RecvPropInt(RECVINFO(m_skybox3d.area)),
|
||||||
|
|
||||||
// 3d skybox fog data
|
// 3d skybox fog data
|
||||||
@ -190,6 +209,9 @@ BEGIN_RECV_TABLE_NOBASE( CPlayerLocalData, DT_Local )
|
|||||||
RecvPropFloat( RECVINFO( m_skybox3d.fog.start ) ),
|
RecvPropFloat( RECVINFO( m_skybox3d.fog.start ) ),
|
||||||
RecvPropFloat( RECVINFO( m_skybox3d.fog.end ) ),
|
RecvPropFloat( RECVINFO( m_skybox3d.fog.end ) ),
|
||||||
RecvPropFloat( RECVINFO( m_skybox3d.fog.maxdensity ) ),
|
RecvPropFloat( RECVINFO( m_skybox3d.fog.maxdensity ) ),
|
||||||
|
#ifdef MAPBASE
|
||||||
|
RecvPropFloat( RECVINFO( m_skybox3d.fog.farz ) ),
|
||||||
|
#endif
|
||||||
|
|
||||||
// fog data
|
// fog data
|
||||||
RecvPropEHandle( RECVINFO( m_PlayerFog.m_hCtrl ) ),
|
RecvPropEHandle( RECVINFO( m_PlayerFog.m_hCtrl ) ),
|
||||||
@ -206,6 +228,14 @@ BEGIN_RECV_TABLE_NOBASE( CPlayerLocalData, DT_Local )
|
|||||||
RecvPropInt( RECVINFO( m_audio.soundscapeIndex ) ),
|
RecvPropInt( RECVINFO( m_audio.soundscapeIndex ) ),
|
||||||
RecvPropInt( RECVINFO( m_audio.localBits ) ),
|
RecvPropInt( RECVINFO( m_audio.localBits ) ),
|
||||||
RecvPropEHandle( RECVINFO( m_audio.ent ) ),
|
RecvPropEHandle( RECVINFO( m_audio.ent ) ),
|
||||||
|
|
||||||
|
//Tony; tonemap stuff! -- TODO! Optimize this with bit sizes from env_tonemap_controller.
|
||||||
|
RecvPropFloat ( RECVINFO( m_TonemapParams.m_flTonemapScale ) ),
|
||||||
|
RecvPropFloat ( RECVINFO( m_TonemapParams.m_flTonemapRate ) ),
|
||||||
|
RecvPropFloat ( RECVINFO( m_TonemapParams.m_flBloomScale ) ),
|
||||||
|
|
||||||
|
RecvPropFloat ( RECVINFO( m_TonemapParams.m_flAutoExposureMin ) ),
|
||||||
|
RecvPropFloat ( RECVINFO( m_TonemapParams.m_flAutoExposureMax ) ),
|
||||||
END_RECV_TABLE()
|
END_RECV_TABLE()
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------- //
|
// -------------------------------------------------------------------------------- //
|
||||||
@ -248,6 +278,14 @@ END_RECV_TABLE()
|
|||||||
RecvPropInt ( RECVINFO( m_nWaterLevel ) ),
|
RecvPropInt ( RECVINFO( m_nWaterLevel ) ),
|
||||||
RecvPropFloat ( RECVINFO( m_flLaggedMovementValue )),
|
RecvPropFloat ( RECVINFO( m_flLaggedMovementValue )),
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// Transmitted from the server for internal player spawnflags.
|
||||||
|
// See baseplayer_shared.h for more details.
|
||||||
|
RecvPropInt ( RECVINFO( m_spawnflags ), 0, RecvProxy_ShiftPlayerSpawnflags ),
|
||||||
|
|
||||||
|
RecvPropBool ( RECVINFO( m_bDrawPlayerModelExternally ) ),
|
||||||
|
#endif
|
||||||
|
|
||||||
END_RECV_TABLE()
|
END_RECV_TABLE()
|
||||||
|
|
||||||
|
|
||||||
@ -296,6 +334,8 @@ END_RECV_TABLE()
|
|||||||
|
|
||||||
RecvPropString( RECVINFO(m_szLastPlaceName) ),
|
RecvPropString( RECVINFO(m_szLastPlaceName) ),
|
||||||
|
|
||||||
|
RecvPropEHandle(RECVINFO(m_hPostProcessCtrl)), // Send to everybody - for spectating
|
||||||
|
|
||||||
#if defined USES_ECON_ITEMS
|
#if defined USES_ECON_ITEMS
|
||||||
RecvPropUtlVector( RECVINFO_UTLVECTOR( m_hMyWearables ), MAX_WEARABLES_SENT_FROM_SERVER, RecvPropEHandle(NULL, 0, 0) ),
|
RecvPropUtlVector( RECVINFO_UTLVECTOR( m_hMyWearables ), MAX_WEARABLES_SENT_FROM_SERVER, RecvPropEHandle(NULL, 0, 0) ),
|
||||||
#endif
|
#endif
|
||||||
@ -399,7 +439,10 @@ BEGIN_PREDICTION_DATA( C_BasePlayer )
|
|||||||
|
|
||||||
END_PREDICTION_DATA()
|
END_PREDICTION_DATA()
|
||||||
|
|
||||||
|
// link this in each derived player class, like the server!!
|
||||||
|
#if 0
|
||||||
LINK_ENTITY_TO_CLASS( player, C_BasePlayer );
|
LINK_ENTITY_TO_CLASS( player, C_BasePlayer );
|
||||||
|
#endif
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------- //
|
// -------------------------------------------------------------------------------- //
|
||||||
// Functions.
|
// Functions.
|
||||||
@ -455,6 +498,13 @@ C_BasePlayer::~C_BasePlayer()
|
|||||||
s_pLocalPlayer = NULL;
|
s_pLocalPlayer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
if ( IsLocalPlayer() && g_pScriptVM )
|
||||||
|
{
|
||||||
|
g_pScriptVM->SetValue( "player", SCRIPT_VARIANT_NULL );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
delete m_pFlashlight;
|
delete m_pFlashlight;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -963,6 +1013,16 @@ void C_BasePlayer::OnRestore()
|
|||||||
input->ClearInputButton( IN_ATTACK | IN_ATTACK2 );
|
input->ClearInputButton( IN_ATTACK | IN_ATTACK2 );
|
||||||
// GetButtonBits() has to be called for the above to take effect
|
// GetButtonBits() has to be called for the above to take effect
|
||||||
input->GetButtonBits( 0 );
|
input->GetButtonBits( 0 );
|
||||||
|
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
// HACK: (03/25/09) Then the player goes across a transition it doesn't spawn and register
|
||||||
|
// it's instance. We're hacking around this for now, but this will go away when we get around to
|
||||||
|
// having entities cross transitions and keep their script state.
|
||||||
|
if ( g_pScriptVM )
|
||||||
|
{
|
||||||
|
g_pScriptVM->SetValue( "player", GetScriptInstance() );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// For ammo history icons to current value so they don't flash on level transtions
|
// For ammo history icons to current value so they don't flash on level transtions
|
||||||
@ -1072,6 +1132,16 @@ void C_BasePlayer::DetermineVguiInputMode( CUserCmd *pCmd )
|
|||||||
|
|
||||||
// If we're in vgui mode *and* we're holding down mouse buttons,
|
// If we're in vgui mode *and* we're holding down mouse buttons,
|
||||||
// stay in vgui mode even if we're outside the screen bounds
|
// stay in vgui mode even if we're outside the screen bounds
|
||||||
|
#ifdef VGUI_SCREEN_FIX
|
||||||
|
if (m_pCurrentVguiScreen.Get() && (pCmd->buttons & (IN_ATTACK | IN_ATTACK2 | IN_VALIDVGUIINPUT)))
|
||||||
|
{
|
||||||
|
SetVGuiScreenButtonState( m_pCurrentVguiScreen.Get(), pCmd->buttons );
|
||||||
|
|
||||||
|
// Kill all attack inputs if we're in vgui screen mode
|
||||||
|
pCmd->buttons &= ~(IN_ATTACK | IN_ATTACK2 | IN_VALIDVGUIINPUT);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#else
|
||||||
if (m_pCurrentVguiScreen.Get() && (pCmd->buttons & (IN_ATTACK | IN_ATTACK2)) )
|
if (m_pCurrentVguiScreen.Get() && (pCmd->buttons & (IN_ATTACK | IN_ATTACK2)) )
|
||||||
{
|
{
|
||||||
SetVGuiScreenButtonState( m_pCurrentVguiScreen.Get(), pCmd->buttons );
|
SetVGuiScreenButtonState( m_pCurrentVguiScreen.Get(), pCmd->buttons );
|
||||||
@ -1080,6 +1150,7 @@ void C_BasePlayer::DetermineVguiInputMode( CUserCmd *pCmd )
|
|||||||
pCmd->buttons &= ~(IN_ATTACK | IN_ATTACK2);
|
pCmd->buttons &= ~(IN_ATTACK | IN_ATTACK2);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// We're not in vgui input mode if we're moving, or have hit a key
|
// We're not in vgui input mode if we're moving, or have hit a key
|
||||||
// that will make us move...
|
// that will make us move...
|
||||||
@ -1201,7 +1272,12 @@ bool C_BasePlayer::CreateMove( float flInputSampleTime, CUserCmd *pCmd )
|
|||||||
m_vecOldViewAngles = pCmd->viewangles;
|
m_vecOldViewAngles = pCmd->viewangles;
|
||||||
|
|
||||||
// Check to see if we're in vgui input mode...
|
// Check to see if we're in vgui input mode...
|
||||||
|
#ifdef VGUI_SCREEN_FIX
|
||||||
|
if(pCmd->buttons & IN_VALIDVGUIINPUT)
|
||||||
|
DetermineVguiInputMode( pCmd );
|
||||||
|
#else
|
||||||
DetermineVguiInputMode( pCmd );
|
DetermineVguiInputMode( pCmd );
|
||||||
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1403,11 +1479,34 @@ bool C_BasePlayer::ShouldInterpolate()
|
|||||||
|
|
||||||
bool C_BasePlayer::ShouldDraw()
|
bool C_BasePlayer::ShouldDraw()
|
||||||
{
|
{
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// We have to "always draw" a player with m_bDrawPlayerModelExternally in order to show up in whatever rendering list all of the views use,
|
||||||
|
// but we can't put this in ShouldDrawThisPlayer() because we would have no way of knowing if it stomps the other checks that draw the player model anyway.
|
||||||
|
// As a result, we have to put it here in the central ShouldDraw() function. DrawModel() makes sure we only draw in non-main views and nothing's drawing the model anyway.
|
||||||
|
return (ShouldDrawThisPlayer() || m_bDrawPlayerModelExternally) && BaseClass::ShouldDraw();
|
||||||
|
#else
|
||||||
return ShouldDrawThisPlayer() && BaseClass::ShouldDraw();
|
return ShouldDrawThisPlayer() && BaseClass::ShouldDraw();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int C_BasePlayer::DrawModel( int flags )
|
int C_BasePlayer::DrawModel( int flags )
|
||||||
{
|
{
|
||||||
|
#ifdef MAPBASE
|
||||||
|
if (m_bDrawPlayerModelExternally)
|
||||||
|
{
|
||||||
|
// Draw the player in any view except the main or "intro" view, both of which are default first-person views.
|
||||||
|
view_id_t viewID = CurrentViewID();
|
||||||
|
if (viewID == VIEW_MAIN || viewID == VIEW_INTRO_CAMERA)
|
||||||
|
{
|
||||||
|
// Make sure the player model wouldn't draw anyway...
|
||||||
|
if (!ShouldDrawThisPlayer())
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return BaseClass::DrawModel( flags );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef PORTAL
|
#ifndef PORTAL
|
||||||
// In Portal this check is already performed as part of
|
// In Portal this check is already performed as part of
|
||||||
// C_Portal_Player::DrawModel()
|
// C_Portal_Player::DrawModel()
|
||||||
@ -1416,6 +1515,7 @@ int C_BasePlayer::DrawModel( int flags )
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return BaseClass::DrawModel( flags );
|
return BaseClass::DrawModel( flags );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1540,7 +1640,14 @@ void C_BasePlayer::CalcChaseCamView(Vector& eyeOrigin, QAngle& eyeAngles, float&
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( target && !target->IsPlayer() && target->IsNextBot() )
|
// SDK TODO
|
||||||
|
if ( target && target->IsBaseTrain() )
|
||||||
|
{
|
||||||
|
// if this is a train, we want to be back a little further so we can see more of it
|
||||||
|
flMaxDistance *= 2.5f;
|
||||||
|
m_flObserverChaseDistance = flMaxDistance;
|
||||||
|
}
|
||||||
|
else if ( target && !target->IsPlayer() && target->IsNextBot() )
|
||||||
{
|
{
|
||||||
// if this is a boss, we want to be back a little further so we can see more of it
|
// if this is a boss, we want to be back a little further so we can see more of it
|
||||||
flMaxDistance *= 2.5f;
|
flMaxDistance *= 2.5f;
|
||||||
@ -1873,6 +1980,12 @@ void C_BasePlayer::ThirdPersonSwitch( bool bThirdperson )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CBaseCombatWeapon *pWeapon = GetActiveWeapon();
|
||||||
|
if ( pWeapon )
|
||||||
|
pWeapon->ThirdPersonSwitch( bThirdperson );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2821,6 +2934,14 @@ void C_BasePlayer::UpdateFogBlend( void )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
C_PostProcessController* C_BasePlayer::GetActivePostProcessController() const
|
||||||
|
{
|
||||||
|
return m_hPostProcessCtrl.Get();
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose:
|
// Purpose:
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "hintsystem.h"
|
#include "hintsystem.h"
|
||||||
#include "SoundEmitterSystem/isoundemittersystembase.h"
|
#include "SoundEmitterSystem/isoundemittersystembase.h"
|
||||||
#include "c_env_fog_controller.h"
|
#include "c_env_fog_controller.h"
|
||||||
|
#include "c_postprocesscontroller.h"
|
||||||
#include "igameevents.h"
|
#include "igameevents.h"
|
||||||
#include "GameEventListener.h"
|
#include "GameEventListener.h"
|
||||||
|
|
||||||
@ -37,6 +38,7 @@ class C_BaseViewModel;
|
|||||||
class C_FuncLadder;
|
class C_FuncLadder;
|
||||||
class CFlashlightEffect;
|
class CFlashlightEffect;
|
||||||
class C_EconWearable;
|
class C_EconWearable;
|
||||||
|
class C_PostProcessController;
|
||||||
|
|
||||||
extern int g_nKillCamMode;
|
extern int g_nKillCamMode;
|
||||||
extern int g_nKillCamTarget1;
|
extern int g_nKillCamTarget1;
|
||||||
@ -183,7 +185,7 @@ public:
|
|||||||
|
|
||||||
// Flashlight
|
// Flashlight
|
||||||
void Flashlight( void );
|
void Flashlight( void );
|
||||||
void UpdateFlashlight( void );
|
virtual void UpdateFlashlight( void );
|
||||||
|
|
||||||
// Weapon selection code
|
// Weapon selection code
|
||||||
virtual bool IsAllowedToSwitchWeapons( void ) { return !IsObserver(); }
|
virtual bool IsAllowedToSwitchWeapons( void ) { return !IsObserver(); }
|
||||||
@ -379,6 +381,8 @@ public:
|
|||||||
void UpdateFogController( void );
|
void UpdateFogController( void );
|
||||||
void UpdateFogBlend( void );
|
void UpdateFogBlend( void );
|
||||||
|
|
||||||
|
C_PostProcessController* GetActivePostProcessController() const;
|
||||||
|
|
||||||
float GetFOVTime( void ){ return m_flFOVTime; }
|
float GetFOVTime( void ){ return m_flFOVTime; }
|
||||||
|
|
||||||
virtual void OnAchievementAchieved( int iAchievement ) {}
|
virtual void OnAchievementAchieved( int iAchievement ) {}
|
||||||
@ -443,20 +447,33 @@ public:
|
|||||||
float m_flConstraintWidth;
|
float m_flConstraintWidth;
|
||||||
float m_flConstraintSpeedFactor;
|
float m_flConstraintSpeedFactor;
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// Transmitted from the server for internal player spawnflags.
|
||||||
|
// See baseplayer_shared.h for more details.
|
||||||
|
int m_spawnflags;
|
||||||
|
|
||||||
|
inline bool HasSpawnFlags( int flags ) { return (m_spawnflags & flags) != 0; }
|
||||||
|
inline void RemoveSpawnFlags( int flags ) { m_spawnflags &= ~flags; }
|
||||||
|
inline void AddSpawnFlags( int flags ) { m_spawnflags |= flags; }
|
||||||
|
|
||||||
|
// Allows the player's model to draw on non-main views, like monitors or mirrors.
|
||||||
|
bool m_bDrawPlayerModelExternally;
|
||||||
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void CalcPlayerView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
|
//Tony; made all of these virtual so mods can override.
|
||||||
void CalcVehicleView(IClientVehicle *pVehicle, Vector& eyeOrigin, QAngle& eyeAngles,
|
virtual void CalcPlayerView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
|
||||||
float& zNear, float& zFar, float& fov );
|
virtual void CalcVehicleView(IClientVehicle *pVehicle, Vector& eyeOrigin, QAngle& eyeAngles, float& zNear, float& zFar, float& fov );
|
||||||
virtual void CalcObserverView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
|
virtual void CalcObserverView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
|
||||||
virtual Vector GetChaseCamViewOffset( CBaseEntity *target );
|
virtual Vector GetChaseCamViewOffset( CBaseEntity *target );
|
||||||
void CalcChaseCamView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
|
virtual void CalcChaseCamView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
|
||||||
virtual void CalcInEyeCamView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
|
virtual void CalcInEyeCamView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
|
||||||
|
|
||||||
virtual float GetDeathCamInterpolationTime();
|
virtual float GetDeathCamInterpolationTime();
|
||||||
|
|
||||||
virtual void CalcDeathCamView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
|
virtual void CalcDeathCamView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
|
||||||
void CalcRoamingView(Vector& eyeOrigin, QAngle& eyeAngles, float& fov);
|
virtual void CalcRoamingView(Vector& eyeOrigin, QAngle& eyeAngles, float& fov);
|
||||||
virtual void CalcFreezeCamView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
|
virtual void CalcFreezeCamView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
|
||||||
|
|
||||||
// Check to see if we're in vgui input mode...
|
// Check to see if we're in vgui input mode...
|
||||||
@ -629,6 +646,8 @@ private:
|
|||||||
// One for left and one for right side of step
|
// One for left and one for right side of step
|
||||||
StepSoundCache_t m_StepSoundCache[ 2 ];
|
StepSoundCache_t m_StepSoundCache[ 2 ];
|
||||||
|
|
||||||
|
CNetworkHandle(C_PostProcessController, m_hPostProcessCtrl); // active postprocessing controller
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
const char *GetLastKnownPlaceName( void ) const { return m_szLastPlaceName; } // return the last nav place name the player occupied
|
const char *GetLastKnownPlaceName( void ) const { return m_szLastPlaceName; } // return the last nav place name the player occupied
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
//
|
//
|
||||||
//=============================================================================//
|
//=============================================================================//
|
||||||
#include "cbase.h"
|
#include "cbase.h"
|
||||||
|
#include "c_effects.h"
|
||||||
#include "c_tracer.h"
|
#include "c_tracer.h"
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
#include "initializer.h"
|
#include "initializer.h"
|
||||||
@ -22,6 +23,7 @@
|
|||||||
#include "collisionutils.h"
|
#include "collisionutils.h"
|
||||||
#include "tier0/vprof.h"
|
#include "tier0/vprof.h"
|
||||||
#include "viewrender.h"
|
#include "viewrender.h"
|
||||||
|
#include "raytrace.h"
|
||||||
|
|
||||||
// memdbgon must be the last include file in a .cpp file!!!
|
// memdbgon must be the last include file in a .cpp file!!!
|
||||||
#include "tier0/memdbgon.h"
|
#include "tier0/memdbgon.h"
|
||||||
@ -35,6 +37,12 @@ float g_flSplashLifetime = 0.5f;
|
|||||||
float g_flSplashAlpha = 0.3f;
|
float g_flSplashAlpha = 0.3f;
|
||||||
ConVar r_RainSplashPercentage( "r_RainSplashPercentage", "20", FCVAR_CHEAT ); // N% chance of a rain particle making a splash.
|
ConVar r_RainSplashPercentage( "r_RainSplashPercentage", "20", FCVAR_CHEAT ); // N% chance of a rain particle making a splash.
|
||||||
|
|
||||||
|
ConVar r_RainParticleDensity( "r_RainParticleDensity", "1", FCVAR_NONE, "Density of Particle Rain 0-1" );
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
ConVar r_RainParticleClampOffset( "r_RainParticleClampOffset", "112", FCVAR_NONE, "How far inward or outward to extrude clamped precipitation particle systems" );
|
||||||
|
ConVar r_RainParticleClampDebug( "r_RainParticleClampDebug", "0", FCVAR_NONE, "Enables debug code for precipitation particle system clamping" );
|
||||||
|
#endif
|
||||||
|
|
||||||
float GUST_INTERVAL_MIN = 1;
|
float GUST_INTERVAL_MIN = 1;
|
||||||
float GUST_INTERVAL_MAX = 2;
|
float GUST_INTERVAL_MAX = 2;
|
||||||
@ -60,151 +68,14 @@ CLIENTEFFECT_MATERIAL( "particle/rain" )
|
|||||||
CLIENTEFFECT_MATERIAL( "particle/snow" )
|
CLIENTEFFECT_MATERIAL( "particle/snow" )
|
||||||
CLIENTEFFECT_REGISTER_END()
|
CLIENTEFFECT_REGISTER_END()
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
CUtlVector< RayTracingEnvironment* > g_RayTraceEnvironments;
|
||||||
// Precipitation particle type
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class CPrecipitationParticle
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Vector m_Pos;
|
|
||||||
Vector m_Velocity;
|
|
||||||
float m_SpawnTime; // Note: Tweak with this to change lifetime
|
|
||||||
float m_Mass;
|
|
||||||
float m_Ramp;
|
|
||||||
|
|
||||||
float m_flCurLifetime;
|
|
||||||
float m_flMaxLifetime;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class CClient_Precipitation;
|
|
||||||
static CUtlVector<CClient_Precipitation*> g_Precipitations;
|
|
||||||
|
|
||||||
//===========
|
|
||||||
// Snow fall
|
|
||||||
//===========
|
|
||||||
class CSnowFallManager;
|
|
||||||
static CSnowFallManager *s_pSnowFallMgr = NULL;
|
|
||||||
bool SnowFallManagerCreate( CClient_Precipitation *pSnowEntity );
|
|
||||||
void SnowFallManagerDestroy( void );
|
|
||||||
|
|
||||||
class AshDebrisEffect : public CSimpleEmitter
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AshDebrisEffect( const char *pDebugName ) : CSimpleEmitter( pDebugName ) {}
|
|
||||||
|
|
||||||
static AshDebrisEffect* Create( const char *pDebugName );
|
|
||||||
|
|
||||||
virtual float UpdateAlpha( const SimpleParticle *pParticle );
|
|
||||||
virtual float UpdateRoll( SimpleParticle *pParticle, float timeDelta );
|
|
||||||
|
|
||||||
private:
|
|
||||||
AshDebrisEffect( const AshDebrisEffect & );
|
|
||||||
};
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Precipitation base entity
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class CClient_Precipitation : public C_BaseEntity
|
|
||||||
{
|
|
||||||
class CPrecipitationEffect;
|
|
||||||
friend class CClient_Precipitation::CPrecipitationEffect;
|
|
||||||
|
|
||||||
public:
|
|
||||||
DECLARE_CLASS( CClient_Precipitation, C_BaseEntity );
|
|
||||||
DECLARE_CLIENTCLASS();
|
|
||||||
|
|
||||||
CClient_Precipitation();
|
|
||||||
virtual ~CClient_Precipitation();
|
|
||||||
|
|
||||||
// Inherited from C_BaseEntity
|
|
||||||
virtual void Precache( );
|
|
||||||
|
|
||||||
void Render();
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
// Creates a single particle
|
|
||||||
CPrecipitationParticle* CreateParticle();
|
|
||||||
|
|
||||||
virtual void OnDataChanged( DataUpdateType_t updateType );
|
|
||||||
virtual void ClientThink();
|
|
||||||
|
|
||||||
void Simulate( float dt );
|
|
||||||
|
|
||||||
// Renders the particle
|
|
||||||
void RenderParticle( CPrecipitationParticle* pParticle, CMeshBuilder &mb );
|
|
||||||
|
|
||||||
void CreateWaterSplashes();
|
|
||||||
|
|
||||||
// Emits the actual particles
|
|
||||||
void EmitParticles( float fTimeDelta );
|
|
||||||
|
|
||||||
// Computes where we're gonna emit
|
|
||||||
bool ComputeEmissionArea( Vector& origin, Vector2D& size );
|
|
||||||
|
|
||||||
// Gets the tracer width and speed
|
|
||||||
float GetWidth() const;
|
|
||||||
float GetLength() const;
|
|
||||||
float GetSpeed() const;
|
|
||||||
|
|
||||||
// Gets the remaining lifetime of the particle
|
|
||||||
float GetRemainingLifetime( CPrecipitationParticle* pParticle ) const;
|
|
||||||
|
|
||||||
// Computes the wind vector
|
|
||||||
static void ComputeWindVector( );
|
|
||||||
|
|
||||||
// simulation methods
|
|
||||||
bool SimulateRain( CPrecipitationParticle* pParticle, float dt );
|
|
||||||
bool SimulateSnow( CPrecipitationParticle* pParticle, float dt );
|
|
||||||
|
|
||||||
void CreateAshParticle( void );
|
|
||||||
void CreateRainOrSnowParticle( Vector vSpawnPosition, Vector vVelocity );
|
|
||||||
|
|
||||||
// Information helpful in creating and rendering particles
|
|
||||||
IMaterial *m_MatHandle; // material used
|
|
||||||
|
|
||||||
float m_Color[4]; // precip color
|
|
||||||
float m_Lifetime; // Precip lifetime
|
|
||||||
float m_InitialRamp; // Initial ramp value
|
|
||||||
float m_Speed; // Precip speed
|
|
||||||
float m_Width; // Tracer width
|
|
||||||
float m_Remainder; // particles we should render next time
|
|
||||||
PrecipitationType_t m_nPrecipType; // Precip type
|
|
||||||
float m_flHalfScreenWidth; // Precalculated each frame.
|
|
||||||
|
|
||||||
float m_flDensity;
|
|
||||||
|
|
||||||
// Some state used in rendering and simulation
|
|
||||||
// Used to modify the rain density and wind from the console
|
|
||||||
static ConVar s_raindensity;
|
|
||||||
static ConVar s_rainwidth;
|
|
||||||
static ConVar s_rainlength;
|
|
||||||
static ConVar s_rainspeed;
|
|
||||||
|
|
||||||
static Vector s_WindVector; // Stores the wind speed vector
|
|
||||||
|
|
||||||
CUtlLinkedList<CPrecipitationParticle> m_Particles;
|
|
||||||
CUtlVector<Vector> m_Splashes;
|
|
||||||
|
|
||||||
CSmartPtr<AshDebrisEffect> m_pAshEmitter;
|
|
||||||
TimedEvent m_tAshParticleTimer;
|
|
||||||
TimedEvent m_tAshParticleTraceTimer;
|
|
||||||
bool m_bActiveAshEmitter;
|
|
||||||
Vector m_vAshSpawnOrigin;
|
|
||||||
|
|
||||||
int m_iAshCount;
|
|
||||||
|
|
||||||
private:
|
|
||||||
CClient_Precipitation( const CClient_Precipitation & ); // not defined, not accessible
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// Just receive the normal data table stuff
|
// Just receive the normal data table stuff
|
||||||
IMPLEMENT_CLIENTCLASS_DT(CClient_Precipitation, DT_Precipitation, CPrecipitation)
|
IMPLEMENT_CLIENTCLASS_DT(CClient_Precipitation, DT_Precipitation, CPrecipitation)
|
||||||
RecvPropInt( RECVINFO( m_nPrecipType ) )
|
RecvPropInt( RECVINFO( m_nPrecipType ) ),
|
||||||
|
#ifdef MAPBASE
|
||||||
|
RecvPropInt( RECVINFO( m_spawnflags ) ),
|
||||||
|
#endif
|
||||||
END_RECV_TABLE()
|
END_RECV_TABLE()
|
||||||
|
|
||||||
static ConVar r_SnowEnable( "r_SnowEnable", "1", FCVAR_CHEAT, "Snow Enable" );
|
static ConVar r_SnowEnable( "r_SnowEnable", "1", FCVAR_CHEAT, "Snow Enable" );
|
||||||
@ -396,6 +267,12 @@ inline bool CClient_Precipitation::SimulateSnow( CPrecipitationParticle* pPartic
|
|||||||
|
|
||||||
void CClient_Precipitation::Simulate( float dt )
|
void CClient_Precipitation::Simulate( float dt )
|
||||||
{
|
{
|
||||||
|
if ( IsParticleRainType(m_nPrecipType) )
|
||||||
|
{
|
||||||
|
CreateParticlePrecip();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE: When client-side prechaching works, we need to remove this
|
// NOTE: When client-side prechaching works, we need to remove this
|
||||||
Precache();
|
Precache();
|
||||||
|
|
||||||
@ -472,6 +349,9 @@ inline void CClient_Precipitation::RenderParticle( CPrecipitationParticle* pPart
|
|||||||
float scale;
|
float scale;
|
||||||
Vector start, delta;
|
Vector start, delta;
|
||||||
|
|
||||||
|
if ( IsParticleRainType(m_nPrecipType) )
|
||||||
|
return;
|
||||||
|
|
||||||
if ( m_nPrecipType == PRECIPITATION_TYPE_ASH )
|
if ( m_nPrecipType == PRECIPITATION_TYPE_ASH )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -562,6 +442,9 @@ void CClient_Precipitation::Render()
|
|||||||
if ( !r_DrawRain.GetInt() )
|
if ( !r_DrawRain.GetInt() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if ( IsParticleRainType(m_nPrecipType) )
|
||||||
|
return;
|
||||||
|
|
||||||
// Don't render in monitors or in reflections or refractions.
|
// Don't render in monitors or in reflections or refractions.
|
||||||
if ( CurrentViewID() == VIEW_MONITOR )
|
if ( CurrentViewID() == VIEW_MONITOR )
|
||||||
return;
|
return;
|
||||||
@ -632,6 +515,11 @@ CClient_Precipitation::CClient_Precipitation() : m_Remainder(0.0f)
|
|||||||
m_nPrecipType = PRECIPITATION_TYPE_RAIN;
|
m_nPrecipType = PRECIPITATION_TYPE_RAIN;
|
||||||
m_MatHandle = INVALID_MATERIAL_HANDLE;
|
m_MatHandle = INVALID_MATERIAL_HANDLE;
|
||||||
m_flHalfScreenWidth = 1;
|
m_flHalfScreenWidth = 1;
|
||||||
|
|
||||||
|
m_pParticlePrecipInnerNear = NULL;
|
||||||
|
m_pParticlePrecipInnerFar = NULL;
|
||||||
|
m_pParticlePrecipOuter = NULL;
|
||||||
|
m_bActiveParticlePrecipEmitter = false;
|
||||||
|
|
||||||
g_Precipitations.AddToTail( this );
|
g_Precipitations.AddToTail( this );
|
||||||
}
|
}
|
||||||
@ -1011,6 +899,363 @@ void CClient_Precipitation::CreateAshParticle( void )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CClient_Precipitation::PrecacheParticlePrecip( void )
|
||||||
|
{
|
||||||
|
if ( m_nPrecipType == PRECIPITATION_TYPE_PARTICLEASH )
|
||||||
|
{
|
||||||
|
PrecacheParticleSystem( "ash" );
|
||||||
|
PrecacheParticleSystem( "ash_outer" );
|
||||||
|
}
|
||||||
|
else if ( m_nPrecipType == PRECIPITATION_TYPE_PARTICLESNOW )
|
||||||
|
{
|
||||||
|
PrecacheParticleSystem( "snow" );
|
||||||
|
PrecacheParticleSystem( "snow_outer" );
|
||||||
|
}
|
||||||
|
else if ( m_nPrecipType == PRECIPITATION_TYPE_PARTICLERAINSTORM )
|
||||||
|
{
|
||||||
|
PrecacheParticleSystem( "rain_storm" );
|
||||||
|
PrecacheParticleSystem( "rain_storm_screen" );
|
||||||
|
PrecacheParticleSystem( "rain_storm_outer" );
|
||||||
|
}
|
||||||
|
else //default to rain
|
||||||
|
{
|
||||||
|
PrecacheParticleSystem( "rain" );
|
||||||
|
PrecacheParticleSystem( "rain_outer" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CClient_Precipitation::CreateParticlePrecip( void )
|
||||||
|
{
|
||||||
|
if ( !m_bParticlePrecipInitialized )
|
||||||
|
{
|
||||||
|
PrecacheParticlePrecip();
|
||||||
|
InitializeParticlePrecip();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||||
|
|
||||||
|
if ( pPlayer == NULL )
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Make sure the emitter is setup
|
||||||
|
if ( !m_bActiveParticlePrecipEmitter )
|
||||||
|
{
|
||||||
|
//Update 8 times per second.
|
||||||
|
m_tParticlePrecipTraceTimer.Init( 8 );
|
||||||
|
DestroyInnerParticlePrecip();
|
||||||
|
DestroyOuterParticlePrecip();
|
||||||
|
m_bActiveParticlePrecipEmitter = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateParticlePrecip( pPlayer );
|
||||||
|
}
|
||||||
|
|
||||||
|
void CClient_Precipitation::UpdateParticlePrecip( C_BasePlayer *pPlayer )
|
||||||
|
{
|
||||||
|
if ( !pPlayer )
|
||||||
|
return;
|
||||||
|
|
||||||
|
Vector vForward;
|
||||||
|
Vector vRight;
|
||||||
|
|
||||||
|
pPlayer->GetVectors( &vForward, &vRight, NULL );
|
||||||
|
vForward.z = 0.0f;
|
||||||
|
vForward.NormalizeInPlace();
|
||||||
|
Vector vForward45Right = vForward + vRight;
|
||||||
|
Vector vForward45Left = vForward - vRight;
|
||||||
|
vForward45Right.NormalizeInPlace();
|
||||||
|
vForward45Left.NormalizeInPlace();
|
||||||
|
fltx4 TMax = ReplicateX4( 320.0f );
|
||||||
|
SubFloat( TMax, 3 ) = FLT_MAX;
|
||||||
|
float curTime = gpGlobals->frametime;
|
||||||
|
|
||||||
|
while ( m_tParticlePrecipTraceTimer.NextEvent( curTime ) )
|
||||||
|
{
|
||||||
|
Vector vPlayerPos = pPlayer->EyePosition();
|
||||||
|
Vector vOffsetPos = vPlayerPos + Vector ( 0, 0, 180 );
|
||||||
|
Vector vOffsetPosNear = vPlayerPos + Vector ( 0, 0, 180 ) + ( vForward * 32 );
|
||||||
|
Vector vOffsetPosFar = vPlayerPos + Vector ( 0, 0, 180 ) + ( vForward * 100 );
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
if (m_spawnflags & SF_PRECIP_PARTICLE_CLAMP)
|
||||||
|
{
|
||||||
|
Vector mins, maxs;
|
||||||
|
modelinfo->GetModelBounds( GetModel(), mins, maxs );
|
||||||
|
|
||||||
|
// Account for precipitation height
|
||||||
|
maxs.z += 180;
|
||||||
|
|
||||||
|
Vector vecOrigin; //= WorldSpaceCenter();
|
||||||
|
VectorLerp( mins, maxs, 0.5f, vecOrigin );
|
||||||
|
|
||||||
|
maxs -= vecOrigin;
|
||||||
|
mins -= vecOrigin;
|
||||||
|
|
||||||
|
float flMax = r_RainParticleClampOffset.GetFloat();
|
||||||
|
Vector addend( flMax, flMax, 0 );
|
||||||
|
mins += addend;
|
||||||
|
maxs -= addend;
|
||||||
|
|
||||||
|
if (flMax > 0)
|
||||||
|
{
|
||||||
|
// Unless this is extruding outwards, make sure the offset isn't inverting the bounds.
|
||||||
|
// This means precipitation triggers with bounds less than offset*2 will turn into a thin line
|
||||||
|
// and the involved precipitation will pretty much be spatial at all times, which is okay.
|
||||||
|
mins.x = clamp( mins.x, -FLT_MAX, -1 );
|
||||||
|
mins.y = clamp( mins.y, -FLT_MAX, -1 );
|
||||||
|
maxs.x = clamp( maxs.x, 1, FLT_MAX );
|
||||||
|
maxs.y = clamp( maxs.y, 1, FLT_MAX );
|
||||||
|
}
|
||||||
|
|
||||||
|
if (r_RainParticleClampDebug.GetBool())
|
||||||
|
debugoverlay->AddBoxOverlay( vecOrigin, mins, maxs, vec3_angle, 255, 0, 0, 128, 0.15f );
|
||||||
|
|
||||||
|
maxs += vecOrigin;
|
||||||
|
mins += vecOrigin;
|
||||||
|
|
||||||
|
CalcClosestPointOnAABB( mins, maxs, vPlayerPos, vPlayerPos );
|
||||||
|
CalcClosestPointOnAABB( mins, maxs, vOffsetPos, vOffsetPos );
|
||||||
|
CalcClosestPointOnAABB( mins, maxs, vOffsetPosNear, vOffsetPosNear );
|
||||||
|
CalcClosestPointOnAABB( mins, maxs, vOffsetPosFar, vOffsetPosFar );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Vector vDensity = Vector( r_RainParticleDensity.GetFloat(), 0, 0 ) * m_flDensity;
|
||||||
|
|
||||||
|
// Get the rain volume Ray Tracing Environment. Currently hard coded to 0, should have this lookup
|
||||||
|
RayTracingEnvironment *RtEnv = g_RayTraceEnvironments.Element( 0 );
|
||||||
|
|
||||||
|
// Our 4 Rays are forward, off to the left and right, and directly up.
|
||||||
|
// Use the first three to determine if there's generally visible rain where we're looking.
|
||||||
|
// The forth, straight up, tells us if we're standing inside a rain volume
|
||||||
|
// (based on the normal that we hit or if we miss entirely)
|
||||||
|
FourRays frRays;
|
||||||
|
FourVectors fvDirection;
|
||||||
|
fvDirection = FourVectors( vForward, vForward45Left, vForward45Right, Vector( 0, 0, 1 ) );
|
||||||
|
frRays.direction = fvDirection;
|
||||||
|
frRays.origin.DuplicateVector( vPlayerPos );
|
||||||
|
RayTracingResult Result;
|
||||||
|
|
||||||
|
RtEnv->Trace4Rays( frRays, Four_Zeros, TMax, &Result );
|
||||||
|
|
||||||
|
i32x4 in4HitIds = LoadAlignedIntSIMD( Result.HitIds );
|
||||||
|
fltx4 fl4HitIds = SignedIntConvertToFltSIMD ( in4HitIds );
|
||||||
|
|
||||||
|
fltx4 fl4Tolerance = ReplicateX4( 300.0f );
|
||||||
|
// ignore upwards test for tolerance, as we may be below an area which is raining, but with it not visible in front of us
|
||||||
|
//SubFloat( fl4Tolerance, 3 ) = 0.0f;
|
||||||
|
|
||||||
|
bool bInside = ( Result.HitIds[3] != -1 && Result.surface_normal.Vec( 3 ).z < 0.0f );
|
||||||
|
bool bNearby = ( IsAnyNegative ( CmpGeSIMD ( fl4HitIds, Four_Zeros ) ) && IsAnyNegative( CmpGeSIMD( fl4Tolerance, Result.HitDistance ) ) );
|
||||||
|
|
||||||
|
if ( bInside || bNearby )
|
||||||
|
{
|
||||||
|
//We can see a rain volume, but it's farther than 180 units away, only use far effect.
|
||||||
|
if ( !bInside && SubFloat( FindLowestSIMD3( Result.HitDistance ), 0 ) >= m_flParticleInnerDist )
|
||||||
|
{
|
||||||
|
// Kill the inner rain if it's previously been in use
|
||||||
|
if ( m_pParticlePrecipInnerNear != NULL )
|
||||||
|
{
|
||||||
|
DestroyInnerParticlePrecip();
|
||||||
|
}
|
||||||
|
// Update if we've already got systems, otherwise, create them.
|
||||||
|
if ( m_pParticlePrecipOuter != NULL )
|
||||||
|
{
|
||||||
|
m_pParticlePrecipOuter->SetControlPoint( 1, vOffsetPos );
|
||||||
|
m_pParticlePrecipOuter->SetControlPoint( 3, vDensity );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DispatchOuterParticlePrecip( pPlayer, vForward );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else //We're close enough to use the near effect.
|
||||||
|
{
|
||||||
|
// Update if we've already got systems, otherwise, create them.
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// The outer can now be suppressed without interfering with other functionality
|
||||||
|
if ( m_pParticlePrecipOuter != NULL )
|
||||||
|
{
|
||||||
|
m_pParticlePrecipOuter->SetControlPoint( 1, vOffsetPos );
|
||||||
|
m_pParticlePrecipOuter->SetControlPoint( 3, vDensity );
|
||||||
|
}
|
||||||
|
if ( m_pParticlePrecipInnerNear != NULL && m_pParticlePrecipInnerFar != NULL )
|
||||||
|
{
|
||||||
|
m_pParticlePrecipInnerNear->SetControlPoint( 1, vOffsetPosNear );
|
||||||
|
m_pParticlePrecipInnerFar->SetControlPoint( 1, vOffsetPosFar );
|
||||||
|
m_pParticlePrecipInnerNear->SetControlPoint( 3, vDensity );
|
||||||
|
m_pParticlePrecipInnerFar->SetControlPoint( 3, vDensity );
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if ( m_pParticlePrecipInnerNear != NULL && m_pParticlePrecipInnerFar != NULL && m_pParticlePrecipOuter != NULL )
|
||||||
|
{
|
||||||
|
m_pParticlePrecipOuter->SetControlPoint( 1, vOffsetPos );
|
||||||
|
m_pParticlePrecipInnerNear->SetControlPoint( 1, vOffsetPosNear );
|
||||||
|
m_pParticlePrecipInnerFar->SetControlPoint( 1, vOffsetPosFar );
|
||||||
|
m_pParticlePrecipInnerNear->SetControlPoint( 3, vDensity );
|
||||||
|
m_pParticlePrecipInnerFar->SetControlPoint( 3, vDensity );
|
||||||
|
m_pParticlePrecipOuter->SetControlPoint( 3, vDensity );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DispatchInnerParticlePrecip( pPlayer, vForward );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // No rain in the area, kill any leftover systems.
|
||||||
|
{
|
||||||
|
DestroyInnerParticlePrecip();
|
||||||
|
DestroyOuterParticlePrecip();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CClient_Precipitation::InitializeParticlePrecip( void )
|
||||||
|
{
|
||||||
|
//Set up which type of precipitation particle we'll use
|
||||||
|
if ( m_nPrecipType == PRECIPITATION_TYPE_PARTICLEASH )
|
||||||
|
{
|
||||||
|
m_pParticleInnerNearDef = "ash";
|
||||||
|
m_pParticleInnerFarDef = "ash";
|
||||||
|
m_pParticleOuterDef = "ash_outer";
|
||||||
|
m_flParticleInnerDist = 280.0;
|
||||||
|
}
|
||||||
|
else if ( m_nPrecipType == PRECIPITATION_TYPE_PARTICLESNOW )
|
||||||
|
{
|
||||||
|
m_pParticleInnerNearDef = "snow";
|
||||||
|
m_pParticleInnerFarDef = "snow";
|
||||||
|
m_pParticleOuterDef = "snow_outer";
|
||||||
|
m_flParticleInnerDist = 280.0;
|
||||||
|
}
|
||||||
|
else if ( m_nPrecipType == PRECIPITATION_TYPE_PARTICLERAINSTORM )
|
||||||
|
{
|
||||||
|
m_pParticleInnerNearDef = "rain_storm";
|
||||||
|
m_pParticleInnerFarDef = "rain_storm_screen";
|
||||||
|
m_pParticleOuterDef = "rain_storm_outer";
|
||||||
|
m_flParticleInnerDist = 0.0;
|
||||||
|
}
|
||||||
|
else //default to rain
|
||||||
|
{
|
||||||
|
m_pParticleInnerNearDef = "rain";
|
||||||
|
m_pParticleInnerFarDef = "rain";
|
||||||
|
m_pParticleOuterDef = "rain_outer";
|
||||||
|
m_flParticleInnerDist = 180.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert( m_pParticleInnerFarDef != NULL );
|
||||||
|
|
||||||
|
//We'll want to change this if/when we add more raytrace environments.
|
||||||
|
g_RayTraceEnvironments.PurgeAndDeleteElements();
|
||||||
|
|
||||||
|
// Sets up ray tracing environments for all func_precipitations and func_precipitation_blockers
|
||||||
|
RayTracingEnvironment *rtEnvRainEmission = new RayTracingEnvironment();
|
||||||
|
g_RayTraceEnvironments.AddToTail( rtEnvRainEmission );
|
||||||
|
RayTracingEnvironment *rtEnvRainBlocker = new RayTracingEnvironment();
|
||||||
|
g_RayTraceEnvironments.AddToTail( rtEnvRainBlocker );
|
||||||
|
|
||||||
|
rtEnvRainEmission->Flags |= RTE_FLAGS_DONT_STORE_TRIANGLE_COLORS; // save some ram
|
||||||
|
rtEnvRainBlocker->Flags |= RTE_FLAGS_DONT_STORE_TRIANGLE_COLORS; // save some ram
|
||||||
|
|
||||||
|
int nTriCount = 1;
|
||||||
|
for ( int i=0; i<g_Precipitations.Count(); ++i )
|
||||||
|
{
|
||||||
|
CClient_Precipitation *volume = g_Precipitations[i];
|
||||||
|
|
||||||
|
vcollide_t *pCollide = modelinfo->GetVCollide( volume->GetModelIndex() );
|
||||||
|
|
||||||
|
if ( !pCollide || pCollide->solidCount <= 0 )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Vector *outVerts;
|
||||||
|
int vertCount = physcollision->CreateDebugMesh( pCollide->solids[0], &outVerts );
|
||||||
|
|
||||||
|
if ( vertCount )
|
||||||
|
{
|
||||||
|
for ( int j = 0; j < vertCount; j += 3 )
|
||||||
|
{
|
||||||
|
rtEnvRainEmission->AddTriangle( nTriCount++, outVerts[j], outVerts[j + 1], outVerts[j + 2], Vector( 1, 1, 1 ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
physcollision->DestroyDebugMesh( vertCount, outVerts );
|
||||||
|
}
|
||||||
|
rtEnvRainEmission->SetupAccelerationStructure();
|
||||||
|
|
||||||
|
m_bParticlePrecipInitialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CClient_Precipitation::DestroyInnerParticlePrecip( void )
|
||||||
|
{
|
||||||
|
if ( m_pParticlePrecipInnerFar != NULL )
|
||||||
|
{
|
||||||
|
m_pParticlePrecipInnerFar->StopEmission();
|
||||||
|
m_pParticlePrecipInnerFar = NULL;
|
||||||
|
}
|
||||||
|
if ( m_pParticlePrecipInnerNear != NULL )
|
||||||
|
{
|
||||||
|
m_pParticlePrecipInnerNear->StopEmission();
|
||||||
|
m_pParticlePrecipInnerNear = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CClient_Precipitation::DestroyOuterParticlePrecip( void )
|
||||||
|
{
|
||||||
|
if ( m_pParticlePrecipOuter != NULL )
|
||||||
|
{
|
||||||
|
m_pParticlePrecipOuter->StopEmission();
|
||||||
|
m_pParticlePrecipOuter = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CClient_Precipitation::DispatchOuterParticlePrecip( C_BasePlayer *pPlayer, Vector vForward )
|
||||||
|
{
|
||||||
|
DestroyOuterParticlePrecip();
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
if (m_spawnflags & SF_PRECIP_PARTICLE_NO_OUTER)
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Vector vDensity = Vector( r_RainParticleDensity.GetFloat(), 0, 0 ) * m_flDensity;
|
||||||
|
Vector vPlayerPos = pPlayer->EyePosition();
|
||||||
|
|
||||||
|
m_pParticlePrecipOuter = ParticleProp()->Create( m_pParticleOuterDef, PATTACH_ABSORIGIN_FOLLOW );
|
||||||
|
m_pParticlePrecipOuter->SetControlPointEntity( 2, pPlayer );
|
||||||
|
m_pParticlePrecipOuter->SetControlPoint( 1, vPlayerPos + Vector (0, 0, 180 ) );
|
||||||
|
m_pParticlePrecipOuter->SetControlPoint( 3, vDensity );
|
||||||
|
}
|
||||||
|
|
||||||
|
void CClient_Precipitation::DispatchInnerParticlePrecip( C_BasePlayer *pPlayer, Vector vForward )
|
||||||
|
{
|
||||||
|
DestroyInnerParticlePrecip();
|
||||||
|
DestroyOuterParticlePrecip();
|
||||||
|
Vector vPlayerPos = pPlayer->EyePosition();
|
||||||
|
Vector vOffsetPos = vPlayerPos + Vector ( 0, 0, 180 );
|
||||||
|
Vector vOffsetPosNear = vPlayerPos + Vector ( 0, 0, 180 ) + ( vForward * 32 );
|
||||||
|
Vector vOffsetPosFar = vPlayerPos + Vector ( 0, 0, 180 ) + ( vForward * m_flParticleInnerDist ); // 100.0
|
||||||
|
Vector vDensity = Vector( r_RainParticleDensity.GetFloat(), 0, 0 ) * m_flDensity;
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
if (!(m_spawnflags & SF_PRECIP_PARTICLE_NO_OUTER))
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
m_pParticlePrecipOuter = ParticleProp()->Create( m_pParticleOuterDef, PATTACH_ABSORIGIN_FOLLOW );
|
||||||
|
m_pParticlePrecipOuter->SetControlPointEntity( 2, pPlayer );
|
||||||
|
m_pParticlePrecipOuter->SetControlPoint( 1, vOffsetPos );
|
||||||
|
m_pParticlePrecipOuter->SetControlPoint( 3, vDensity );
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pParticlePrecipInnerNear = ParticleProp()->Create( m_pParticleInnerNearDef, PATTACH_ABSORIGIN_FOLLOW );
|
||||||
|
m_pParticlePrecipInnerFar = ParticleProp()->Create( m_pParticleInnerFarDef, PATTACH_ABSORIGIN_FOLLOW );
|
||||||
|
m_pParticlePrecipInnerNear->SetControlPointEntity( 2, pPlayer );
|
||||||
|
m_pParticlePrecipInnerFar->SetControlPointEntity( 2, pPlayer );
|
||||||
|
m_pParticlePrecipInnerNear->SetControlPoint( 1, vOffsetPosNear );
|
||||||
|
m_pParticlePrecipInnerFar->SetControlPoint( 1, vOffsetPosFar );
|
||||||
|
m_pParticlePrecipInnerNear->SetControlPoint( 3, vDensity );
|
||||||
|
m_pParticlePrecipInnerFar->SetControlPoint( 3, vDensity );
|
||||||
|
}
|
||||||
|
|
||||||
void CClient_Precipitation::CreateRainOrSnowParticle( Vector vSpawnPosition, Vector vVelocity )
|
void CClient_Precipitation::CreateRainOrSnowParticle( Vector vSpawnPosition, Vector vVelocity )
|
||||||
{
|
{
|
||||||
// Create the particle
|
// Create the particle
|
||||||
@ -1206,6 +1451,12 @@ BEGIN_RECV_TABLE_NOBASE(CEnvWindShared, DT_EnvWindShared)
|
|||||||
RecvPropFloat (RECVINFO(m_flStartTime)),
|
RecvPropFloat (RECVINFO(m_flStartTime)),
|
||||||
RecvPropFloat (RECVINFO(m_flGustDuration)),
|
RecvPropFloat (RECVINFO(m_flGustDuration)),
|
||||||
// RecvPropInt (RECVINFO(m_iszGustSound)),
|
// RecvPropInt (RECVINFO(m_iszGustSound)),
|
||||||
|
#ifdef MAPBASE
|
||||||
|
RecvPropFloat (RECVINFO(m_windRadius)),
|
||||||
|
RecvPropFloat (RECVINFO(m_windRadiusInner)),
|
||||||
|
RecvPropVector (RECVINFO(m_location)),
|
||||||
|
RecvPropFloat (RECVINFO(m_flTreeSwayScale)),
|
||||||
|
#endif
|
||||||
END_RECV_TABLE()
|
END_RECV_TABLE()
|
||||||
|
|
||||||
IMPLEMENT_CLIENTCLASS_DT( C_EnvWind, DT_EnvWind, CEnvWind )
|
IMPLEMENT_CLIENTCLASS_DT( C_EnvWind, DT_EnvWind, CEnvWind )
|
||||||
@ -1540,8 +1791,12 @@ public:
|
|||||||
|
|
||||||
pParticle->m_vecVelocity *= flSpeed;
|
pParticle->m_vecVelocity *= flSpeed;
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
Vector vecWindVelocity = GetWindspeedAtLocation( pParticle->m_Pos );
|
||||||
|
#else
|
||||||
Vector vecWindVelocity;
|
Vector vecWindVelocity;
|
||||||
GetWindspeedAtTime( gpGlobals->curtime, vecWindVelocity );
|
GetWindspeedAtTime( gpGlobals->curtime, vecWindVelocity );
|
||||||
|
#endif
|
||||||
pParticle->m_vecVelocity += ( vecWindVelocity * r_SnowWindScale.GetFloat() );
|
pParticle->m_vecVelocity += ( vecWindVelocity * r_SnowWindScale.GetFloat() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,9 +10,178 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "cbase.h"
|
||||||
|
#include "precipitation_shared.h"
|
||||||
|
|
||||||
// Draw rain effects.
|
// Draw rain effects.
|
||||||
void DrawPrecipitation();
|
void DrawPrecipitation();
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Precipitation particle type
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class CPrecipitationParticle
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Vector m_Pos;
|
||||||
|
Vector m_Velocity;
|
||||||
|
float m_SpawnTime; // Note: Tweak with this to change lifetime
|
||||||
|
float m_Mass;
|
||||||
|
float m_Ramp;
|
||||||
|
|
||||||
|
float m_flCurLifetime;
|
||||||
|
float m_flMaxLifetime;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class CClient_Precipitation;
|
||||||
|
static CUtlVector<CClient_Precipitation*> g_Precipitations;
|
||||||
|
|
||||||
|
//===========
|
||||||
|
// Snow fall
|
||||||
|
//===========
|
||||||
|
class CSnowFallManager;
|
||||||
|
static CSnowFallManager *s_pSnowFallMgr = NULL;
|
||||||
|
bool SnowFallManagerCreate( CClient_Precipitation *pSnowEntity );
|
||||||
|
void SnowFallManagerDestroy( void );
|
||||||
|
|
||||||
|
class AshDebrisEffect : public CSimpleEmitter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AshDebrisEffect( const char *pDebugName ) : CSimpleEmitter( pDebugName ) {}
|
||||||
|
|
||||||
|
static AshDebrisEffect* Create( const char *pDebugName );
|
||||||
|
|
||||||
|
virtual float UpdateAlpha( const SimpleParticle *pParticle );
|
||||||
|
virtual float UpdateRoll( SimpleParticle *pParticle, float timeDelta );
|
||||||
|
|
||||||
|
private:
|
||||||
|
AshDebrisEffect( const AshDebrisEffect & );
|
||||||
|
};
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Precipitation base entity
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class CClient_Precipitation : public C_BaseEntity
|
||||||
|
{
|
||||||
|
class CPrecipitationEffect;
|
||||||
|
friend class CClient_Precipitation::CPrecipitationEffect;
|
||||||
|
|
||||||
|
public:
|
||||||
|
DECLARE_CLASS( CClient_Precipitation, C_BaseEntity );
|
||||||
|
DECLARE_CLIENTCLASS();
|
||||||
|
|
||||||
|
CClient_Precipitation();
|
||||||
|
virtual ~CClient_Precipitation();
|
||||||
|
|
||||||
|
// Inherited from C_BaseEntity
|
||||||
|
virtual void Precache( );
|
||||||
|
|
||||||
|
void Render();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Creates a single particle
|
||||||
|
CPrecipitationParticle* CreateParticle();
|
||||||
|
|
||||||
|
virtual void OnDataChanged( DataUpdateType_t updateType );
|
||||||
|
virtual void ClientThink();
|
||||||
|
|
||||||
|
void Simulate( float dt );
|
||||||
|
|
||||||
|
// Renders the particle
|
||||||
|
void RenderParticle( CPrecipitationParticle* pParticle, CMeshBuilder &mb );
|
||||||
|
|
||||||
|
void CreateWaterSplashes();
|
||||||
|
|
||||||
|
// Emits the actual particles
|
||||||
|
void EmitParticles( float fTimeDelta );
|
||||||
|
|
||||||
|
// Computes where we're gonna emit
|
||||||
|
bool ComputeEmissionArea( Vector& origin, Vector2D& size );
|
||||||
|
|
||||||
|
// Gets the tracer width and speed
|
||||||
|
float GetWidth() const;
|
||||||
|
float GetLength() const;
|
||||||
|
float GetSpeed() const;
|
||||||
|
|
||||||
|
// Gets the remaining lifetime of the particle
|
||||||
|
float GetRemainingLifetime( CPrecipitationParticle* pParticle ) const;
|
||||||
|
|
||||||
|
// Computes the wind vector
|
||||||
|
static void ComputeWindVector( );
|
||||||
|
|
||||||
|
// simulation methods
|
||||||
|
bool SimulateRain( CPrecipitationParticle* pParticle, float dt );
|
||||||
|
bool SimulateSnow( CPrecipitationParticle* pParticle, float dt );
|
||||||
|
|
||||||
|
void PrecacheParticlePrecip( void );
|
||||||
|
void CreateParticlePrecip( void );
|
||||||
|
void InitializeParticlePrecip( void );
|
||||||
|
void DispatchOuterParticlePrecip( C_BasePlayer *pPlayer, Vector vForward );
|
||||||
|
void DispatchInnerParticlePrecip( C_BasePlayer *pPlayer, Vector vForward );
|
||||||
|
void DestroyOuterParticlePrecip( void );
|
||||||
|
void DestroyInnerParticlePrecip( void );
|
||||||
|
|
||||||
|
void UpdateParticlePrecip( C_BasePlayer *pPlayer );
|
||||||
|
|
||||||
|
private:
|
||||||
|
void CreateAshParticle( void );
|
||||||
|
void CreateRainOrSnowParticle( Vector vSpawnPosition, Vector vVelocity );
|
||||||
|
|
||||||
|
// Information helpful in creating and rendering particles
|
||||||
|
IMaterial *m_MatHandle; // material used
|
||||||
|
|
||||||
|
float m_Color[4]; // precip color
|
||||||
|
float m_Lifetime; // Precip lifetime
|
||||||
|
float m_InitialRamp; // Initial ramp value
|
||||||
|
float m_Speed; // Precip speed
|
||||||
|
float m_Width; // Tracer width
|
||||||
|
float m_Remainder; // particles we should render next time
|
||||||
|
PrecipitationType_t m_nPrecipType; // Precip type
|
||||||
|
float m_flHalfScreenWidth; // Precalculated each frame.
|
||||||
|
|
||||||
|
float m_flDensity;
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
int m_spawnflags;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Some state used in rendering and simulation
|
||||||
|
// Used to modify the rain density and wind from the console
|
||||||
|
static ConVar s_raindensity;
|
||||||
|
static ConVar s_rainwidth;
|
||||||
|
static ConVar s_rainlength;
|
||||||
|
static ConVar s_rainspeed;
|
||||||
|
|
||||||
|
static Vector s_WindVector; // Stores the wind speed vector
|
||||||
|
|
||||||
|
CUtlLinkedList<CPrecipitationParticle> m_Particles;
|
||||||
|
CUtlVector<Vector> m_Splashes;
|
||||||
|
|
||||||
|
CSmartPtr<AshDebrisEffect> m_pAshEmitter;
|
||||||
|
TimedEvent m_tAshParticleTimer;
|
||||||
|
TimedEvent m_tAshParticleTraceTimer;
|
||||||
|
bool m_bActiveAshEmitter;
|
||||||
|
Vector m_vAshSpawnOrigin;
|
||||||
|
|
||||||
|
int m_iAshCount;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
float m_flParticleInnerDist; //The distance at which to start drawing the inner system
|
||||||
|
char *m_pParticleInnerNearDef; //Name of the first inner system
|
||||||
|
char *m_pParticleInnerFarDef; //Name of the second inner system
|
||||||
|
char *m_pParticleOuterDef; //Name of the outer system
|
||||||
|
HPARTICLEFFECT m_pParticlePrecipInnerNear;
|
||||||
|
HPARTICLEFFECT m_pParticlePrecipInnerFar;
|
||||||
|
HPARTICLEFFECT m_pParticlePrecipOuter;
|
||||||
|
TimedEvent m_tParticlePrecipTraceTimer;
|
||||||
|
bool m_bActiveParticlePrecipEmitter;
|
||||||
|
bool m_bParticlePrecipInitialized;
|
||||||
|
|
||||||
|
private:
|
||||||
|
CClient_Precipitation( const CClient_Precipitation & ); // not defined, not accessible
|
||||||
|
};
|
||||||
|
|
||||||
#endif // C_EFFECTS_H
|
#endif // C_EFFECTS_H
|
||||||
|
88
mp/src/game/client/c_env_dof_controller.cpp
Normal file
88
mp/src/game/client/c_env_dof_controller.cpp
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
|
||||||
|
//
|
||||||
|
// Purpose: Depth of field controller entity
|
||||||
|
//
|
||||||
|
//=============================================================================
|
||||||
|
|
||||||
|
#include "cbase.h"
|
||||||
|
|
||||||
|
// NOTE: This has to be the last file included!
|
||||||
|
#include "tier0/memdbgon.h"
|
||||||
|
|
||||||
|
|
||||||
|
extern bool g_bDOFEnabled;
|
||||||
|
extern float g_flDOFNearBlurDepth;
|
||||||
|
extern float g_flDOFNearFocusDepth;
|
||||||
|
extern float g_flDOFFarFocusDepth;
|
||||||
|
extern float g_flDOFFarBlurDepth;
|
||||||
|
extern float g_flDOFNearBlurRadius;
|
||||||
|
extern float g_flDOFFarBlurRadius;
|
||||||
|
|
||||||
|
EHANDLE g_hDOFControllerInUse = NULL;
|
||||||
|
|
||||||
|
class C_EnvDOFController : public C_BaseEntity
|
||||||
|
{
|
||||||
|
DECLARE_CLASS( C_EnvDOFController, C_BaseEntity );
|
||||||
|
public:
|
||||||
|
DECLARE_CLIENTCLASS();
|
||||||
|
|
||||||
|
C_EnvDOFController();
|
||||||
|
~C_EnvDOFController();
|
||||||
|
virtual void OnDataChanged( DataUpdateType_t updateType );
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_bDOFEnabled;
|
||||||
|
float m_flNearBlurDepth;
|
||||||
|
float m_flNearFocusDepth;
|
||||||
|
float m_flFarFocusDepth;
|
||||||
|
float m_flFarBlurDepth;
|
||||||
|
float m_flNearBlurRadius;
|
||||||
|
float m_flFarBlurRadius;
|
||||||
|
|
||||||
|
private:
|
||||||
|
C_EnvDOFController( const C_EnvDOFController & );
|
||||||
|
};
|
||||||
|
|
||||||
|
IMPLEMENT_CLIENTCLASS_DT( C_EnvDOFController, DT_EnvDOFController, CEnvDOFController )
|
||||||
|
RecvPropInt( RECVINFO(m_bDOFEnabled) ),
|
||||||
|
RecvPropFloat( RECVINFO(m_flNearBlurDepth) ),
|
||||||
|
RecvPropFloat( RECVINFO(m_flNearFocusDepth) ),
|
||||||
|
RecvPropFloat( RECVINFO(m_flFarFocusDepth) ),
|
||||||
|
RecvPropFloat( RECVINFO(m_flFarBlurDepth) ),
|
||||||
|
RecvPropFloat( RECVINFO(m_flNearBlurRadius) ),
|
||||||
|
RecvPropFloat( RECVINFO(m_flFarBlurRadius) )
|
||||||
|
END_RECV_TABLE()
|
||||||
|
|
||||||
|
C_EnvDOFController::C_EnvDOFController()
|
||||||
|
: m_bDOFEnabled( true ),
|
||||||
|
m_flNearBlurDepth( 20.0f ),
|
||||||
|
m_flNearFocusDepth( 100.0f ),
|
||||||
|
m_flFarFocusDepth( 250.0f ),
|
||||||
|
m_flFarBlurDepth( 1000.0f ),
|
||||||
|
m_flNearBlurRadius( 0.0f ), // no near blur by default
|
||||||
|
m_flFarBlurRadius( 5.0f )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
C_EnvDOFController::~C_EnvDOFController()
|
||||||
|
{
|
||||||
|
if ( g_hDOFControllerInUse == this )
|
||||||
|
{
|
||||||
|
g_bDOFEnabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void C_EnvDOFController::OnDataChanged( DataUpdateType_t updateType )
|
||||||
|
{
|
||||||
|
BaseClass::OnDataChanged( updateType );
|
||||||
|
|
||||||
|
g_bDOFEnabled = m_bDOFEnabled && ( ( m_flNearBlurRadius > 0.0f ) || ( m_flFarBlurRadius > 0.0f ) );
|
||||||
|
g_flDOFNearBlurDepth = m_flNearBlurDepth;
|
||||||
|
g_flDOFNearFocusDepth = m_flNearFocusDepth;
|
||||||
|
g_flDOFFarFocusDepth = m_flFarFocusDepth;
|
||||||
|
g_flDOFFarBlurDepth = m_flFarBlurDepth;
|
||||||
|
g_flDOFNearBlurRadius = m_flNearBlurRadius;
|
||||||
|
g_flDOFFarBlurRadius = m_flFarBlurRadius;
|
||||||
|
|
||||||
|
g_hDOFControllerInUse = this;
|
||||||
|
}
|
338
mp/src/game/client/c_env_global_light.cpp
Normal file
338
mp/src/game/client/c_env_global_light.cpp
Normal file
@ -0,0 +1,338 @@
|
|||||||
|
//========= Copyright 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||||
|
//
|
||||||
|
// Purpose: Sunlight shadow control entity.
|
||||||
|
//
|
||||||
|
// $NoKeywords: $
|
||||||
|
//=============================================================================//
|
||||||
|
#include "cbase.h"
|
||||||
|
|
||||||
|
#include "c_baseplayer.h"
|
||||||
|
#include "tier0/vprof.h"
|
||||||
|
#ifdef MAPBASE
|
||||||
|
#include "materialsystem/itexture.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// memdbgon must be the last include file in a .cpp file!!!
|
||||||
|
#include "tier0/memdbgon.h"
|
||||||
|
|
||||||
|
|
||||||
|
extern ConVar cl_sunlight_ortho_size;
|
||||||
|
extern ConVar cl_sunlight_depthbias;
|
||||||
|
|
||||||
|
ConVar cl_globallight_freeze( "cl_globallight_freeze", "0" );
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// I imagine these values might've been designed for the ASW view.
|
||||||
|
// You can set these as KV anyway.
|
||||||
|
ConVar cl_globallight_xoffset( "cl_globallight_xoffset", "0" );
|
||||||
|
ConVar cl_globallight_yoffset( "cl_globallight_yoffset", "0" );
|
||||||
|
#else
|
||||||
|
ConVar cl_globallight_xoffset( "cl_globallight_xoffset", "-800" );
|
||||||
|
ConVar cl_globallight_yoffset( "cl_globallight_yoffset", "1600" );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// Purpose : Sunlights shadow control entity
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
class C_GlobalLight : public C_BaseEntity
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DECLARE_CLASS( C_GlobalLight, C_BaseEntity );
|
||||||
|
|
||||||
|
DECLARE_CLIENTCLASS();
|
||||||
|
|
||||||
|
virtual ~C_GlobalLight();
|
||||||
|
|
||||||
|
void OnDataChanged( DataUpdateType_t updateType );
|
||||||
|
void Spawn();
|
||||||
|
bool ShouldDraw();
|
||||||
|
|
||||||
|
void ClientThink();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Vector m_shadowDirection;
|
||||||
|
bool m_bEnabled;
|
||||||
|
char m_TextureName[ MAX_PATH ];
|
||||||
|
#ifdef MAPBASE
|
||||||
|
int m_nSpotlightTextureFrame;
|
||||||
|
#endif
|
||||||
|
CTextureReference m_SpotlightTexture;
|
||||||
|
color32 m_LightColor;
|
||||||
|
#ifdef MAPBASE
|
||||||
|
float m_flBrightnessScale;
|
||||||
|
float m_flCurrentBrightnessScale;
|
||||||
|
#endif
|
||||||
|
Vector m_CurrentLinearFloatLightColor;
|
||||||
|
float m_flCurrentLinearFloatLightAlpha;
|
||||||
|
float m_flColorTransitionTime;
|
||||||
|
float m_flSunDistance;
|
||||||
|
float m_flFOV;
|
||||||
|
float m_flNearZ;
|
||||||
|
float m_flNorthOffset;
|
||||||
|
#ifdef MAPBASE
|
||||||
|
float m_flEastOffset;
|
||||||
|
float m_flForwardOffset;
|
||||||
|
float m_flOrthoSize;
|
||||||
|
#endif
|
||||||
|
bool m_bEnableShadows;
|
||||||
|
bool m_bOldEnableShadows;
|
||||||
|
|
||||||
|
static ClientShadowHandle_t m_LocalFlashlightHandle;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
ClientShadowHandle_t C_GlobalLight::m_LocalFlashlightHandle = CLIENTSHADOW_INVALID_HANDLE;
|
||||||
|
|
||||||
|
|
||||||
|
IMPLEMENT_CLIENTCLASS_DT(C_GlobalLight, DT_GlobalLight, CGlobalLight)
|
||||||
|
RecvPropVector(RECVINFO(m_shadowDirection)),
|
||||||
|
RecvPropBool(RECVINFO(m_bEnabled)),
|
||||||
|
RecvPropString(RECVINFO(m_TextureName)),
|
||||||
|
#ifdef MAPBASE
|
||||||
|
RecvPropInt(RECVINFO(m_nSpotlightTextureFrame)),
|
||||||
|
#endif
|
||||||
|
/*RecvPropInt(RECVINFO(m_LightColor), 0, RecvProxy_Int32ToColor32),*/
|
||||||
|
RecvPropInt(RECVINFO(m_LightColor), 0, RecvProxy_IntToColor32),
|
||||||
|
#ifdef MAPBASE
|
||||||
|
RecvPropFloat(RECVINFO(m_flBrightnessScale)),
|
||||||
|
#endif
|
||||||
|
RecvPropFloat(RECVINFO(m_flColorTransitionTime)),
|
||||||
|
RecvPropFloat(RECVINFO(m_flSunDistance)),
|
||||||
|
RecvPropFloat(RECVINFO(m_flFOV)),
|
||||||
|
RecvPropFloat(RECVINFO(m_flNearZ)),
|
||||||
|
RecvPropFloat(RECVINFO(m_flNorthOffset)),
|
||||||
|
#ifdef MAPBASE
|
||||||
|
RecvPropFloat(RECVINFO(m_flEastOffset)),
|
||||||
|
RecvPropFloat(RECVINFO(m_flForwardOffset)),
|
||||||
|
RecvPropFloat(RECVINFO(m_flOrthoSize)),
|
||||||
|
#endif
|
||||||
|
RecvPropBool(RECVINFO(m_bEnableShadows)),
|
||||||
|
END_RECV_TABLE()
|
||||||
|
|
||||||
|
|
||||||
|
C_GlobalLight::~C_GlobalLight()
|
||||||
|
{
|
||||||
|
if ( m_LocalFlashlightHandle != CLIENTSHADOW_INVALID_HANDLE )
|
||||||
|
{
|
||||||
|
g_pClientShadowMgr->DestroyFlashlight( m_LocalFlashlightHandle );
|
||||||
|
m_LocalFlashlightHandle = CLIENTSHADOW_INVALID_HANDLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void C_GlobalLight::OnDataChanged( DataUpdateType_t updateType )
|
||||||
|
{
|
||||||
|
if ( updateType == DATA_UPDATE_CREATED )
|
||||||
|
{
|
||||||
|
m_SpotlightTexture.Init( m_TextureName, TEXTURE_GROUP_OTHER, true );
|
||||||
|
}
|
||||||
|
#ifdef MAPBASE
|
||||||
|
else //if ( updateType == DATA_UPDATE_DATATABLE_CHANGED )
|
||||||
|
{
|
||||||
|
// It could've been changed via input
|
||||||
|
if( !FStrEq(m_SpotlightTexture->GetName(), m_TextureName) )
|
||||||
|
{
|
||||||
|
m_SpotlightTexture.Init( m_TextureName, TEXTURE_GROUP_OTHER, true );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
BaseClass::OnDataChanged( updateType );
|
||||||
|
}
|
||||||
|
|
||||||
|
void C_GlobalLight::Spawn()
|
||||||
|
{
|
||||||
|
BaseClass::Spawn();
|
||||||
|
|
||||||
|
m_bOldEnableShadows = m_bEnableShadows;
|
||||||
|
|
||||||
|
SetNextClientThink( CLIENT_THINK_ALWAYS );
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// We don't draw...
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
bool C_GlobalLight::ShouldDraw()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void C_GlobalLight::ClientThink()
|
||||||
|
{
|
||||||
|
VPROF("C_GlobalLight::ClientThink");
|
||||||
|
|
||||||
|
bool bSupressWorldLights = false;
|
||||||
|
|
||||||
|
if ( cl_globallight_freeze.GetBool() == true )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( m_bEnabled )
|
||||||
|
{
|
||||||
|
Vector vLinearFloatLightColor( m_LightColor.r, m_LightColor.g, m_LightColor.b );
|
||||||
|
float flLinearFloatLightAlpha = m_LightColor.a;
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
if ( m_CurrentLinearFloatLightColor != vLinearFloatLightColor || m_flCurrentLinearFloatLightAlpha != flLinearFloatLightAlpha || m_flCurrentBrightnessScale != m_flBrightnessScale )
|
||||||
|
{
|
||||||
|
if (m_flColorTransitionTime != 0.0f)
|
||||||
|
{
|
||||||
|
float flColorTransitionSpeed = gpGlobals->frametime * m_flColorTransitionTime * 255.0f;
|
||||||
|
|
||||||
|
m_CurrentLinearFloatLightColor.x = Approach( vLinearFloatLightColor.x, m_CurrentLinearFloatLightColor.x, flColorTransitionSpeed );
|
||||||
|
m_CurrentLinearFloatLightColor.y = Approach( vLinearFloatLightColor.y, m_CurrentLinearFloatLightColor.y, flColorTransitionSpeed );
|
||||||
|
m_CurrentLinearFloatLightColor.z = Approach( vLinearFloatLightColor.z, m_CurrentLinearFloatLightColor.z, flColorTransitionSpeed );
|
||||||
|
m_flCurrentLinearFloatLightAlpha = Approach( flLinearFloatLightAlpha, m_flCurrentLinearFloatLightAlpha, flColorTransitionSpeed );
|
||||||
|
m_flCurrentBrightnessScale = Approach( m_flBrightnessScale, m_flCurrentBrightnessScale, flColorTransitionSpeed );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Just do it instantly
|
||||||
|
m_CurrentLinearFloatLightColor.x = vLinearFloatLightColor.x;
|
||||||
|
m_CurrentLinearFloatLightColor.y = vLinearFloatLightColor.y;
|
||||||
|
m_CurrentLinearFloatLightColor.z = vLinearFloatLightColor.z;
|
||||||
|
m_flCurrentLinearFloatLightAlpha = flLinearFloatLightAlpha;
|
||||||
|
m_flCurrentBrightnessScale = m_flBrightnessScale;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if ( m_CurrentLinearFloatLightColor != vLinearFloatLightColor || m_flCurrentLinearFloatLightAlpha != flLinearFloatLightAlpha )
|
||||||
|
{
|
||||||
|
float flColorTransitionSpeed = gpGlobals->frametime * m_flColorTransitionTime * 255.0f;
|
||||||
|
|
||||||
|
m_CurrentLinearFloatLightColor.x = Approach( vLinearFloatLightColor.x, m_CurrentLinearFloatLightColor.x, flColorTransitionSpeed );
|
||||||
|
m_CurrentLinearFloatLightColor.y = Approach( vLinearFloatLightColor.y, m_CurrentLinearFloatLightColor.y, flColorTransitionSpeed );
|
||||||
|
m_CurrentLinearFloatLightColor.z = Approach( vLinearFloatLightColor.z, m_CurrentLinearFloatLightColor.z, flColorTransitionSpeed );
|
||||||
|
m_flCurrentLinearFloatLightAlpha = Approach( flLinearFloatLightAlpha, m_flCurrentLinearFloatLightAlpha, flColorTransitionSpeed );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
FlashlightState_t state;
|
||||||
|
|
||||||
|
Vector vDirection = m_shadowDirection;
|
||||||
|
VectorNormalize( vDirection );
|
||||||
|
|
||||||
|
//Vector vViewUp = Vector( 0.0f, 1.0f, 0.0f );
|
||||||
|
Vector vSunDirection2D = vDirection;
|
||||||
|
vSunDirection2D.z = 0.0f;
|
||||||
|
|
||||||
|
/*HACK_GETLOCALPLAYER_GUARD( "C_GlobalLight::ClientThink" );*/
|
||||||
|
|
||||||
|
if ( !C_BasePlayer::GetLocalPlayer() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
Vector vPos;
|
||||||
|
QAngle EyeAngles;
|
||||||
|
float flZNear, flZFar, flFov;
|
||||||
|
|
||||||
|
C_BasePlayer::GetLocalPlayer()->CalcView( vPos, EyeAngles, flZNear, flZFar, flFov );
|
||||||
|
// Vector vPos = C_BasePlayer::GetLocalPlayer()->GetAbsOrigin();
|
||||||
|
|
||||||
|
// vPos = Vector( 0.0f, 0.0f, 500.0f );
|
||||||
|
vPos = ( vPos + vSunDirection2D * m_flNorthOffset ) - vDirection * m_flSunDistance;
|
||||||
|
#ifdef MAPBASE
|
||||||
|
vPos += Vector( m_flEastOffset + cl_globallight_xoffset.GetFloat(), m_flForwardOffset + cl_globallight_yoffset.GetFloat(), 0.0f );
|
||||||
|
#else
|
||||||
|
vPos += Vector( cl_globallight_xoffset.GetFloat(), cl_globallight_yoffset.GetFloat(), 0.0f );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QAngle angAngles;
|
||||||
|
VectorAngles( vDirection, angAngles );
|
||||||
|
|
||||||
|
Vector vForward, vRight, vUp;
|
||||||
|
AngleVectors( angAngles, &vForward, &vRight, &vUp );
|
||||||
|
|
||||||
|
state.m_fHorizontalFOVDegrees = m_flFOV;
|
||||||
|
state.m_fVerticalFOVDegrees = m_flFOV;
|
||||||
|
|
||||||
|
state.m_vecLightOrigin = vPos;
|
||||||
|
BasisToQuaternion( vForward, vRight, vUp, state.m_quatOrientation );
|
||||||
|
|
||||||
|
state.m_fQuadraticAtten = 0.0f;
|
||||||
|
state.m_fLinearAtten = m_flSunDistance * 2.0f;
|
||||||
|
state.m_fConstantAtten = 0.0f;
|
||||||
|
state.m_FarZAtten = m_flSunDistance * 2.0f;
|
||||||
|
#ifdef MAPBASE
|
||||||
|
float flAlpha = m_flCurrentLinearFloatLightAlpha * (1.0f / 255.0f);
|
||||||
|
state.m_Color[0] = (m_CurrentLinearFloatLightColor.x * ( 1.0f / 255.0f ) * flAlpha) * m_flCurrentBrightnessScale;
|
||||||
|
state.m_Color[1] = (m_CurrentLinearFloatLightColor.y * ( 1.0f / 255.0f ) * flAlpha) * m_flCurrentBrightnessScale;
|
||||||
|
state.m_Color[2] = (m_CurrentLinearFloatLightColor.z * ( 1.0f / 255.0f ) * flAlpha) * m_flCurrentBrightnessScale;
|
||||||
|
#else
|
||||||
|
state.m_Color[0] = m_CurrentLinearFloatLightColor.x * ( 1.0f / 255.0f ) * m_flCurrentLinearFloatLightAlpha;
|
||||||
|
state.m_Color[1] = m_CurrentLinearFloatLightColor.y * ( 1.0f / 255.0f ) * m_flCurrentLinearFloatLightAlpha;
|
||||||
|
state.m_Color[2] = m_CurrentLinearFloatLightColor.z * ( 1.0f / 255.0f ) * m_flCurrentLinearFloatLightAlpha;
|
||||||
|
#endif
|
||||||
|
state.m_Color[3] = 0.0f; // fixme: need to make ambient work m_flAmbient;
|
||||||
|
state.m_NearZ = 4.0f;
|
||||||
|
state.m_FarZ = m_flSunDistance * 2.0f;
|
||||||
|
state.m_fBrightnessScale = 2.0f;
|
||||||
|
state.m_bGlobalLight = true;
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
float flOrthoSize = m_flOrthoSize;
|
||||||
|
#else
|
||||||
|
float flOrthoSize = 1000.0f;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if ( flOrthoSize > 0 )
|
||||||
|
{
|
||||||
|
state.m_bOrtho = true;
|
||||||
|
state.m_fOrthoLeft = -flOrthoSize;
|
||||||
|
state.m_fOrthoTop = -flOrthoSize;
|
||||||
|
state.m_fOrthoRight = flOrthoSize;
|
||||||
|
state.m_fOrthoBottom = flOrthoSize;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
state.m_bOrtho = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef MAPBASE // Don't draw that huge debug thing
|
||||||
|
state.m_bDrawShadowFrustum = true;
|
||||||
|
#endif
|
||||||
|
/*state.m_flShadowSlopeScaleDepthBias = g_pMaterialSystemHardwareConfig->GetShadowSlopeScaleDepthBias();;
|
||||||
|
state.m_flShadowDepthBias = g_pMaterialSystemHardwareConfig->GetShadowDepthBias();*/
|
||||||
|
state.m_bEnableShadows = m_bEnableShadows;
|
||||||
|
state.m_pSpotlightTexture = m_SpotlightTexture;
|
||||||
|
#ifdef MAPBASE
|
||||||
|
state.m_nSpotlightTextureFrame = m_nSpotlightTextureFrame;
|
||||||
|
#else
|
||||||
|
state.m_nSpotlightTextureFrame = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
state.m_nShadowQuality = 1; // Allow entity to affect shadow quality
|
||||||
|
// state.m_bShadowHighRes = true;
|
||||||
|
|
||||||
|
if ( m_bOldEnableShadows != m_bEnableShadows )
|
||||||
|
{
|
||||||
|
// If they change the shadow enable/disable, we need to make a new handle
|
||||||
|
if ( m_LocalFlashlightHandle != CLIENTSHADOW_INVALID_HANDLE )
|
||||||
|
{
|
||||||
|
g_pClientShadowMgr->DestroyFlashlight( m_LocalFlashlightHandle );
|
||||||
|
m_LocalFlashlightHandle = CLIENTSHADOW_INVALID_HANDLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_bOldEnableShadows = m_bEnableShadows;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( m_LocalFlashlightHandle == CLIENTSHADOW_INVALID_HANDLE )
|
||||||
|
{
|
||||||
|
m_LocalFlashlightHandle = g_pClientShadowMgr->CreateFlashlight( state );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_pClientShadowMgr->UpdateFlashlightState( m_LocalFlashlightHandle, state );
|
||||||
|
g_pClientShadowMgr->UpdateProjectedTexture( m_LocalFlashlightHandle, true );
|
||||||
|
}
|
||||||
|
|
||||||
|
bSupressWorldLights = m_bEnableShadows;
|
||||||
|
}
|
||||||
|
else if ( m_LocalFlashlightHandle != CLIENTSHADOW_INVALID_HANDLE )
|
||||||
|
{
|
||||||
|
g_pClientShadowMgr->DestroyFlashlight( m_LocalFlashlightHandle );
|
||||||
|
m_LocalFlashlightHandle = CLIENTSHADOW_INVALID_HANDLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_pClientShadowMgr->SetShadowFromWorldLightsEnabled( !bSupressWorldLights );
|
||||||
|
|
||||||
|
BaseClass::ClientThink();
|
||||||
|
}
|
@ -5,6 +5,13 @@
|
|||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
#include "cbase.h"
|
#include "cbase.h"
|
||||||
|
#ifdef ASW_PROJECTED_TEXTURES
|
||||||
|
#include "C_Env_Projected_Texture.h"
|
||||||
|
#include "vprof.h"
|
||||||
|
#endif
|
||||||
|
#ifdef MAPBASE
|
||||||
|
#include "materialsystem/itexture.h"
|
||||||
|
#endif
|
||||||
#include "shareddefs.h"
|
#include "shareddefs.h"
|
||||||
#include "materialsystem/imesh.h"
|
#include "materialsystem/imesh.h"
|
||||||
#include "materialsystem/imaterial.h"
|
#include "materialsystem/imaterial.h"
|
||||||
@ -17,8 +24,475 @@
|
|||||||
// memdbgon must be the last include file in a .cpp file!!!
|
// memdbgon must be the last include file in a .cpp file!!!
|
||||||
#include "tier0/memdbgon.h"
|
#include "tier0/memdbgon.h"
|
||||||
|
|
||||||
|
#ifdef ASW_PROJECTED_TEXTURES
|
||||||
|
static ConVar mat_slopescaledepthbias_shadowmap( "mat_slopescaledepthbias_shadowmap", "16", FCVAR_CHEAT );
|
||||||
|
static ConVar mat_depthbias_shadowmap( "mat_depthbias_shadowmap", "0.00001", FCVAR_CHEAT );
|
||||||
|
|
||||||
|
float C_EnvProjectedTexture::m_flVisibleBBoxMinHeight = -FLT_MAX;
|
||||||
|
|
||||||
|
|
||||||
|
IMPLEMENT_CLIENTCLASS_DT( C_EnvProjectedTexture, DT_EnvProjectedTexture, CEnvProjectedTexture )
|
||||||
|
RecvPropEHandle( RECVINFO( m_hTargetEntity ) ),
|
||||||
|
#ifdef MAPBASE
|
||||||
|
RecvPropBool( RECVINFO( m_bDontFollowTarget )),
|
||||||
|
#endif
|
||||||
|
RecvPropBool( RECVINFO( m_bState ) ),
|
||||||
|
RecvPropBool( RECVINFO( m_bAlwaysUpdate ) ),
|
||||||
|
RecvPropFloat( RECVINFO( m_flLightFOV ) ),
|
||||||
|
#ifdef MAPBASE
|
||||||
|
RecvPropFloat( RECVINFO( m_flLightHorFOV ) ),
|
||||||
|
#endif
|
||||||
|
RecvPropBool( RECVINFO( m_bEnableShadows ) ),
|
||||||
|
RecvPropBool( RECVINFO( m_bLightOnlyTarget ) ),
|
||||||
|
RecvPropBool( RECVINFO( m_bLightWorld ) ),
|
||||||
|
RecvPropBool( RECVINFO( m_bCameraSpace ) ),
|
||||||
|
RecvPropFloat( RECVINFO( m_flBrightnessScale ) ),
|
||||||
|
RecvPropInt( RECVINFO( m_LightColor ), 0, RecvProxy_IntToColor32 ),
|
||||||
|
RecvPropFloat( RECVINFO( m_flColorTransitionTime ) ),
|
||||||
|
RecvPropFloat( RECVINFO( m_flAmbient ) ),
|
||||||
|
RecvPropString( RECVINFO( m_SpotlightTextureName ) ),
|
||||||
|
RecvPropInt( RECVINFO( m_nSpotlightTextureFrame ) ),
|
||||||
|
RecvPropFloat( RECVINFO( m_flNearZ ) ),
|
||||||
|
RecvPropFloat( RECVINFO( m_flFarZ ) ),
|
||||||
|
RecvPropInt( RECVINFO( m_nShadowQuality ) ),
|
||||||
|
#ifdef MAPBASE
|
||||||
|
RecvPropFloat( RECVINFO( m_flConstantAtten ) ),
|
||||||
|
RecvPropFloat( RECVINFO( m_flLinearAtten ) ),
|
||||||
|
RecvPropFloat( RECVINFO( m_flQuadraticAtten ) ),
|
||||||
|
RecvPropFloat( RECVINFO( m_flShadowAtten ) ),
|
||||||
|
RecvPropBool( RECVINFO( m_bAlwaysDraw ) ),
|
||||||
|
|
||||||
|
// Not needed on the client right now, change when it actually is needed
|
||||||
|
//RecvPropBool( RECVINFO( m_bProjectedTextureVersion ) ),
|
||||||
|
#endif
|
||||||
|
END_RECV_TABLE()
|
||||||
|
|
||||||
|
C_EnvProjectedTexture *C_EnvProjectedTexture::Create( )
|
||||||
|
{
|
||||||
|
C_EnvProjectedTexture *pEnt = new C_EnvProjectedTexture();
|
||||||
|
|
||||||
|
pEnt->m_flNearZ = 4.0f;
|
||||||
|
pEnt->m_flFarZ = 2000.0f;
|
||||||
|
// strcpy( pEnt->m_SpotlightTextureName, "particle/rj" );
|
||||||
|
pEnt->m_bLightWorld = true;
|
||||||
|
pEnt->m_bLightOnlyTarget = false;
|
||||||
|
pEnt->m_nShadowQuality = 1;
|
||||||
|
pEnt->m_flLightFOV = 10.0f;
|
||||||
|
#ifdef MAPBASE
|
||||||
|
pEnt->m_flLightHorFOV = 10.0f;
|
||||||
|
#endif
|
||||||
|
pEnt->m_LightColor.r = 255;
|
||||||
|
pEnt->m_LightColor.g = 255;
|
||||||
|
pEnt->m_LightColor.b = 255;
|
||||||
|
pEnt->m_LightColor.a = 255;
|
||||||
|
pEnt->m_bEnableShadows = false;
|
||||||
|
pEnt->m_flColorTransitionTime = 1.0f;
|
||||||
|
pEnt->m_bCameraSpace = false;
|
||||||
|
pEnt->SetAbsAngles( QAngle( 90, 0, 0 ) );
|
||||||
|
pEnt->m_bAlwaysUpdate = true;
|
||||||
|
pEnt->m_bState = true;
|
||||||
|
#ifdef MAPBASE
|
||||||
|
pEnt->m_bAlwaysDraw = false;
|
||||||
|
pEnt->m_flConstantAtten = 0.0f;
|
||||||
|
pEnt->m_flLinearAtten = 100.0f;
|
||||||
|
pEnt->m_flQuadraticAtten = 0.0f;
|
||||||
|
pEnt->m_flShadowAtten = 0.0f;
|
||||||
|
//pEnt->m_bProjectedTextureVersion = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return pEnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
C_EnvProjectedTexture::C_EnvProjectedTexture( void )
|
||||||
|
{
|
||||||
|
m_LightHandle = CLIENTSHADOW_INVALID_HANDLE;
|
||||||
|
m_bForceUpdate = true;
|
||||||
|
#ifndef MAPBASE
|
||||||
|
AddToEntityList( ENTITY_LIST_SIMULATE );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
C_EnvProjectedTexture::~C_EnvProjectedTexture( void )
|
||||||
|
{
|
||||||
|
ShutDownLightHandle();
|
||||||
|
}
|
||||||
|
|
||||||
|
void C_EnvProjectedTexture::ShutDownLightHandle( void )
|
||||||
|
{
|
||||||
|
// Clear out the light
|
||||||
|
if( m_LightHandle != CLIENTSHADOW_INVALID_HANDLE )
|
||||||
|
{
|
||||||
|
g_pClientShadowMgr->DestroyFlashlight( m_LightHandle );
|
||||||
|
m_LightHandle = CLIENTSHADOW_INVALID_HANDLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void C_EnvProjectedTexture::SetLightColor( byte r, byte g, byte b, byte a )
|
||||||
|
{
|
||||||
|
m_LightColor.r = r;
|
||||||
|
m_LightColor.g = g;
|
||||||
|
m_LightColor.b = b;
|
||||||
|
m_LightColor.a = a;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
// Input : updateType -
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void C_EnvProjectedTexture::OnDataChanged( DataUpdateType_t updateType )
|
||||||
|
{
|
||||||
|
if ( updateType == DATA_UPDATE_CREATED )
|
||||||
|
{
|
||||||
|
m_SpotlightTexture.Init( m_SpotlightTextureName, TEXTURE_GROUP_OTHER, true );
|
||||||
|
}
|
||||||
|
#ifdef MAPBASE
|
||||||
|
else //if ( updateType == DATA_UPDATE_DATATABLE_CHANGED )
|
||||||
|
{
|
||||||
|
// It could've been changed via input
|
||||||
|
if( !FStrEq(m_SpotlightTexture->GetName(), m_SpotlightTextureName) )
|
||||||
|
{
|
||||||
|
m_SpotlightTexture.Init( m_SpotlightTextureName, TEXTURE_GROUP_OTHER, true );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
m_bForceUpdate = true;
|
||||||
|
UpdateLight();
|
||||||
|
BaseClass::OnDataChanged( updateType );
|
||||||
|
}
|
||||||
|
|
||||||
|
static ConVar asw_perf_wtf("asw_perf_wtf", "0", FCVAR_DEVELOPMENTONLY, "Disable updating of projected shadow textures from UpdateLight" );
|
||||||
|
void C_EnvProjectedTexture::UpdateLight( void )
|
||||||
|
{
|
||||||
|
VPROF("C_EnvProjectedTexture::UpdateLight");
|
||||||
|
bool bVisible = true;
|
||||||
|
|
||||||
|
Vector vLinearFloatLightColor( m_LightColor.r, m_LightColor.g, m_LightColor.b );
|
||||||
|
float flLinearFloatLightAlpha = m_LightColor.a;
|
||||||
|
|
||||||
|
if ( m_bAlwaysUpdate )
|
||||||
|
{
|
||||||
|
m_bForceUpdate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
if ( m_CurrentLinearFloatLightColor != vLinearFloatLightColor || m_flCurrentLinearFloatLightAlpha != flLinearFloatLightAlpha || m_flCurrentBrightnessScale != m_flBrightnessScale )
|
||||||
|
{
|
||||||
|
if (m_flColorTransitionTime != 0.0f)
|
||||||
|
{
|
||||||
|
float flColorTransitionSpeed = gpGlobals->frametime * m_flColorTransitionTime * 255.0f;
|
||||||
|
|
||||||
|
m_CurrentLinearFloatLightColor.x = Approach( vLinearFloatLightColor.x, m_CurrentLinearFloatLightColor.x, flColorTransitionSpeed );
|
||||||
|
m_CurrentLinearFloatLightColor.y = Approach( vLinearFloatLightColor.y, m_CurrentLinearFloatLightColor.y, flColorTransitionSpeed );
|
||||||
|
m_CurrentLinearFloatLightColor.z = Approach( vLinearFloatLightColor.z, m_CurrentLinearFloatLightColor.z, flColorTransitionSpeed );
|
||||||
|
m_flCurrentLinearFloatLightAlpha = Approach( flLinearFloatLightAlpha, m_flCurrentLinearFloatLightAlpha, flColorTransitionSpeed );
|
||||||
|
m_flCurrentBrightnessScale = Approach( m_flBrightnessScale, m_flCurrentBrightnessScale, flColorTransitionSpeed );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Just do it instantly
|
||||||
|
m_CurrentLinearFloatLightColor.x = vLinearFloatLightColor.x;
|
||||||
|
m_CurrentLinearFloatLightColor.y = vLinearFloatLightColor.y;
|
||||||
|
m_CurrentLinearFloatLightColor.z = vLinearFloatLightColor.z;
|
||||||
|
m_flCurrentLinearFloatLightAlpha = flLinearFloatLightAlpha;
|
||||||
|
m_flCurrentBrightnessScale = m_flBrightnessScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_bForceUpdate = true;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if ( m_CurrentLinearFloatLightColor != vLinearFloatLightColor || m_flCurrentLinearFloatLightAlpha != flLinearFloatLightAlpha )
|
||||||
|
{
|
||||||
|
float flColorTransitionSpeed = gpGlobals->frametime * m_flColorTransitionTime * 255.0f;
|
||||||
|
|
||||||
|
m_CurrentLinearFloatLightColor.x = Approach( vLinearFloatLightColor.x, m_CurrentLinearFloatLightColor.x, flColorTransitionSpeed );
|
||||||
|
m_CurrentLinearFloatLightColor.y = Approach( vLinearFloatLightColor.y, m_CurrentLinearFloatLightColor.y, flColorTransitionSpeed );
|
||||||
|
m_CurrentLinearFloatLightColor.z = Approach( vLinearFloatLightColor.z, m_CurrentLinearFloatLightColor.z, flColorTransitionSpeed );
|
||||||
|
m_flCurrentLinearFloatLightAlpha = Approach( flLinearFloatLightAlpha, m_flCurrentLinearFloatLightAlpha, flColorTransitionSpeed );
|
||||||
|
|
||||||
|
m_bForceUpdate = true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if ( !m_bForceUpdate )
|
||||||
|
{
|
||||||
|
bVisible = IsBBoxVisible();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( m_bState == false || !bVisible )
|
||||||
|
{
|
||||||
|
// Spotlight's extents aren't in view
|
||||||
|
ShutDownLightHandle();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( m_LightHandle == CLIENTSHADOW_INVALID_HANDLE || m_hTargetEntity != NULL || m_bForceUpdate )
|
||||||
|
{
|
||||||
|
Vector vForward, vRight, vUp, vPos = GetAbsOrigin();
|
||||||
|
FlashlightState_t state;
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
if ( m_hTargetEntity != NULL && !m_bDontFollowTarget )
|
||||||
|
#else
|
||||||
|
if ( m_hTargetEntity != NULL )
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
if ( m_bCameraSpace )
|
||||||
|
{
|
||||||
|
const QAngle &angles = GetLocalAngles();
|
||||||
|
|
||||||
|
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||||
|
if( pPlayer )
|
||||||
|
{
|
||||||
|
const QAngle playerAngles = pPlayer->GetAbsAngles();
|
||||||
|
|
||||||
|
Vector vPlayerForward, vPlayerRight, vPlayerUp;
|
||||||
|
AngleVectors( playerAngles, &vPlayerForward, &vPlayerRight, &vPlayerUp );
|
||||||
|
|
||||||
|
matrix3x4_t mRotMatrix;
|
||||||
|
AngleMatrix( angles, mRotMatrix );
|
||||||
|
|
||||||
|
VectorITransform( vPlayerForward, mRotMatrix, vForward );
|
||||||
|
VectorITransform( vPlayerRight, mRotMatrix, vRight );
|
||||||
|
VectorITransform( vPlayerUp, mRotMatrix, vUp );
|
||||||
|
|
||||||
|
float dist = (m_hTargetEntity->GetAbsOrigin() - GetAbsOrigin()).Length();
|
||||||
|
vPos = m_hTargetEntity->GetAbsOrigin() - vForward*dist;
|
||||||
|
|
||||||
|
VectorNormalize( vForward );
|
||||||
|
VectorNormalize( vRight );
|
||||||
|
VectorNormalize( vUp );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vForward = m_hTargetEntity->GetAbsOrigin() - GetAbsOrigin();
|
||||||
|
VectorNormalize( vForward );
|
||||||
|
|
||||||
|
// JasonM - unimplemented
|
||||||
|
Assert (0);
|
||||||
|
|
||||||
|
//Quaternion q = DirectionToOrientation( dir );
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// JasonM - set up vRight, vUp
|
||||||
|
//
|
||||||
|
|
||||||
|
// VectorNormalize( vRight );
|
||||||
|
// VectorNormalize( vUp );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AngleVectors( GetAbsAngles(), &vForward, &vRight, &vUp );
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
float fHighFOV;
|
||||||
|
if( m_flLightFOV > m_flLightHorFOV )
|
||||||
|
fHighFOV = m_flLightFOV;
|
||||||
|
else
|
||||||
|
fHighFOV = m_flLightHorFOV;
|
||||||
|
|
||||||
|
state.m_fHorizontalFOVDegrees = m_flLightHorFOV;
|
||||||
|
#else
|
||||||
|
state.m_fHorizontalFOVDegrees = m_flLightFOV;
|
||||||
|
#endif
|
||||||
|
state.m_fVerticalFOVDegrees = m_flLightFOV;
|
||||||
|
|
||||||
|
state.m_vecLightOrigin = vPos;
|
||||||
|
BasisToQuaternion( vForward, vRight, vUp, state.m_quatOrientation );
|
||||||
|
state.m_NearZ = m_flNearZ;
|
||||||
|
state.m_FarZ = m_flFarZ;
|
||||||
|
|
||||||
|
// quickly check the proposed light's bbox against the view frustum to determine whether we
|
||||||
|
// should bother to create it, if it doesn't exist, or cull it, if it does.
|
||||||
|
// get the half-widths of the near and far planes,
|
||||||
|
// based on the FOV which is in degrees. Remember that
|
||||||
|
// on planet Valve, x is forward, y left, and z up.
|
||||||
|
#ifdef MAPBASE
|
||||||
|
const float tanHalfAngle = tan( fHighFOV * ( M_PI/180.0f ) * 0.5f );
|
||||||
|
#else
|
||||||
|
const float tanHalfAngle = tan( m_flLightFOV * ( M_PI/180.0f ) * 0.5f );
|
||||||
|
#endif
|
||||||
|
const float halfWidthNear = tanHalfAngle * m_flNearZ;
|
||||||
|
const float halfWidthFar = tanHalfAngle * m_flFarZ;
|
||||||
|
// now we can build coordinates in local space: the near rectangle is eg
|
||||||
|
// (0, -halfWidthNear, -halfWidthNear), (0, halfWidthNear, -halfWidthNear),
|
||||||
|
// (0, halfWidthNear, halfWidthNear), (0, -halfWidthNear, halfWidthNear)
|
||||||
|
|
||||||
|
VectorAligned vNearRect[4] = {
|
||||||
|
VectorAligned( m_flNearZ, -halfWidthNear, -halfWidthNear), VectorAligned( m_flNearZ, halfWidthNear, -halfWidthNear),
|
||||||
|
VectorAligned( m_flNearZ, halfWidthNear, halfWidthNear), VectorAligned( m_flNearZ, -halfWidthNear, halfWidthNear)
|
||||||
|
};
|
||||||
|
|
||||||
|
VectorAligned vFarRect[4] = {
|
||||||
|
VectorAligned( m_flFarZ, -halfWidthFar, -halfWidthFar), VectorAligned( m_flFarZ, halfWidthFar, -halfWidthFar),
|
||||||
|
VectorAligned( m_flFarZ, halfWidthFar, halfWidthFar), VectorAligned( m_flFarZ, -halfWidthFar, halfWidthFar)
|
||||||
|
};
|
||||||
|
|
||||||
|
matrix3x4_t matOrientation( vForward, -vRight, vUp, vPos );
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
kNEAR = 0,
|
||||||
|
kFAR = 1,
|
||||||
|
};
|
||||||
|
VectorAligned vOutRects[2][4];
|
||||||
|
|
||||||
|
for ( int i = 0 ; i < 4 ; ++i )
|
||||||
|
{
|
||||||
|
VectorTransform( vNearRect[i].Base(), matOrientation, vOutRects[0][i].Base() );
|
||||||
|
}
|
||||||
|
for ( int i = 0 ; i < 4 ; ++i )
|
||||||
|
{
|
||||||
|
VectorTransform( vFarRect[i].Base(), matOrientation, vOutRects[1][i].Base() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// now take the min and max extents for the bbox, and see if it is visible.
|
||||||
|
Vector mins = **vOutRects;
|
||||||
|
Vector maxs = **vOutRects;
|
||||||
|
for ( int i = 1; i < 8 ; ++i )
|
||||||
|
{
|
||||||
|
VectorMin( mins, *(*vOutRects+i), mins );
|
||||||
|
VectorMax( maxs, *(*vOutRects+i), maxs );
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0 //for debugging the visibility frustum we just calculated
|
||||||
|
NDebugOverlay::Triangle( vOutRects[0][0], vOutRects[0][1], vOutRects[0][2], 255, 0, 0, 100, true, 0.0f ); //first tri
|
||||||
|
NDebugOverlay::Triangle( vOutRects[0][2], vOutRects[0][1], vOutRects[0][0], 255, 0, 0, 100, true, 0.0f ); //make it double sided
|
||||||
|
NDebugOverlay::Triangle( vOutRects[0][2], vOutRects[0][3], vOutRects[0][0], 255, 0, 0, 100, true, 0.0f ); //second tri
|
||||||
|
NDebugOverlay::Triangle( vOutRects[0][0], vOutRects[0][3], vOutRects[0][2], 255, 0, 0, 100, true, 0.0f ); //make it double sided
|
||||||
|
|
||||||
|
NDebugOverlay::Triangle( vOutRects[1][0], vOutRects[1][1], vOutRects[1][2], 0, 0, 255, 100, true, 0.0f ); //first tri
|
||||||
|
NDebugOverlay::Triangle( vOutRects[1][2], vOutRects[1][1], vOutRects[1][0], 0, 0, 255, 100, true, 0.0f ); //make it double sided
|
||||||
|
NDebugOverlay::Triangle( vOutRects[1][2], vOutRects[1][3], vOutRects[1][0], 0, 0, 255, 100, true, 0.0f ); //second tri
|
||||||
|
NDebugOverlay::Triangle( vOutRects[1][0], vOutRects[1][3], vOutRects[1][2], 0, 0, 255, 100, true, 0.0f ); //make it double sided
|
||||||
|
|
||||||
|
NDebugOverlay::Box( vec3_origin, mins, maxs, 0, 255, 0, 100, 0.0f );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool bVisible = IsBBoxVisible( mins, maxs );
|
||||||
|
if (!bVisible)
|
||||||
|
{
|
||||||
|
// Spotlight's extents aren't in view
|
||||||
|
if ( m_LightHandle != CLIENTSHADOW_INVALID_HANDLE )
|
||||||
|
{
|
||||||
|
ShutDownLightHandle();
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
float flAlpha = m_flCurrentLinearFloatLightAlpha * ( 1.0f / 255.0f );
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
state.m_fConstantAtten = m_flConstantAtten;
|
||||||
|
state.m_fLinearAtten = m_flLinearAtten;
|
||||||
|
state.m_fQuadraticAtten = m_flQuadraticAtten;
|
||||||
|
state.m_FarZAtten = m_flFarZ;
|
||||||
|
state.m_Color[0] = (m_CurrentLinearFloatLightColor.x * ( 1.0f / 255.0f ) * flAlpha) * m_flCurrentBrightnessScale;
|
||||||
|
state.m_Color[1] = (m_CurrentLinearFloatLightColor.y * ( 1.0f / 255.0f ) * flAlpha) * m_flCurrentBrightnessScale;
|
||||||
|
state.m_Color[2] = (m_CurrentLinearFloatLightColor.z * ( 1.0f / 255.0f ) * flAlpha) * m_flCurrentBrightnessScale;
|
||||||
|
state.m_Color[3] = 0.0f; // fixme: need to make ambient work m_flAmbient;
|
||||||
|
state.m_flShadowSlopeScaleDepthBias = mat_slopescaledepthbias_shadowmap.GetFloat();
|
||||||
|
state.m_flShadowDepthBias = mat_depthbias_shadowmap.GetFloat();
|
||||||
|
state.m_flShadowAtten = m_flShadowAtten;
|
||||||
|
#else
|
||||||
|
state.m_fQuadraticAtten = 0.0;
|
||||||
|
state.m_fLinearAtten = 100;
|
||||||
|
state.m_fConstantAtten = 0.0f;
|
||||||
|
state.m_FarZAtten = m_flFarZ;
|
||||||
|
state.m_fBrightnessScale = m_flBrightnessScale;
|
||||||
|
state.m_Color[0] = m_CurrentLinearFloatLightColor.x * ( 1.0f / 255.0f ) * flAlpha;
|
||||||
|
state.m_Color[1] = m_CurrentLinearFloatLightColor.y * ( 1.0f / 255.0f ) * flAlpha;
|
||||||
|
state.m_Color[2] = m_CurrentLinearFloatLightColor.z * ( 1.0f / 255.0f ) * flAlpha;
|
||||||
|
state.m_Color[3] = 0.0f; // fixme: need to make ambient work m_flAmbient;
|
||||||
|
state.m_flShadowSlopeScaleDepthBias = g_pMaterialSystemHardwareConfig->GetShadowSlopeScaleDepthBias();
|
||||||
|
state.m_flShadowDepthBias = g_pMaterialSystemHardwareConfig->GetShadowDepthBias();
|
||||||
|
#endif
|
||||||
|
state.m_bEnableShadows = m_bEnableShadows;
|
||||||
|
state.m_pSpotlightTexture = m_SpotlightTexture;
|
||||||
|
state.m_nSpotlightTextureFrame = m_nSpotlightTextureFrame;
|
||||||
|
|
||||||
|
state.m_nShadowQuality = m_nShadowQuality; // Allow entity to affect shadow quality
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
state.m_bAlwaysDraw = m_bAlwaysDraw;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if( m_LightHandle == CLIENTSHADOW_INVALID_HANDLE )
|
||||||
|
{
|
||||||
|
m_LightHandle = g_pClientShadowMgr->CreateFlashlight( state );
|
||||||
|
|
||||||
|
if ( m_LightHandle != CLIENTSHADOW_INVALID_HANDLE )
|
||||||
|
{
|
||||||
|
m_bForceUpdate = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_pClientShadowMgr->UpdateFlashlightState( m_LightHandle, state );
|
||||||
|
m_bForceUpdate = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_pClientShadowMgr->GetFrustumExtents( m_LightHandle, m_vecExtentsMin, m_vecExtentsMax );
|
||||||
|
|
||||||
|
m_vecExtentsMin = m_vecExtentsMin - GetAbsOrigin();
|
||||||
|
m_vecExtentsMax = m_vecExtentsMax - GetAbsOrigin();
|
||||||
|
}
|
||||||
|
|
||||||
|
if( m_bLightOnlyTarget )
|
||||||
|
{
|
||||||
|
g_pClientShadowMgr->SetFlashlightTarget( m_LightHandle, m_hTargetEntity );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_pClientShadowMgr->SetFlashlightTarget( m_LightHandle, NULL );
|
||||||
|
}
|
||||||
|
|
||||||
|
g_pClientShadowMgr->SetFlashlightLightWorld( m_LightHandle, m_bLightWorld );
|
||||||
|
|
||||||
|
if ( !asw_perf_wtf.GetBool() && !m_bForceUpdate )
|
||||||
|
{
|
||||||
|
g_pClientShadowMgr->UpdateProjectedTexture( m_LightHandle, true );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void C_EnvProjectedTexture::Simulate( void )
|
||||||
|
{
|
||||||
|
UpdateLight();
|
||||||
|
|
||||||
|
BaseClass::Simulate();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool C_EnvProjectedTexture::IsBBoxVisible( Vector vecExtentsMin, Vector vecExtentsMax )
|
||||||
|
{
|
||||||
|
#ifdef MAPBASE
|
||||||
|
if (m_bAlwaysDraw)
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Z position clamped to the min height (but must be less than the max)
|
||||||
|
float flVisibleBBoxMinHeight = MIN( vecExtentsMax.z - 1.0f, m_flVisibleBBoxMinHeight );
|
||||||
|
vecExtentsMin.z = MAX( vecExtentsMin.z, flVisibleBBoxMinHeight );
|
||||||
|
|
||||||
|
// Check if the bbox is in the view
|
||||||
|
return !engine->CullBox( vecExtentsMin, vecExtentsMax );
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#ifndef MAPBASE
|
||||||
static ConVar mat_slopescaledepthbias_shadowmap( "mat_slopescaledepthbias_shadowmap", "16", FCVAR_CHEAT );
|
static ConVar mat_slopescaledepthbias_shadowmap( "mat_slopescaledepthbias_shadowmap", "16", FCVAR_CHEAT );
|
||||||
static ConVar mat_depthbias_shadowmap( "mat_depthbias_shadowmap", "0.0005", FCVAR_CHEAT );
|
static ConVar mat_depthbias_shadowmap( "mat_depthbias_shadowmap", "0.0005", FCVAR_CHEAT );
|
||||||
|
#else
|
||||||
|
static ConVar mat_slopescaledepthbias_shadowmap( "mat_slopescaledepthbias_shadowmap", "4", FCVAR_CHEAT );
|
||||||
|
static ConVar mat_depthbias_shadowmap( "mat_depthbias_shadowmap", "0.00001", FCVAR_CHEAT );
|
||||||
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose:
|
// Purpose:
|
||||||
@ -34,7 +508,11 @@ public:
|
|||||||
|
|
||||||
virtual void Simulate();
|
virtual void Simulate();
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
void UpdateLight();
|
||||||
|
#else
|
||||||
void UpdateLight( bool bForceUpdate );
|
void UpdateLight( bool bForceUpdate );
|
||||||
|
#endif
|
||||||
|
|
||||||
C_EnvProjectedTexture();
|
C_EnvProjectedTexture();
|
||||||
~C_EnvProjectedTexture();
|
~C_EnvProjectedTexture();
|
||||||
@ -42,10 +520,16 @@ public:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
ClientShadowHandle_t m_LightHandle;
|
ClientShadowHandle_t m_LightHandle;
|
||||||
|
#ifdef MAPBASE
|
||||||
|
bool m_bForceUpdate;
|
||||||
|
#endif
|
||||||
|
|
||||||
EHANDLE m_hTargetEntity;
|
EHANDLE m_hTargetEntity;
|
||||||
|
|
||||||
bool m_bState;
|
bool m_bState;
|
||||||
|
#ifdef MAPBASE
|
||||||
|
bool m_bAlwaysUpdate;
|
||||||
|
#endif
|
||||||
float m_flLightFOV;
|
float m_flLightFOV;
|
||||||
bool m_bEnableShadows;
|
bool m_bEnableShadows;
|
||||||
bool m_bLightOnlyTarget;
|
bool m_bLightOnlyTarget;
|
||||||
@ -63,6 +547,9 @@ private:
|
|||||||
IMPLEMENT_CLIENTCLASS_DT( C_EnvProjectedTexture, DT_EnvProjectedTexture, CEnvProjectedTexture )
|
IMPLEMENT_CLIENTCLASS_DT( C_EnvProjectedTexture, DT_EnvProjectedTexture, CEnvProjectedTexture )
|
||||||
RecvPropEHandle( RECVINFO( m_hTargetEntity ) ),
|
RecvPropEHandle( RECVINFO( m_hTargetEntity ) ),
|
||||||
RecvPropBool( RECVINFO( m_bState ) ),
|
RecvPropBool( RECVINFO( m_bState ) ),
|
||||||
|
#ifdef MAPBASE
|
||||||
|
RecvPropBool( RECVINFO( m_bAlwaysUpdate ) ),
|
||||||
|
#endif
|
||||||
RecvPropFloat( RECVINFO( m_flLightFOV ) ),
|
RecvPropFloat( RECVINFO( m_flLightFOV ) ),
|
||||||
RecvPropBool( RECVINFO( m_bEnableShadows ) ),
|
RecvPropBool( RECVINFO( m_bEnableShadows ) ),
|
||||||
RecvPropBool( RECVINFO( m_bLightOnlyTarget ) ),
|
RecvPropBool( RECVINFO( m_bLightOnlyTarget ) ),
|
||||||
@ -103,12 +590,22 @@ void C_EnvProjectedTexture::ShutDownLightHandle( void )
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void C_EnvProjectedTexture::OnDataChanged( DataUpdateType_t updateType )
|
void C_EnvProjectedTexture::OnDataChanged( DataUpdateType_t updateType )
|
||||||
{
|
{
|
||||||
|
#ifdef MAPBASE
|
||||||
|
m_bForceUpdate = true;
|
||||||
|
UpdateLight();
|
||||||
|
#else
|
||||||
UpdateLight( true );
|
UpdateLight( true );
|
||||||
|
#endif
|
||||||
BaseClass::OnDataChanged( updateType );
|
BaseClass::OnDataChanged( updateType );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef MAPBASE
|
||||||
void C_EnvProjectedTexture::UpdateLight( bool bForceUpdate )
|
void C_EnvProjectedTexture::UpdateLight( bool bForceUpdate )
|
||||||
|
#else
|
||||||
|
void C_EnvProjectedTexture::UpdateLight()
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
|
#ifndef MAPBASE
|
||||||
if ( m_bState == false )
|
if ( m_bState == false )
|
||||||
{
|
{
|
||||||
if ( m_LightHandle != CLIENTSHADOW_INVALID_HANDLE )
|
if ( m_LightHandle != CLIENTSHADOW_INVALID_HANDLE )
|
||||||
@ -118,7 +615,25 @@ void C_EnvProjectedTexture::UpdateLight( bool bForceUpdate )
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
if ( m_bAlwaysUpdate )
|
||||||
|
{
|
||||||
|
m_bForceUpdate = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( m_bState == false )
|
||||||
|
{
|
||||||
|
// Spotlight's extents aren't in view
|
||||||
|
ShutDownLightHandle();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
if ( m_LightHandle == CLIENTSHADOW_INVALID_HANDLE || m_hTargetEntity != NULL || m_bForceUpdate )
|
||||||
|
{
|
||||||
|
#endif
|
||||||
Vector vForward, vRight, vUp, vPos = GetAbsOrigin();
|
Vector vForward, vRight, vUp, vPos = GetAbsOrigin();
|
||||||
FlashlightState_t state;
|
FlashlightState_t state;
|
||||||
|
|
||||||
@ -153,8 +668,24 @@ void C_EnvProjectedTexture::UpdateLight( bool bForceUpdate )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifndef MAPBASE
|
||||||
vForward = m_hTargetEntity->GetAbsOrigin() - GetAbsOrigin();
|
vForward = m_hTargetEntity->GetAbsOrigin() - GetAbsOrigin();
|
||||||
VectorNormalize( vForward );
|
VectorNormalize( vForward );
|
||||||
|
#else
|
||||||
|
// VXP: Fixing targeting
|
||||||
|
Vector vecToTarget;
|
||||||
|
QAngle vecAngles;
|
||||||
|
if (m_hTargetEntity == NULL)
|
||||||
|
{
|
||||||
|
vecAngles = GetAbsAngles();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vecToTarget = m_hTargetEntity->GetAbsOrigin() - GetAbsOrigin();
|
||||||
|
VectorAngles(vecToTarget, vecAngles);
|
||||||
|
}
|
||||||
|
AngleVectors(vecAngles, &vForward, &vRight, &vUp);
|
||||||
|
#endif
|
||||||
|
|
||||||
// JasonM - unimplemented
|
// JasonM - unimplemented
|
||||||
Assert (0);
|
Assert (0);
|
||||||
@ -204,11 +735,19 @@ void C_EnvProjectedTexture::UpdateLight( bool bForceUpdate )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifndef MAPBASE
|
||||||
if ( m_hTargetEntity != NULL || bForceUpdate == true )
|
if ( m_hTargetEntity != NULL || bForceUpdate == true )
|
||||||
{
|
{
|
||||||
g_pClientShadowMgr->UpdateFlashlightState( m_LightHandle, state );
|
g_pClientShadowMgr->UpdateFlashlightState( m_LightHandle, state );
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
g_pClientShadowMgr->UpdateFlashlightState( m_LightHandle, state );
|
||||||
|
m_bForceUpdate = false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
#ifdef MAPBASE
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if( m_bLightOnlyTarget )
|
if( m_bLightOnlyTarget )
|
||||||
{
|
{
|
||||||
@ -221,16 +760,29 @@ void C_EnvProjectedTexture::UpdateLight( bool bForceUpdate )
|
|||||||
|
|
||||||
g_pClientShadowMgr->SetFlashlightLightWorld( m_LightHandle, m_bLightWorld );
|
g_pClientShadowMgr->SetFlashlightLightWorld( m_LightHandle, m_bLightWorld );
|
||||||
|
|
||||||
|
#ifndef MAPBASE
|
||||||
if ( bForceUpdate == false )
|
if ( bForceUpdate == false )
|
||||||
{
|
{
|
||||||
g_pClientShadowMgr->UpdateProjectedTexture( m_LightHandle, true );
|
g_pClientShadowMgr->UpdateProjectedTexture( m_LightHandle, true );
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
if ( !m_bForceUpdate )
|
||||||
|
{
|
||||||
|
g_pClientShadowMgr->UpdateProjectedTexture( m_LightHandle, true );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void C_EnvProjectedTexture::Simulate( void )
|
void C_EnvProjectedTexture::Simulate( void )
|
||||||
{
|
{
|
||||||
|
#ifndef MAPBASE
|
||||||
UpdateLight( false );
|
UpdateLight( false );
|
||||||
|
#else
|
||||||
|
UpdateLight();
|
||||||
|
#endif
|
||||||
|
|
||||||
BaseClass::Simulate();
|
BaseClass::Simulate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@ -88,8 +88,9 @@ void CDustEffect::RenderParticles( CParticleRenderIterator *pIterator )
|
|||||||
void CDustEffect::SimulateParticles( CParticleSimulateIterator *pIterator )
|
void CDustEffect::SimulateParticles( CParticleSimulateIterator *pIterator )
|
||||||
{
|
{
|
||||||
Vector vecWind;
|
Vector vecWind;
|
||||||
|
#ifndef MAPBASE
|
||||||
GetWindspeedAtTime( gpGlobals->curtime, vecWind );
|
GetWindspeedAtTime( gpGlobals->curtime, vecWind );
|
||||||
|
#endif
|
||||||
|
|
||||||
CFuncDustParticle *pParticle = (CFuncDustParticle*)pIterator->GetFirst();
|
CFuncDustParticle *pParticle = (CFuncDustParticle*)pIterator->GetFirst();
|
||||||
while ( pParticle )
|
while ( pParticle )
|
||||||
@ -105,6 +106,9 @@ void CDustEffect::SimulateParticles( CParticleSimulateIterator *pIterator )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifdef MAPBASE
|
||||||
|
vecWind = GetWindspeedAtLocation( pParticle->m_Pos );
|
||||||
|
#endif
|
||||||
for ( int i = 0 ; i < 2 ; i++ )
|
for ( int i = 0 ; i < 2 ; i++ )
|
||||||
{
|
{
|
||||||
if ( pParticle->m_vVelocity[i] < vecWind[i] )
|
if ( pParticle->m_vVelocity[i] < vecWind[i] )
|
||||||
|
@ -30,6 +30,9 @@ public:
|
|||||||
// These are documented in the server-side entity.
|
// These are documented in the server-side entity.
|
||||||
public:
|
public:
|
||||||
float m_fDisappearDist;
|
float m_fDisappearDist;
|
||||||
|
#ifdef MAPBASE
|
||||||
|
float m_fDisappearMaxDist;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -43,6 +46,9 @@ ConVar lod_TransitionDist("lod_TransitionDist", "800");
|
|||||||
// Datatable..
|
// Datatable..
|
||||||
IMPLEMENT_CLIENTCLASS_DT(C_Func_LOD, DT_Func_LOD, CFunc_LOD)
|
IMPLEMENT_CLIENTCLASS_DT(C_Func_LOD, DT_Func_LOD, CFunc_LOD)
|
||||||
RecvPropFloat(RECVINFO(m_fDisappearDist)),
|
RecvPropFloat(RECVINFO(m_fDisappearDist)),
|
||||||
|
#ifdef MAPBASE
|
||||||
|
RecvPropFloat(RECVINFO(m_fDisappearMaxDist)),
|
||||||
|
#endif
|
||||||
END_RECV_TABLE()
|
END_RECV_TABLE()
|
||||||
|
|
||||||
|
|
||||||
@ -54,6 +60,9 @@ END_RECV_TABLE()
|
|||||||
C_Func_LOD::C_Func_LOD()
|
C_Func_LOD::C_Func_LOD()
|
||||||
{
|
{
|
||||||
m_fDisappearDist = 5000.0f;
|
m_fDisappearDist = 5000.0f;
|
||||||
|
#ifdef MAPBASE
|
||||||
|
m_fDisappearMaxDist = 0.0f;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -61,7 +70,11 @@ C_Func_LOD::C_Func_LOD()
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
unsigned char C_Func_LOD::GetClientSideFade()
|
unsigned char C_Func_LOD::GetClientSideFade()
|
||||||
{
|
{
|
||||||
|
#ifdef MAPBASE
|
||||||
|
return UTIL_ComputeEntityFade( this, m_fDisappearDist, m_fDisappearDist + (m_fDisappearMaxDist != 0 ? m_fDisappearMaxDist : lod_TransitionDist.GetFloat()), 1.0f );
|
||||||
|
#else
|
||||||
return UTIL_ComputeEntityFade( this, m_fDisappearDist, m_fDisappearDist + lod_TransitionDist.GetFloat(), 1.0f );
|
return UTIL_ComputeEntityFade( this, m_fDisappearDist, m_fDisappearDist + lod_TransitionDist.GetFloat(), 1.0f );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,6 +6,9 @@
|
|||||||
//===========================================================================//
|
//===========================================================================//
|
||||||
#include "cbase.h"
|
#include "cbase.h"
|
||||||
#include "view_shared.h"
|
#include "view_shared.h"
|
||||||
|
#ifdef MAPBASE
|
||||||
|
#include "viewrender.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
// memdbgon must be the last include file in a .cpp file!!!
|
// memdbgon must be the last include file in a .cpp file!!!
|
||||||
#include "tier0/memdbgon.h"
|
#include "tier0/memdbgon.h"
|
||||||
@ -23,10 +26,27 @@ public:
|
|||||||
|
|
||||||
virtual bool ShouldDraw();
|
virtual bool ShouldDraw();
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
virtual void OnDataChanged( DataUpdateType_t type );
|
||||||
|
ITexture *ReflectionRenderTarget();
|
||||||
|
ITexture *RefractionRenderTarget();
|
||||||
|
|
||||||
|
char m_iszReflectRenderTarget[64];
|
||||||
|
char m_iszRefractRenderTarget[64];
|
||||||
|
ITexture *m_pReflectRenderTarget;
|
||||||
|
ITexture *m_pRefractRenderTarget;
|
||||||
|
#endif
|
||||||
|
|
||||||
C_FuncReflectiveGlass *m_pNext;
|
C_FuncReflectiveGlass *m_pNext;
|
||||||
};
|
};
|
||||||
|
|
||||||
IMPLEMENT_CLIENTCLASS_DT( C_FuncReflectiveGlass, DT_FuncReflectiveGlass, CFuncReflectiveGlass )
|
IMPLEMENT_CLIENTCLASS_DT( C_FuncReflectiveGlass, DT_FuncReflectiveGlass, CFuncReflectiveGlass )
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
RecvPropString( RECVINFO( m_iszReflectRenderTarget ) ),
|
||||||
|
RecvPropString( RECVINFO( m_iszRefractRenderTarget ) ),
|
||||||
|
#endif
|
||||||
|
|
||||||
END_RECV_TABLE()
|
END_RECV_TABLE()
|
||||||
|
|
||||||
|
|
||||||
@ -47,6 +67,11 @@ C_FuncReflectiveGlass* GetReflectiveGlassList()
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
C_FuncReflectiveGlass::C_FuncReflectiveGlass()
|
C_FuncReflectiveGlass::C_FuncReflectiveGlass()
|
||||||
{
|
{
|
||||||
|
#ifdef MAPBASE
|
||||||
|
m_iszReflectRenderTarget[0] = '\0';
|
||||||
|
m_iszRefractRenderTarget[0] = '\0';
|
||||||
|
#endif
|
||||||
|
|
||||||
g_ReflectiveGlassList.Insert( this );
|
g_ReflectiveGlassList.Insert( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,5 +139,111 @@ bool IsReflectiveGlassInView( const CViewSetup& view, cplane_t &plane )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Iterates through reflective glass instead of just picking one
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
C_BaseEntity *NextReflectiveGlass( C_BaseEntity *pStart, const CViewSetup& view, cplane_t &plane,
|
||||||
|
const Frustum_t &frustum, ITexture **pRenderTargets )
|
||||||
|
{
|
||||||
|
// Early out if no cameras
|
||||||
|
C_FuncReflectiveGlass *pReflectiveGlass = NULL;
|
||||||
|
if (!pStart)
|
||||||
|
pReflectiveGlass = GetReflectiveGlassList();
|
||||||
|
else
|
||||||
|
pReflectiveGlass = ((C_FuncReflectiveGlass*)pStart)->m_pNext;
|
||||||
|
|
||||||
|
cplane_t localPlane;
|
||||||
|
Vector vecOrigin, vecWorld, vecDelta;
|
||||||
|
for ( ; pReflectiveGlass != NULL; pReflectiveGlass = pReflectiveGlass->m_pNext )
|
||||||
|
{
|
||||||
|
if ( pReflectiveGlass->IsDormant() )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if ( pReflectiveGlass->m_iViewHideFlags & (1 << CurrentViewID()) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Vector vecMins, vecMaxs;
|
||||||
|
pReflectiveGlass->GetRenderBoundsWorldspace( vecMins, vecMaxs );
|
||||||
|
if ( R_CullBox( vecMins, vecMaxs, frustum ) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const model_t *pModel = pReflectiveGlass->GetModel();
|
||||||
|
const matrix3x4_t& mat = pReflectiveGlass->EntityToWorldTransform();
|
||||||
|
|
||||||
|
int nCount = modelinfo->GetBrushModelPlaneCount( pModel );
|
||||||
|
for ( int i = 0; i < nCount; ++i )
|
||||||
|
{
|
||||||
|
modelinfo->GetBrushModelPlane( pModel, i, localPlane, &vecOrigin );
|
||||||
|
|
||||||
|
MatrixTransformPlane( mat, localPlane, plane ); // Transform to world space
|
||||||
|
VectorTransform( vecOrigin, mat, vecWorld );
|
||||||
|
|
||||||
|
if ( view.origin.Dot( plane.normal ) <= plane.dist ) // Check for view behind plane
|
||||||
|
continue;
|
||||||
|
|
||||||
|
VectorSubtract( vecWorld, view.origin, vecDelta ); // Backface cull
|
||||||
|
if ( vecDelta.Dot( plane.normal ) >= 0 )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (pRenderTargets != NULL)
|
||||||
|
{
|
||||||
|
pRenderTargets[0] = pReflectiveGlass->ReflectionRenderTarget();
|
||||||
|
pRenderTargets[1] = pReflectiveGlass->RefractionRenderTarget();
|
||||||
|
}
|
||||||
|
|
||||||
|
return pReflectiveGlass;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void C_FuncReflectiveGlass::OnDataChanged( DataUpdateType_t type )
|
||||||
|
{
|
||||||
|
// Reset render textures
|
||||||
|
m_pReflectRenderTarget = NULL;
|
||||||
|
m_pRefractRenderTarget = NULL;
|
||||||
|
|
||||||
|
return BaseClass::OnDataChanged( type );
|
||||||
|
}
|
||||||
|
|
||||||
|
ITexture *C_FuncReflectiveGlass::ReflectionRenderTarget()
|
||||||
|
{
|
||||||
|
if (m_iszReflectRenderTarget[0] != '\0')
|
||||||
|
{
|
||||||
|
if (!m_pReflectRenderTarget)
|
||||||
|
{
|
||||||
|
// We don't use a CTextureReference for this because we don't want to shut down the texture on removal/change
|
||||||
|
m_pReflectRenderTarget = materials->FindTexture( m_iszReflectRenderTarget, TEXTURE_GROUP_RENDER_TARGET );
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_pReflectRenderTarget)
|
||||||
|
return m_pReflectRenderTarget;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
//return GetWaterReflectionTexture();
|
||||||
|
}
|
||||||
|
|
||||||
|
ITexture *C_FuncReflectiveGlass::RefractionRenderTarget()
|
||||||
|
{
|
||||||
|
if (m_iszRefractRenderTarget[0] != '\0')
|
||||||
|
{
|
||||||
|
if (!m_pRefractRenderTarget)
|
||||||
|
{
|
||||||
|
// We don't use a CTextureReference for this because we don't want to shut down the texture on removal/change
|
||||||
|
m_pRefractRenderTarget = materials->FindTexture( m_iszRefractRenderTarget, TEXTURE_GROUP_RENDER_TARGET );
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_pRefractRenderTarget)
|
||||||
|
return m_pRefractRenderTarget;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
//return GetWaterRefractionTexture();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,6 +21,11 @@ class CViewSetup;
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool IsReflectiveGlassInView( const CViewSetup& view, cplane_t &plane );
|
bool IsReflectiveGlassInView( const CViewSetup& view, cplane_t &plane );
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
C_BaseEntity *NextReflectiveGlass( C_BaseEntity *pStart, const CViewSetup& view, cplane_t &plane,
|
||||||
|
const Frustum_t &frustum, ITexture **pRenderTargets = NULL );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif // C_FUNC_REFLECTIVE_GLASS
|
#endif // C_FUNC_REFLECTIVE_GLASS
|
||||||
|
|
||||||
|
1312
mp/src/game/client/c_gameinstructor.cpp
Normal file
1312
mp/src/game/client/c_gameinstructor.cpp
Normal file
File diff suppressed because it is too large
Load Diff
118
mp/src/game/client/c_gameinstructor.h
Normal file
118
mp/src/game/client/c_gameinstructor.h
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
//========= Copyright © 1996-2008, Valve Corporation, All rights reserved. ============//
|
||||||
|
//
|
||||||
|
// Purpose: Client handler for instruction players how to play
|
||||||
|
//
|
||||||
|
//=============================================================================//
|
||||||
|
|
||||||
|
#ifndef _C_GAMEINSTRUCTOR_H_
|
||||||
|
#define _C_GAMEINSTRUCTOR_H_
|
||||||
|
|
||||||
|
|
||||||
|
#include "GameEventListener.h"
|
||||||
|
#include "vgui_controls/phandle.h"
|
||||||
|
|
||||||
|
class CBaseLesson;
|
||||||
|
|
||||||
|
|
||||||
|
struct LessonGroupConVarToggle_t
|
||||||
|
{
|
||||||
|
ConVarRef var;
|
||||||
|
char szLessonGroupName[ 64 ];
|
||||||
|
|
||||||
|
LessonGroupConVarToggle_t( const char *pchConVarName ) :
|
||||||
|
var( pchConVarName )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class C_GameInstructor : public CAutoGameSystemPerFrame, public CGameEventListener
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
C_GameInstructor() : CAutoGameSystemPerFrame( "C_GameInstructor" )
|
||||||
|
{
|
||||||
|
m_bHasLoadedSaveData = false;
|
||||||
|
m_bDirtySaveData = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Methods of IGameSystem
|
||||||
|
virtual bool Init( void );
|
||||||
|
virtual void Shutdown( void );
|
||||||
|
virtual void Update( float frametime );
|
||||||
|
|
||||||
|
void UpdateHiddenByOtherElements( void );
|
||||||
|
bool Mod_HiddenByOtherElements( void );
|
||||||
|
|
||||||
|
virtual void FireGameEvent( IGameEvent *event );
|
||||||
|
|
||||||
|
void DefineLesson( CBaseLesson *pLesson );
|
||||||
|
|
||||||
|
const CBaseLesson * GetLesson( const char *pchLessonName );
|
||||||
|
bool IsLessonOfSameTypeOpen( const CBaseLesson *pLesson ) const;
|
||||||
|
|
||||||
|
bool ReadSaveData( void );
|
||||||
|
bool WriteSaveData( void );
|
||||||
|
void RefreshDisplaysAndSuccesses( void );
|
||||||
|
void ResetDisplaysAndSuccesses( void );
|
||||||
|
void MarkDisplayed( const char *pchLessonName );
|
||||||
|
void MarkSucceeded( const char *pchLessonName );
|
||||||
|
|
||||||
|
void PlaySound( const char *pchSoundName );
|
||||||
|
|
||||||
|
bool OpenOpportunity( CBaseLesson *pLesson );
|
||||||
|
|
||||||
|
void DumpOpenOpportunities( void );
|
||||||
|
|
||||||
|
KeyValues * GetScriptKeys( void );
|
||||||
|
C_BasePlayer * GetLocalPlayer( void );
|
||||||
|
|
||||||
|
void EvaluateLessonsForGameRules( void );
|
||||||
|
void SetLessonGroupEnabled( const char *pszGroup, bool bEnabled );
|
||||||
|
|
||||||
|
// Mapbase needs this to be public for map-specific file system
|
||||||
|
void ReadLessonsFromFile( const char *pchFileName );
|
||||||
|
|
||||||
|
private:
|
||||||
|
void FindErrors( void );
|
||||||
|
|
||||||
|
bool UpdateActiveLesson( CBaseLesson *pLesson, const CBaseLesson *pRootLesson );
|
||||||
|
void UpdateInactiveLesson( CBaseLesson *pLesson );
|
||||||
|
|
||||||
|
CBaseLesson * GetLesson_Internal( const char *pchLessonName );
|
||||||
|
|
||||||
|
void StopAllLessons( void );
|
||||||
|
|
||||||
|
void CloseAllOpenOpportunities( void );
|
||||||
|
void CloseOpportunity( CBaseLesson *pLesson );
|
||||||
|
|
||||||
|
void InitLessonPrerequisites( void );
|
||||||
|
|
||||||
|
private:
|
||||||
|
CUtlVector < CBaseLesson* > m_Lessons;
|
||||||
|
CUtlVector < CBaseLesson* > m_OpenOpportunities;
|
||||||
|
|
||||||
|
CUtlVector < LessonGroupConVarToggle_t > m_LessonGroupConVarToggles;
|
||||||
|
|
||||||
|
KeyValues *m_pScriptKeys;
|
||||||
|
|
||||||
|
bool m_bNoDraw;
|
||||||
|
bool m_bHiddenDueToOtherElements;
|
||||||
|
|
||||||
|
int m_iCurrentPriority;
|
||||||
|
EHANDLE m_hLastSpectatedPlayer;
|
||||||
|
bool m_bSpectatedPlayerChanged;
|
||||||
|
|
||||||
|
char m_szPreviousStartSound[ 128 ];
|
||||||
|
float m_fNextStartSoundTime;
|
||||||
|
|
||||||
|
bool m_bHasLoadedSaveData;
|
||||||
|
bool m_bDirtySaveData;
|
||||||
|
};
|
||||||
|
|
||||||
|
C_GameInstructor &GetGameInstructor();
|
||||||
|
|
||||||
|
void GameInstructor_Init();
|
||||||
|
void GameInstructor_Shutdown();
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _C_GAMEINSTRUCTOR_H_
|
@ -102,6 +102,10 @@ public:
|
|||||||
C_LightGlowOverlay m_Glow;
|
C_LightGlowOverlay m_Glow;
|
||||||
|
|
||||||
float m_flGlowProxySize;
|
float m_flGlowProxySize;
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
bool m_bDisabled;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
static void RecvProxy_HDRColorScale( const CRecvProxyData *pData, void *pStruct, void *pOut )
|
static void RecvProxy_HDRColorScale( const CRecvProxyData *pData, void *pStruct, void *pOut )
|
||||||
@ -123,6 +127,9 @@ IMPLEMENT_CLIENTCLASS_DT_NOBASE( C_LightGlow, DT_LightGlow, CLightGlow )
|
|||||||
RecvPropQAngles( RECVINFO_NAME( m_angNetworkAngles, m_angRotation ) ),
|
RecvPropQAngles( RECVINFO_NAME( m_angNetworkAngles, m_angRotation ) ),
|
||||||
RecvPropInt( RECVINFO_NAME(m_hNetworkMoveParent, moveparent), 0, RecvProxy_IntToMoveParent ),
|
RecvPropInt( RECVINFO_NAME(m_hNetworkMoveParent, moveparent), 0, RecvProxy_IntToMoveParent ),
|
||||||
RecvPropFloat(RECVINFO(m_flGlowProxySize)),
|
RecvPropFloat(RECVINFO(m_flGlowProxySize)),
|
||||||
|
#ifdef MAPBASE
|
||||||
|
RecvPropBool( RECVINFO( m_bDisabled ) ),
|
||||||
|
#endif
|
||||||
RecvPropFloat("HDRColorScale", 0, SIZEOF_IGNORE, 0, RecvProxy_HDRColorScale),
|
RecvPropFloat("HDRColorScale", 0, SIZEOF_IGNORE, 0, RecvProxy_HDRColorScale),
|
||||||
END_RECV_TABLE()
|
END_RECV_TABLE()
|
||||||
|
|
||||||
@ -202,7 +209,11 @@ void C_LightGlow::OnDataChanged( DataUpdateType_t updateType )
|
|||||||
void C_LightGlow::ClientThink( void )
|
void C_LightGlow::ClientThink( void )
|
||||||
{
|
{
|
||||||
Vector mins = GetAbsOrigin();
|
Vector mins = GetAbsOrigin();
|
||||||
|
#ifdef MAPBASE
|
||||||
|
if ( engine->IsBoxVisible( mins, mins ) && !m_bDisabled )
|
||||||
|
#else
|
||||||
if ( engine->IsBoxVisible( mins, mins ) )
|
if ( engine->IsBoxVisible( mins, mins ) )
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
m_Glow.Activate();
|
m_Glow.Activate();
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,9 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
int m_iEffectIndex;
|
int m_iEffectIndex;
|
||||||
bool m_bActive;
|
bool m_bActive;
|
||||||
|
#ifdef MAPBASE
|
||||||
|
bool m_bDestroyImmediately;
|
||||||
|
#endif
|
||||||
bool m_bOldActive;
|
bool m_bOldActive;
|
||||||
float m_flStartTime; // Time at which the effect started
|
float m_flStartTime; // Time at which the effect started
|
||||||
|
|
||||||
@ -56,6 +59,9 @@ BEGIN_RECV_TABLE_NOBASE( C_ParticleSystem, DT_ParticleSystem )
|
|||||||
|
|
||||||
RecvPropInt( RECVINFO( m_iEffectIndex ) ),
|
RecvPropInt( RECVINFO( m_iEffectIndex ) ),
|
||||||
RecvPropBool( RECVINFO( m_bActive ) ),
|
RecvPropBool( RECVINFO( m_bActive ) ),
|
||||||
|
#ifdef MAPBASE
|
||||||
|
RecvPropBool( RECVINFO( m_bDestroyImmediately ) ),
|
||||||
|
#endif
|
||||||
RecvPropFloat( RECVINFO( m_flStartTime ) ),
|
RecvPropFloat( RECVINFO( m_flStartTime ) ),
|
||||||
|
|
||||||
RecvPropArray3( RECVINFO_ARRAY(m_hControlPointEnts), RecvPropEHandle( RECVINFO( m_hControlPointEnts[0] ) ) ),
|
RecvPropArray3( RECVINFO_ARRAY(m_hControlPointEnts), RecvPropEHandle( RECVINFO( m_hControlPointEnts[0] ) ) ),
|
||||||
@ -108,9 +114,18 @@ void C_ParticleSystem::PostDataUpdate( DataUpdateType_t updateType )
|
|||||||
SetNextClientThink( gpGlobals->curtime );
|
SetNextClientThink( gpGlobals->curtime );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#ifdef MAPBASE
|
||||||
|
{
|
||||||
|
if (!m_bDestroyImmediately)
|
||||||
|
ParticleProp()->StopEmission();
|
||||||
|
else
|
||||||
|
ParticleProp()->StopEmissionAndDestroyImmediately();
|
||||||
|
}
|
||||||
|
#else
|
||||||
{
|
{
|
||||||
ParticleProp()->StopEmission();
|
ParticleProp()->StopEmission();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -429,8 +429,10 @@ void CPixelVisibilityQuery::IssueQuery( IMatRenderContext *pRenderContext, float
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifndef MAPBASE // Mapbase can also query visibility several times via multiple point_cameras, etc.
|
||||||
#ifndef PORTAL // FIXME: In portal we query visibility multiple times per frame because of portal renders!
|
#ifndef PORTAL // FIXME: In portal we query visibility multiple times per frame because of portal renders!
|
||||||
Assert ( ( m_frameIssued != gpGlobals->framecount ) || UseVR() );
|
Assert ( ( m_frameIssued != gpGlobals->framecount ) || UseVR() );
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_frameIssued = gpGlobals->framecount;
|
m_frameIssued = gpGlobals->framecount;
|
||||||
|
@ -75,6 +75,9 @@ public:
|
|||||||
|
|
||||||
bool m_bSlowMovement;
|
bool m_bSlowMovement;
|
||||||
|
|
||||||
|
//Tony; added so tonemap controller can work in multiplayer with inputs.
|
||||||
|
tonemap_params_t m_TonemapParams;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // C_PLAYERLOCALDATA_H
|
#endif // C_PLAYERLOCALDATA_H
|
||||||
|
@ -25,6 +25,10 @@ IMPLEMENT_CLIENTCLASS_DT( C_PointCamera, DT_PointCamera, CPointCamera )
|
|||||||
RecvPropFloat( RECVINFO( m_flFogMaxDensity ) ),
|
RecvPropFloat( RECVINFO( m_flFogMaxDensity ) ),
|
||||||
RecvPropInt( RECVINFO( m_bActive ) ),
|
RecvPropInt( RECVINFO( m_bActive ) ),
|
||||||
RecvPropInt( RECVINFO( m_bUseScreenAspectRatio ) ),
|
RecvPropInt( RECVINFO( m_bUseScreenAspectRatio ) ),
|
||||||
|
#ifdef MAPBASE
|
||||||
|
RecvPropInt( RECVINFO( m_iSkyMode ) ),
|
||||||
|
RecvPropString( RECVINFO( m_iszRenderTarget ) ),
|
||||||
|
#endif
|
||||||
END_RECV_TABLE()
|
END_RECV_TABLE()
|
||||||
|
|
||||||
C_EntityClassList<C_PointCamera> g_PointCameraList;
|
C_EntityClassList<C_PointCamera> g_PointCameraList;
|
||||||
@ -40,6 +44,10 @@ C_PointCamera::C_PointCamera()
|
|||||||
m_bActive = false;
|
m_bActive = false;
|
||||||
m_bFogEnable = false;
|
m_bFogEnable = false;
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
m_iszRenderTarget[0] = '\0';
|
||||||
|
#endif
|
||||||
|
|
||||||
g_PointCameraList.Insert( this );
|
g_PointCameraList.Insert( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,6 +61,16 @@ bool C_PointCamera::ShouldDraw()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void C_PointCamera::OnDataChanged( DataUpdateType_t type )
|
||||||
|
{
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// Reset render texture
|
||||||
|
m_pRenderTarget = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return BaseClass::OnDataChanged( type );
|
||||||
|
}
|
||||||
|
|
||||||
float C_PointCamera::GetFOV()
|
float C_PointCamera::GetFOV()
|
||||||
{
|
{
|
||||||
return m_FOV;
|
return m_FOV;
|
||||||
@ -113,4 +131,31 @@ void C_PointCamera::GetToolRecordingState( KeyValues *msg )
|
|||||||
msg->SetPtr( "monitor", &state );
|
msg->SetPtr( "monitor", &state );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
extern ITexture *GetCameraTexture( void );
|
||||||
|
extern void AddReleaseFunc( void );
|
||||||
|
|
||||||
|
ITexture *C_PointCamera::RenderTarget()
|
||||||
|
{
|
||||||
|
if (m_iszRenderTarget[0] != '\0')
|
||||||
|
{
|
||||||
|
if (!m_pRenderTarget)
|
||||||
|
{
|
||||||
|
// We don't use a CTextureReference for this because we don't want to shut down the texture on removal/change
|
||||||
|
m_pRenderTarget = materials->FindTexture( m_iszRenderTarget, TEXTURE_GROUP_RENDER_TARGET );
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_pRenderTarget)
|
||||||
|
return m_pRenderTarget;
|
||||||
|
}
|
||||||
|
|
||||||
|
return GetCameraTexture();
|
||||||
|
}
|
||||||
|
|
||||||
|
IMPLEMENT_CLIENTCLASS_DT( C_PointCameraOrtho, DT_PointCameraOrtho, CPointCameraOrtho )
|
||||||
|
RecvPropInt( RECVINFO( m_bOrtho ) ),
|
||||||
|
RecvPropArray( RecvPropFloat( RECVINFO( m_OrthoDimensions[0] ) ), m_OrthoDimensions ),
|
||||||
|
END_RECV_TABLE()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,6 +29,9 @@ public:
|
|||||||
// C_BaseEntity.
|
// C_BaseEntity.
|
||||||
virtual bool ShouldDraw();
|
virtual bool ShouldDraw();
|
||||||
|
|
||||||
|
// Mapbase uses this for m_iszRenderTarget
|
||||||
|
virtual void OnDataChanged( DataUpdateType_t type );
|
||||||
|
|
||||||
float GetFOV();
|
float GetFOV();
|
||||||
float GetResolution();
|
float GetResolution();
|
||||||
bool IsFogEnabled();
|
bool IsFogEnabled();
|
||||||
@ -37,6 +40,14 @@ public:
|
|||||||
float GetFogMaxDensity();
|
float GetFogMaxDensity();
|
||||||
float GetFogEnd();
|
float GetFogEnd();
|
||||||
bool UseScreenAspectRatio() const { return m_bUseScreenAspectRatio; }
|
bool UseScreenAspectRatio() const { return m_bUseScreenAspectRatio; }
|
||||||
|
#ifdef MAPBASE
|
||||||
|
virtual bool IsOrtho() const { return false; }
|
||||||
|
virtual void GetOrthoDimensions(float &up, float &dn, float &lf, float &rt) const {}
|
||||||
|
|
||||||
|
SkyboxVisibility_t SkyMode() { return m_iSkyMode; }
|
||||||
|
|
||||||
|
ITexture *RenderTarget();
|
||||||
|
#endif
|
||||||
|
|
||||||
virtual void GetToolRecordingState( KeyValues *msg );
|
virtual void GetToolRecordingState( KeyValues *msg );
|
||||||
|
|
||||||
@ -50,11 +61,37 @@ private:
|
|||||||
float m_flFogMaxDensity;
|
float m_flFogMaxDensity;
|
||||||
bool m_bActive;
|
bool m_bActive;
|
||||||
bool m_bUseScreenAspectRatio;
|
bool m_bUseScreenAspectRatio;
|
||||||
|
#ifdef MAPBASE
|
||||||
|
SkyboxVisibility_t m_iSkyMode;
|
||||||
|
ITexture *m_pRenderTarget;
|
||||||
|
char m_iszRenderTarget[64];
|
||||||
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
C_PointCamera *m_pNext;
|
C_PointCamera *m_pNext;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
class C_PointCameraOrtho : public C_PointCamera
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DECLARE_CLASS( C_PointCameraOrtho, C_PointCamera );
|
||||||
|
DECLARE_CLIENTCLASS();
|
||||||
|
|
||||||
|
public:
|
||||||
|
bool IsOrtho() const { return m_bOrtho; }
|
||||||
|
void GetOrthoDimensions( float &up, float &dn, float &lf, float &rt ) const
|
||||||
|
{
|
||||||
|
up = m_OrthoDimensions[0], dn = m_OrthoDimensions[1];
|
||||||
|
lf = m_OrthoDimensions[2], rt = m_OrthoDimensions[3];
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_bOrtho;
|
||||||
|
float m_OrthoDimensions[4];
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
C_PointCamera *GetPointCameraList();
|
C_PointCamera *GetPointCameraList();
|
||||||
|
|
||||||
#endif // C_POINTCAMERA_H
|
#endif // C_POINTCAMERA_H
|
||||||
|
63
mp/src/game/client/c_postprocesscontroller.cpp
Normal file
63
mp/src/game/client/c_postprocesscontroller.cpp
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
//====== Copyright © 1996-2008, Valve Corporation, All rights reserved. =======
|
||||||
|
//
|
||||||
|
// Purpose: stores map postprocess params
|
||||||
|
//
|
||||||
|
//=============================================================================
|
||||||
|
#include "cbase.h"
|
||||||
|
#include "c_postprocesscontroller.h"
|
||||||
|
|
||||||
|
// memdbgon must be the last include file in a .cpp file!!!
|
||||||
|
#include "tier0/memdbgon.h"
|
||||||
|
|
||||||
|
IMPLEMENT_CLIENTCLASS_DT( C_PostProcessController, DT_PostProcessController, CPostProcessController )
|
||||||
|
RecvPropArray3( RECVINFO_NAME( m_PostProcessParameters.m_flParameters[0], m_flPostProcessParameters ), POST_PROCESS_PARAMETER_COUNT, RecvPropFloat( RECVINFO_NAME( m_PostProcessParameters.m_flParameters[0], m_flPostProcessParameters[0] ) ) ),
|
||||||
|
RecvPropBool( RECVINFO(m_bMaster) )
|
||||||
|
END_RECV_TABLE()
|
||||||
|
|
||||||
|
C_PostProcessController* C_PostProcessController::ms_pMasterController = nullptr;
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
C_PostProcessController::C_PostProcessController()
|
||||||
|
: m_bMaster( false )
|
||||||
|
{
|
||||||
|
if ( ms_pMasterController == nullptr)
|
||||||
|
{
|
||||||
|
ms_pMasterController = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
C_PostProcessController::~C_PostProcessController()
|
||||||
|
{
|
||||||
|
if ( ms_pMasterController == this )
|
||||||
|
{
|
||||||
|
ms_pMasterController = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void C_PostProcessController::PostDataUpdate( DataUpdateType_t updateType )
|
||||||
|
{
|
||||||
|
BaseClass::PostDataUpdate( updateType );
|
||||||
|
|
||||||
|
if ( m_bMaster )
|
||||||
|
{
|
||||||
|
ms_pMasterController = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// Prevents parameters from fading after a save/restore
|
||||||
|
bool g_bPostProcessNeedsRestore = false;
|
||||||
|
|
||||||
|
void C_PostProcessController::OnRestore()
|
||||||
|
{
|
||||||
|
BaseClass::OnRestore();
|
||||||
|
|
||||||
|
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||||
|
if ( pPlayer && pPlayer->GetActivePostProcessController() == this )
|
||||||
|
{
|
||||||
|
// Tell clientmode this is part of a save/restore
|
||||||
|
g_bPostProcessNeedsRestore = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
33
mp/src/game/client/c_postprocesscontroller.h
Normal file
33
mp/src/game/client/c_postprocesscontroller.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "postprocess_shared.h"
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
//
|
||||||
|
// Class Postprocess Controller:
|
||||||
|
//
|
||||||
|
class C_PostProcessController : public C_BaseEntity
|
||||||
|
{
|
||||||
|
DECLARE_CLASS( C_PostProcessController, C_BaseEntity );
|
||||||
|
public:
|
||||||
|
DECLARE_CLIENTCLASS();
|
||||||
|
|
||||||
|
C_PostProcessController();
|
||||||
|
virtual ~C_PostProcessController();
|
||||||
|
|
||||||
|
virtual void PostDataUpdate( DataUpdateType_t updateType );
|
||||||
|
|
||||||
|
static C_PostProcessController* GetMasterController() { return ms_pMasterController; }
|
||||||
|
|
||||||
|
PostProcessParameters_t m_PostProcessParameters;
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// Prevents fade time from being used in save/restore
|
||||||
|
virtual void OnRestore();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_bMaster;
|
||||||
|
|
||||||
|
static C_PostProcessController* ms_pMasterController;
|
||||||
|
};
|
File diff suppressed because it is too large
Load Diff
@ -107,7 +107,9 @@ public:
|
|||||||
|
|
||||||
// Get the rope material data.
|
// Get the rope material data.
|
||||||
IMaterial *GetSolidMaterial( void );
|
IMaterial *GetSolidMaterial( void );
|
||||||
|
#ifndef MAPBASE
|
||||||
IMaterial *GetBackMaterial( void );
|
IMaterial *GetBackMaterial( void );
|
||||||
|
#endif
|
||||||
|
|
||||||
struct BuildRopeQueuedData_t
|
struct BuildRopeQueuedData_t
|
||||||
{
|
{
|
||||||
@ -119,7 +121,11 @@ public:
|
|||||||
float m_Slack;
|
float m_Slack;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
void BuildRope( RopeSegData_t *pRopeSegment, const Vector &vCurrentViewForward, const Vector &vCurrentViewOrigin, BuildRopeQueuedData_t *pQueuedData );
|
||||||
|
#else
|
||||||
void BuildRope( RopeSegData_t *pRopeSegment, const Vector &vCurrentViewForward, const Vector &vCurrentViewOrigin, BuildRopeQueuedData_t *pQueuedData, bool bQueued );
|
void BuildRope( RopeSegData_t *pRopeSegment, const Vector &vCurrentViewForward, const Vector &vCurrentViewOrigin, BuildRopeQueuedData_t *pQueuedData, bool bQueued );
|
||||||
|
#endif
|
||||||
|
|
||||||
// C_BaseEntity overrides.
|
// C_BaseEntity overrides.
|
||||||
public:
|
public:
|
||||||
@ -196,19 +202,29 @@ private:
|
|||||||
float m_TextureScale; // pixels per inch
|
float m_TextureScale; // pixels per inch
|
||||||
|
|
||||||
int m_fLockedPoints; // Which points are locked down.
|
int m_fLockedPoints; // Which points are locked down.
|
||||||
|
#ifdef MAPBASE
|
||||||
|
int m_nChangeCount;
|
||||||
|
#endif
|
||||||
|
|
||||||
float m_Width;
|
float m_Width;
|
||||||
|
|
||||||
CPhysicsDelegate m_PhysicsDelegate;
|
CPhysicsDelegate m_PhysicsDelegate;
|
||||||
|
|
||||||
IMaterial *m_pMaterial;
|
IMaterial *m_pMaterial;
|
||||||
|
#ifndef MAPBASE
|
||||||
IMaterial *m_pBackMaterial; // Optional translucent background material for the rope to help reduce aliasing.
|
IMaterial *m_pBackMaterial; // Optional translucent background material for the rope to help reduce aliasing.
|
||||||
|
#endif
|
||||||
|
|
||||||
int m_TextureHeight; // Texture height, for texture scale calculations.
|
int m_TextureHeight; // Texture height, for texture scale calculations.
|
||||||
|
|
||||||
// Instantaneous force
|
// Instantaneous force
|
||||||
|
#ifdef MAPBASE
|
||||||
|
Vector m_vecImpulse;
|
||||||
|
Vector m_vecPreviousImpulse;
|
||||||
|
#else
|
||||||
Vector m_flImpulse;
|
Vector m_flImpulse;
|
||||||
Vector m_flPreviousImpulse;
|
Vector m_flPreviousImpulse;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Simulated wind gusts.
|
// Simulated wind gusts.
|
||||||
float m_flCurrentGustTimer;
|
float m_flCurrentGustTimer;
|
||||||
@ -250,7 +266,9 @@ public:
|
|||||||
virtual void ResetRenderCache( void ) = 0;
|
virtual void ResetRenderCache( void ) = 0;
|
||||||
virtual void AddToRenderCache( C_RopeKeyframe *pRope ) = 0;
|
virtual void AddToRenderCache( C_RopeKeyframe *pRope ) = 0;
|
||||||
virtual void DrawRenderCache( bool bShadowDepth ) = 0;
|
virtual void DrawRenderCache( bool bShadowDepth ) = 0;
|
||||||
|
#ifndef MAPBASE
|
||||||
virtual void OnRenderStart( void ) = 0;
|
virtual void OnRenderStart( void ) = 0;
|
||||||
|
#endif
|
||||||
virtual void SetHolidayLightMode( bool bHoliday ) = 0;
|
virtual void SetHolidayLightMode( bool bHoliday ) = 0;
|
||||||
virtual bool IsHolidayLightMode( void ) = 0;
|
virtual bool IsHolidayLightMode( void ) = 0;
|
||||||
virtual int GetHolidayLightStyle( void ) = 0;
|
virtual int GetHolidayLightStyle( void ) = 0;
|
||||||
|
@ -676,7 +676,7 @@ void C_SceneEntity::DispatchStartSpeak( CChoreoScene *scene, C_BaseFlex *actor,
|
|||||||
es.m_pSoundName = event->GetParameters();
|
es.m_pSoundName = event->GetParameters();
|
||||||
|
|
||||||
EmitSound( filter, actor->entindex(), es );
|
EmitSound( filter, actor->entindex(), es );
|
||||||
actor->AddSceneEvent( scene, event, NULL, IsClientOnly() );
|
actor->AddSceneEvent( scene, event, NULL, IsClientOnly(), this );
|
||||||
|
|
||||||
// Close captioning only on master token no matter what...
|
// Close captioning only on master token no matter what...
|
||||||
if ( event->GetCloseCaptionType() == CChoreoEvent::CC_MASTER )
|
if ( event->GetCloseCaptionType() == CChoreoEvent::CC_MASTER )
|
||||||
@ -806,20 +806,72 @@ CChoreoStringPool g_ChoreoStringPool;
|
|||||||
|
|
||||||
CChoreoScene *C_SceneEntity::LoadScene( const char *filename )
|
CChoreoScene *C_SceneEntity::LoadScene( const char *filename )
|
||||||
{
|
{
|
||||||
|
#ifdef MAPBASE
|
||||||
|
char loadfile[MAX_PATH];
|
||||||
|
#else
|
||||||
char loadfile[ 512 ];
|
char loadfile[ 512 ];
|
||||||
|
#endif
|
||||||
Q_strncpy( loadfile, filename, sizeof( loadfile ) );
|
Q_strncpy( loadfile, filename, sizeof( loadfile ) );
|
||||||
Q_SetExtension( loadfile, ".vcd", sizeof( loadfile ) );
|
Q_SetExtension( loadfile, ".vcd", sizeof( loadfile ) );
|
||||||
Q_FixSlashes( loadfile );
|
Q_FixSlashes( loadfile );
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
//
|
||||||
|
// Raw scene file support
|
||||||
|
//
|
||||||
|
void *pBuffer = 0;
|
||||||
|
size_t bufsize = scenefilecache->GetSceneBufferSize( loadfile );
|
||||||
|
CChoreoScene *pScene = NULL;
|
||||||
|
if ( bufsize > 0 )
|
||||||
|
{
|
||||||
|
// Definitely in scenes.image
|
||||||
|
pBuffer = malloc( bufsize );
|
||||||
|
if ( !scenefilecache->GetSceneData( filename, (byte *)pBuffer, bufsize ) )
|
||||||
|
{
|
||||||
|
free( pBuffer );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ( IsBufferBinaryVCD( (char*)pBuffer, bufsize ) )
|
||||||
|
{
|
||||||
|
pScene = new CChoreoScene( this );
|
||||||
|
CUtlBuffer buf( pBuffer, bufsize, CUtlBuffer::READ_ONLY );
|
||||||
|
if ( !pScene->RestoreFromBinaryBuffer( buf, loadfile, &g_ChoreoStringPool ) )
|
||||||
|
{
|
||||||
|
Warning( "Unable to restore scene '%s'\n", loadfile );
|
||||||
|
delete pScene;
|
||||||
|
pScene = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (filesystem->ReadFileEx( loadfile, "MOD", &pBuffer, true ))
|
||||||
|
{
|
||||||
|
// Not in scenes.image, but it's a raw file
|
||||||
|
g_TokenProcessor.SetBuffer((char*)pBuffer);
|
||||||
|
pScene = ChoreoLoadScene( loadfile, this, &g_TokenProcessor, Scene_Printf );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Abandon ship
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(pScene)
|
||||||
|
{
|
||||||
|
pScene->SetPrintFunc( Scene_Printf );
|
||||||
|
pScene->SetEventCallbackInterface( this );
|
||||||
|
}
|
||||||
|
#else
|
||||||
char *pBuffer = NULL;
|
char *pBuffer = NULL;
|
||||||
size_t bufsize = scenefilecache->GetSceneBufferSize( loadfile );
|
size_t bufsize = scenefilecache->GetSceneBufferSize( loadfile );
|
||||||
if ( bufsize <= 0 )
|
if ( bufsize <= 0 )
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
pBuffer = new char[ bufsize ];
|
pBuffer = malloc( bufsize );
|
||||||
if ( !scenefilecache->GetSceneData( filename, (byte *)pBuffer, bufsize ) )
|
if ( !scenefilecache->GetSceneData( filename, (byte *)pBuffer, bufsize ) )
|
||||||
{
|
{
|
||||||
delete[] pBuffer;
|
free( pBuffer );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -845,8 +897,9 @@ CChoreoScene *C_SceneEntity::LoadScene( const char *filename )
|
|||||||
g_TokenProcessor.SetBuffer( pBuffer );
|
g_TokenProcessor.SetBuffer( pBuffer );
|
||||||
pScene = ChoreoLoadScene( loadfile, this, &g_TokenProcessor, Scene_Printf );
|
pScene = ChoreoLoadScene( loadfile, this, &g_TokenProcessor, Scene_Printf );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
delete[] pBuffer;
|
free( pBuffer );
|
||||||
return pScene;
|
return pScene;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -913,7 +966,7 @@ void C_SceneEntity::UnloadScene( void )
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void C_SceneEntity::DispatchStartFlexAnimation( CChoreoScene *scene, C_BaseFlex *actor, CChoreoEvent *event )
|
void C_SceneEntity::DispatchStartFlexAnimation( CChoreoScene *scene, C_BaseFlex *actor, CChoreoEvent *event )
|
||||||
{
|
{
|
||||||
actor->AddSceneEvent( scene, event, NULL, IsClientOnly() );
|
actor->AddSceneEvent( scene, event, NULL, IsClientOnly(), this );
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -933,7 +986,7 @@ void C_SceneEntity::DispatchEndFlexAnimation( CChoreoScene *scene, C_BaseFlex *a
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void C_SceneEntity::DispatchStartExpression( CChoreoScene *scene, C_BaseFlex *actor, CChoreoEvent *event )
|
void C_SceneEntity::DispatchStartExpression( CChoreoScene *scene, C_BaseFlex *actor, CChoreoEvent *event )
|
||||||
{
|
{
|
||||||
actor->AddSceneEvent( scene, event, NULL, IsClientOnly() );
|
actor->AddSceneEvent( scene, event, NULL, IsClientOnly(), this );
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -957,7 +1010,7 @@ void C_SceneEntity::DispatchStartGesture( CChoreoScene *scene, C_BaseFlex *actor
|
|||||||
if ( !Q_stricmp( event->GetName(), "NULL" ) )
|
if ( !Q_stricmp( event->GetName(), "NULL" ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
actor->AddSceneEvent( scene, event, NULL, IsClientOnly() );
|
actor->AddSceneEvent( scene, event, NULL, IsClientOnly(), this );
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -972,7 +1025,7 @@ void C_SceneEntity::DispatchProcessGesture( CChoreoScene *scene, C_BaseFlex *act
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
actor->RemoveSceneEvent( scene, event, false );
|
actor->RemoveSceneEvent( scene, event, false );
|
||||||
actor->AddSceneEvent( scene, event, NULL, IsClientOnly() );
|
actor->AddSceneEvent( scene, event, NULL, IsClientOnly(), this );
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -995,7 +1048,7 @@ void C_SceneEntity::DispatchEndGesture( CChoreoScene *scene, C_BaseFlex *actor,
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void C_SceneEntity::DispatchStartSequence( CChoreoScene *scene, CBaseFlex *actor, CChoreoEvent *event )
|
void C_SceneEntity::DispatchStartSequence( CChoreoScene *scene, CBaseFlex *actor, CChoreoEvent *event )
|
||||||
{
|
{
|
||||||
actor->AddSceneEvent( scene, event, NULL, IsClientOnly() );
|
actor->AddSceneEvent( scene, event, NULL, IsClientOnly(), this );
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -1005,7 +1058,7 @@ void C_SceneEntity::DispatchStartSequence( CChoreoScene *scene, CBaseFlex *actor
|
|||||||
void C_SceneEntity::DispatchProcessSequence( CChoreoScene *scene, CBaseFlex *actor, CChoreoEvent *event )
|
void C_SceneEntity::DispatchProcessSequence( CChoreoScene *scene, CBaseFlex *actor, CChoreoEvent *event )
|
||||||
{
|
{
|
||||||
actor->RemoveSceneEvent( scene, event, false );
|
actor->RemoveSceneEvent( scene, event, false );
|
||||||
actor->AddSceneEvent( scene, event, NULL, IsClientOnly() );
|
actor->AddSceneEvent( scene, event, NULL, IsClientOnly(), this );
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -1210,4 +1263,4 @@ void C_SceneEntity::PrefetchAnimBlocks( CChoreoScene *pScene )
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
Msg( "%d of %d animations resident\n", nResident, nChecked );
|
Msg( "%d of %d animations resident\n", nResident, nChecked );
|
||||||
}
|
}
|
||||||
|
@ -32,13 +32,24 @@ private:
|
|||||||
color32 m_shadowColor;
|
color32 m_shadowColor;
|
||||||
float m_flShadowMaxDist;
|
float m_flShadowMaxDist;
|
||||||
bool m_bDisableShadows;
|
bool m_bDisableShadows;
|
||||||
|
#ifdef MAPBASE
|
||||||
|
bool m_bEnableLocalLightShadows;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
IMPLEMENT_CLIENTCLASS_DT(C_ShadowControl, DT_ShadowControl, CShadowControl)
|
IMPLEMENT_CLIENTCLASS_DT(C_ShadowControl, DT_ShadowControl, CShadowControl)
|
||||||
RecvPropVector(RECVINFO(m_shadowDirection)),
|
RecvPropVector(RECVINFO(m_shadowDirection)),
|
||||||
|
#ifdef MAPBASE
|
||||||
|
/*RecvPropInt(RECVINFO(m_shadowColor), 0, RecvProxy_Int32ToColor32),*/
|
||||||
|
RecvPropInt(RECVINFO(m_shadowColor), 0, RecvProxy_IntToColor32),
|
||||||
|
#else
|
||||||
RecvPropInt(RECVINFO(m_shadowColor)),
|
RecvPropInt(RECVINFO(m_shadowColor)),
|
||||||
|
#endif
|
||||||
RecvPropFloat(RECVINFO(m_flShadowMaxDist)),
|
RecvPropFloat(RECVINFO(m_flShadowMaxDist)),
|
||||||
RecvPropBool(RECVINFO(m_bDisableShadows)),
|
RecvPropBool(RECVINFO(m_bDisableShadows)),
|
||||||
|
#ifdef MAPBASE
|
||||||
|
RecvPropBool(RECVINFO(m_bEnableLocalLightShadows)),
|
||||||
|
#endif
|
||||||
END_RECV_TABLE()
|
END_RECV_TABLE()
|
||||||
|
|
||||||
|
|
||||||
@ -54,6 +65,9 @@ void C_ShadowControl::OnDataChanged(DataUpdateType_t updateType)
|
|||||||
g_pClientShadowMgr->SetShadowColor( m_shadowColor.r, m_shadowColor.g, m_shadowColor.b );
|
g_pClientShadowMgr->SetShadowColor( m_shadowColor.r, m_shadowColor.g, m_shadowColor.b );
|
||||||
g_pClientShadowMgr->SetShadowDistance( m_flShadowMaxDist );
|
g_pClientShadowMgr->SetShadowDistance( m_flShadowMaxDist );
|
||||||
g_pClientShadowMgr->SetShadowsDisabled( m_bDisableShadows );
|
g_pClientShadowMgr->SetShadowsDisabled( m_bDisableShadows );
|
||||||
|
#ifdef DYNAMIC_RTT_SHADOWS
|
||||||
|
g_pClientShadowMgr->SetShadowFromWorldLightsEnabled( m_bEnableLocalLightShadows );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
@ -207,6 +207,9 @@ public:
|
|||||||
// "dsp_volume"
|
// "dsp_volume"
|
||||||
void ProcessDSPVolume( KeyValues *pKey, subsoundscapeparams_t ¶ms );
|
void ProcessDSPVolume( KeyValues *pKey, subsoundscapeparams_t ¶ms );
|
||||||
|
|
||||||
|
#ifdef MAPBASE // Moved to public space
|
||||||
|
void AddSoundScapeFile( const char *filename );
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -215,7 +218,9 @@ private:
|
|||||||
return gpGlobals->framecount == m_nRestoreFrame ? true : false;
|
return gpGlobals->framecount == m_nRestoreFrame ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef MAPBASE // Moved to public space
|
||||||
void AddSoundScapeFile( const char *filename );
|
void AddSoundScapeFile( const char *filename );
|
||||||
|
#endif
|
||||||
|
|
||||||
void TouchPlayLooping( KeyValues *pAmbient );
|
void TouchPlayLooping( KeyValues *pAmbient );
|
||||||
void TouchPlayRandom( KeyValues *pPlayRandom );
|
void TouchPlayRandom( KeyValues *pPlayRandom );
|
||||||
@ -265,6 +270,13 @@ void Soundscape_Update( audioparams_t &audio )
|
|||||||
g_SoundscapeSystem.UpdateAudioParams( audio );
|
g_SoundscapeSystem.UpdateAudioParams( audio );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
void Soundscape_AddFile( const char *szFile )
|
||||||
|
{
|
||||||
|
g_SoundscapeSystem.AddSoundScapeFile(szFile);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#define SOUNDSCAPE_MANIFEST_FILE "scripts/soundscapes_manifest.txt"
|
#define SOUNDSCAPE_MANIFEST_FILE "scripts/soundscapes_manifest.txt"
|
||||||
|
|
||||||
void C_SoundscapeSystem::AddSoundScapeFile( const char *filename )
|
void C_SoundscapeSystem::AddSoundScapeFile( const char *filename )
|
||||||
@ -310,6 +322,16 @@ bool C_SoundscapeSystem::Init()
|
|||||||
mapSoundscapeFilename = VarArgs( "scripts/soundscapes_%s.txt", mapname );
|
mapSoundscapeFilename = VarArgs( "scripts/soundscapes_%s.txt", mapname );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
if (filesystem->FileExists(VarArgs("maps/%s_soundscapes.txt", mapname)))
|
||||||
|
{
|
||||||
|
// A Mapbase-specific file exists. Load that instead.
|
||||||
|
// Any additional soundscape files, like the original scripts/soundscapes version,
|
||||||
|
// could be loaded through #include and/or #base.
|
||||||
|
mapSoundscapeFilename = VarArgs("maps/%s_soundscapes.txt", mapname);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
KeyValues *manifest = new KeyValues( SOUNDSCAPE_MANIFEST_FILE );
|
KeyValues *manifest = new KeyValues( SOUNDSCAPE_MANIFEST_FILE );
|
||||||
if ( filesystem->LoadKeyValues( *manifest, IFileSystem::TYPE_SOUNDSCAPE, SOUNDSCAPE_MANIFEST_FILE, "GAME" ) )
|
if ( filesystem->LoadKeyValues( *manifest, IFileSystem::TYPE_SOUNDSCAPE, SOUNDSCAPE_MANIFEST_FILE, "GAME" ) )
|
||||||
{
|
{
|
||||||
|
@ -24,4 +24,8 @@ extern void Soundscape_Update( audioparams_t &audio );
|
|||||||
// sounds are still playing when they're not.
|
// sounds are still playing when they're not.
|
||||||
void Soundscape_OnStopAllSounds();
|
void Soundscape_OnStopAllSounds();
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
void Soundscape_AddFile( const char *szFile );
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // C_SOUNDSCAPE_H
|
#endif // C_SOUNDSCAPE_H
|
||||||
|
@ -179,6 +179,10 @@ void DispatchEffect( const char *pName, const CEffectData &data )
|
|||||||
te->DispatchEffect( filter, 0.0, data.m_vOrigin, pName, data );
|
te->DispatchEffect( filter, 0.0, data.m_vOrigin, pName, data );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DispatchEffect( const char *pName, const CEffectData &data, IRecipientFilter &filter )
|
||||||
|
{
|
||||||
|
te->DispatchEffect( filter, 0.0, data.m_vOrigin, pName, data );
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Playback
|
// Playback
|
||||||
|
@ -42,5 +42,6 @@ public:
|
|||||||
|
|
||||||
void DispatchEffectToCallback( const char *pEffectName, const CEffectData &m_EffectData );
|
void DispatchEffectToCallback( const char *pEffectName, const CEffectData &m_EffectData );
|
||||||
void DispatchEffect( const char *pName, const CEffectData &data );
|
void DispatchEffect( const char *pName, const CEffectData &data );
|
||||||
|
void DispatchEffect( const char *pName, const CEffectData &data, IRecipientFilter &filter );
|
||||||
|
|
||||||
#endif // C_TE_EFFECT_DISPATCH_H
|
#endif // C_TE_EFFECT_DISPATCH_H
|
||||||
|
@ -64,7 +64,12 @@ void C_TELargeFunnel::CreateFunnel( void )
|
|||||||
float ratio = 0.25;
|
float ratio = 0.25;
|
||||||
float invratio = 1 / ratio;
|
float invratio = 1 / ratio;
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// Uh...figure out how to fix this
|
||||||
PMaterialHandle hMaterial = pSimple->GetPMaterial( "sprites/flare6" );
|
PMaterialHandle hMaterial = pSimple->GetPMaterial( "sprites/flare6" );
|
||||||
|
#else
|
||||||
|
PMaterialHandle hMaterial = pSimple->GetPMaterial( "sprites/flare6" );
|
||||||
|
#endif
|
||||||
|
|
||||||
for ( i = -256 ; i <= 256 ; i += 24 ) //24 from 32.. little more dense
|
for ( i = -256 ; i <= 256 ; i += 24 ) //24 from 32.. little more dense
|
||||||
{
|
{
|
||||||
|
@ -597,8 +597,12 @@ bool C_LocalTempEntity::Frame( float frametime, int framenumber )
|
|||||||
|
|
||||||
if ( flags & FTENT_WINDBLOWN )
|
if ( flags & FTENT_WINDBLOWN )
|
||||||
{
|
{
|
||||||
|
#ifdef MAPBASE
|
||||||
|
Vector vecWind = GetWindspeedAtLocation( GetAbsOrigin() );
|
||||||
|
#else
|
||||||
Vector vecWind;
|
Vector vecWind;
|
||||||
GetWindspeedAtTime( gpGlobals->curtime, vecWind );
|
GetWindspeedAtTime( gpGlobals->curtime, vecWind );
|
||||||
|
#endif
|
||||||
|
|
||||||
for ( int i = 0 ; i < 2 ; i++ )
|
for ( int i = 0 ; i < 2 ; i++ )
|
||||||
{
|
{
|
||||||
@ -1829,6 +1833,9 @@ void CTempEnts::MuzzleFlash( const Vector& pos1, const QAngle& angles, int type,
|
|||||||
|
|
||||||
// UNDONE: These need their own effects/sprites. For now use the pistol
|
// UNDONE: These need their own effects/sprites. For now use the pistol
|
||||||
// SMG1
|
// SMG1
|
||||||
|
#if defined ( HL2MP ) // HACK for hl2mp, make the default muzzleflash the smg muzzleflash for weapons like the RPG that are using 'type 0'
|
||||||
|
default:
|
||||||
|
#endif // HL2MP
|
||||||
case MUZZLEFLASH_SMG1:
|
case MUZZLEFLASH_SMG1:
|
||||||
if ( firstPerson )
|
if ( firstPerson )
|
||||||
{
|
{
|
||||||
@ -1866,10 +1873,12 @@ void CTempEnts::MuzzleFlash( const Vector& pos1, const QAngle& angles, int type,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
#if !defined ( HL2MP ) // HACK for hl2mp, make the default muzzleflash the smg muzzleflash for weapons like the RPG that are using 'type 0'
|
||||||
default:
|
default:
|
||||||
// There's no supported muzzle flash for the type specified!
|
// There's no supported muzzle flash for the type specified!
|
||||||
Assert(0);
|
Assert(0);
|
||||||
break;
|
break;
|
||||||
|
#endif // HL2MP
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -8,10 +8,10 @@
|
|||||||
#include "c_team_train_watcher.h"
|
#include "c_team_train_watcher.h"
|
||||||
#include "igameevents.h"
|
#include "igameevents.h"
|
||||||
#include "c_team_objectiveresource.h"
|
#include "c_team_objectiveresource.h"
|
||||||
|
#include "teamplayroundbased_gamerules.h"
|
||||||
|
|
||||||
#ifdef TF_CLIENT_DLL
|
#ifdef TF_CLIENT_DLL
|
||||||
#include "tf_shareddefs.h"
|
#include "tf_shareddefs.h"
|
||||||
#include "teamplayroundbased_gamerules.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// memdbgon must be the last include file in a .cpp file!!!
|
// memdbgon must be the last include file in a .cpp file!!!
|
||||||
|
@ -54,7 +54,12 @@ public:
|
|||||||
flFOV = m_flFOV;
|
flFOV = m_flFOV;
|
||||||
}
|
}
|
||||||
virtual void DrawHudElements();
|
virtual void DrawHudElements();
|
||||||
|
#ifdef MAPBASE
|
||||||
|
virtual bool IsPassengerUsingStandardWeapons( int nRole = VEHICLE_ROLE_DRIVER ) { return m_bAllowStandardWeapons; }
|
||||||
|
bool m_bAllowStandardWeapons;
|
||||||
|
#else
|
||||||
virtual bool IsPassengerUsingStandardWeapons( int nRole = VEHICLE_ROLE_DRIVER ) { return false; }
|
virtual bool IsPassengerUsingStandardWeapons( int nRole = VEHICLE_ROLE_DRIVER ) { return false; }
|
||||||
|
#endif
|
||||||
virtual void UpdateViewAngles( C_BasePlayer *pLocalPlayer, CUserCmd *pCmd );
|
virtual void UpdateViewAngles( C_BasePlayer *pLocalPlayer, CUserCmd *pCmd );
|
||||||
virtual C_BaseCombatCharacter *GetPassenger( int nRole );
|
virtual C_BaseCombatCharacter *GetPassenger( int nRole );
|
||||||
virtual int GetPassengerRole( C_BaseCombatCharacter *pPassenger );
|
virtual int GetPassengerRole( C_BaseCombatCharacter *pPassenger );
|
||||||
@ -107,6 +112,9 @@ IMPLEMENT_CLIENTCLASS_DT(C_PropVehicleChoreoGeneric, DT_PropVehicleChoreoGeneric
|
|||||||
RecvPropFloat( RECVINFO( m_vehicleView.flYawMax ) ),
|
RecvPropFloat( RECVINFO( m_vehicleView.flYawMax ) ),
|
||||||
RecvPropFloat( RECVINFO( m_vehicleView.flPitchMin ) ),
|
RecvPropFloat( RECVINFO( m_vehicleView.flPitchMin ) ),
|
||||||
RecvPropFloat( RECVINFO( m_vehicleView.flPitchMax ) ),
|
RecvPropFloat( RECVINFO( m_vehicleView.flPitchMax ) ),
|
||||||
|
#ifdef MAPBASE
|
||||||
|
RecvPropBool( RECVINFO( m_bAllowStandardWeapons ) ),
|
||||||
|
#endif
|
||||||
END_RECV_TABLE()
|
END_RECV_TABLE()
|
||||||
|
|
||||||
|
|
||||||
|
@ -59,8 +59,18 @@ BEGIN_RECV_TABLE( C_World, DT_World )
|
|||||||
RecvPropFloat(RECVINFO(m_flMinPropScreenSpaceWidth)),
|
RecvPropFloat(RECVINFO(m_flMinPropScreenSpaceWidth)),
|
||||||
RecvPropString(RECVINFO(m_iszDetailSpriteMaterial)),
|
RecvPropString(RECVINFO(m_iszDetailSpriteMaterial)),
|
||||||
RecvPropInt(RECVINFO(m_bColdWorld)),
|
RecvPropInt(RECVINFO(m_bColdWorld)),
|
||||||
|
#ifdef MAPBASE
|
||||||
|
RecvPropString(RECVINFO(m_iszChapterTitle)),
|
||||||
|
#endif
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
RecvPropInt(RECVINFO(m_iScriptLanguageClient)),
|
||||||
|
#endif
|
||||||
END_RECV_TABLE()
|
END_RECV_TABLE()
|
||||||
|
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
extern bool VScriptClientInit();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
C_World::C_World( void )
|
C_World::C_World( void )
|
||||||
{
|
{
|
||||||
@ -119,6 +129,11 @@ void C_World::OnDataChanged( DataUpdateType_t updateType )
|
|||||||
engine->SetOcclusionParameters( params );
|
engine->SetOcclusionParameters( params );
|
||||||
|
|
||||||
modelinfo->SetLevelScreenFadeRange( m_flMinPropScreenSpaceWidth, m_flMaxPropScreenSpaceWidth );
|
modelinfo->SetLevelScreenFadeRange( m_flMinPropScreenSpaceWidth, m_flMaxPropScreenSpaceWidth );
|
||||||
|
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
// This is now here so that C_World has time to receive the selected script language
|
||||||
|
VScriptClientInit();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,6 +41,10 @@ public:
|
|||||||
float GetWaveHeight() const;
|
float GetWaveHeight() const;
|
||||||
const char *GetDetailSpriteMaterial() const;
|
const char *GetDetailSpriteMaterial() const;
|
||||||
|
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
ScriptLanguage_t GetScriptLanguage() { return (ScriptLanguage_t)m_iScriptLanguageClient; }
|
||||||
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@ -56,6 +60,12 @@ public:
|
|||||||
float m_flMinPropScreenSpaceWidth;
|
float m_flMinPropScreenSpaceWidth;
|
||||||
float m_flMaxPropScreenSpaceWidth;
|
float m_flMaxPropScreenSpaceWidth;
|
||||||
bool m_bColdWorld;
|
bool m_bColdWorld;
|
||||||
|
#ifdef MAPBASE
|
||||||
|
char m_iszChapterTitle[64];
|
||||||
|
#endif
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
int m_iScriptLanguageClient;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void RegisterSharedActivities( void );
|
void RegisterSharedActivities( void );
|
||||||
|
@ -37,6 +37,10 @@ struct studiohdr_t;
|
|||||||
#include <icvar.h>
|
#include <icvar.h>
|
||||||
#include <baseentity_shared.h>
|
#include <baseentity_shared.h>
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
#include "tier1/mapbase_con_groups.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// This is a precompiled header. Include a bunch of common stuff.
|
// This is a precompiled header. Include a bunch of common stuff.
|
||||||
// This is kind of ugly in that it adds a bunch of dependency where it isn't needed.
|
// This is kind of ugly in that it adds a bunch of dependency where it isn't needed.
|
||||||
|
@ -215,6 +215,11 @@ IEngineReplay *g_pEngineReplay = NULL;
|
|||||||
IEngineClientReplay *g_pEngineClientReplay = NULL;
|
IEngineClientReplay *g_pEngineClientReplay = NULL;
|
||||||
IReplaySystem *g_pReplay = NULL;
|
IReplaySystem *g_pReplay = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef MAPBASE
|
||||||
|
IVEngineServer *serverengine = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
IScriptManager *scriptmanager = NULL;
|
||||||
|
|
||||||
IHaptics* haptics = NULL;// NVNT haptics system interface singleton
|
IHaptics* haptics = NULL;// NVNT haptics system interface singleton
|
||||||
|
|
||||||
@ -336,6 +341,13 @@ static ConVar s_cl_class("cl_class", "default", FCVAR_USERINFO|FCVAR_ARCHIVE, "D
|
|||||||
static ConVar s_cl_load_hl1_content("cl_load_hl1_content", "0", FCVAR_ARCHIVE, "Mount the content from Half-Life: Source if possible");
|
static ConVar s_cl_load_hl1_content("cl_load_hl1_content", "0", FCVAR_ARCHIVE, "Mount the content from Half-Life: Source if possible");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MAPBASE_RPC
|
||||||
|
// Mapbase stuff
|
||||||
|
extern void MapbaseRPC_Init();
|
||||||
|
extern void MapbaseRPC_Shutdown();
|
||||||
|
extern void MapbaseRPC_Update( int iType, const char *pMapName );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Physics system
|
// Physics system
|
||||||
bool g_bLevelInitialized;
|
bool g_bLevelInitialized;
|
||||||
@ -847,6 +859,7 @@ CHLClient::CHLClient()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern IGameSystem *ViewportClientSystem();
|
extern IGameSystem *ViewportClientSystem();
|
||||||
|
|
||||||
|
|
||||||
@ -940,9 +953,28 @@ int CHLClient::Init( CreateInterfaceFn appSystemFactory, CreateInterfaceFn physi
|
|||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// Implements the server engine interface on the client.
|
||||||
|
// I'm extremely confused as to how this is even possible, but Saul Rennison's worldlight did it.
|
||||||
|
// If it's really this possible, why wasn't it available before?
|
||||||
|
// Hopefully there's no SP-only magic going on here, because I want to use this for RPC.
|
||||||
|
if ( (serverengine = (IVEngineServer*)appSystemFactory(INTERFACEVERSION_VENGINESERVER, NULL )) == NULL )
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!g_pMatSystemSurface)
|
if (!g_pMatSystemSurface)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if ( !CommandLine()->CheckParm( "-noscripting") )
|
||||||
|
{
|
||||||
|
scriptmanager = (IScriptManager *)appSystemFactory( VSCRIPT_INTERFACE_VERSION, NULL );
|
||||||
|
|
||||||
|
if (scriptmanager == nullptr)
|
||||||
|
{
|
||||||
|
scriptmanager = (IScriptManager*)Sys_GetFactoryThis()(VSCRIPT_INTERFACE_VERSION, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef WORKSHOP_IMPORT_ENABLED
|
#ifdef WORKSHOP_IMPORT_ENABLED
|
||||||
if ( !ConnectDataModel( appSystemFactory ) )
|
if ( !ConnectDataModel( appSystemFactory ) )
|
||||||
return false;
|
return false;
|
||||||
@ -1089,6 +1121,14 @@ int CHLClient::Init( CreateInterfaceFn appSystemFactory, CreateInterfaceFn physi
|
|||||||
HookHapticMessages(); // Always hook the messages
|
HookHapticMessages(); // Always hook the messages
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MAPBASE_RPC
|
||||||
|
MapbaseRPC_Init();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
CommandLine()->AppendParm( "+r_hunkalloclightmaps", "0" );
|
||||||
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1213,6 +1253,10 @@ void CHLClient::Shutdown( void )
|
|||||||
DisconnectDataModel();
|
DisconnectDataModel();
|
||||||
ShutdownFbx();
|
ShutdownFbx();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MAPBASE_RPC
|
||||||
|
MapbaseRPC_Shutdown();
|
||||||
|
#endif
|
||||||
|
|
||||||
// This call disconnects the VGui libraries which we rely on later in the shutdown path, so don't do it
|
// This call disconnects the VGui libraries which we rely on later in the shutdown path, so don't do it
|
||||||
// DisconnectTier3Libraries( );
|
// DisconnectTier3Libraries( );
|
||||||
@ -1626,6 +1670,13 @@ void CHLClient::LevelInitPreEntity( char const* pMapName )
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MAPBASE_RPC
|
||||||
|
if (!g_bTextMode)
|
||||||
|
{
|
||||||
|
MapbaseRPC_Update(RPCSTATE_LEVEL_INIT, pMapName);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Check low violence settings for this map
|
// Check low violence settings for this map
|
||||||
g_RagdollLVManager.SetLowViolence( pMapName );
|
g_RagdollLVManager.SetLowViolence( pMapName );
|
||||||
|
|
||||||
@ -1717,6 +1768,13 @@ void CHLClient::LevelShutdown( void )
|
|||||||
|
|
||||||
gHUD.LevelShutdown();
|
gHUD.LevelShutdown();
|
||||||
|
|
||||||
|
#ifdef MAPBASE_RPC
|
||||||
|
if (!g_bTextMode)
|
||||||
|
{
|
||||||
|
MapbaseRPC_Update(RPCSTATE_LEVEL_SHUTDOWN, NULL);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
internalCenterPrint->Clear();
|
internalCenterPrint->Clear();
|
||||||
|
|
||||||
messagechars->Clear();
|
messagechars->Clear();
|
||||||
@ -2147,7 +2205,9 @@ void OnRenderStart()
|
|||||||
// are at the correct location
|
// are at the correct location
|
||||||
view->OnRenderStart();
|
view->OnRenderStart();
|
||||||
|
|
||||||
|
#ifndef MAPBASE
|
||||||
RopeManager()->OnRenderStart();
|
RopeManager()->OnRenderStart();
|
||||||
|
#endif
|
||||||
|
|
||||||
// This will place all entities in the correct position in world space and in the KD-tree
|
// This will place all entities in the correct position in world space and in the KD-tree
|
||||||
C_BaseAnimating::UpdateClientSideAnimations();
|
C_BaseAnimating::UpdateClientSideAnimations();
|
||||||
|
@ -110,6 +110,9 @@ extern IReplayManager *g_pReplayManager;
|
|||||||
extern IReplayScreenshotManager *g_pReplayScreenshotManager;
|
extern IReplayScreenshotManager *g_pReplayScreenshotManager;
|
||||||
extern IEngineReplay *g_pEngineReplay;
|
extern IEngineReplay *g_pEngineReplay;
|
||||||
extern IEngineClientReplay *g_pEngineClientReplay;
|
extern IEngineClientReplay *g_pEngineClientReplay;
|
||||||
|
#ifdef MAPBASE
|
||||||
|
extern IVEngineServer *serverengine;
|
||||||
|
#endif
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
// HPE_BEGIN
|
// HPE_BEGIN
|
||||||
@ -177,4 +180,16 @@ extern CSteamID GetSteamIDForPlayerIndex( int iPlayerIndex );
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// Mapbase RPC stuff
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
RPCSTATE_INIT,
|
||||||
|
RPCSTATE_LEVEL_INIT,
|
||||||
|
RPCSTATE_LEVEL_SHUTDOWN,
|
||||||
|
|
||||||
|
RPCSTATE_UPDATE,
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // CDLL_CLIENT_INT_H
|
#endif // CDLL_CLIENT_INT_H
|
||||||
|
@ -703,6 +703,24 @@ int UTIL_EntitiesAlongRay( C_BaseEntity **pList, int listMax, const Ray_t &ray,
|
|||||||
return rayEnum.GetCount();
|
return rayEnum.GetCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: Pass in an array of pointers and an array size, it fills the array and returns the number inserted
|
||||||
|
// Input : **pList -
|
||||||
|
// listMax -
|
||||||
|
// &point -
|
||||||
|
// flagMask -
|
||||||
|
// Output : int
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
int UTIL_EntitiesAtPoint( C_BaseEntity **pList, int listMax, const Vector &point, int flagMask, int partitionMask )
|
||||||
|
{
|
||||||
|
CFlaggedEntitiesEnum rayEnum( pList, listMax, flagMask );
|
||||||
|
partition->EnumerateElementsAtPoint( partitionMask, point, false, &rayEnum );
|
||||||
|
|
||||||
|
return rayEnum.GetCount();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
CEntitySphereQuery::CEntitySphereQuery( const Vector ¢er, float radius, int flagMask, int partitionMask )
|
CEntitySphereQuery::CEntitySphereQuery( const Vector ¢er, float radius, int flagMask, int partitionMask )
|
||||||
{
|
{
|
||||||
m_listIndex = 0;
|
m_listIndex = 0;
|
||||||
@ -729,11 +747,14 @@ CBaseEntity *CEntitySphereQuery::GetCurrentEntity()
|
|||||||
// sep - Character to use as separator. UNDONE: allow multiple separator chars
|
// sep - Character to use as separator. UNDONE: allow multiple separator chars
|
||||||
// Output : Returns a pointer to the next token to be parsed.
|
// Output : Returns a pointer to the next token to be parsed.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
const char *nexttoken(char *token, const char *str, char sep)
|
const char *nexttoken(char *token, const char *str, char sep, size_t tokenLen)
|
||||||
{
|
{
|
||||||
if ((str == NULL) || (*str == '\0'))
|
if ((str == NULL) || (*str == '\0'))
|
||||||
{
|
{
|
||||||
*token = '\0';
|
if(tokenLen)
|
||||||
|
{
|
||||||
|
*token = '\0';
|
||||||
|
}
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -741,11 +762,25 @@ const char *nexttoken(char *token, const char *str, char sep)
|
|||||||
// Copy everything up to the first separator into the return buffer.
|
// Copy everything up to the first separator into the return buffer.
|
||||||
// Do not include separators in the return buffer.
|
// Do not include separators in the return buffer.
|
||||||
//
|
//
|
||||||
while ((*str != sep) && (*str != '\0'))
|
while ((*str != sep) && (*str != '\0') && (tokenLen > 1))
|
||||||
{
|
{
|
||||||
*token++ = *str++;
|
*token++ = *str++;
|
||||||
|
tokenLen--;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// If token is to big for return buffer, skip rest of token.
|
||||||
|
//
|
||||||
|
while ((*str != sep) && (*str != '\0'))
|
||||||
|
{
|
||||||
|
str++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(tokenLen)
|
||||||
|
{
|
||||||
|
*token = '\0';
|
||||||
|
tokenLen--;
|
||||||
}
|
}
|
||||||
*token = '\0';
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Advance the pointer unless we hit the end of the input string.
|
// Advance the pointer unless we hit the end of the input string.
|
||||||
|
@ -89,7 +89,7 @@ void NormalizeAngles( QAngle& angles );
|
|||||||
void InterpolateAngles( const QAngle& start, const QAngle& end, QAngle& output, float frac );
|
void InterpolateAngles( const QAngle& start, const QAngle& end, QAngle& output, float frac );
|
||||||
void InterpolateVector( float frac, const Vector& src, const Vector& dest, Vector& output );
|
void InterpolateVector( float frac, const Vector& src, const Vector& dest, Vector& output );
|
||||||
|
|
||||||
const char *nexttoken(char *token, const char *str, char sep);
|
const char *nexttoken(char *token, const char *str, char sep, size_t tokenLen);
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Base light indices to avoid index collision
|
// Base light indices to avoid index collision
|
||||||
@ -119,6 +119,9 @@ void ClientPrint( C_BasePlayer *player, int msg_dest, const char *msg_name, cons
|
|||||||
int UTIL_EntitiesInBox( C_BaseEntity **pList, int listMax, const Vector &mins, const Vector &maxs, int flagMask, int partitionMask = PARTITION_CLIENT_NON_STATIC_EDICTS );
|
int UTIL_EntitiesInBox( C_BaseEntity **pList, int listMax, const Vector &mins, const Vector &maxs, int flagMask, int partitionMask = PARTITION_CLIENT_NON_STATIC_EDICTS );
|
||||||
int UTIL_EntitiesInSphere( C_BaseEntity **pList, int listMax, const Vector ¢er, float radius, int flagMask, int partitionMask = PARTITION_CLIENT_NON_STATIC_EDICTS );
|
int UTIL_EntitiesInSphere( C_BaseEntity **pList, int listMax, const Vector ¢er, float radius, int flagMask, int partitionMask = PARTITION_CLIENT_NON_STATIC_EDICTS );
|
||||||
int UTIL_EntitiesAlongRay( C_BaseEntity **pList, int listMax, const Ray_t &ray, int flagMask, int partitionMask = PARTITION_CLIENT_NON_STATIC_EDICTS );
|
int UTIL_EntitiesAlongRay( C_BaseEntity **pList, int listMax, const Ray_t &ray, int flagMask, int partitionMask = PARTITION_CLIENT_NON_STATIC_EDICTS );
|
||||||
|
#ifdef MAPBASE
|
||||||
|
int UTIL_EntitiesAtPoint( C_BaseEntity **pList, int listMax, const Vector &point, int flagMask, int partitionMask = PARTITION_CLIENT_NON_STATIC_EDICTS );
|
||||||
|
#endif
|
||||||
|
|
||||||
// make this a fixed size so it just sits on the stack
|
// make this a fixed size so it just sits on the stack
|
||||||
#define MAX_SPHERE_QUERY 256
|
#define MAX_SPHERE_QUERY 256
|
||||||
@ -161,7 +164,13 @@ T *_CreateEntity( T *newClass, const char *className )
|
|||||||
// Misc useful
|
// Misc useful
|
||||||
inline bool FStrEq(const char *sz1, const char *sz2)
|
inline bool FStrEq(const char *sz1, const char *sz2)
|
||||||
{
|
{
|
||||||
return (sz1 == sz2 || V_stricmp(sz1, sz2) == 0);
|
#ifdef MAPBASE
|
||||||
|
// V_stricmp() already checks if the pointers are equal, so having a comparison here is pointless.
|
||||||
|
// I had few reasons to do this, but maybe you'll thank me later.
|
||||||
|
return ( V_stricmp(sz1, sz2) == 0 );
|
||||||
|
#else
|
||||||
|
return ( sz1 == sz2 || V_stricmp(sz1, sz2) == 0 );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Given a vector, clamps the scalar axes to MAX_COORD_FLOAT ranges from worldsize.h
|
// Given a vector, clamps the scalar axes to MAX_COORD_FLOAT ranges from worldsize.h
|
||||||
|
@ -18,6 +18,9 @@ $include "$SRCDIR\vpc_scripts\protobuf_builder.vpc"
|
|||||||
$Include "$SRCDIR\vpc_scripts\source_replay.vpc" [$TF]
|
$Include "$SRCDIR\vpc_scripts\source_replay.vpc" [$TF]
|
||||||
$Include "$SRCDIR\game\protobuf_include.vpc"
|
$Include "$SRCDIR\game\protobuf_include.vpc"
|
||||||
|
|
||||||
|
// Mapbase stuff
|
||||||
|
$Include "$SRCDIR\game\client\client_mapbase.vpc" [$MAPBASE]
|
||||||
|
|
||||||
$Configuration "Debug"
|
$Configuration "Debug"
|
||||||
{
|
{
|
||||||
$General
|
$General
|
||||||
@ -489,6 +492,11 @@ $Project
|
|||||||
$File "viewrender.cpp"
|
$File "viewrender.cpp"
|
||||||
$File "$SRCDIR\game\shared\voice_banmgr.cpp"
|
$File "$SRCDIR\game\shared\voice_banmgr.cpp"
|
||||||
$File "$SRCDIR\game\shared\voice_status.cpp"
|
$File "$SRCDIR\game\shared\voice_status.cpp"
|
||||||
|
$File "vscript_client.cpp"
|
||||||
|
$File "vscript_client.h"
|
||||||
|
$File "vscript_client.nut"
|
||||||
|
$File "$SRCDIR\game\shared\vscript_shared.cpp"
|
||||||
|
$File "$SRCDIR\game\shared\vscript_shared.h"
|
||||||
$File "warp_overlay.cpp"
|
$File "warp_overlay.cpp"
|
||||||
$File "WaterLODMaterialProxy.cpp"
|
$File "WaterLODMaterialProxy.cpp"
|
||||||
$File "$SRCDIR\game\shared\weapon_parse.cpp"
|
$File "$SRCDIR\game\shared\weapon_parse.cpp"
|
||||||
|
132
mp/src/game/client/client_episodic.vpc
Normal file
132
mp/src/game/client/client_episodic.vpc
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// CLIENT_EPISODIC.VPC
|
||||||
|
//
|
||||||
|
// Project Script
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
$Macro SRCDIR "..\.."
|
||||||
|
$Macro GAMENAME "episodic" [!$SOURCESDK]
|
||||||
|
$Macro GAMENAME "mod_episodic" [$SOURCESDK]
|
||||||
|
|
||||||
|
$Include "$SRCDIR\game\client\client_base.vpc"
|
||||||
|
|
||||||
|
$Configuration
|
||||||
|
{
|
||||||
|
$Compiler
|
||||||
|
{
|
||||||
|
$AdditionalIncludeDirectories ".\hl2;.\hl2\elements;$SRCDIR\game\shared\hl2;$SRCDIR\game\shared\episodic;..\..\public;$BASE"
|
||||||
|
$PreprocessorDefinitions "$BASE;HL2_CLIENT_DLL;HL2_EPISODIC"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$Project "Client (Episodic)"
|
||||||
|
{
|
||||||
|
$Folder "Source Files"
|
||||||
|
{
|
||||||
|
$File "hud_chat.cpp"
|
||||||
|
$File "c_team_objectiveresource.cpp"
|
||||||
|
$File "c_team_objectiveresource.h"
|
||||||
|
|
||||||
|
$Folder "HL2 DLL"
|
||||||
|
{
|
||||||
|
$File "$SRCDIR\game\shared\hl2\basehlcombatweapon_shared.cpp"
|
||||||
|
$File "$SRCDIR\game\shared\episodic\achievements_ep1.cpp"
|
||||||
|
$File "$SRCDIR\game\shared\episodic\achievements_ep2.cpp"
|
||||||
|
$File "$SRCDIR\game\shared\episodic\achievements_epx.cpp"
|
||||||
|
$File "hl2\c_antlion_dust.cpp"
|
||||||
|
$File "hl2\c_ar2_explosion.cpp"
|
||||||
|
$File "hl2\c_barnacle.cpp"
|
||||||
|
$File "hl2\c_barney.cpp"
|
||||||
|
$File "hl2\c_basehelicopter.cpp"
|
||||||
|
$File "hl2\c_basehelicopter.h"
|
||||||
|
$File "hl2\c_basehlcombatweapon.cpp"
|
||||||
|
$File "hl2\c_basehlcombatweapon.h"
|
||||||
|
$File "hl2\c_basehlplayer.cpp"
|
||||||
|
$File "hl2\c_basehlplayer.h"
|
||||||
|
$File "hl2\c_citadel_effects.cpp"
|
||||||
|
$File "hl2\c_corpse.cpp"
|
||||||
|
$File "hl2\c_corpse.h"
|
||||||
|
$File "hl2\c_env_alyxtemp.cpp"
|
||||||
|
$File "hl2\c_env_headcrabcanister.cpp"
|
||||||
|
$File "hl2\c_env_starfield.cpp"
|
||||||
|
$File "hl2\c_func_tankmortar.cpp"
|
||||||
|
$File "hl2\c_hl2_playerlocaldata.cpp"
|
||||||
|
$File "hl2\c_hl2_playerlocaldata.h"
|
||||||
|
$File "hl2\c_info_teleporter_countdown.cpp"
|
||||||
|
$File "hl2\c_npc_antlionguard.cpp"
|
||||||
|
$File "hl2\c_npc_combinegunship.cpp"
|
||||||
|
$File "hl2\c_npc_manhack.cpp"
|
||||||
|
$File "hl2\c_npc_rollermine.cpp"
|
||||||
|
$File "hl2\c_plasma_beam_node.cpp"
|
||||||
|
$File "hl2\c_prop_combine_ball.cpp"
|
||||||
|
$File "hl2\c_prop_combine_ball.h"
|
||||||
|
$File "episodic\c_prop_scalable.cpp"
|
||||||
|
$File "hl2\c_rotorwash.cpp"
|
||||||
|
$File "hl2\c_script_intro.cpp"
|
||||||
|
$File "$SRCDIR\game\shared\script_intro_shared.cpp"
|
||||||
|
$File "hl2\c_strider.cpp"
|
||||||
|
$File "hl2\c_te_concussiveexplosion.cpp"
|
||||||
|
$File "hl2\c_te_flare.cpp"
|
||||||
|
$File "hl2\c_thumper_dust.cpp"
|
||||||
|
$File "hl2\c_vehicle_airboat.cpp"
|
||||||
|
$File "hl2\c_vehicle_cannon.cpp"
|
||||||
|
$File "hl2\c_vehicle_crane.cpp"
|
||||||
|
$File "hl2\c_vehicle_crane.h"
|
||||||
|
$File "episodic\c_vehicle_jeep_episodic.cpp"
|
||||||
|
$File "hl2\c_vehicle_prisoner_pod.cpp"
|
||||||
|
$File "episodic\c_vort_charge_token.cpp"
|
||||||
|
$File "hl2\c_weapon__stubs_hl2.cpp"
|
||||||
|
$File "hl2\c_weapon_crossbow.cpp"
|
||||||
|
$File "episodic\c_weapon_hopwire.cpp"
|
||||||
|
$File "hl2\c_weapon_physcannon.cpp"
|
||||||
|
$File "hl2\c_weapon_stunstick.cpp" [!$MAPBASE] // See client_mapbase.vpc
|
||||||
|
$File "$SRCDIR\game\shared\hl2\citadel_effects_shared.h"
|
||||||
|
$File "hl2\clientmode_hlnormal.cpp"
|
||||||
|
$File "hl2\clientmode_hlnormal.h"
|
||||||
|
$File "death.cpp"
|
||||||
|
$File "$SRCDIR\game\shared\hl2\env_headcrabcanister_shared.cpp"
|
||||||
|
$File "$SRCDIR\game\shared\hl2\env_headcrabcanister_shared.h"
|
||||||
|
$File "$SRCDIR\game\shared\episodic\npc_advisor_shared.h"
|
||||||
|
$File "episodic\c_npc_advisor.cpp"
|
||||||
|
$File "episodic\episodic_screenspaceeffects.cpp"
|
||||||
|
$File "episodic\episodic_screenspaceeffects.h"
|
||||||
|
$File "episodic\flesh_internal_material_proxy.cpp"
|
||||||
|
$File "hl2\fx_antlion.cpp"
|
||||||
|
$File "hl2\fx_bugbait.cpp"
|
||||||
|
$File "hl2\fx_hl2_impacts.cpp"
|
||||||
|
$File "hl2\fx_hl2_tracers.cpp"
|
||||||
|
$File "hl2\hl2_clientmode.cpp"
|
||||||
|
$File "$SRCDIR\game\shared\hl2\hl2_gamerules.cpp"
|
||||||
|
$File "$SRCDIR\game\shared\hl2\hl2_gamerules.h"
|
||||||
|
$File "$SRCDIR\game\shared\hl2\hl2_shareddefs.h"
|
||||||
|
$File "$SRCDIR\game\shared\hl2\hl2_usermessages.cpp"
|
||||||
|
$File "$SRCDIR\game\shared\hl2\hl_gamemovement.cpp"
|
||||||
|
$File "$SRCDIR\game\shared\hl2\hl_gamemovement.h"
|
||||||
|
$File "hl2\hl_in_main.cpp"
|
||||||
|
$File "hl2\hl_prediction.cpp"
|
||||||
|
$File "hl2\hud_ammo.cpp"
|
||||||
|
$File "hl2\hud_battery.cpp"
|
||||||
|
$File "hl2\hud_blood.cpp"
|
||||||
|
$File "hl2\hud_credits.cpp"
|
||||||
|
$File "hl2\hud_damageindicator.cpp"
|
||||||
|
$File "hl2\hud_flashlight.cpp"
|
||||||
|
$File "hl2\hud_locator.cpp"
|
||||||
|
$File "hl2\hud_health.cpp"
|
||||||
|
$File "hl2\hud_poisondamageindicator.cpp"
|
||||||
|
$File "hud_posture.cpp"
|
||||||
|
$File "hl2\hud_quickinfo.cpp"
|
||||||
|
$File "hl2\hud_radar.cpp"
|
||||||
|
$File "hl2\hud_radar.h"
|
||||||
|
$File "hud_squadstatus.cpp"
|
||||||
|
$File "hl2\hud_suitpower.cpp"
|
||||||
|
$File "hl2\hud_suitpower.h"
|
||||||
|
$File "hl2\hud_weaponselection.cpp"
|
||||||
|
$File "hl2\hud_zoom.cpp"
|
||||||
|
$File "hl2\shieldproxy.cpp"
|
||||||
|
$File "$SRCDIR\game\shared\hl2\survival_gamerules.cpp"
|
||||||
|
$File "hl2\vgui_rootpanel_hl2.cpp"
|
||||||
|
$File "episodic\c_npc_puppet.cpp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
82
mp/src/game/client/client_mapbase.vpc
Normal file
82
mp/src/game/client/client_mapbase.vpc
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// CLIENT_MAPBASE.VPC
|
||||||
|
//
|
||||||
|
// Project Script
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
$Configuration
|
||||||
|
{
|
||||||
|
$Compiler
|
||||||
|
{
|
||||||
|
$PreprocessorDefinitions "$BASE;ASW_PROJECTED_TEXTURES;DYNAMIC_RTT_SHADOWS;GLOWS_ENABLE"
|
||||||
|
|
||||||
|
$PreprocessorDefinitions "$BASE;MAPBASE_RPC;DISCORD_RPC;STEAM_RPC" [$MAPBASE_RPC]
|
||||||
|
$PreprocessorDefinitions "$BASE;MAPBASE_VSCRIPT" [$MAPBASE_VSCRIPT]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$Project
|
||||||
|
{
|
||||||
|
$Folder "Source Files"
|
||||||
|
{
|
||||||
|
$File "c_env_global_light.cpp"
|
||||||
|
$File "worldlight.cpp"
|
||||||
|
$File "worldlight.h"
|
||||||
|
$File "c_baselesson.cpp"
|
||||||
|
$File "c_baselesson.h"
|
||||||
|
$File "c_gameinstructor.cpp"
|
||||||
|
$File "c_gameinstructor.h"
|
||||||
|
$File "hud_locator_target.cpp"
|
||||||
|
$File "hud_locator_target.h"
|
||||||
|
$File "c_postprocesscontroller.cpp"
|
||||||
|
$File "c_postprocesscontroller.h"
|
||||||
|
$File "c_env_dof_controller.cpp"
|
||||||
|
|
||||||
|
$Folder "Mapbase"
|
||||||
|
{
|
||||||
|
$File "$SRCDIR\game\shared\mapbase\mapbase_shared.cpp"
|
||||||
|
$File "$SRCDIR\game\shared\mapbase\mapbase_rpc.cpp"
|
||||||
|
$File "$SRCDIR\game\shared\mapbase\mapbase_game_log.cpp"
|
||||||
|
$File "$SRCDIR\game\shared\mapbase\MapEdit.cpp"
|
||||||
|
$File "$SRCDIR\game\shared\mapbase\MapEdit.h"
|
||||||
|
$File "$SRCDIR\game\shared\mapbase\matchers.cpp"
|
||||||
|
$File "$SRCDIR\game\shared\mapbase\matchers.h"
|
||||||
|
$File "$SRCDIR\game\shared\mapbase\vscript_funcs_shared.cpp" [$MAPBASE_VSCRIPT]
|
||||||
|
$File "$SRCDIR\game\shared\mapbase\vscript_funcs_shared.h" [$MAPBASE_VSCRIPT]
|
||||||
|
$File "$SRCDIR\game\shared\mapbase\vscript_singletons.cpp" [$MAPBASE_VSCRIPT]
|
||||||
|
$File "$SRCDIR\game\shared\mapbase\vscript_singletons.h" [$MAPBASE_VSCRIPT]
|
||||||
|
$File "$SRCDIR\game\shared\mapbase\vscript_funcs_hl2.cpp" [$MAPBASE_VSCRIPT]
|
||||||
|
$File "$SRCDIR\game\shared\mapbase\vscript_consts_shared.cpp" [$MAPBASE_VSCRIPT]
|
||||||
|
$File "$SRCDIR\game\shared\mapbase\vscript_consts_weapons.cpp" [$MAPBASE_VSCRIPT]
|
||||||
|
$File "$SRCDIR\game\shared\mapbase\weapon_custom_scripted.cpp" [$MAPBASE_VSCRIPT]
|
||||||
|
$File "$SRCDIR\game\shared\mapbase\weapon_custom_scripted.h" [$MAPBASE_VSCRIPT]
|
||||||
|
|
||||||
|
$File "mapbase\c_func_clientclip.cpp"
|
||||||
|
$File "mapbase\c_func_fake_worldportal.cpp"
|
||||||
|
$File "mapbase\c_func_fake_worldportal.h"
|
||||||
|
$File "mapbase\c_point_glow.cpp"
|
||||||
|
}
|
||||||
|
|
||||||
|
$Folder "HL2 DLL"
|
||||||
|
{
|
||||||
|
// Original stunstick files are conditional'd out in the HL2 VPCs
|
||||||
|
$File "$SRCDIR\game\shared\hl2mp\weapon_stunstick.cpp"
|
||||||
|
$File "$SRCDIR\game\shared\hl2mp\weapon_stunstick.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
$Folder "HL2MP"
|
||||||
|
{
|
||||||
|
$Folder "Weapons"
|
||||||
|
{
|
||||||
|
$File "$SRCDIR\game\shared\hl2mp\weapon_slam.cpp"
|
||||||
|
$File "$SRCDIR\game\shared\hl2mp\weapon_slam.h"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$Folder "Link Libraries"
|
||||||
|
{
|
||||||
|
$Lib "vscript" [$MAPBASE_VSCRIPT]
|
||||||
|
$Lib "raytrace"
|
||||||
|
}
|
||||||
|
}
|
@ -1481,10 +1481,12 @@ inline void AddRenderableToRenderList( CClientRenderablesList &renderList, IClie
|
|||||||
pEntry->m_RenderHandle = renderHandle;
|
pEntry->m_RenderHandle = renderHandle;
|
||||||
curCount++;
|
curCount++;
|
||||||
}
|
}
|
||||||
|
#ifndef MAPBASE // According to ficool2, this message can cause significant lag
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
engine->Con_NPrintf( 10, "Warning: overflowed CClientRenderablesList group %d", group );
|
engine->Con_NPrintf( 10, "Warning: overflowed CClientRenderablesList group %d", group );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,7 +52,11 @@ class CClientRenderablesList : public CRefCounted<>
|
|||||||
public:
|
public:
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
#ifdef MAPBASE
|
||||||
|
MAX_GROUP_ENTITIES = 16834 // According to ficool2, this limit is bogus/not enforced by the engine and can be "safely" raised.
|
||||||
|
#else
|
||||||
MAX_GROUP_ENTITIES = 4096
|
MAX_GROUP_ENTITIES = 4096
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CEntry
|
struct CEntry
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include <vgui/ILocalize.h>
|
#include <vgui/ILocalize.h>
|
||||||
#include "hud_vote.h"
|
#include "hud_vote.h"
|
||||||
#include "ienginevgui.h"
|
#include "ienginevgui.h"
|
||||||
|
#include "viewpostprocess.h"
|
||||||
#include "sourcevr/isourcevirtualreality.h"
|
#include "sourcevr/isourcevirtualreality.h"
|
||||||
#if defined( _X360 )
|
#if defined( _X360 )
|
||||||
#include "xbox/xbox_console.h"
|
#include "xbox/xbox_console.h"
|
||||||
@ -65,6 +66,10 @@ extern ConVar replay_rendersetting_renderglow;
|
|||||||
#include "econ_item_description.h"
|
#include "econ_item_description.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef GLOWS_ENABLE
|
||||||
|
#include "clienteffectprecachesystem.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
// memdbgon must be the last include file in a .cpp file!!!
|
// memdbgon must be the last include file in a .cpp file!!!
|
||||||
#include "tier0/memdbgon.h"
|
#include "tier0/memdbgon.h"
|
||||||
|
|
||||||
@ -77,6 +82,9 @@ class CHudVote;
|
|||||||
static vgui::HContext s_hVGuiContext = DEFAULT_VGUI_CONTEXT;
|
static vgui::HContext s_hVGuiContext = DEFAULT_VGUI_CONTEXT;
|
||||||
|
|
||||||
ConVar cl_drawhud( "cl_drawhud", "1", FCVAR_CHEAT, "Enable the rendering of the hud" );
|
ConVar cl_drawhud( "cl_drawhud", "1", FCVAR_CHEAT, "Enable the rendering of the hud" );
|
||||||
|
#ifdef DEMO_AUTORECORD
|
||||||
|
ConVar cl_autorecord("cl_autorecord", "0", FCVAR_CLIENTDLL | FCVAR_ARCHIVE, "Start recording demos automatically with an incremental name based on this value.");
|
||||||
|
#endif
|
||||||
ConVar hud_takesshots( "hud_takesshots", "0", FCVAR_CLIENTDLL | FCVAR_ARCHIVE, "Auto-save a scoreboard screenshot at the end of a map." );
|
ConVar hud_takesshots( "hud_takesshots", "0", FCVAR_CLIENTDLL | FCVAR_ARCHIVE, "Auto-save a scoreboard screenshot at the end of a map." );
|
||||||
ConVar hud_freezecamhide( "hud_freezecamhide", "0", FCVAR_CLIENTDLL | FCVAR_ARCHIVE, "Hide the HUD during freeze-cam" );
|
ConVar hud_freezecamhide( "hud_freezecamhide", "0", FCVAR_CLIENTDLL | FCVAR_ARCHIVE, "Hide the HUD during freeze-cam" );
|
||||||
ConVar cl_show_num_particle_systems( "cl_show_num_particle_systems", "0", FCVAR_CLIENTDLL, "Display the number of active particle systems." );
|
ConVar cl_show_num_particle_systems( "cl_show_num_particle_systems", "0", FCVAR_CLIENTDLL, "Display the number of active particle systems." );
|
||||||
@ -92,6 +100,13 @@ CON_COMMAND( cl_reload_localization_files, "Reloads all localization files" )
|
|||||||
g_pVGuiLocalize->ReloadLocalizationFiles();
|
g_pVGuiLocalize->ReloadLocalizationFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef GLOWS_ENABLE
|
||||||
|
CLIENTEFFECT_REGISTER_BEGIN( PrecachePostProcessingEffectsGlow )
|
||||||
|
CLIENTEFFECT_MATERIAL( "dev/glow_color" )
|
||||||
|
CLIENTEFFECT_MATERIAL( "dev/halo_add_to_screen" )
|
||||||
|
CLIENTEFFECT_REGISTER_END_CONDITIONAL( engine->GetDXSupportLevel() >= 90 )
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef VOICE_VOX_ENABLE
|
#ifdef VOICE_VOX_ENABLE
|
||||||
void VoxCallback( IConVar *var, const char *oldString, float oldFloat )
|
void VoxCallback( IConVar *var, const char *oldString, float oldFloat )
|
||||||
{
|
{
|
||||||
@ -283,6 +298,9 @@ ClientModeShared::ClientModeShared()
|
|||||||
m_pWeaponSelection = NULL;
|
m_pWeaponSelection = NULL;
|
||||||
m_nRootSize[ 0 ] = m_nRootSize[ 1 ] = -1;
|
m_nRootSize[ 0 ] = m_nRootSize[ 1 ] = -1;
|
||||||
|
|
||||||
|
m_pCurrentPostProcessController = NULL;
|
||||||
|
m_PostProcessLerpTimer.Invalidate();
|
||||||
|
|
||||||
#if defined( REPLAY_ENABLED )
|
#if defined( REPLAY_ENABLED )
|
||||||
m_pReplayReminderPanel = NULL;
|
m_pReplayReminderPanel = NULL;
|
||||||
m_flReplayStartRecordTime = 0.0f;
|
m_flReplayStartRecordTime = 0.0f;
|
||||||
@ -611,6 +629,8 @@ void ClientModeShared::Update()
|
|||||||
m_pViewport->SetVisible( cl_drawhud.GetBool() );
|
m_pViewport->SetVisible( cl_drawhud.GetBool() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdatePostProcessingEffects();
|
||||||
|
|
||||||
UpdateRumbleEffects();
|
UpdateRumbleEffects();
|
||||||
|
|
||||||
if ( cl_show_num_particle_systems.GetBool() )
|
if ( cl_show_num_particle_systems.GetBool() )
|
||||||
@ -782,6 +802,10 @@ int ClientModeShared::HudElementKeyInput( int down, ButtonCode_t keynum, const c
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool ClientModeShared::DoPostScreenSpaceEffects( const CViewSetup *pSetup )
|
bool ClientModeShared::DoPostScreenSpaceEffects( const CViewSetup *pSetup )
|
||||||
{
|
{
|
||||||
|
#ifdef GLOWS_ENABLE
|
||||||
|
g_GlowObjectManager.RenderGlowEffects( pSetup, 0 );
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined( REPLAY_ENABLED )
|
#if defined( REPLAY_ENABLED )
|
||||||
if ( engine->IsPlayingDemo() )
|
if ( engine->IsPlayingDemo() )
|
||||||
{
|
{
|
||||||
@ -851,8 +875,54 @@ void ClientModeShared::LevelInit( const char *newmap )
|
|||||||
// Reset any player explosion/shock effects
|
// Reset any player explosion/shock effects
|
||||||
CLocalPlayerFilter filter;
|
CLocalPlayerFilter filter;
|
||||||
enginesound->SetPlayerDSP( filter, 0, true );
|
enginesound->SetPlayerDSP( filter, 0, true );
|
||||||
|
|
||||||
|
#ifdef DEMO_AUTORECORD
|
||||||
|
AutoRecord(newmap);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEMO_AUTORECORD
|
||||||
|
void ClientModeShared::AutoRecord(const char *map)
|
||||||
|
{
|
||||||
|
if (!cl_autorecord.GetBool()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (map == nullptr) {
|
||||||
|
Warning("null map in ClientModeShared::AutoRecord");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// stop any demo to make sure they're saved
|
||||||
|
engine->ClientCmd("stop");
|
||||||
|
|
||||||
|
// KLEMS: sanitize space in client name because having to type "" while playing back lots of demos is annoying
|
||||||
|
ConVarRef name("name");
|
||||||
|
char nameStr[128];
|
||||||
|
memset(nameStr, 0, sizeof(nameStr));
|
||||||
|
Q_snprintf(nameStr, sizeof(nameStr), "%s", name.GetString());
|
||||||
|
int i = 0;
|
||||||
|
while (nameStr[i]) {
|
||||||
|
char c = nameStr[i];
|
||||||
|
if (!( (c >= '0' && c <= '9') ||
|
||||||
|
(c >= 'a' && c <= 'z') ||
|
||||||
|
(c >= 'A' && c <= 'Z'))) {
|
||||||
|
nameStr[i] = '_';
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
nameStr[127] = 0;
|
||||||
|
|
||||||
|
char cmd[256];
|
||||||
|
Q_snprintf(cmd, sizeof(cmd), "record \"%s_%04d_%s\"", nameStr, cl_autorecord.GetInt(), map);
|
||||||
|
cl_autorecord.SetValue(cl_autorecord.GetInt() + 1);
|
||||||
|
engine->ClientCmd(cmd);
|
||||||
|
|
||||||
|
// write to config to make sure the cvar is recorded
|
||||||
|
engine->ClientCmd("host_writeconfig");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose:
|
// Purpose:
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -871,6 +941,17 @@ void ClientModeShared::LevelShutdown( void )
|
|||||||
s_hVGuiContext = DEFAULT_VGUI_CONTEXT;
|
s_hVGuiContext = DEFAULT_VGUI_CONTEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// Always reset post-processing on level unload
|
||||||
|
//if (m_pCurrentPostProcessController)
|
||||||
|
{
|
||||||
|
m_CurrentPostProcessParameters = PostProcessParameters_t();
|
||||||
|
m_LerpEndPostProcessParameters = PostProcessParameters_t();
|
||||||
|
m_pCurrentPostProcessController = NULL;
|
||||||
|
SetPostProcessParams( &m_CurrentPostProcessParameters );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Reset any player explosion/shock effects
|
// Reset any player explosion/shock effects
|
||||||
CLocalPlayerFilter filter;
|
CLocalPlayerFilter filter;
|
||||||
enginesound->SetPlayerDSP( filter, 0, true );
|
enginesound->SetPlayerDSP( filter, 0, true );
|
||||||
@ -945,6 +1026,69 @@ float ClientModeShared::GetViewModelFOV( void )
|
|||||||
return v_viewmodel_fov.GetFloat();
|
return v_viewmodel_fov.GetFloat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
extern bool g_bPostProcessNeedsRestore;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void ClientModeShared::UpdatePostProcessingEffects()
|
||||||
|
{
|
||||||
|
C_PostProcessController* pNewPostProcessController = NULL;
|
||||||
|
C_BasePlayer* pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||||
|
|
||||||
|
if (pPlayer)
|
||||||
|
pNewPostProcessController = pPlayer->GetActivePostProcessController();
|
||||||
|
|
||||||
|
if (!pNewPostProcessController)
|
||||||
|
{
|
||||||
|
m_CurrentPostProcessParameters = PostProcessParameters_t();
|
||||||
|
m_pCurrentPostProcessController = NULL;
|
||||||
|
SetPostProcessParams( &m_CurrentPostProcessParameters );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pNewPostProcessController != m_pCurrentPostProcessController)
|
||||||
|
m_pCurrentPostProcessController = pNewPostProcessController;
|
||||||
|
|
||||||
|
// Start a lerp timer if the parameters changed, regardless of whether the controller changed
|
||||||
|
if (m_LerpEndPostProcessParameters != pNewPostProcessController->m_PostProcessParameters)
|
||||||
|
{
|
||||||
|
m_LerpStartPostProcessParameters = m_CurrentPostProcessParameters;
|
||||||
|
m_LerpEndPostProcessParameters = pNewPostProcessController ? pNewPostProcessController->m_PostProcessParameters : m_CurrentPostProcessParameters;
|
||||||
|
|
||||||
|
float flFadeTime = pNewPostProcessController ? pNewPostProcessController->m_PostProcessParameters.m_flParameters[PPPN_FADE_TIME] : 0.0f;
|
||||||
|
if (flFadeTime <= 0.0f)
|
||||||
|
{
|
||||||
|
flFadeTime = 0.001f;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_PostProcessLerpTimer.Start( flFadeTime );
|
||||||
|
}
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// HACKHACK: Needs to be checked here because OnRestore() doesn't seem to run before a lerp begins
|
||||||
|
else if (g_bPostProcessNeedsRestore)
|
||||||
|
{
|
||||||
|
// The player just loaded a saved game.
|
||||||
|
// Don't fade parameters from 0; instead, take what's already there and assume they were already active.
|
||||||
|
// (we have no way of knowing if they were in the middle of a lerp)
|
||||||
|
m_PostProcessLerpTimer.Invalidate();
|
||||||
|
g_bPostProcessNeedsRestore = false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Lerp between old and new parameters
|
||||||
|
float flLerpFactor = 1.0f - m_PostProcessLerpTimer.GetRemainingRatio();
|
||||||
|
for (int nParameter = 0; nParameter < POST_PROCESS_PARAMETER_COUNT; ++nParameter)
|
||||||
|
{
|
||||||
|
m_CurrentPostProcessParameters.m_flParameters[nParameter] =
|
||||||
|
Lerp(
|
||||||
|
flLerpFactor,
|
||||||
|
m_LerpStartPostProcessParameters.m_flParameters[nParameter],
|
||||||
|
m_LerpEndPostProcessParameters.m_flParameters[nParameter] );
|
||||||
|
}
|
||||||
|
|
||||||
|
SetPostProcessParams( &m_CurrentPostProcessParameters );
|
||||||
|
}
|
||||||
|
|
||||||
class CHudChat;
|
class CHudChat;
|
||||||
|
|
||||||
bool PlayerNameNotSetYet( const char *pszName )
|
bool PlayerNameNotSetYet( const char *pszName )
|
||||||
|
@ -42,6 +42,10 @@ class CReplayReminderPanel;
|
|||||||
|
|
||||||
#define USERID2PLAYER(i) ToBasePlayer( ClientEntityList().GetEnt( engine->GetPlayerForUserID( i ) ) )
|
#define USERID2PLAYER(i) ToBasePlayer( ClientEntityList().GetEnt( engine->GetPlayerForUserID( i ) ) )
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
#define DEMO_AUTORECORD 1
|
||||||
|
#endif
|
||||||
|
|
||||||
extern IClientMode *GetClientModeNormal(); // must be implemented
|
extern IClientMode *GetClientModeNormal(); // must be implemented
|
||||||
|
|
||||||
// This class implements client mode functionality common to HL2 and TF2.
|
// This class implements client mode functionality common to HL2 and TF2.
|
||||||
@ -62,6 +66,10 @@ public:
|
|||||||
virtual void LevelInit( const char *newmap );
|
virtual void LevelInit( const char *newmap );
|
||||||
virtual void LevelShutdown( void );
|
virtual void LevelShutdown( void );
|
||||||
|
|
||||||
|
#ifdef DEMO_AUTORECORD
|
||||||
|
virtual void AutoRecord( const char *map );
|
||||||
|
#endif
|
||||||
|
|
||||||
virtual void Enable();
|
virtual void Enable();
|
||||||
virtual void Disable();
|
virtual void Disable();
|
||||||
virtual void Layout();
|
virtual void Layout();
|
||||||
@ -156,6 +164,13 @@ private:
|
|||||||
vgui::HCursor m_CursorNone;
|
vgui::HCursor m_CursorNone;
|
||||||
CBaseHudWeaponSelection *m_pWeaponSelection;
|
CBaseHudWeaponSelection *m_pWeaponSelection;
|
||||||
int m_nRootSize[2];
|
int m_nRootSize[2];
|
||||||
|
|
||||||
|
void UpdatePostProcessingEffects();
|
||||||
|
|
||||||
|
const C_PostProcessController* m_pCurrentPostProcessController;
|
||||||
|
PostProcessParameters_t m_CurrentPostProcessParameters;
|
||||||
|
PostProcessParameters_t m_LerpStartPostProcessParameters, m_LerpEndPostProcessParameters;
|
||||||
|
CountdownTimer m_PostProcessLerpTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CLIENTMODE_NORMAL_H
|
#endif // CLIENTMODE_NORMAL_H
|
||||||
|
@ -81,6 +81,16 @@
|
|||||||
#include "toolframework_client.h"
|
#include "toolframework_client.h"
|
||||||
#include "bonetoworldarray.h"
|
#include "bonetoworldarray.h"
|
||||||
#include "cmodel.h"
|
#include "cmodel.h"
|
||||||
|
#ifdef MAPBASE
|
||||||
|
#include "renderparm.h"
|
||||||
|
#endif
|
||||||
|
#ifdef ASW_PROJECTED_TEXTURES
|
||||||
|
#include "flashlighteffect.h"
|
||||||
|
#endif
|
||||||
|
#ifdef DYNAMIC_RTT_SHADOWS
|
||||||
|
#include "debugoverlay_shared.h"
|
||||||
|
#include "worldlight.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// memdbgon must be the last include file in a .cpp file!!!
|
// memdbgon must be the last include file in a .cpp file!!!
|
||||||
@ -89,6 +99,12 @@
|
|||||||
static ConVar r_flashlightdrawfrustum( "r_flashlightdrawfrustum", "0" );
|
static ConVar r_flashlightdrawfrustum( "r_flashlightdrawfrustum", "0" );
|
||||||
static ConVar r_flashlightmodels( "r_flashlightmodels", "1" );
|
static ConVar r_flashlightmodels( "r_flashlightmodels", "1" );
|
||||||
static ConVar r_shadowrendertotexture( "r_shadowrendertotexture", "0" );
|
static ConVar r_shadowrendertotexture( "r_shadowrendertotexture", "0" );
|
||||||
|
#ifdef ASW_PROJECTED_TEXTURES
|
||||||
|
static ConVar r_shadow_lightpos_lerptime( "r_shadow_lightpos_lerptime", "0.5" );
|
||||||
|
static ConVar r_shadowfromworldlights_debug( "r_shadowfromworldlights_debug", "0", FCVAR_CHEAT );
|
||||||
|
static ConVar r_shadow_shortenfactor( "r_shadow_shortenfactor", "2" , 0, "Makes shadows cast from local lights shorter" );
|
||||||
|
static ConVar r_shadow_mincastintensity( "r_shadow_mincastintensity", "0.3", FCVAR_CHEAT, "Minimum brightness of a light to be classed as shadow casting", true, 0, false, 0 );
|
||||||
|
#endif
|
||||||
static ConVar r_flashlight_version2( "r_flashlight_version2", "0", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY );
|
static ConVar r_flashlight_version2( "r_flashlight_version2", "0", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY );
|
||||||
|
|
||||||
ConVar r_flashlightdepthtexture( "r_flashlightdepthtexture", "1" );
|
ConVar r_flashlightdepthtexture( "r_flashlightdepthtexture", "1" );
|
||||||
@ -96,10 +112,18 @@ ConVar r_flashlightdepthtexture( "r_flashlightdepthtexture", "1" );
|
|||||||
#if defined( _X360 )
|
#if defined( _X360 )
|
||||||
ConVar r_flashlightdepthres( "r_flashlightdepthres", "512" );
|
ConVar r_flashlightdepthres( "r_flashlightdepthres", "512" );
|
||||||
#else
|
#else
|
||||||
|
#ifdef MAPBASE
|
||||||
|
ConVar r_flashlightdepthres( "r_flashlightdepthres", "2048" );
|
||||||
|
#else
|
||||||
ConVar r_flashlightdepthres( "r_flashlightdepthres", "1024" );
|
ConVar r_flashlightdepthres( "r_flashlightdepthres", "1024" );
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ASW_PROJECTED_TEXTURES
|
||||||
|
ConVar r_threaded_client_shadow_manager( "r_threaded_client_shadow_manager", "1" );
|
||||||
|
#else
|
||||||
ConVar r_threaded_client_shadow_manager( "r_threaded_client_shadow_manager", "0" );
|
ConVar r_threaded_client_shadow_manager( "r_threaded_client_shadow_manager", "0" );
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#pragma warning( disable: 4701 )
|
#pragma warning( disable: 4701 )
|
||||||
@ -782,7 +806,11 @@ public:
|
|||||||
void RestoreRenderState();
|
void RestoreRenderState();
|
||||||
|
|
||||||
// Computes a rough bounding box encompassing the volume of the shadow
|
// Computes a rough bounding box encompassing the volume of the shadow
|
||||||
|
#ifdef DYNAMIC_RTT_SHADOWS
|
||||||
|
void ComputeShadowBBox( IClientRenderable *pRenderable, ClientShadowHandle_t shadowHandle, const Vector &vecAbsCenter, float flRadius, Vector *pAbsMins, Vector *pAbsMaxs );
|
||||||
|
#else
|
||||||
void ComputeShadowBBox( IClientRenderable *pRenderable, const Vector &vecAbsCenter, float flRadius, Vector *pAbsMins, Vector *pAbsMaxs );
|
void ComputeShadowBBox( IClientRenderable *pRenderable, const Vector &vecAbsCenter, float flRadius, Vector *pAbsMins, Vector *pAbsMaxs );
|
||||||
|
#endif
|
||||||
|
|
||||||
bool WillParentRenderBlobbyShadow( IClientRenderable *pRenderable );
|
bool WillParentRenderBlobbyShadow( IClientRenderable *pRenderable );
|
||||||
|
|
||||||
@ -794,6 +822,13 @@ public:
|
|||||||
r_shadows_gamecontrol.SetValue( bDisabled != 1 );
|
r_shadows_gamecontrol.SetValue( bDisabled != 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DYNAMIC_RTT_SHADOWS
|
||||||
|
// Toggle shadow casting from world light sources
|
||||||
|
virtual void SetShadowFromWorldLightsEnabled( bool bEnable );
|
||||||
|
void SuppressShadowFromWorldLights( bool bSuppress );
|
||||||
|
bool IsShadowingFromWorldLights() const { return m_bShadowFromWorldLights && !m_bSuppressShadowFromWorldLights; }
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@ -811,8 +846,16 @@ private:
|
|||||||
unsigned short m_Flags;
|
unsigned short m_Flags;
|
||||||
VMatrix m_WorldToShadow;
|
VMatrix m_WorldToShadow;
|
||||||
Vector2D m_WorldSize;
|
Vector2D m_WorldSize;
|
||||||
|
#ifdef DYNAMIC_RTT_SHADOWS
|
||||||
|
Vector m_ShadowDir;
|
||||||
|
#endif
|
||||||
Vector m_LastOrigin;
|
Vector m_LastOrigin;
|
||||||
QAngle m_LastAngles;
|
QAngle m_LastAngles;
|
||||||
|
#ifdef DYNAMIC_RTT_SHADOWS
|
||||||
|
Vector m_CurrentLightPos; // When shadowing from local lights, stores the position of the currently shadowing light
|
||||||
|
Vector m_TargetLightPos; // When shadowing from local lights, stores the position of the new shadowing light
|
||||||
|
float m_LightPosLerp; // Lerp progress when going from current to target light
|
||||||
|
#endif
|
||||||
TextureHandle_t m_ShadowTexture;
|
TextureHandle_t m_ShadowTexture;
|
||||||
CTextureReference m_ShadowDepthTexture;
|
CTextureReference m_ShadowDepthTexture;
|
||||||
int m_nRenderFrame;
|
int m_nRenderFrame;
|
||||||
@ -825,6 +868,11 @@ private:
|
|||||||
void UpdateBrushShadow( IClientRenderable *pRenderable, ClientShadowHandle_t handle );
|
void UpdateBrushShadow( IClientRenderable *pRenderable, ClientShadowHandle_t handle );
|
||||||
void UpdateShadow( ClientShadowHandle_t handle, bool force );
|
void UpdateShadow( ClientShadowHandle_t handle, bool force );
|
||||||
|
|
||||||
|
#ifdef DYNAMIC_RTT_SHADOWS
|
||||||
|
// Updates shadow cast direction when shadowing from world lights
|
||||||
|
void UpdateShadowDirectionFromLocalLightSource( ClientShadowHandle_t shadowHandle );
|
||||||
|
#endif
|
||||||
|
|
||||||
// Gets the entity whose shadow this shadow will render into
|
// Gets the entity whose shadow this shadow will render into
|
||||||
IClientRenderable *GetParentShadowEntity( ClientShadowHandle_t handle );
|
IClientRenderable *GetParentShadowEntity( ClientShadowHandle_t handle );
|
||||||
|
|
||||||
@ -842,6 +890,10 @@ private:
|
|||||||
|
|
||||||
void BuildPerspectiveWorldToFlashlightMatrix( VMatrix& matWorldToShadow, const FlashlightState_t &flashlightState );
|
void BuildPerspectiveWorldToFlashlightMatrix( VMatrix& matWorldToShadow, const FlashlightState_t &flashlightState );
|
||||||
|
|
||||||
|
#ifdef ASW_PROJECTED_TEXTURES
|
||||||
|
void BuildOrthoWorldToFlashlightMatrix( VMatrix& matWorldToShadow, const FlashlightState_t &flashlightState );
|
||||||
|
#endif
|
||||||
|
|
||||||
// Update a shadow
|
// Update a shadow
|
||||||
void UpdateProjectedTextureInternal( ClientShadowHandle_t handle, bool force );
|
void UpdateProjectedTextureInternal( ClientShadowHandle_t handle, bool force );
|
||||||
|
|
||||||
@ -910,6 +962,9 @@ private:
|
|||||||
// Returns renderable-specific shadow info
|
// Returns renderable-specific shadow info
|
||||||
float GetShadowDistance( IClientRenderable *pRenderable ) const;
|
float GetShadowDistance( IClientRenderable *pRenderable ) const;
|
||||||
const Vector &GetShadowDirection( IClientRenderable *pRenderable ) const;
|
const Vector &GetShadowDirection( IClientRenderable *pRenderable ) const;
|
||||||
|
#ifdef DYNAMIC_RTT_SHADOWS
|
||||||
|
const Vector &GetShadowDirection( ClientShadowHandle_t shadowHandle ) const;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Initialize, shutdown render-to-texture shadows
|
// Initialize, shutdown render-to-texture shadows
|
||||||
void InitDepthTextureShadows();
|
void InitDepthTextureShadows();
|
||||||
@ -933,6 +988,11 @@ private:
|
|||||||
// Set and clear flashlight target renderable
|
// Set and clear flashlight target renderable
|
||||||
void SetFlashlightTarget( ClientShadowHandle_t shadowHandle, EHANDLE targetEntity );
|
void SetFlashlightTarget( ClientShadowHandle_t shadowHandle, EHANDLE targetEntity );
|
||||||
|
|
||||||
|
#ifdef ASW_PROJECTED_TEXTURES
|
||||||
|
// Get current frustum extents
|
||||||
|
void GetFrustumExtents( ClientShadowHandle_t handle, Vector &vecMin, Vector &vecMax );
|
||||||
|
#endif
|
||||||
|
|
||||||
// Set flashlight light world flag
|
// Set flashlight light world flag
|
||||||
void SetFlashlightLightWorld( ClientShadowHandle_t shadowHandle, bool bLightWorld );
|
void SetFlashlightLightWorld( ClientShadowHandle_t shadowHandle, bool bLightWorld );
|
||||||
|
|
||||||
@ -941,9 +1001,18 @@ private:
|
|||||||
// Builds a list of active shadows requiring shadow depth renders
|
// Builds a list of active shadows requiring shadow depth renders
|
||||||
int BuildActiveShadowDepthList( const CViewSetup &viewSetup, int nMaxDepthShadows, ClientShadowHandle_t *pActiveDepthShadows );
|
int BuildActiveShadowDepthList( const CViewSetup &viewSetup, int nMaxDepthShadows, ClientShadowHandle_t *pActiveDepthShadows );
|
||||||
|
|
||||||
|
#ifdef ASW_PROJECTED_TEXTURES
|
||||||
|
// Builds a list of active flashlights
|
||||||
|
int BuildActiveFlashlightList( const CViewSetup &viewSetup, int nMaxFlashlights, ClientShadowHandle_t *pActiveFlashlights );
|
||||||
|
#endif
|
||||||
|
|
||||||
// Sets the view's active flashlight render state
|
// Sets the view's active flashlight render state
|
||||||
void SetViewFlashlightState( int nActiveFlashlightCount, ClientShadowHandle_t* pActiveFlashlights );
|
void SetViewFlashlightState( int nActiveFlashlightCount, ClientShadowHandle_t* pActiveFlashlights );
|
||||||
|
|
||||||
|
#ifdef DYNAMIC_RTT_SHADOWS
|
||||||
|
void UpdateDirtyShadow( ClientShadowHandle_t handle );
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector m_SimpleShadowDir;
|
Vector m_SimpleShadowDir;
|
||||||
color32 m_AmbientLightColor;
|
color32 m_AmbientLightColor;
|
||||||
@ -963,6 +1032,10 @@ private:
|
|||||||
CUtlRBTree< ClientShadowHandle_t, unsigned short > m_DirtyShadows;
|
CUtlRBTree< ClientShadowHandle_t, unsigned short > m_DirtyShadows;
|
||||||
CUtlVector< ClientShadowHandle_t > m_TransparentShadows;
|
CUtlVector< ClientShadowHandle_t > m_TransparentShadows;
|
||||||
|
|
||||||
|
#ifdef ASW_PROJECTED_TEXTURES
|
||||||
|
int m_nPrevFrameCount;
|
||||||
|
#endif
|
||||||
|
|
||||||
// These members maintain current state of depth texturing (size and global active state)
|
// These members maintain current state of depth texturing (size and global active state)
|
||||||
// If either changes in a frame, PreRender() will catch it and do the appropriate allocation, deallocation or reallocation
|
// If either changes in a frame, PreRender() will catch it and do the appropriate allocation, deallocation or reallocation
|
||||||
bool m_bDepthTextureActive;
|
bool m_bDepthTextureActive;
|
||||||
@ -972,6 +1045,11 @@ private:
|
|||||||
CUtlVector< bool > m_DepthTextureCacheLocks;
|
CUtlVector< bool > m_DepthTextureCacheLocks;
|
||||||
int m_nMaxDepthTextureShadows;
|
int m_nMaxDepthTextureShadows;
|
||||||
|
|
||||||
|
#ifdef DYNAMIC_RTT_SHADOWS
|
||||||
|
bool m_bShadowFromWorldLights;
|
||||||
|
bool m_bSuppressShadowFromWorldLights;
|
||||||
|
#endif
|
||||||
|
|
||||||
friend class CVisibleShadowList;
|
friend class CVisibleShadowList;
|
||||||
friend class CVisibleShadowFrustumList;
|
friend class CVisibleShadowFrustumList;
|
||||||
};
|
};
|
||||||
@ -1064,6 +1142,12 @@ void CVisibleShadowList::EnumShadow( unsigned short clientShadowHandle )
|
|||||||
if ( shadow.m_nRenderFrame == gpGlobals->framecount )
|
if ( shadow.m_nRenderFrame == gpGlobals->framecount )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#ifdef ASW_PROJECTED_TEXTURES
|
||||||
|
// Don't bother with flashlights
|
||||||
|
if ( ( shadow.m_Flags & SHADOW_FLAGS_FLASHLIGHT ) != 0 )
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
// We don't need to bother with it if it's not render-to-texture
|
// We don't need to bother with it if it's not render-to-texture
|
||||||
if ( s_ClientShadowMgr.GetActualShadowCastType( clientShadowHandle ) != SHADOWS_RENDER_TO_TEXTURE )
|
if ( s_ClientShadowMgr.GetActualShadowCastType( clientShadowHandle ) != SHADOWS_RENDER_TO_TEXTURE )
|
||||||
return;
|
return;
|
||||||
@ -1088,7 +1172,11 @@ void CVisibleShadowList::EnumShadow( unsigned short clientShadowHandle )
|
|||||||
|
|
||||||
// Compute a box surrounding the shadow
|
// Compute a box surrounding the shadow
|
||||||
Vector vecAbsMins, vecAbsMaxs;
|
Vector vecAbsMins, vecAbsMaxs;
|
||||||
|
#ifdef DYNAMIC_RTT_SHADOWS
|
||||||
|
s_ClientShadowMgr.ComputeShadowBBox( pRenderable, shadow.m_ShadowHandle, vecAbsCenter, flRadius, &vecAbsMins, &vecAbsMaxs );
|
||||||
|
#else
|
||||||
s_ClientShadowMgr.ComputeShadowBBox( pRenderable, vecAbsCenter, flRadius, &vecAbsMins, &vecAbsMaxs );
|
s_ClientShadowMgr.ComputeShadowBBox( pRenderable, vecAbsCenter, flRadius, &vecAbsMins, &vecAbsMaxs );
|
||||||
|
#endif
|
||||||
|
|
||||||
// FIXME: Add distance check here?
|
// FIXME: Add distance check here?
|
||||||
|
|
||||||
@ -1167,7 +1255,14 @@ int CVisibleShadowList::FindShadows( const CViewSetup *pView, int nLeafCount, Le
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
CClientShadowMgr::CClientShadowMgr() :
|
CClientShadowMgr::CClientShadowMgr() :
|
||||||
m_DirtyShadows( 0, 0, ShadowHandleCompareFunc ),
|
m_DirtyShadows( 0, 0, ShadowHandleCompareFunc ),
|
||||||
|
#ifdef ASW_PROJECTED_TEXTURES
|
||||||
|
m_nPrevFrameCount( -1 ),
|
||||||
|
#endif
|
||||||
m_RenderToTextureActive( false ),
|
m_RenderToTextureActive( false ),
|
||||||
|
#ifdef DYNAMIC_RTT_SHADOWS
|
||||||
|
m_bShadowFromWorldLights( false ),
|
||||||
|
m_bSuppressShadowFromWorldLights( false ),
|
||||||
|
#endif
|
||||||
m_bDepthTextureActive( false )
|
m_bDepthTextureActive( false )
|
||||||
{
|
{
|
||||||
m_nDepthTextureResolution = r_flashlightdepthres.GetInt();
|
m_nDepthTextureResolution = r_flashlightdepthres.GetInt();
|
||||||
@ -1271,6 +1366,15 @@ CON_COMMAND_F( r_shadowblobbycutoff, "some shadow stuff", FCVAR_CHEAT )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DYNAMIC_RTT_SHADOWS
|
||||||
|
void OnShadowFromWorldLights( IConVar *var, const char *pOldValue, float flOldValue );
|
||||||
|
static ConVar r_shadowfromworldlights( "r_shadowfromworldlights", "1", FCVAR_NONE, "Enable shadowing from world lights", OnShadowFromWorldLights );
|
||||||
|
void OnShadowFromWorldLights( IConVar *var, const char *pOldValue, float flOldValue )
|
||||||
|
{
|
||||||
|
s_ClientShadowMgr.SuppressShadowFromWorldLights( !r_shadowfromworldlights.GetBool() );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void ShadowRestoreFunc( int nChangeFlags )
|
static void ShadowRestoreFunc( int nChangeFlags )
|
||||||
{
|
{
|
||||||
s_ClientShadowMgr.RestoreRenderState();
|
s_ClientShadowMgr.RestoreRenderState();
|
||||||
@ -1290,8 +1394,14 @@ bool CClientShadowMgr::Init()
|
|||||||
|
|
||||||
SetShadowBlobbyCutoffArea( 0.005 );
|
SetShadowBlobbyCutoffArea( 0.005 );
|
||||||
|
|
||||||
|
#ifndef MAPBASE
|
||||||
bool bTools = CommandLine()->CheckParm( "-tools" ) != NULL;
|
bool bTools = CommandLine()->CheckParm( "-tools" ) != NULL;
|
||||||
m_nMaxDepthTextureShadows = bTools ? 4 : 1; // Just one shadow depth texture in games, more in tools
|
m_nMaxDepthTextureShadows = bTools ? 4 : 1; // Just one shadow depth texture in games, more in tools
|
||||||
|
#else
|
||||||
|
// 5 lets mappers use up to 4 shadow-casting projected textures, which is better than 3.
|
||||||
|
int iNumShadows = CommandLine()->ParmValue( "-numshadowtextures", 5 );
|
||||||
|
m_nMaxDepthTextureShadows = iNumShadows;
|
||||||
|
#endif
|
||||||
|
|
||||||
bool bLowEnd = ( g_pMaterialSystemHardwareConfig->GetDXSupportLevel() < 80 );
|
bool bLowEnd = ( g_pMaterialSystemHardwareConfig->GetDXSupportLevel() < 80 );
|
||||||
|
|
||||||
@ -1336,6 +1446,11 @@ void CClientShadowMgr::InitDepthTextureShadows()
|
|||||||
{
|
{
|
||||||
VPROF_BUDGET( "CClientShadowMgr::InitDepthTextureShadows", VPROF_BUDGETGROUP_SHADOW_DEPTH_TEXTURING );
|
VPROF_BUDGET( "CClientShadowMgr::InitDepthTextureShadows", VPROF_BUDGETGROUP_SHADOW_DEPTH_TEXTURING );
|
||||||
|
|
||||||
|
#if defined(MAPBASE) //&& !defined(ASW_PROJECTED_TEXTURES)
|
||||||
|
// SAUL: set m_nDepthTextureResolution to the depth resolution we want
|
||||||
|
m_nDepthTextureResolution = r_flashlightdepthres.GetInt();
|
||||||
|
#endif
|
||||||
|
|
||||||
if( !m_bDepthTextureActive )
|
if( !m_bDepthTextureActive )
|
||||||
{
|
{
|
||||||
m_bDepthTextureActive = true;
|
m_bDepthTextureActive = true;
|
||||||
@ -1351,8 +1466,13 @@ void CClientShadowMgr::InitDepthTextureShadows()
|
|||||||
// only need the dummy surface, don't care about color results
|
// only need the dummy surface, don't care about color results
|
||||||
m_DummyColorTexture.InitRenderTargetTexture( r_flashlightdepthres.GetInt(), r_flashlightdepthres.GetInt(), RT_SIZE_OFFSCREEN, IMAGE_FORMAT_BGR565, MATERIAL_RT_DEPTH_SHARED, false, "_rt_ShadowDummy" );
|
m_DummyColorTexture.InitRenderTargetTexture( r_flashlightdepthres.GetInt(), r_flashlightdepthres.GetInt(), RT_SIZE_OFFSCREEN, IMAGE_FORMAT_BGR565, MATERIAL_RT_DEPTH_SHARED, false, "_rt_ShadowDummy" );
|
||||||
m_DummyColorTexture.InitRenderTargetSurface( r_flashlightdepthres.GetInt(), r_flashlightdepthres.GetInt(), IMAGE_FORMAT_BGR565, true );
|
m_DummyColorTexture.InitRenderTargetSurface( r_flashlightdepthres.GetInt(), r_flashlightdepthres.GetInt(), IMAGE_FORMAT_BGR565, true );
|
||||||
|
#else
|
||||||
|
#if defined(MAPBASE) //&& !defined(ASW_PROJECTED_TEXTURES)
|
||||||
|
// SAUL: we want to create a render target of specific size, so use RT_SIZE_NO_CHANGE
|
||||||
|
m_DummyColorTexture.InitRenderTarget( m_nDepthTextureResolution, m_nDepthTextureResolution, RT_SIZE_NO_CHANGE, nullFormat, MATERIAL_RT_DEPTH_NONE, false, "_rt_ShadowDummy" );
|
||||||
#else
|
#else
|
||||||
m_DummyColorTexture.InitRenderTarget( r_flashlightdepthres.GetInt(), r_flashlightdepthres.GetInt(), RT_SIZE_OFFSCREEN, nullFormat, MATERIAL_RT_DEPTH_NONE, false, "_rt_ShadowDummy" );
|
m_DummyColorTexture.InitRenderTarget( r_flashlightdepthres.GetInt(), r_flashlightdepthres.GetInt(), RT_SIZE_OFFSCREEN, nullFormat, MATERIAL_RT_DEPTH_NONE, false, "_rt_ShadowDummy" );
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Create some number of depth-stencil textures
|
// Create some number of depth-stencil textures
|
||||||
@ -1371,9 +1491,20 @@ void CClientShadowMgr::InitDepthTextureShadows()
|
|||||||
// surface is effectively never used
|
// surface is effectively never used
|
||||||
depthTex.InitRenderTargetTexture( m_nDepthTextureResolution, m_nDepthTextureResolution, RT_SIZE_OFFSCREEN, dstFormat, MATERIAL_RT_DEPTH_NONE, false, strRTName );
|
depthTex.InitRenderTargetTexture( m_nDepthTextureResolution, m_nDepthTextureResolution, RT_SIZE_OFFSCREEN, dstFormat, MATERIAL_RT_DEPTH_NONE, false, strRTName );
|
||||||
depthTex.InitRenderTargetSurface( 1, 1, dstFormat, false );
|
depthTex.InitRenderTargetSurface( 1, 1, dstFormat, false );
|
||||||
|
#else
|
||||||
|
#if defined(MAPBASE) //&& !defined(ASW_PROJECTED_TEXTURES)
|
||||||
|
// SAUL: we want to create a *DEPTH TEXTURE* of specific size, so use RT_SIZE_NO_CHANGE and MATERIAL_RT_DEPTH_ONLY
|
||||||
|
// However, MATERIAL_RT_DEPTH_ONLY forces point filtering to be enabled which negatively affect PCF, so the standard MATERIAL_RT_DEPTH_NONE works better.
|
||||||
|
depthTex.InitRenderTarget( m_nDepthTextureResolution, m_nDepthTextureResolution, RT_SIZE_NO_CHANGE, dstFormat, MATERIAL_RT_DEPTH_NONE, false, strRTName );
|
||||||
#else
|
#else
|
||||||
depthTex.InitRenderTarget( m_nDepthTextureResolution, m_nDepthTextureResolution, RT_SIZE_OFFSCREEN, dstFormat, MATERIAL_RT_DEPTH_NONE, false, strRTName );
|
depthTex.InitRenderTarget( m_nDepthTextureResolution, m_nDepthTextureResolution, RT_SIZE_OFFSCREEN, dstFormat, MATERIAL_RT_DEPTH_NONE, false, strRTName );
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MAPBASE) //&& !defined(ASW_PROJECTED_TEXTURES)
|
||||||
|
// SAUL: ensure the depth texture size wasn't changed
|
||||||
|
Assert(depthTex->GetActualWidth() == m_nDepthTextureResolution);
|
||||||
|
#endif
|
||||||
|
|
||||||
if ( i == 0 )
|
if ( i == 0 )
|
||||||
{
|
{
|
||||||
@ -1514,6 +1645,15 @@ void CClientShadowMgr::LevelInitPreEntity()
|
|||||||
{
|
{
|
||||||
m_bUpdatingDirtyShadows = false;
|
m_bUpdatingDirtyShadows = false;
|
||||||
|
|
||||||
|
#ifdef DYNAMIC_RTT_SHADOWS
|
||||||
|
// Default setting for this, can be overridden by shadow control entities
|
||||||
|
#ifdef MAPBASE
|
||||||
|
SetShadowFromWorldLightsEnabled( false );
|
||||||
|
#else
|
||||||
|
SetShadowFromWorldLightsEnabled( true );
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
Vector ambientColor;
|
Vector ambientColor;
|
||||||
engine->GetAmbientLightColor( ambientColor );
|
engine->GetAmbientLightColor( ambientColor );
|
||||||
ambientColor *= 3;
|
ambientColor *= 3;
|
||||||
@ -1698,6 +1838,158 @@ const Vector &CClientShadowMgr::GetShadowDirection( IClientRenderable *pRenderab
|
|||||||
return vecResult;
|
return vecResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DYNAMIC_RTT_SHADOWS
|
||||||
|
const Vector &CClientShadowMgr::GetShadowDirection( ClientShadowHandle_t shadowHandle ) const
|
||||||
|
{
|
||||||
|
Assert( shadowHandle != CLIENTSHADOW_INVALID_HANDLE );
|
||||||
|
|
||||||
|
IClientRenderable* pRenderable = ClientEntityList().GetClientRenderableFromHandle( m_Shadows[shadowHandle].m_Entity );
|
||||||
|
Assert( pRenderable );
|
||||||
|
|
||||||
|
if ( !IsShadowingFromWorldLights() )
|
||||||
|
{
|
||||||
|
return GetShadowDirection( pRenderable );
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector &vecResult = AllocTempVector();
|
||||||
|
vecResult = m_Shadows[shadowHandle].m_ShadowDir;
|
||||||
|
|
||||||
|
// Allow the renderable to override the default
|
||||||
|
pRenderable->GetShadowCastDirection( &vecResult, GetActualShadowCastType( pRenderable ) );
|
||||||
|
|
||||||
|
return vecResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CClientShadowMgr::UpdateShadowDirectionFromLocalLightSource( ClientShadowHandle_t shadowHandle )
|
||||||
|
{
|
||||||
|
Assert( shadowHandle != CLIENTSHADOW_INVALID_HANDLE );
|
||||||
|
|
||||||
|
ClientShadow_t& shadow = m_Shadows[shadowHandle];
|
||||||
|
|
||||||
|
IClientRenderable* pRenderable = ClientEntityList().GetClientRenderableFromHandle( shadow.m_Entity );
|
||||||
|
|
||||||
|
// TODO: Figure out why this still gets hit
|
||||||
|
Assert( pRenderable );
|
||||||
|
if ( !pRenderable )
|
||||||
|
{
|
||||||
|
DevWarning( "%s(): Skipping shadow with invalid client renderable (shadow handle %d)\n", __FUNCTION__, shadowHandle );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector bbMin, bbMax;
|
||||||
|
pRenderable->GetRenderBoundsWorldspace( bbMin, bbMax );
|
||||||
|
Vector origin( 0.5f * ( bbMin + bbMax ) );
|
||||||
|
origin.z = bbMin.z; // Putting origin at the bottom of the bounding box makes the shadows a little shorter
|
||||||
|
|
||||||
|
Vector lightPos;
|
||||||
|
Vector lightBrightness;
|
||||||
|
|
||||||
|
if ( shadow.m_LightPosLerp >= 1.0f ) // skip finding new light source if we're in the middle of a lerp
|
||||||
|
{
|
||||||
|
// Calculate minimum brightness squared
|
||||||
|
float flMinBrightnessSqr = r_shadow_mincastintensity.GetFloat();
|
||||||
|
flMinBrightnessSqr *= flMinBrightnessSqr;
|
||||||
|
|
||||||
|
if(g_pWorldLights->GetBrightestLightSource(pRenderable->GetRenderOrigin(), lightPos, lightBrightness) == false ||
|
||||||
|
lightBrightness.LengthSqr() < flMinBrightnessSqr )
|
||||||
|
{
|
||||||
|
// didn't find a light source at all, use default shadow direction
|
||||||
|
// TODO: Could switch to using blobby shadow in this case
|
||||||
|
lightPos.Init( FLT_MAX, FLT_MAX, FLT_MAX );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( shadow.m_LightPosLerp == FLT_MAX ) // first light pos ever, just init
|
||||||
|
{
|
||||||
|
shadow.m_CurrentLightPos = lightPos;
|
||||||
|
shadow.m_TargetLightPos = lightPos;
|
||||||
|
shadow.m_LightPosLerp = 1.0f;
|
||||||
|
}
|
||||||
|
else if ( shadow.m_LightPosLerp < 1.0f )
|
||||||
|
{
|
||||||
|
// We're in the middle of a lerp from current to target light. Finish it.
|
||||||
|
shadow.m_LightPosLerp += gpGlobals->frametime * 1.0f/r_shadow_lightpos_lerptime.GetFloat();
|
||||||
|
shadow.m_LightPosLerp = clamp( shadow.m_LightPosLerp, 0.0f, 1.0f );
|
||||||
|
|
||||||
|
Vector currLightPos( shadow.m_CurrentLightPos );
|
||||||
|
Vector targetLightPos( shadow.m_TargetLightPos );
|
||||||
|
if ( currLightPos.x == FLT_MAX )
|
||||||
|
{
|
||||||
|
currLightPos = origin - 200.0f * GetShadowDirection();
|
||||||
|
}
|
||||||
|
if ( targetLightPos.x == FLT_MAX )
|
||||||
|
{
|
||||||
|
targetLightPos = origin - 200.0f * GetShadowDirection();
|
||||||
|
}
|
||||||
|
|
||||||
|
// lerp light pos
|
||||||
|
Vector v1 = origin - shadow.m_CurrentLightPos;
|
||||||
|
v1.NormalizeInPlace();
|
||||||
|
|
||||||
|
Vector v2 = origin - shadow.m_TargetLightPos;
|
||||||
|
v2.NormalizeInPlace();
|
||||||
|
|
||||||
|
// SAULUNDONE: caused over top sweeping far too often
|
||||||
|
#if 0
|
||||||
|
if ( v1.Dot( v2 ) < 0.0f )
|
||||||
|
{
|
||||||
|
// if change in shadow angle is more than 90 degrees, lerp over the renderable's top to avoid long sweeping shadows
|
||||||
|
Vector fakeOverheadLightPos( origin.x, origin.y, origin.z + 200.0f );
|
||||||
|
if( shadow.m_LightPosLerp < 0.5f )
|
||||||
|
{
|
||||||
|
lightPos = Lerp( 2.0f * shadow.m_LightPosLerp, currLightPos, fakeOverheadLightPos );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lightPos = Lerp( 2.0f * shadow.m_LightPosLerp - 1.0f, fakeOverheadLightPos, targetLightPos );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
lightPos = Lerp( shadow.m_LightPosLerp, currLightPos, targetLightPos );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( shadow.m_LightPosLerp >= 1.0f )
|
||||||
|
{
|
||||||
|
shadow.m_CurrentLightPos = shadow.m_TargetLightPos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( shadow.m_LightPosLerp >= 1.0f )
|
||||||
|
{
|
||||||
|
// check if we have a new closest light position and start a new lerp
|
||||||
|
float flDistSq = ( lightPos - shadow.m_CurrentLightPos ).LengthSqr();
|
||||||
|
|
||||||
|
if ( flDistSq > 1.0f )
|
||||||
|
{
|
||||||
|
// light position has changed, which means we got a new light source. Initiate a lerp
|
||||||
|
shadow.m_TargetLightPos = lightPos;
|
||||||
|
shadow.m_LightPosLerp = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
lightPos = shadow.m_CurrentLightPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( lightPos.x == FLT_MAX )
|
||||||
|
{
|
||||||
|
lightPos = origin - 200.0f * GetShadowDirection();
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector vecResult( origin - lightPos );
|
||||||
|
vecResult.NormalizeInPlace();
|
||||||
|
|
||||||
|
vecResult.z *= r_shadow_shortenfactor.GetFloat();
|
||||||
|
vecResult.NormalizeInPlace();
|
||||||
|
|
||||||
|
shadow.m_ShadowDir = vecResult;
|
||||||
|
|
||||||
|
if ( r_shadowfromworldlights_debug.GetBool() )
|
||||||
|
{
|
||||||
|
NDebugOverlay::Line( lightPos, origin, 255, 255, 0, false, 0.0f );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Sets the shadow distance
|
// Sets the shadow distance
|
||||||
@ -1818,6 +2110,12 @@ ClientShadowHandle_t CClientShadowMgr::CreateProjectedTexture( ClientEntityHandl
|
|||||||
shadow.m_ClientLeafShadowHandle = ClientLeafSystem()->AddShadow( h, flags );
|
shadow.m_ClientLeafShadowHandle = ClientLeafSystem()->AddShadow( h, flags );
|
||||||
shadow.m_Flags = flags;
|
shadow.m_Flags = flags;
|
||||||
shadow.m_nRenderFrame = -1;
|
shadow.m_nRenderFrame = -1;
|
||||||
|
#ifdef DYNAMIC_RTT_SHADOWS
|
||||||
|
shadow.m_ShadowDir = GetShadowDirection();
|
||||||
|
shadow.m_CurrentLightPos.Init( FLT_MAX, FLT_MAX, FLT_MAX );
|
||||||
|
shadow.m_TargetLightPos.Init( FLT_MAX, FLT_MAX, FLT_MAX );
|
||||||
|
shadow.m_LightPosLerp = FLT_MAX;
|
||||||
|
#endif
|
||||||
shadow.m_LastOrigin.Init( FLT_MAX, FLT_MAX, FLT_MAX );
|
shadow.m_LastOrigin.Init( FLT_MAX, FLT_MAX, FLT_MAX );
|
||||||
shadow.m_LastAngles.Init( FLT_MAX, FLT_MAX, FLT_MAX );
|
shadow.m_LastAngles.Init( FLT_MAX, FLT_MAX, FLT_MAX );
|
||||||
Assert( ( ( shadow.m_Flags & SHADOW_FLAGS_FLASHLIGHT ) == 0 ) !=
|
Assert( ( ( shadow.m_Flags & SHADOW_FLAGS_FLASHLIGHT ) == 0 ) !=
|
||||||
@ -1837,12 +2135,21 @@ ClientShadowHandle_t CClientShadowMgr::CreateProjectedTexture( ClientEntityHandl
|
|||||||
pShadowProxyData = (void*)(uintp)h;
|
pShadowProxyData = (void*)(uintp)h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ASW_PROJECTED_TEXTURES
|
||||||
|
if( ( flags & SHADOW_FLAGS_USE_DEPTH_TEXTURE ) || ( flags & ( SHADOW_FLAGS_FLASHLIGHT ) ) )
|
||||||
|
{
|
||||||
|
pShadowMaterial = NULL; // these materials aren't used for shadow depth texture shadows.
|
||||||
|
pShadowModelMaterial = NULL;
|
||||||
|
pShadowProxyData = (void*)(uintp)h;
|
||||||
|
}
|
||||||
|
#else
|
||||||
if( flags & SHADOW_FLAGS_USE_DEPTH_TEXTURE )
|
if( flags & SHADOW_FLAGS_USE_DEPTH_TEXTURE )
|
||||||
{
|
{
|
||||||
pShadowMaterial = m_RenderShadow;
|
pShadowMaterial = m_RenderShadow;
|
||||||
pShadowModelMaterial = m_RenderModelShadow;
|
pShadowModelMaterial = m_RenderModelShadow;
|
||||||
pShadowProxyData = (void*)(uintp)h;
|
pShadowProxyData = (void*)(uintp)h;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int createShadowFlags;
|
int createShadowFlags;
|
||||||
if( flags & SHADOW_FLAGS_FLASHLIGHT )
|
if( flags & SHADOW_FLAGS_FLASHLIGHT )
|
||||||
@ -1905,7 +2212,27 @@ void CClientShadowMgr::UpdateFlashlightState( ClientShadowHandle_t shadowHandle,
|
|||||||
{
|
{
|
||||||
VPROF_BUDGET( "CClientShadowMgr::UpdateFlashlightState", VPROF_BUDGETGROUP_SHADOW_DEPTH_TEXTURING );
|
VPROF_BUDGET( "CClientShadowMgr::UpdateFlashlightState", VPROF_BUDGETGROUP_SHADOW_DEPTH_TEXTURING );
|
||||||
|
|
||||||
|
#ifdef ASW_PROJECTED_TEXTURES
|
||||||
|
if( flashlightState.m_bEnableShadows && r_flashlightdepthtexture.GetBool() )
|
||||||
|
{
|
||||||
|
m_Shadows[shadowHandle].m_Flags |= SHADOW_FLAGS_USE_DEPTH_TEXTURE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_Shadows[shadowHandle].m_Flags &= ~SHADOW_FLAGS_USE_DEPTH_TEXTURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( flashlightState.m_bOrtho )
|
||||||
|
{
|
||||||
|
BuildOrthoWorldToFlashlightMatrix( m_Shadows[shadowHandle].m_WorldToShadow, flashlightState );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BuildPerspectiveWorldToFlashlightMatrix( m_Shadows[shadowHandle].m_WorldToShadow, flashlightState );
|
||||||
|
}
|
||||||
|
#else
|
||||||
BuildPerspectiveWorldToFlashlightMatrix( m_Shadows[shadowHandle].m_WorldToShadow, flashlightState );
|
BuildPerspectiveWorldToFlashlightMatrix( m_Shadows[shadowHandle].m_WorldToShadow, flashlightState );
|
||||||
|
#endif
|
||||||
|
|
||||||
shadowmgr->UpdateFlashlightState( m_Shadows[shadowHandle].m_ShadowHandle, flashlightState );
|
shadowmgr->UpdateFlashlightState( m_Shadows[shadowHandle].m_ShadowHandle, flashlightState );
|
||||||
}
|
}
|
||||||
@ -2016,6 +2343,40 @@ void CClientShadowMgr::BuildPerspectiveWorldToFlashlightMatrix( VMatrix& matWorl
|
|||||||
MatrixMultiply( matPerspective, matWorldToShadowView, matWorldToShadow );
|
MatrixMultiply( matPerspective, matWorldToShadowView, matWorldToShadow );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ASW_PROJECTED_TEXTURES
|
||||||
|
void CClientShadowMgr::BuildOrthoWorldToFlashlightMatrix( VMatrix& matWorldToShadow, const FlashlightState_t &flashlightState )
|
||||||
|
{
|
||||||
|
VPROF_BUDGET( "CClientShadowMgr::BuildPerspectiveWorldToFlashlightMatrix", VPROF_BUDGETGROUP_SHADOW_DEPTH_TEXTURING );
|
||||||
|
|
||||||
|
// Buildworld to shadow matrix, then perspective projection and concatenate
|
||||||
|
VMatrix matWorldToShadowView, matPerspective;
|
||||||
|
BuildWorldToShadowMatrix( matWorldToShadowView, flashlightState.m_vecLightOrigin,
|
||||||
|
flashlightState.m_quatOrientation );
|
||||||
|
|
||||||
|
MatrixBuildOrtho( matPerspective,
|
||||||
|
flashlightState.m_fOrthoLeft, flashlightState.m_fOrthoTop, flashlightState.m_fOrthoRight, flashlightState.m_fOrthoBottom,
|
||||||
|
flashlightState.m_NearZ, flashlightState.m_FarZ );
|
||||||
|
|
||||||
|
// Shift it z/y to 0 to -2 space
|
||||||
|
VMatrix addW;
|
||||||
|
addW.Identity();
|
||||||
|
addW[0][3] = -1.0f;
|
||||||
|
addW[1][3] = -1.0f;
|
||||||
|
addW[2][3] = 0.0f;
|
||||||
|
MatrixMultiply( addW, matPerspective, matPerspective );
|
||||||
|
|
||||||
|
// Flip x/y to positive 0 to 1... flip z to negative
|
||||||
|
VMatrix scaleHalf;
|
||||||
|
scaleHalf.Identity();
|
||||||
|
scaleHalf[0][0] = -0.5f;
|
||||||
|
scaleHalf[1][1] = -0.5f;
|
||||||
|
scaleHalf[2][2] = -1.0f;
|
||||||
|
MatrixMultiply( scaleHalf, matPerspective, matPerspective );
|
||||||
|
|
||||||
|
MatrixMultiply( matPerspective, matWorldToShadowView, matWorldToShadow );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Compute the shadow origin and attenuation start distance
|
// Compute the shadow origin and attenuation start distance
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -2289,7 +2650,11 @@ void CClientShadowMgr::BuildOrthoShadow( IClientRenderable* pRenderable,
|
|||||||
AngleVectors( pRenderable->GetRenderAngles(), &vec[0], &vec[1], &vec[2] );
|
AngleVectors( pRenderable->GetRenderAngles(), &vec[0], &vec[1], &vec[2] );
|
||||||
vec[1] *= -1.0f;
|
vec[1] *= -1.0f;
|
||||||
|
|
||||||
|
#ifdef DYNAMIC_RTT_SHADOWS
|
||||||
|
Vector vecShadowDir = GetShadowDirection( handle );
|
||||||
|
#else
|
||||||
Vector vecShadowDir = GetShadowDirection( pRenderable );
|
Vector vecShadowDir = GetShadowDirection( pRenderable );
|
||||||
|
#endif
|
||||||
|
|
||||||
// Project the shadow casting direction into the space of the object
|
// Project the shadow casting direction into the space of the object
|
||||||
Vector localShadowDir;
|
Vector localShadowDir;
|
||||||
@ -2375,7 +2740,11 @@ void CClientShadowMgr::BuildOrthoShadow( IClientRenderable* pRenderable,
|
|||||||
|
|
||||||
// Compute extra clip planes to prevent poke-thru
|
// Compute extra clip planes to prevent poke-thru
|
||||||
// FIXME!!!!!!!!!!!!!! Removing this for now since it seems to mess up the blobby shadows.
|
// FIXME!!!!!!!!!!!!!! Removing this for now since it seems to mess up the blobby shadows.
|
||||||
|
#ifdef ASW_PROJECTED_TEXTURES
|
||||||
|
ComputeExtraClipPlanes( pRenderable, handle, vec, mins, maxs, localShadowDir );
|
||||||
|
#else
|
||||||
// ComputeExtraClipPlanes( pEnt, handle, vec, mins, maxs, localShadowDir );
|
// ComputeExtraClipPlanes( pEnt, handle, vec, mins, maxs, localShadowDir );
|
||||||
|
#endif
|
||||||
|
|
||||||
// Add the shadow to the client leaf system so it correctly marks
|
// Add the shadow to the client leaf system so it correctly marks
|
||||||
// leafs as being affected by a particular shadow
|
// leafs as being affected by a particular shadow
|
||||||
@ -2472,7 +2841,11 @@ void CClientShadowMgr::BuildRenderToTextureShadow( IClientRenderable* pRenderabl
|
|||||||
AngleVectors( pRenderable->GetRenderAngles(), &vec[0], &vec[1], &vec[2] );
|
AngleVectors( pRenderable->GetRenderAngles(), &vec[0], &vec[1], &vec[2] );
|
||||||
vec[1] *= -1.0f;
|
vec[1] *= -1.0f;
|
||||||
|
|
||||||
|
#ifdef DYNAMIC_RTT_SHADOWS
|
||||||
|
Vector vecShadowDir = GetShadowDirection( handle );
|
||||||
|
#else
|
||||||
Vector vecShadowDir = GetShadowDirection( pRenderable );
|
Vector vecShadowDir = GetShadowDirection( pRenderable );
|
||||||
|
#endif
|
||||||
|
|
||||||
// Debugging aid
|
// Debugging aid
|
||||||
// const model_t *pModel = pRenderable->GetModel();
|
// const model_t *pModel = pRenderable->GetModel();
|
||||||
@ -2864,6 +3237,13 @@ bool CClientShadowMgr::ShouldUseParentShadow( IClientRenderable *pRenderable )
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void CClientShadowMgr::PreRender()
|
void CClientShadowMgr::PreRender()
|
||||||
{
|
{
|
||||||
|
#ifdef ASW_PROJECTED_TEXTURES
|
||||||
|
// only update shadows once per frame
|
||||||
|
if( gpGlobals->framecount == m_nPrevFrameCount )
|
||||||
|
return;
|
||||||
|
m_nPrevFrameCount = gpGlobals->framecount;
|
||||||
|
#endif
|
||||||
|
|
||||||
VPROF_BUDGET( "CClientShadowMgr::PreRender", VPROF_BUDGETGROUP_SHADOW_RENDERING );
|
VPROF_BUDGET( "CClientShadowMgr::PreRender", VPROF_BUDGETGROUP_SHADOW_RENDERING );
|
||||||
MDLCACHE_CRITICAL_SECTION();
|
MDLCACHE_CRITICAL_SECTION();
|
||||||
|
|
||||||
@ -2936,8 +3316,12 @@ void CClientShadowMgr::PreRender()
|
|||||||
{
|
{
|
||||||
MDLCACHE_CRITICAL_SECTION();
|
MDLCACHE_CRITICAL_SECTION();
|
||||||
ClientShadowHandle_t& handle = m_DirtyShadows[ i ];
|
ClientShadowHandle_t& handle = m_DirtyShadows[ i ];
|
||||||
|
#ifdef DYNAMIC_RTT_SHADOWS
|
||||||
|
UpdateDirtyShadow(handle);
|
||||||
|
#else
|
||||||
Assert( m_Shadows.IsValidIndex( handle ) );
|
Assert( m_Shadows.IsValidIndex( handle ) );
|
||||||
UpdateProjectedTextureInternal( handle, false );
|
UpdateProjectedTextureInternal( handle, false );
|
||||||
|
#endif
|
||||||
i = m_DirtyShadows.NextInorder(i);
|
i = m_DirtyShadows.NextInorder(i);
|
||||||
}
|
}
|
||||||
m_DirtyShadows.RemoveAll();
|
m_DirtyShadows.RemoveAll();
|
||||||
@ -2953,6 +3337,20 @@ void CClientShadowMgr::PreRender()
|
|||||||
m_bUpdatingDirtyShadows = false;
|
m_bUpdatingDirtyShadows = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DYNAMIC_RTT_SHADOWS
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Updates a single dirty shadow
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void CClientShadowMgr::UpdateDirtyShadow( ClientShadowHandle_t handle )
|
||||||
|
{
|
||||||
|
Assert( m_Shadows.IsValidIndex( handle ) );
|
||||||
|
if ( IsShadowingFromWorldLights() )
|
||||||
|
{
|
||||||
|
UpdateShadowDirectionFromLocalLightSource( handle );
|
||||||
|
}
|
||||||
|
UpdateProjectedTextureInternal( handle, false );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Gets the entity whose shadow this shadow will render into
|
// Gets the entity whose shadow this shadow will render into
|
||||||
@ -3127,7 +3525,11 @@ void CClientShadowMgr::UpdateShadow( ClientShadowHandle_t handle, bool force )
|
|||||||
const Vector& origin = pRenderable->GetRenderOrigin();
|
const Vector& origin = pRenderable->GetRenderOrigin();
|
||||||
const QAngle& angles = pRenderable->GetRenderAngles();
|
const QAngle& angles = pRenderable->GetRenderAngles();
|
||||||
|
|
||||||
|
#ifdef DYNAMIC_RTT_SHADOWS
|
||||||
|
if (force || (origin != shadow.m_LastOrigin) || (angles != shadow.m_LastAngles) || shadow.m_LightPosLerp < 1.0f)
|
||||||
|
#else
|
||||||
if (force || (origin != shadow.m_LastOrigin) || (angles != shadow.m_LastAngles))
|
if (force || (origin != shadow.m_LastOrigin) || (angles != shadow.m_LastAngles))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
// Store off the new pos/orientation
|
// Store off the new pos/orientation
|
||||||
VectorCopy( origin, shadow.m_LastOrigin );
|
VectorCopy( origin, shadow.m_LastOrigin );
|
||||||
@ -3246,12 +3648,20 @@ void CClientShadowMgr::ComputeBoundingSphere( IClientRenderable* pRenderable, Ve
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Computes a rough AABB encompassing the volume of the shadow
|
// Computes a rough AABB encompassing the volume of the shadow
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
#ifdef DYNAMIC_RTT_SHADOWS
|
||||||
|
void CClientShadowMgr::ComputeShadowBBox( IClientRenderable *pRenderable, ClientShadowHandle_t shadowHandle, const Vector &vecAbsCenter, float flRadius, Vector *pAbsMins, Vector *pAbsMaxs )
|
||||||
|
#else
|
||||||
void CClientShadowMgr::ComputeShadowBBox( IClientRenderable *pRenderable, const Vector &vecAbsCenter, float flRadius, Vector *pAbsMins, Vector *pAbsMaxs )
|
void CClientShadowMgr::ComputeShadowBBox( IClientRenderable *pRenderable, const Vector &vecAbsCenter, float flRadius, Vector *pAbsMins, Vector *pAbsMaxs )
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
// This is *really* rough. Basically we simply determine the
|
// This is *really* rough. Basically we simply determine the
|
||||||
// maximum shadow casting length and extrude the box by that distance
|
// maximum shadow casting length and extrude the box by that distance
|
||||||
|
|
||||||
|
#ifdef DYNAMIC_RTT_SHADOWS
|
||||||
|
Vector vecShadowDir = GetShadowDirection( shadowHandle );
|
||||||
|
#else
|
||||||
Vector vecShadowDir = GetShadowDirection( pRenderable );
|
Vector vecShadowDir = GetShadowDirection( pRenderable );
|
||||||
|
#endif
|
||||||
for (int i = 0; i < 3; ++i)
|
for (int i = 0; i < 3; ++i)
|
||||||
{
|
{
|
||||||
float flShadowCastDistance = GetShadowDistance( pRenderable );
|
float flShadowCastDistance = GetShadowDistance( pRenderable );
|
||||||
@ -3349,7 +3759,11 @@ bool CClientShadowMgr::CullReceiver( ClientShadowHandle_t handle, IClientRendera
|
|||||||
if (foundSeparatingPlane)
|
if (foundSeparatingPlane)
|
||||||
{
|
{
|
||||||
// Compute which side of the plane the renderable is on..
|
// Compute which side of the plane the renderable is on..
|
||||||
|
#ifdef DYNAMIC_RTT_SHADOWS
|
||||||
|
Vector vecShadowDir = GetShadowDirection( handle );
|
||||||
|
#else
|
||||||
Vector vecShadowDir = GetShadowDirection( pSourceRenderable );
|
Vector vecShadowDir = GetShadowDirection( pSourceRenderable );
|
||||||
|
#endif
|
||||||
float shadowDot = DotProduct( vecShadowDir, plane.normal );
|
float shadowDot = DotProduct( vecShadowDir, plane.normal );
|
||||||
float receiverDot = DotProduct( plane.normal, origin );
|
float receiverDot = DotProduct( plane.normal, origin );
|
||||||
float sourceDot = DotProduct( plane.normal, originSource );
|
float sourceDot = DotProduct( plane.normal, originSource );
|
||||||
@ -3836,6 +4250,11 @@ void CClientShadowMgr::AdvanceFrame()
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
int CClientShadowMgr::BuildActiveShadowDepthList( const CViewSetup &viewSetup, int nMaxDepthShadows, ClientShadowHandle_t *pActiveDepthShadows )
|
int CClientShadowMgr::BuildActiveShadowDepthList( const CViewSetup &viewSetup, int nMaxDepthShadows, ClientShadowHandle_t *pActiveDepthShadows )
|
||||||
{
|
{
|
||||||
|
#ifdef ASW_PROJECTED_TEXTURES
|
||||||
|
Frustum_t viewFrustum;
|
||||||
|
GeneratePerspectiveFrustum( viewSetup.origin, viewSetup.angles, viewSetup.zNear, viewSetup.zFar, viewSetup.fov, viewSetup.m_flAspectRatio, viewFrustum );
|
||||||
|
#endif
|
||||||
|
|
||||||
int nActiveDepthShadowCount = 0;
|
int nActiveDepthShadowCount = 0;
|
||||||
for ( ClientShadowHandle_t i = m_Shadows.Head(); i != m_Shadows.InvalidIndex(); i = m_Shadows.Next(i) )
|
for ( ClientShadowHandle_t i = m_Shadows.Head(); i != m_Shadows.InvalidIndex(); i = m_Shadows.Next(i) )
|
||||||
{
|
{
|
||||||
@ -3860,7 +4279,13 @@ int CClientShadowMgr::BuildActiveShadowDepthList( const CViewSetup &viewSetup, i
|
|||||||
|
|
||||||
// FIXME: Could do other sorts of culling here, such as frustum-frustum test, distance etc.
|
// FIXME: Could do other sorts of culling here, such as frustum-frustum test, distance etc.
|
||||||
// If it's not in the view frustum, move on
|
// If it's not in the view frustum, move on
|
||||||
|
#ifdef MAPBASE
|
||||||
|
if ( !flashlightState.m_bAlwaysDraw && !flashlightState.m_bOrtho && R_CullBox( vecAbsMins, vecAbsMaxs, viewFrustum ) )
|
||||||
|
#elif ASW_PROJECTED_TEXTURES
|
||||||
|
if ( !flashlightState.m_bOrtho && R_CullBox( vecAbsMins, vecAbsMaxs, viewFrustum ) )
|
||||||
|
#else
|
||||||
if ( R_CullBox( vecAbsMins, vecAbsMaxs, viewFrustum ) )
|
if ( R_CullBox( vecAbsMins, vecAbsMaxs, viewFrustum ) )
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
shadowmgr->SetFlashlightDepthTexture( shadow.m_ShadowHandle, NULL, 0 );
|
shadowmgr->SetFlashlightDepthTexture( shadow.m_ShadowHandle, NULL, 0 );
|
||||||
continue;
|
continue;
|
||||||
@ -3885,6 +4310,53 @@ int CClientShadowMgr::BuildActiveShadowDepthList( const CViewSetup &viewSetup, i
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef ASW_PROJECTED_TEXTURES
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Re-render shadow depth textures that lie in the leaf list
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
int CClientShadowMgr::BuildActiveFlashlightList( const CViewSetup &viewSetup, int nMaxFlashlights, ClientShadowHandle_t *pActiveFlashlights )
|
||||||
|
{
|
||||||
|
int nActiveFlashlightCount = 0;
|
||||||
|
for ( ClientShadowHandle_t i = m_Shadows.Head(); i != m_Shadows.InvalidIndex(); i = m_Shadows.Next(i) )
|
||||||
|
{
|
||||||
|
ClientShadow_t& shadow = m_Shadows[i];
|
||||||
|
|
||||||
|
if ( ( shadow.m_Flags & SHADOW_FLAGS_FLASHLIGHT ) == 0 )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Calculate an AABB around the shadow frustum
|
||||||
|
Vector vecAbsMins, vecAbsMaxs;
|
||||||
|
CalculateAABBFromProjectionMatrix( shadow.m_WorldToShadow, &vecAbsMins, &vecAbsMaxs );
|
||||||
|
|
||||||
|
Frustum_t viewFrustum;
|
||||||
|
GeneratePerspectiveFrustum( viewSetup.origin, viewSetup.angles, viewSetup.zNear, viewSetup.zFar, viewSetup.fov, viewSetup.m_flAspectRatio, viewFrustum );
|
||||||
|
|
||||||
|
// FIXME: Could do other sorts of culling here, such as frustum-frustum test, distance etc.
|
||||||
|
// If it's not in the view frustum, move on
|
||||||
|
if ( R_CullBox( vecAbsMins, vecAbsMaxs, viewFrustum ) )
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( nActiveFlashlightCount >= nMaxFlashlights )
|
||||||
|
{
|
||||||
|
static bool s_bOverflowWarning = false;
|
||||||
|
if ( !s_bOverflowWarning )
|
||||||
|
{
|
||||||
|
Warning( "Too many flashlights rendered in a single view!\n" );
|
||||||
|
Assert( 0 );
|
||||||
|
s_bOverflowWarning = true;
|
||||||
|
}
|
||||||
|
//shadowmgr->SetFlashlightDepthTexture( shadow.m_ShadowHandle, NULL, 0 );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
pActiveFlashlights[nActiveFlashlightCount++] = i;
|
||||||
|
}
|
||||||
|
return nActiveFlashlightCount;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Sets the view's active flashlight render state
|
// Sets the view's active flashlight render state
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -3908,12 +4380,56 @@ void CClientShadowMgr::SetViewFlashlightState( int nActiveFlashlightCount, Clien
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ASW_PROJECTED_TEXTURES
|
||||||
|
void AddPointToExtentsHelper( const VMatrix &flashlightToWorld, const Vector &vecPos, Vector &vecMin, Vector &vecMax )
|
||||||
|
{
|
||||||
|
Vector worldSpacePos;
|
||||||
|
|
||||||
|
Vector3DMultiplyPositionProjective( flashlightToWorld, vecPos, worldSpacePos );
|
||||||
|
VectorMin( vecMin, worldSpacePos, vecMin );
|
||||||
|
VectorMax( vecMax, worldSpacePos, vecMax );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CClientShadowMgr::GetFrustumExtents( ClientShadowHandle_t handle, Vector &vecMin, Vector &vecMax )
|
||||||
|
{
|
||||||
|
Assert( m_Shadows.IsValidIndex( handle ) );
|
||||||
|
|
||||||
|
CClientShadowMgr::ClientShadow_t &shadow = m_Shadows[ handle ];
|
||||||
|
|
||||||
|
VMatrix flashlightToWorld;
|
||||||
|
MatrixInverseGeneral( shadow.m_WorldToShadow, flashlightToWorld );
|
||||||
|
|
||||||
|
vecMin = Vector( FLT_MAX, FLT_MAX, FLT_MAX );
|
||||||
|
vecMax = Vector( -FLT_MAX, -FLT_MAX, -FLT_MAX );
|
||||||
|
|
||||||
|
AddPointToExtentsHelper( flashlightToWorld, Vector( 0.0f, 0.0f, 0.0f ), vecMin, vecMax );
|
||||||
|
AddPointToExtentsHelper( flashlightToWorld, Vector( 0.0f, 0.0f, 1.0f ), vecMin, vecMax );
|
||||||
|
AddPointToExtentsHelper( flashlightToWorld, Vector( 0.0f, 1.0f, 0.0f ), vecMin, vecMax );
|
||||||
|
AddPointToExtentsHelper( flashlightToWorld, Vector( 1.0f, 0.0f, 0.0f ), vecMin, vecMax );
|
||||||
|
AddPointToExtentsHelper( flashlightToWorld, Vector( 0.0f, 1.0f, 1.0f ), vecMin, vecMax );
|
||||||
|
AddPointToExtentsHelper( flashlightToWorld, Vector( 1.0f, 0.0f, 1.0f ), vecMin, vecMax );
|
||||||
|
AddPointToExtentsHelper( flashlightToWorld, Vector( 1.0f, 1.0f, 0.0f ), vecMin, vecMax );
|
||||||
|
AddPointToExtentsHelper( flashlightToWorld, Vector( 1.0f, 1.0f, 1.0f ), vecMin, vecMax );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Re-render shadow depth textures that lie in the leaf list
|
// Re-render shadow depth textures that lie in the leaf list
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void CClientShadowMgr::ComputeShadowDepthTextures( const CViewSetup &viewSetup )
|
void CClientShadowMgr::ComputeShadowDepthTextures( const CViewSetup &viewSetup )
|
||||||
{
|
{
|
||||||
|
#ifdef ASW_PROJECTED_TEXTURES
|
||||||
|
if ( !r_flashlightdepthtexture.GetBool() )
|
||||||
|
{
|
||||||
|
// Build list of active flashlights
|
||||||
|
ClientShadowHandle_t pActiveFlashlights[16];
|
||||||
|
int nActiveFlashlights = BuildActiveFlashlightList( viewSetup, ARRAYSIZE( pActiveFlashlights ), pActiveFlashlights );
|
||||||
|
SetViewFlashlightState( nActiveFlashlights, pActiveFlashlights );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
VPROF_BUDGET( "CClientShadowMgr::ComputeShadowDepthTextures", VPROF_BUDGETGROUP_SHADOW_DEPTH_TEXTURING );
|
VPROF_BUDGET( "CClientShadowMgr::ComputeShadowDepthTextures", VPROF_BUDGETGROUP_SHADOW_DEPTH_TEXTURING );
|
||||||
|
|
||||||
CMatRenderContextPtr pRenderContext( materials );
|
CMatRenderContextPtr pRenderContext( materials );
|
||||||
@ -3929,6 +4445,10 @@ void CClientShadowMgr::ComputeShadowDepthTextures( const CViewSetup &viewSetup )
|
|||||||
{
|
{
|
||||||
ClientShadow_t& shadow = m_Shadows[ pActiveDepthShadows[j] ];
|
ClientShadow_t& shadow = m_Shadows[ pActiveDepthShadows[j] ];
|
||||||
|
|
||||||
|
#ifdef ASW_PROJECTED_TEXTURES
|
||||||
|
FlashlightState_t& flashlightState = const_cast<FlashlightState_t&>( shadowmgr->GetFlashlightState( shadow.m_ShadowHandle ) );
|
||||||
|
#endif
|
||||||
|
|
||||||
CTextureReference shadowDepthTexture;
|
CTextureReference shadowDepthTexture;
|
||||||
bool bGotShadowDepthTexture = LockShadowDepthTexture( &shadowDepthTexture );
|
bool bGotShadowDepthTexture = LockShadowDepthTexture( &shadowDepthTexture );
|
||||||
if ( !bGotShadowDepthTexture )
|
if ( !bGotShadowDepthTexture )
|
||||||
@ -3943,6 +4463,12 @@ void CClientShadowMgr::ComputeShadowDepthTextures( const CViewSetup &viewSetup )
|
|||||||
|
|
||||||
Assert(0);
|
Assert(0);
|
||||||
shadowmgr->SetFlashlightDepthTexture( shadow.m_ShadowHandle, NULL, 0 );
|
shadowmgr->SetFlashlightDepthTexture( shadow.m_ShadowHandle, NULL, 0 );
|
||||||
|
#ifdef MAPBASE
|
||||||
|
if ( j <= ( INT_FLASHLIGHT_DEPTHTEXTURE_FALLBACK_LAST - INT_FLASHLIGHT_DEPTHTEXTURE_FALLBACK_FIRST ) )
|
||||||
|
{
|
||||||
|
pRenderContext->SetIntRenderingParameter( INT_FLASHLIGHT_DEPTHTEXTURE_FALLBACK_FIRST + j, 0 );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3951,11 +4477,30 @@ void CClientShadowMgr::ComputeShadowDepthTextures( const CViewSetup &viewSetup )
|
|||||||
shadowView.x = shadowView.y = 0;
|
shadowView.x = shadowView.y = 0;
|
||||||
shadowView.width = shadowDepthTexture->GetActualWidth();
|
shadowView.width = shadowDepthTexture->GetActualWidth();
|
||||||
shadowView.height = shadowDepthTexture->GetActualHeight();
|
shadowView.height = shadowDepthTexture->GetActualHeight();
|
||||||
|
#ifndef ASW_PROJECTED_TEXTURES
|
||||||
shadowView.m_bOrtho = false;
|
shadowView.m_bOrtho = false;
|
||||||
shadowView.m_bDoBloomAndToneMapping = false;
|
shadowView.m_bDoBloomAndToneMapping = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Copy flashlight parameters
|
// Copy flashlight parameters
|
||||||
|
#ifdef ASW_PROJECTED_TEXTURES
|
||||||
|
if ( !flashlightState.m_bOrtho )
|
||||||
|
{
|
||||||
|
shadowView.m_bOrtho = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
shadowView.m_bOrtho = true;
|
||||||
|
shadowView.m_OrthoLeft = flashlightState.m_fOrthoLeft;
|
||||||
|
shadowView.m_OrthoTop = flashlightState.m_fOrthoTop;
|
||||||
|
shadowView.m_OrthoRight = flashlightState.m_fOrthoRight;
|
||||||
|
shadowView.m_OrthoBottom = flashlightState.m_fOrthoBottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
shadowView.m_bDoBloomAndToneMapping = false;
|
||||||
|
#else
|
||||||
const FlashlightState_t& flashlightState = shadowmgr->GetFlashlightState( shadow.m_ShadowHandle );
|
const FlashlightState_t& flashlightState = shadowmgr->GetFlashlightState( shadow.m_ShadowHandle );
|
||||||
|
#endif
|
||||||
shadowView.fov = shadowView.fovViewmodel = flashlightState.m_fHorizontalFOVDegrees;
|
shadowView.fov = shadowView.fovViewmodel = flashlightState.m_fHorizontalFOVDegrees;
|
||||||
shadowView.origin = flashlightState.m_vecLightOrigin;
|
shadowView.origin = flashlightState.m_vecLightOrigin;
|
||||||
QuaternionAngles( flashlightState.m_quatOrientation, shadowView.angles ); // Convert from Quaternion to QAngle
|
QuaternionAngles( flashlightState.m_quatOrientation, shadowView.angles ); // Convert from Quaternion to QAngle
|
||||||
@ -3976,6 +4521,19 @@ void CClientShadowMgr::ComputeShadowDepthTextures( const CViewSetup &viewSetup )
|
|||||||
// Render to the shadow depth texture with appropriate view
|
// Render to the shadow depth texture with appropriate view
|
||||||
view->UpdateShadowDepthTexture( m_DummyColorTexture, shadowDepthTexture, shadowView );
|
view->UpdateShadowDepthTexture( m_DummyColorTexture, shadowDepthTexture, shadowView );
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
if ( j <= ( INT_FLASHLIGHT_DEPTHTEXTURE_FALLBACK_LAST - INT_FLASHLIGHT_DEPTHTEXTURE_FALLBACK_FIRST ) )
|
||||||
|
{
|
||||||
|
pRenderContext->SetIntRenderingParameter( INT_FLASHLIGHT_DEPTHTEXTURE_FALLBACK_FIRST + j, int((ITexture*)shadowDepthTexture) );
|
||||||
|
|
||||||
|
FlashlightState_t state = shadowmgr->GetFlashlightState( shadow.m_ShadowHandle );
|
||||||
|
|
||||||
|
state.m_nShadowQuality = state.m_nShadowQuality | ( ( j + 1 ) << 16 );
|
||||||
|
|
||||||
|
shadowmgr->UpdateFlashlightState( shadow.m_ShadowHandle, state );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Associate the shadow depth texture and stencil bit with the flashlight for use during scene rendering
|
// Associate the shadow depth texture and stencil bit with the flashlight for use during scene rendering
|
||||||
shadowmgr->SetFlashlightDepthTexture( shadow.m_ShadowHandle, shadowDepthTexture, 0 );
|
shadowmgr->SetFlashlightDepthTexture( shadow.m_ShadowHandle, shadowDepthTexture, 0 );
|
||||||
}
|
}
|
||||||
@ -4000,7 +4558,11 @@ void CClientShadowMgr::ComputeShadowTextures( const CViewSetup &view, int leafCo
|
|||||||
if ( !m_RenderToTextureActive || (r_shadows.GetInt() == 0) || r_shadows_gamecontrol.GetInt() == 0 )
|
if ( !m_RenderToTextureActive || (r_shadows.GetInt() == 0) || r_shadows_gamecontrol.GetInt() == 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#ifdef ASW_PROJECTED_TEXTURES
|
||||||
|
m_bThreaded = ( r_threaded_client_shadow_manager.GetBool() && g_pThreadPool->NumIdleThreads() );
|
||||||
|
#else
|
||||||
m_bThreaded = false;//( r_threaded_client_shadow_manager.GetBool() && g_pThreadPool->NumIdleThreads() );
|
m_bThreaded = false;//( r_threaded_client_shadow_manager.GetBool() && g_pThreadPool->NumIdleThreads() );
|
||||||
|
#endif
|
||||||
|
|
||||||
MDLCACHE_CRITICAL_SECTION();
|
MDLCACHE_CRITICAL_SECTION();
|
||||||
// First grab all shadow textures we may want to render
|
// First grab all shadow textures we may want to render
|
||||||
@ -4184,6 +4746,28 @@ bool CClientShadowMgr::IsFlashlightTarget( ClientShadowHandle_t shadowHandle, IC
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DYNAMIC_RTT_SHADOWS
|
||||||
|
void CClientShadowMgr::SetShadowFromWorldLightsEnabled( bool bEnable )
|
||||||
|
{
|
||||||
|
bool bIsShadowingFromWorldLights = IsShadowingFromWorldLights();
|
||||||
|
m_bShadowFromWorldLights = bEnable;
|
||||||
|
if ( bIsShadowingFromWorldLights != IsShadowingFromWorldLights() )
|
||||||
|
{
|
||||||
|
UpdateAllShadows();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CClientShadowMgr::SuppressShadowFromWorldLights( bool bSuppress )
|
||||||
|
{
|
||||||
|
bool bIsShadowingFromWorldLights = IsShadowingFromWorldLights();
|
||||||
|
m_bSuppressShadowFromWorldLights = bSuppress;
|
||||||
|
if ( bIsShadowingFromWorldLights != IsShadowingFromWorldLights() )
|
||||||
|
{
|
||||||
|
UpdateAllShadows();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// A material proxy that resets the base texture to use the rendered shadow
|
// A material proxy that resets the base texture to use the rendered shadow
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -1471,6 +1471,7 @@ void CDetailObjectSystem::LevelInitPreEntity()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef MAPBASE
|
||||||
if ( m_DetailObjects.Count() || m_DetailSpriteDict.Count() )
|
if ( m_DetailObjects.Count() || m_DetailSpriteDict.Count() )
|
||||||
{
|
{
|
||||||
// There are detail objects in the level, so precache the material
|
// There are detail objects in the level, so precache the material
|
||||||
@ -1489,6 +1490,7 @@ void CDetailObjectSystem::LevelInitPreEntity()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int detailPropLightingLump;
|
int detailPropLightingLump;
|
||||||
if( g_pMaterialSystemHardwareConfig->GetHDRType() != HDR_TYPE_NONE )
|
if( g_pMaterialSystemHardwareConfig->GetHDRType() != HDR_TYPE_NONE )
|
||||||
@ -1512,6 +1514,32 @@ void CDetailObjectSystem::LevelInitPreEntity()
|
|||||||
|
|
||||||
void CDetailObjectSystem::LevelInitPostEntity()
|
void CDetailObjectSystem::LevelInitPostEntity()
|
||||||
{
|
{
|
||||||
|
#ifdef MAPBASE
|
||||||
|
if ( m_DetailObjects.Count() || m_DetailSpriteDict.Count() )
|
||||||
|
{
|
||||||
|
const char *pDetailSpriteMaterial = DETAIL_SPRITE_MATERIAL;
|
||||||
|
C_World *pWorld = GetClientWorldEntity();
|
||||||
|
if ( pWorld && pWorld->GetDetailSpriteMaterial() && *(pWorld->GetDetailSpriteMaterial()) )
|
||||||
|
pDetailSpriteMaterial = pWorld->GetDetailSpriteMaterial();
|
||||||
|
|
||||||
|
m_DetailSpriteMaterial.Init( pDetailSpriteMaterial, TEXTURE_GROUP_OTHER );
|
||||||
|
PrecacheMaterial( pDetailSpriteMaterial );
|
||||||
|
IMaterial *pMat = m_DetailSpriteMaterial;
|
||||||
|
|
||||||
|
// adjust for non-square textures (cropped)
|
||||||
|
float flRatio = pMat->GetMappingWidth() / pMat->GetMappingHeight();
|
||||||
|
if ( flRatio > 1.0 )
|
||||||
|
{
|
||||||
|
for( int i = 0; i<m_DetailSpriteDict.Count(); i++ )
|
||||||
|
{
|
||||||
|
m_DetailSpriteDict[i].m_TexUL.y *= flRatio;
|
||||||
|
m_DetailSpriteDict[i].m_TexLR.y *= flRatio;
|
||||||
|
m_DetailSpriteDictFlipped[i].m_TexUL.y *= flRatio;
|
||||||
|
m_DetailSpriteDictFlipped[i].m_TexLR.y *= flRatio;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
const char *pDetailSpriteMaterial = DETAIL_SPRITE_MATERIAL;
|
const char *pDetailSpriteMaterial = DETAIL_SPRITE_MATERIAL;
|
||||||
C_World *pWorld = GetClientWorldEntity();
|
C_World *pWorld = GetClientWorldEntity();
|
||||||
if ( pWorld && pWorld->GetDetailSpriteMaterial() && *(pWorld->GetDetailSpriteMaterial()) )
|
if ( pWorld && pWorld->GetDetailSpriteMaterial() && *(pWorld->GetDetailSpriteMaterial()) )
|
||||||
@ -1519,6 +1547,7 @@ void CDetailObjectSystem::LevelInitPostEntity()
|
|||||||
pDetailSpriteMaterial = pWorld->GetDetailSpriteMaterial();
|
pDetailSpriteMaterial = pWorld->GetDetailSpriteMaterial();
|
||||||
}
|
}
|
||||||
m_DetailSpriteMaterial.Init( pDetailSpriteMaterial, TEXTURE_GROUP_OTHER );
|
m_DetailSpriteMaterial.Init( pDetailSpriteMaterial, TEXTURE_GROUP_OTHER );
|
||||||
|
#endif
|
||||||
|
|
||||||
if ( GetDetailController() )
|
if ( GetDetailController() )
|
||||||
{
|
{
|
||||||
@ -1595,12 +1624,14 @@ void CDetailObjectSystem::UnserializeModelDict( CUtlBuffer& buf )
|
|||||||
DetailModelDict_t dict;
|
DetailModelDict_t dict;
|
||||||
dict.m_pModel = (model_t *)engine->LoadModel( lump.m_Name, true );
|
dict.m_pModel = (model_t *)engine->LoadModel( lump.m_Name, true );
|
||||||
|
|
||||||
|
#ifndef MAPBASE
|
||||||
// Don't allow vertex-lit models
|
// Don't allow vertex-lit models
|
||||||
if (modelinfo->IsModelVertexLit(dict.m_pModel))
|
if (modelinfo->IsModelVertexLit(dict.m_pModel))
|
||||||
{
|
{
|
||||||
Warning("Detail prop model %s is using vertex-lit materials!\nIt must use unlit materials!\n", lump.m_Name );
|
Warning("Detail prop model %s is using vertex-lit materials!\nIt must use unlit materials!\n", lump.m_Name );
|
||||||
dict.m_pModel = (model_t *)engine->LoadModel( "models/error.mdl" );
|
dict.m_pModel = (model_t *)engine->LoadModel( "models/error.mdl" );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
m_DetailObjectDict.AddToTail( dict );
|
m_DetailObjectDict.AddToTail( dict );
|
||||||
}
|
}
|
||||||
|
@ -48,8 +48,16 @@ static ConVar r_flashlightvisualizetrace( "r_flashlightvisualizetrace", "0", FCV
|
|||||||
static ConVar r_flashlightambient( "r_flashlightambient", "0.0", FCVAR_CHEAT );
|
static ConVar r_flashlightambient( "r_flashlightambient", "0.0", FCVAR_CHEAT );
|
||||||
static ConVar r_flashlightshadowatten( "r_flashlightshadowatten", "0.35", FCVAR_CHEAT );
|
static ConVar r_flashlightshadowatten( "r_flashlightshadowatten", "0.35", FCVAR_CHEAT );
|
||||||
static ConVar r_flashlightladderdist( "r_flashlightladderdist", "40.0", FCVAR_CHEAT );
|
static ConVar r_flashlightladderdist( "r_flashlightladderdist", "40.0", FCVAR_CHEAT );
|
||||||
|
#ifndef MAPBASE
|
||||||
static ConVar mat_slopescaledepthbias_shadowmap( "mat_slopescaledepthbias_shadowmap", "16", FCVAR_CHEAT );
|
static ConVar mat_slopescaledepthbias_shadowmap( "mat_slopescaledepthbias_shadowmap", "16", FCVAR_CHEAT );
|
||||||
static ConVar mat_depthbias_shadowmap( "mat_depthbias_shadowmap", "0.0005", FCVAR_CHEAT );
|
static ConVar mat_depthbias_shadowmap( "mat_depthbias_shadowmap", "0.0005", FCVAR_CHEAT );
|
||||||
|
#else
|
||||||
|
static ConVar mat_slopescaledepthbias_shadowmap( "mat_slopescaledepthbias_shadowmap", "4", FCVAR_CHEAT );
|
||||||
|
static ConVar mat_depthbias_shadowmap( "mat_depthbias_shadowmap", "0.00001", FCVAR_CHEAT );
|
||||||
|
#endif
|
||||||
|
#ifdef MAPBASE
|
||||||
|
static ConVar r_flashlighttextureoverride( "r_flashlighttextureoverride", "", FCVAR_CHEAT );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void r_newflashlightCallback_f( IConVar *pConVar, const char *pOldString, float flOldValue )
|
void r_newflashlightCallback_f( IConVar *pConVar, const char *pOldString, float flOldValue )
|
||||||
@ -78,6 +86,13 @@ CFlashlightEffect::CFlashlightEffect(int nEntIndex)
|
|||||||
r_newflashlight.SetValue( 0 );
|
r_newflashlight.SetValue( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
if ( r_flashlighttextureoverride.GetString()[0] != '\0' )
|
||||||
|
{
|
||||||
|
m_FlashlightTexture.Init( r_flashlighttextureoverride.GetString(), TEXTURE_GROUP_OTHER, true );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
if ( g_pMaterialSystemHardwareConfig->SupportsBorderColor() )
|
if ( g_pMaterialSystemHardwareConfig->SupportsBorderColor() )
|
||||||
{
|
{
|
||||||
m_FlashlightTexture.Init( "effects/flashlight_border", TEXTURE_GROUP_OTHER, true );
|
m_FlashlightTexture.Init( "effects/flashlight_border", TEXTURE_GROUP_OTHER, true );
|
||||||
|
@ -1256,6 +1256,13 @@ void FX_BuildTeslaHitbox( const CEffectData &data )
|
|||||||
{
|
{
|
||||||
Vector vColor( 1, 1, 1 );
|
Vector vColor( 1, 1, 1 );
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
if ( data.m_bCustomColors )
|
||||||
|
{
|
||||||
|
vColor = data.m_CustomColors.m_vecColor1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
C_BaseEntity *pEntity = ClientEntityList().GetEnt( data.entindex() );
|
C_BaseEntity *pEntity = ClientEntityList().GetEnt( data.entindex() );
|
||||||
C_BaseAnimating *pAnimating = pEntity ? pEntity->GetBaseAnimating() : NULL;
|
C_BaseAnimating *pAnimating = pEntity ? pEntity->GetBaseAnimating() : NULL;
|
||||||
if (!pAnimating)
|
if (!pAnimating)
|
||||||
|
@ -40,11 +40,13 @@ Vector GetTracerOrigin( const CEffectData &data )
|
|||||||
|
|
||||||
C_BaseEntity *pEnt = data.GetEntity();
|
C_BaseEntity *pEnt = data.GetEntity();
|
||||||
|
|
||||||
// This check should probably be for all multiplayer games, investigate later
|
// This check should probably be for all multiplayer games, investigate later
|
||||||
#if defined( HL2MP ) || defined( TF_CLIENT_DLL )
|
// 10/09/2008: It should.
|
||||||
if ( pEnt && pEnt->IsDormant() )
|
if ( gpGlobals->maxClients > 1 )
|
||||||
return vecStart;
|
{
|
||||||
#endif
|
if ( pEnt && pEnt->IsDormant() )
|
||||||
|
return vecStart;
|
||||||
|
}
|
||||||
|
|
||||||
C_BaseCombatWeapon *pWpn = dynamic_cast<C_BaseCombatWeapon *>( pEnt );
|
C_BaseCombatWeapon *pWpn = dynamic_cast<C_BaseCombatWeapon *>( pEnt );
|
||||||
if ( pWpn && pWpn->ShouldDrawUsingViewModel() )
|
if ( pWpn && pWpn->ShouldDrawUsingViewModel() )
|
||||||
|
@ -38,6 +38,11 @@ BEGIN_PREDICTION_DATA( C_BaseHLPlayer )
|
|||||||
DEFINE_PRED_FIELD( m_fIsSprinting, FIELD_BOOLEAN, FTYPEDESC_INSENDTABLE ),
|
DEFINE_PRED_FIELD( m_fIsSprinting, FIELD_BOOLEAN, FTYPEDESC_INSENDTABLE ),
|
||||||
END_PREDICTION_DATA()
|
END_PREDICTION_DATA()
|
||||||
|
|
||||||
|
// link to the correct class.
|
||||||
|
#if !defined ( HL2MP ) && !defined ( PORTAL )
|
||||||
|
LINK_ENTITY_TO_CLASS( player, C_BaseHLPlayer );
|
||||||
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: Drops player's primary weapon
|
// Purpose: Drops player's primary weapon
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -66,6 +71,11 @@ C_BaseHLPlayer::C_BaseHLPlayer()
|
|||||||
m_flZoomRate = 0.0f;
|
m_flZoomRate = 0.0f;
|
||||||
m_flZoomStartTime = 0.0f;
|
m_flZoomStartTime = 0.0f;
|
||||||
m_flSpeedMod = cl_forwardspeed.GetFloat();
|
m_flSpeedMod = cl_forwardspeed.GetFloat();
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
ConVarRef scissor("r_flashlightscissor");
|
||||||
|
scissor.SetValue("0");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
// $Workfile: $
|
// $Workfile: $
|
||||||
// $NoKeywords: $
|
// $NoKeywords: $
|
||||||
//=============================================================================//
|
//=============================================================================//
|
||||||
|
|
||||||
#if !defined( C_BASEHLPLAYER_H )
|
#if !defined( C_BASEHLPLAYER_H )
|
||||||
#define C_BASEHLPLAYER_H
|
#define C_BASEHLPLAYER_H
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -34,10 +33,17 @@ public:
|
|||||||
float GetZoom( void );
|
float GetZoom( void );
|
||||||
bool IsZoomed( void ) { return m_HL2Local.m_bZooming; }
|
bool IsZoomed( void ) { return m_HL2Local.m_bZooming; }
|
||||||
|
|
||||||
bool IsSprinting( void ) { return m_HL2Local.m_bitsActiveDevices & bits_SUIT_DEVICE_SPRINT; }
|
//Tony; minor cosmetic really, fix confusion by simply renaming this one; everything calls IsSprinting(), and this isn't really even used.
|
||||||
|
bool IsSprintActive( void ) { return m_HL2Local.m_bitsActiveDevices & bits_SUIT_DEVICE_SPRINT; }
|
||||||
bool IsFlashlightActive( void ) { return m_HL2Local.m_bitsActiveDevices & bits_SUIT_DEVICE_FLASHLIGHT; }
|
bool IsFlashlightActive( void ) { return m_HL2Local.m_bitsActiveDevices & bits_SUIT_DEVICE_FLASHLIGHT; }
|
||||||
bool IsBreatherActive( void ) { return m_HL2Local.m_bitsActiveDevices & bits_SUIT_DEVICE_BREATHER; }
|
bool IsBreatherActive( void ) { return m_HL2Local.m_bitsActiveDevices & bits_SUIT_DEVICE_BREATHER; }
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
bool IsCustomDevice0Active( void ) { return m_HL2Local.m_bitsActiveDevices & bits_SUIT_DEVICE_CUSTOM0; }
|
||||||
|
bool IsCustomDevice1Active( void ) { return m_HL2Local.m_bitsActiveDevices & bits_SUIT_DEVICE_CUSTOM1; }
|
||||||
|
bool IsCustomDevice2Active( void ) { return m_HL2Local.m_bitsActiveDevices & bits_SUIT_DEVICE_CUSTOM2; }
|
||||||
|
#endif
|
||||||
|
|
||||||
virtual int DrawModel( int flags );
|
virtual int DrawModel( int flags );
|
||||||
virtual void BuildTransformations( CStudioHdr *hdr, Vector *pos, Quaternion q[], const matrix3x4_t& cameraTransform, int boneMask, CBoneBitList &boneComputed );
|
virtual void BuildTransformations( CStudioHdr *hdr, Vector *pos, Quaternion q[], const matrix3x4_t& cameraTransform, int boneMask, CBoneBitList &boneComputed );
|
||||||
|
|
||||||
|
@ -90,6 +90,11 @@ void C_EnvStarfield::ClientThink( void )
|
|||||||
if ( !m_bOn || !m_flDensity )
|
if ( !m_bOn || !m_flDensity )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
if ( engine->IsPaused() )
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
PMaterialHandle hParticleMaterial = m_pEmitter->GetPMaterial( "effects/spark_noz" );
|
PMaterialHandle hParticleMaterial = m_pEmitter->GetPMaterial( "effects/spark_noz" );
|
||||||
|
|
||||||
// Find a start & end point for the particle
|
// Find a start & end point for the particle
|
||||||
|
@ -10,6 +10,9 @@
|
|||||||
#include "iviewrender.h"
|
#include "iviewrender.h"
|
||||||
#include "view_shared.h"
|
#include "view_shared.h"
|
||||||
#include "viewrender.h"
|
#include "viewrender.h"
|
||||||
|
#ifdef MAPBASE
|
||||||
|
#include "c_point_camera.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
// memdbgon must be the last include file in a .cpp file!!!
|
// memdbgon must be the last include file in a .cpp file!!!
|
||||||
#include "tier0/memdbgon.h"
|
#include "tier0/memdbgon.h"
|
||||||
@ -53,6 +56,11 @@ private:
|
|||||||
float m_flBlendStartTime;
|
float m_flBlendStartTime;
|
||||||
bool m_bActive;
|
bool m_bActive;
|
||||||
EHANDLE m_hCameraEntity;
|
EHANDLE m_hCameraEntity;
|
||||||
|
#ifdef MAPBASE
|
||||||
|
bool m_bDrawSky;
|
||||||
|
bool m_bDrawSky2;
|
||||||
|
bool m_bUseEyePosition;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Fades
|
// Fades
|
||||||
float m_flFadeColor[3]; // Server's desired fade color
|
float m_flFadeColor[3]; // Server's desired fade color
|
||||||
@ -71,6 +79,11 @@ IMPLEMENT_CLIENTCLASS_DT( C_ScriptIntro, DT_ScriptIntro, CScriptIntro )
|
|||||||
RecvPropFloat( RECVINFO( m_flNextBlendTime ) ),
|
RecvPropFloat( RECVINFO( m_flNextBlendTime ) ),
|
||||||
RecvPropFloat( RECVINFO( m_flBlendStartTime ) ),
|
RecvPropFloat( RECVINFO( m_flBlendStartTime ) ),
|
||||||
RecvPropBool( RECVINFO( m_bActive ) ),
|
RecvPropBool( RECVINFO( m_bActive ) ),
|
||||||
|
#ifdef MAPBASE
|
||||||
|
RecvPropBool( RECVINFO( m_bDrawSky ) ),
|
||||||
|
RecvPropBool( RECVINFO( m_bDrawSky2 ) ),
|
||||||
|
RecvPropBool( RECVINFO( m_bUseEyePosition ) ),
|
||||||
|
#endif
|
||||||
|
|
||||||
// Fov & fov blends
|
// Fov & fov blends
|
||||||
RecvPropInt( RECVINFO( m_iFOV ) ),
|
RecvPropInt( RECVINFO( m_iFOV ) ),
|
||||||
@ -140,6 +153,10 @@ void C_ScriptIntro::PostDataUpdate( DataUpdateType_t updateType )
|
|||||||
m_IntroData.m_vecCameraViewAngles = m_vecCameraViewAngles;
|
m_IntroData.m_vecCameraViewAngles = m_vecCameraViewAngles;
|
||||||
m_IntroData.m_Passes.SetCount( 0 );
|
m_IntroData.m_Passes.SetCount( 0 );
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
m_IntroData.m_bDrawSky = m_bDrawSky;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Find/Create our first pass
|
// Find/Create our first pass
|
||||||
IntroDataBlendPass_t *pass1;
|
IntroDataBlendPass_t *pass1;
|
||||||
if ( m_IntroData.m_Passes.Count() == 0 )
|
if ( m_IntroData.m_Passes.Count() == 0 )
|
||||||
@ -161,6 +178,20 @@ void C_ScriptIntro::PostDataUpdate( DataUpdateType_t updateType )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_IntroData.m_bDrawPrimary = true;
|
m_IntroData.m_bDrawPrimary = true;
|
||||||
|
#ifdef MAPBASE
|
||||||
|
m_IntroData.m_bDrawSky2 = m_bDrawSky2;
|
||||||
|
|
||||||
|
// If it's a point_camera and it's ortho, send it to the intro data
|
||||||
|
// Change this code if the purpose of m_hCameraEntity in intro data ever goes beyond ortho
|
||||||
|
if ( m_hCameraEntity && Q_strncmp(m_hCameraEntity->GetClassname(), "point_camera", 12) == 0 )
|
||||||
|
{
|
||||||
|
C_PointCamera *pCamera = dynamic_cast<C_PointCamera*>(m_hCameraEntity.Get());
|
||||||
|
if (pCamera && pCamera->IsOrtho())
|
||||||
|
{
|
||||||
|
m_IntroData.m_hCameraEntity = m_hCameraEntity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're currently blending to a new mode, set the second pass
|
// If we're currently blending to a new mode, set the second pass
|
||||||
@ -239,8 +270,20 @@ void C_ScriptIntro::ClientThink( void )
|
|||||||
|
|
||||||
if ( m_hCameraEntity )
|
if ( m_hCameraEntity )
|
||||||
{
|
{
|
||||||
|
#ifdef MAPBASE
|
||||||
|
if ( m_bUseEyePosition )
|
||||||
|
{
|
||||||
|
m_hCameraEntity->GetEyePosition( m_IntroData.m_vecCameraView, m_IntroData.m_vecCameraViewAngles );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_IntroData.m_vecCameraView = m_hCameraEntity->GetAbsOrigin();
|
||||||
|
m_IntroData.m_vecCameraViewAngles = m_hCameraEntity->GetAbsAngles();
|
||||||
|
}
|
||||||
|
#else
|
||||||
m_IntroData.m_vecCameraView = m_hCameraEntity->GetAbsOrigin();
|
m_IntroData.m_vecCameraView = m_hCameraEntity->GetAbsOrigin();
|
||||||
m_IntroData.m_vecCameraViewAngles = m_hCameraEntity->GetAbsAngles();
|
m_IntroData.m_vecCameraViewAngles = m_hCameraEntity->GetAbsAngles();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
CalculateFOV();
|
CalculateFOV();
|
||||||
@ -325,3 +368,135 @@ void C_ScriptIntro::CalculateAlpha( void )
|
|||||||
m_IntroData.m_flCurrentFadeColor[3] = flNewAlpha;
|
m_IntroData.m_flCurrentFadeColor[3] = flNewAlpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
class C_PlayerViewProxy : public C_BaseEntity
|
||||||
|
{
|
||||||
|
DECLARE_CLASS( C_PlayerViewProxy, C_BaseEntity );
|
||||||
|
public:
|
||||||
|
DECLARE_CLIENTCLASS();
|
||||||
|
|
||||||
|
Vector EyePosition( void ); // position of eyes
|
||||||
|
const QAngle &EyeAngles( void ); // Direction of eyes in world space
|
||||||
|
void GetEyePosition( Vector &vecOrigin, QAngle &angAngles );
|
||||||
|
const QAngle &LocalEyeAngles( void ); // Direction of eyes
|
||||||
|
Vector EarPosition( void ); // position of ears
|
||||||
|
|
||||||
|
#ifdef MAPBASE_MP
|
||||||
|
C_BasePlayer *GetPlayer() { return m_bEnabled ? (m_hPlayer.Get() ? m_hPlayer.Get() : C_BasePlayer::GetLocalPlayer()) : NULL; }
|
||||||
|
#else
|
||||||
|
C_BasePlayer *GetPlayer() { return m_bEnabled ? C_BasePlayer::GetLocalPlayer() : NULL; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
#ifdef MAPBASE_MP
|
||||||
|
CHandle<C_BasePlayer> m_hPlayer;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool m_bEnabled;
|
||||||
|
};
|
||||||
|
|
||||||
|
IMPLEMENT_CLIENTCLASS_DT( C_PlayerViewProxy, DT_PlayerViewProxy, CPlayerViewProxy )
|
||||||
|
#ifdef MAPBASE_MP
|
||||||
|
RecvPropEHandle( RECVINFO( m_hPlayer ) ),
|
||||||
|
#endif
|
||||||
|
RecvPropBool( RECVINFO( m_bEnabled ) ),
|
||||||
|
END_RECV_TABLE()
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
Vector C_PlayerViewProxy::EyePosition( void )
|
||||||
|
{
|
||||||
|
C_BasePlayer *pPlayer = GetPlayer();
|
||||||
|
if (pPlayer)
|
||||||
|
{
|
||||||
|
//Vector vecPlayerOffset = m_hPlayer.Get()->EyePosition() - m_hPlayer.Get()->GetAbsOrigin();
|
||||||
|
//return GetAbsOrigin() + vecPlayerOffset;
|
||||||
|
|
||||||
|
Vector vecOrigin;
|
||||||
|
QAngle angAngles;
|
||||||
|
float fldummy;
|
||||||
|
pPlayer->CalcView( vecOrigin, angAngles, fldummy, fldummy, fldummy );
|
||||||
|
|
||||||
|
return GetAbsOrigin() + (vecOrigin - pPlayer->GetAbsOrigin());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return BaseClass::EyePosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
const QAngle &C_PlayerViewProxy::EyeAngles( void )
|
||||||
|
{
|
||||||
|
C_BasePlayer *pPlayer = GetPlayer();
|
||||||
|
if (pPlayer)
|
||||||
|
{
|
||||||
|
Vector vecOrigin;
|
||||||
|
static QAngle angAngles;
|
||||||
|
float fldummy;
|
||||||
|
pPlayer->CalcView( vecOrigin, angAngles, fldummy, fldummy, fldummy );
|
||||||
|
|
||||||
|
angAngles = GetAbsAngles() + (angAngles - pPlayer->GetAbsAngles());
|
||||||
|
return angAngles;
|
||||||
|
|
||||||
|
//return m_hPlayer.Get()->EyeAngles();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return BaseClass::EyeAngles();
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void C_PlayerViewProxy::GetEyePosition( Vector &vecOrigin, QAngle &angAngles )
|
||||||
|
{
|
||||||
|
C_BasePlayer *pPlayer = GetPlayer();
|
||||||
|
if (pPlayer)
|
||||||
|
{
|
||||||
|
float fldummy;
|
||||||
|
pPlayer->CalcView( vecOrigin, angAngles, fldummy, fldummy, fldummy );
|
||||||
|
|
||||||
|
vecOrigin = GetAbsOrigin() + (vecOrigin - pPlayer->GetAbsOrigin());
|
||||||
|
angAngles = GetAbsAngles() + (angAngles - pPlayer->GetAbsAngles());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BaseClass::GetEyePosition( vecOrigin, angAngles );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
const QAngle &C_PlayerViewProxy::LocalEyeAngles( void )
|
||||||
|
{
|
||||||
|
C_BasePlayer *pPlayer = GetPlayer();
|
||||||
|
if (pPlayer) {
|
||||||
|
static QAngle angAngles;
|
||||||
|
angAngles = GetAbsAngles() + (pPlayer->LocalEyeAngles() - pPlayer->GetAbsAngles());
|
||||||
|
return angAngles;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return BaseClass::LocalEyeAngles();
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
Vector C_PlayerViewProxy::EarPosition( void )
|
||||||
|
{
|
||||||
|
C_BasePlayer *pPlayer = GetPlayer();
|
||||||
|
if (pPlayer)
|
||||||
|
{
|
||||||
|
Vector vecPlayerOffset = pPlayer->GetAbsOrigin() - pPlayer->EarPosition();
|
||||||
|
return GetAbsOrigin() + vecPlayerOffset;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return BaseClass::EarPosition();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@ -33,7 +33,9 @@ STUB_WEAPON_CLASS( weapon_shotgun, WeaponShotgun, C_BaseHLCombatWeapon );
|
|||||||
STUB_WEAPON_CLASS( weapon_smg1, WeaponSMG1, C_HLSelectFireMachineGun );
|
STUB_WEAPON_CLASS( weapon_smg1, WeaponSMG1, C_HLSelectFireMachineGun );
|
||||||
STUB_WEAPON_CLASS( weapon_357, Weapon357, C_BaseHLCombatWeapon );
|
STUB_WEAPON_CLASS( weapon_357, Weapon357, C_BaseHLCombatWeapon );
|
||||||
STUB_WEAPON_CLASS( weapon_crossbow, WeaponCrossbow, C_BaseHLCombatWeapon );
|
STUB_WEAPON_CLASS( weapon_crossbow, WeaponCrossbow, C_BaseHLCombatWeapon );
|
||||||
|
#ifndef MAPBASE
|
||||||
STUB_WEAPON_CLASS( weapon_slam, Weapon_SLAM, C_BaseHLCombatWeapon );
|
STUB_WEAPON_CLASS( weapon_slam, Weapon_SLAM, C_BaseHLCombatWeapon );
|
||||||
|
#endif
|
||||||
STUB_WEAPON_CLASS( weapon_crowbar, WeaponCrowbar, C_BaseHLBludgeonWeapon );
|
STUB_WEAPON_CLASS( weapon_crowbar, WeaponCrowbar, C_BaseHLBludgeonWeapon );
|
||||||
#ifdef HL2_EPISODIC
|
#ifdef HL2_EPISODIC
|
||||||
STUB_WEAPON_CLASS( weapon_hopwire, WeaponHopwire, C_BaseHLCombatWeapon );
|
STUB_WEAPON_CLASS( weapon_hopwire, WeaponHopwire, C_BaseHLCombatWeapon );
|
||||||
|
@ -109,6 +109,9 @@ private:
|
|||||||
|
|
||||||
float m_flScrollTime;
|
float m_flScrollTime;
|
||||||
float m_flSeparation;
|
float m_flSeparation;
|
||||||
|
#ifdef MAPBASE
|
||||||
|
int m_iEndLines;
|
||||||
|
#endif
|
||||||
float m_flFadeTime;
|
float m_flFadeTime;
|
||||||
bool m_bLastOneInPlace;
|
bool m_bLastOneInPlace;
|
||||||
int m_Alpha;
|
int m_Alpha;
|
||||||
@ -133,6 +136,12 @@ private:
|
|||||||
char m_szLogo2[256];
|
char m_szLogo2[256];
|
||||||
|
|
||||||
Color m_cColor;
|
Color m_cColor;
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
char m_szCreditsFile[MAX_PATH];
|
||||||
|
|
||||||
|
char m_szLogoFont[64];
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -141,7 +150,11 @@ void CHudCredits::PrepareCredits( const char *pKeyName )
|
|||||||
Clear();
|
Clear();
|
||||||
|
|
||||||
KeyValues *pKV= new KeyValues( "CreditsFile" );
|
KeyValues *pKV= new KeyValues( "CreditsFile" );
|
||||||
|
#ifdef MAPBASE
|
||||||
|
if ( !pKV->LoadFromFile( filesystem, m_szCreditsFile, "MOD" ) )
|
||||||
|
#else
|
||||||
if ( !pKV->LoadFromFile( filesystem, CREDITS_FILE, "MOD" ) )
|
if ( !pKV->LoadFromFile( filesystem, CREDITS_FILE, "MOD" ) )
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
pKV->deleteThis();
|
pKV->deleteThis();
|
||||||
|
|
||||||
@ -233,6 +246,9 @@ void CHudCredits::ReadParams( KeyValues *pKeyValue )
|
|||||||
|
|
||||||
m_flScrollTime = pKeyValue->GetFloat( "scrolltime", 57 );
|
m_flScrollTime = pKeyValue->GetFloat( "scrolltime", 57 );
|
||||||
m_flSeparation = pKeyValue->GetFloat( "separation", 5 );
|
m_flSeparation = pKeyValue->GetFloat( "separation", 5 );
|
||||||
|
#ifdef MAPBASE
|
||||||
|
m_iEndLines = pKeyValue->GetInt( "endlines", 1 );
|
||||||
|
#endif
|
||||||
|
|
||||||
m_flFadeInTime = pKeyValue->GetFloat( "fadeintime", 1 );
|
m_flFadeInTime = pKeyValue->GetFloat( "fadeintime", 1 );
|
||||||
m_flFadeHoldTime = pKeyValue->GetFloat( "fadeholdtime", 3 );
|
m_flFadeHoldTime = pKeyValue->GetFloat( "fadeholdtime", 3 );
|
||||||
@ -249,6 +265,10 @@ void CHudCredits::ReadParams( KeyValues *pKeyValue )
|
|||||||
|
|
||||||
Q_strncpy( m_szLogo, pKeyValue->GetString( "logo", "HALF-LIFE'" ), sizeof( m_szLogo ) );
|
Q_strncpy( m_szLogo, pKeyValue->GetString( "logo", "HALF-LIFE'" ), sizeof( m_szLogo ) );
|
||||||
Q_strncpy( m_szLogo2, pKeyValue->GetString( "logo2", "" ), sizeof( m_szLogo2 ) );
|
Q_strncpy( m_szLogo2, pKeyValue->GetString( "logo2", "" ), sizeof( m_szLogo2 ) );
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
Q_strncpy( m_szLogoFont, pKeyValue->GetString( "logofont", "" ), sizeof( m_szLogoFont ) );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int CHudCredits::GetStringPixelWidth( wchar_t *pString, vgui::HFont hFont )
|
int CHudCredits::GetStringPixelWidth( wchar_t *pString, vgui::HFont hFont )
|
||||||
@ -296,9 +316,14 @@ void CHudCredits::DrawOutroCreditsName( void )
|
|||||||
|
|
||||||
Color cColor = m_TextColor;
|
Color cColor = m_TextColor;
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// Some lines should stick around and fade out
|
||||||
|
if ( i >= m_CreditsList.Count()-m_iEndLines )
|
||||||
|
#else
|
||||||
//HACKHACK
|
//HACKHACK
|
||||||
//Last one stays on screen and fades out
|
//Last one stays on screen and fades out
|
||||||
if ( i == m_CreditsList.Count()-1 )
|
if ( i == m_CreditsList.Count()-1 )
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
if ( m_bLastOneInPlace == false )
|
if ( m_bLastOneInPlace == false )
|
||||||
{
|
{
|
||||||
@ -418,6 +443,14 @@ void CHudCredits::DrawLogo( void )
|
|||||||
|
|
||||||
char szLogoFont[64];
|
char szLogoFont[64];
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
if (m_szLogoFont[0] != '\0')
|
||||||
|
{
|
||||||
|
// Custom logo font
|
||||||
|
Q_strncpy( szLogoFont, m_szLogoFont, sizeof( szLogoFont ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
if ( IsXbox() )
|
if ( IsXbox() )
|
||||||
{
|
{
|
||||||
Q_snprintf( szLogoFont, sizeof( szLogoFont ), "WeaponIcons_Small" );
|
Q_snprintf( szLogoFont, sizeof( szLogoFont ), "WeaponIcons_Small" );
|
||||||
@ -638,6 +671,20 @@ void CHudCredits::PrepareOutroCredits( void )
|
|||||||
|
|
||||||
int iHeight = iTall;
|
int iHeight = iTall;
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
if (m_iEndLines <= 0)
|
||||||
|
{
|
||||||
|
// We need a credit to fade out at the end so we know when the credits are done.
|
||||||
|
// Add a dummy credit to act as the "end line".
|
||||||
|
creditname_t DummyCredit;
|
||||||
|
V_strcpy_safe( DummyCredit.szCreditName, "");
|
||||||
|
V_strcpy_safe( DummyCredit.szFontName, "Default" );
|
||||||
|
|
||||||
|
m_CreditsList.AddToTail(DummyCredit);
|
||||||
|
m_iEndLines = 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
for ( int i = 0; i < m_CreditsList.Count(); i++ )
|
for ( int i = 0; i < m_CreditsList.Count(); i++ )
|
||||||
{
|
{
|
||||||
creditname_t *pCredit = &m_CreditsList[i];
|
creditname_t *pCredit = &m_CreditsList[i];
|
||||||
@ -706,6 +753,13 @@ void CHudCredits::MsgFunc_CreditsMsg( bf_read &msg )
|
|||||||
{
|
{
|
||||||
m_iCreditsType = msg.ReadByte();
|
m_iCreditsType = msg.ReadByte();
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
msg.ReadString(m_szCreditsFile, sizeof(m_szCreditsFile));
|
||||||
|
|
||||||
|
if (m_szCreditsFile[0] == '\0')
|
||||||
|
Q_strncpy(m_szCreditsFile, CREDITS_FILE, sizeof(m_szCreditsFile));
|
||||||
|
#endif
|
||||||
|
|
||||||
switch ( m_iCreditsType )
|
switch ( m_iCreditsType )
|
||||||
{
|
{
|
||||||
case CREDITS_LOGO:
|
case CREDITS_LOGO:
|
||||||
@ -729,7 +783,17 @@ void CHudCredits::MsgFunc_CreditsMsg( bf_read &msg )
|
|||||||
void CHudCredits::MsgFunc_LogoTimeMsg( bf_read &msg )
|
void CHudCredits::MsgFunc_LogoTimeMsg( bf_read &msg )
|
||||||
{
|
{
|
||||||
m_iCreditsType = CREDITS_LOGO;
|
m_iCreditsType = CREDITS_LOGO;
|
||||||
|
#ifdef MAPBASE
|
||||||
|
float flLogoTime = msg.ReadFloat();
|
||||||
|
msg.ReadString(m_szCreditsFile, sizeof(m_szCreditsFile));
|
||||||
|
|
||||||
|
if (m_szCreditsFile[0] == '\0')
|
||||||
|
Q_strncpy(m_szCreditsFile, CREDITS_FILE, sizeof(m_szCreditsFile));
|
||||||
|
|
||||||
|
PrepareLogo(flLogoTime);
|
||||||
|
#else
|
||||||
PrepareLogo( msg.ReadFloat() );
|
PrepareLogo( msg.ReadFloat() );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -104,12 +104,27 @@ void CHudSuitPower::OnThink( void )
|
|||||||
bool breatherActive = pPlayer->IsBreatherActive();
|
bool breatherActive = pPlayer->IsBreatherActive();
|
||||||
int activeDevices = (int)flashlightActive + (int)sprintActive + (int)breatherActive;
|
int activeDevices = (int)flashlightActive + (int)sprintActive + (int)breatherActive;
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
activeDevices += (int)pPlayer->IsCustomDevice0Active() + (int)pPlayer->IsCustomDevice1Active() + (int)pPlayer->IsCustomDevice2Active();
|
||||||
|
#endif
|
||||||
|
|
||||||
if (activeDevices != m_iActiveSuitDevices)
|
if (activeDevices != m_iActiveSuitDevices)
|
||||||
{
|
{
|
||||||
m_iActiveSuitDevices = activeDevices;
|
m_iActiveSuitDevices = activeDevices;
|
||||||
|
|
||||||
switch ( m_iActiveSuitDevices )
|
switch ( m_iActiveSuitDevices )
|
||||||
{
|
{
|
||||||
|
#ifdef MAPBASE
|
||||||
|
case 6:
|
||||||
|
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("SuitAuxPowerSixItemsActive");
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("SuitAuxPowerFiveItemsActive");
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("SuitAuxPowerFourItemsActive");
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
case 3:
|
case 3:
|
||||||
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("SuitAuxPowerThreeItemsActive");
|
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("SuitAuxPowerThreeItemsActive");
|
||||||
@ -251,6 +266,59 @@ void CHudSuitPower::Paint()
|
|||||||
}
|
}
|
||||||
ypos += text2_gap;
|
ypos += text2_gap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
if (pPlayer->IsCustomDevice0Active())
|
||||||
|
{
|
||||||
|
tempString = g_pVGuiLocalize->Find("#Mapbase_Hud_DEVICE0");
|
||||||
|
|
||||||
|
surface()->DrawSetTextPos(text2_xpos, ypos);
|
||||||
|
|
||||||
|
if (tempString)
|
||||||
|
{
|
||||||
|
surface()->DrawPrintText(tempString, wcslen(tempString));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
surface()->DrawPrintText(L"CUSTOM 0", wcslen(L"CUSTOM 0"));
|
||||||
|
}
|
||||||
|
ypos += text2_gap;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pPlayer->IsCustomDevice1Active())
|
||||||
|
{
|
||||||
|
tempString = g_pVGuiLocalize->Find("#Mapbase_Hud_DEVICE1");
|
||||||
|
|
||||||
|
surface()->DrawSetTextPos(text2_xpos, ypos);
|
||||||
|
|
||||||
|
if (tempString)
|
||||||
|
{
|
||||||
|
surface()->DrawPrintText(tempString, wcslen(tempString));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
surface()->DrawPrintText(L"CUSTOM 1", wcslen(L"CUSTOM 1"));
|
||||||
|
}
|
||||||
|
ypos += text2_gap;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pPlayer->IsCustomDevice2Active())
|
||||||
|
{
|
||||||
|
tempString = g_pVGuiLocalize->Find("#Mapbase_Hud_DEVICE2");
|
||||||
|
|
||||||
|
surface()->DrawSetTextPos(text2_xpos, ypos);
|
||||||
|
|
||||||
|
if (tempString)
|
||||||
|
{
|
||||||
|
surface()->DrawPrintText(tempString, wcslen(tempString));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
surface()->DrawPrintText(L"CUSTOM 2", wcslen(L"CUSTOM 2"));
|
||||||
|
}
|
||||||
|
ypos += text2_gap;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,10 +134,13 @@ void LoadHudTextures( CUtlDict< CHudTexture *, int >& list, const char *szFilena
|
|||||||
pTemp = pTemp->GetNextKey();
|
pTemp = pTemp->GetNextKey();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Failed for some reason. Delete the Key data and abort.
|
pKeyValuesData->deleteThis();
|
||||||
pKeyValuesData->deleteThis();
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Warning( "Unable to read script %s.\n", szFilenameWithoutExtension );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -469,6 +472,8 @@ void CHud::Init( void )
|
|||||||
}
|
}
|
||||||
|
|
||||||
FreeHudTextureList( textureList );
|
FreeHudTextureList( textureList );
|
||||||
|
|
||||||
|
HudIcons().Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -1197,3 +1202,232 @@ CON_COMMAND_F( testhudanim, "Test a hud element animation.\n\tArguments: <anim n
|
|||||||
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( args[1] );
|
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( args[1] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CHudIcons::CHudIcons() :
|
||||||
|
m_bHudTexturesLoaded( false )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
CHudIcons::~CHudIcons()
|
||||||
|
{
|
||||||
|
int c = m_Icons.Count();
|
||||||
|
for ( int i = c - 1; i >= 0; i-- )
|
||||||
|
{
|
||||||
|
CHudTexture *tex = m_Icons[ i ];
|
||||||
|
g_HudTextureMemoryPool.Free( tex );
|
||||||
|
}
|
||||||
|
m_Icons.Purge();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CHudIcons::Init()
|
||||||
|
{
|
||||||
|
if ( m_bHudTexturesLoaded )
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_bHudTexturesLoaded = true;
|
||||||
|
CUtlDict< CHudTexture *, int > textureList;
|
||||||
|
|
||||||
|
// check to see if we have sprites for this res; if not, step down
|
||||||
|
LoadHudTextures( textureList, "scripts/hud_textures", NULL );
|
||||||
|
LoadHudTextures( textureList, "scripts/mod_textures", NULL );
|
||||||
|
|
||||||
|
LoadHudTextures( textureList, "scripts/instructor_textures", NULL );
|
||||||
|
#ifdef HL2_CLIENT_DLL
|
||||||
|
LoadHudTextures( textureList, "scripts/instructor_textures_hl2", NULL );
|
||||||
|
#endif
|
||||||
|
LoadHudTextures( textureList, "scripts/instructor_modtextures", NULL );
|
||||||
|
|
||||||
|
int c = textureList.Count();
|
||||||
|
for ( int index = 0; index < c; index++ )
|
||||||
|
{
|
||||||
|
CHudTexture* tex = textureList[ index ];
|
||||||
|
AddSearchableHudIconToList( *tex );
|
||||||
|
}
|
||||||
|
|
||||||
|
FreeHudTextureList( textureList );
|
||||||
|
}
|
||||||
|
|
||||||
|
void CHudIcons::Shutdown()
|
||||||
|
{
|
||||||
|
m_bHudTexturesLoaded = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
CHudTexture *CHudIcons::AddUnsearchableHudIconToList( CHudTexture& texture )
|
||||||
|
{
|
||||||
|
// These names are composed based on the texture file name
|
||||||
|
char composedName[ 512 ];
|
||||||
|
|
||||||
|
if ( texture.bRenderUsingFont )
|
||||||
|
{
|
||||||
|
Q_snprintf( composedName, sizeof( composedName ), "%s_c%i",
|
||||||
|
texture.szTextureFile, texture.cCharacterInFont );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Q_snprintf( composedName, sizeof( composedName ), "%s_%i_%i_%i_%i",
|
||||||
|
texture.szTextureFile, texture.rc.left, texture.rc.top, texture.rc.right, texture.rc.bottom );
|
||||||
|
}
|
||||||
|
|
||||||
|
CHudTexture *icon = GetIcon( composedName );
|
||||||
|
if ( icon )
|
||||||
|
{
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
CHudTexture *newTexture = ( CHudTexture * )g_HudTextureMemoryPool.Alloc();
|
||||||
|
*newTexture = texture;
|
||||||
|
|
||||||
|
SetupNewHudTexture( newTexture );
|
||||||
|
|
||||||
|
int idx = m_Icons.Insert( composedName, newTexture );
|
||||||
|
return m_Icons[ idx ];
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
CHudTexture *CHudIcons::AddSearchableHudIconToList( CHudTexture& texture )
|
||||||
|
{
|
||||||
|
CHudTexture *icon = GetIcon( texture.szShortName );
|
||||||
|
if ( icon )
|
||||||
|
{
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
CHudTexture *newTexture = ( CHudTexture * )g_HudTextureMemoryPool.Alloc();
|
||||||
|
*newTexture = texture;
|
||||||
|
|
||||||
|
SetupNewHudTexture( newTexture );
|
||||||
|
|
||||||
|
int idx = m_Icons.Insert( texture.szShortName, newTexture );
|
||||||
|
return m_Icons[ idx ];
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: returns a pointer to an icon in the list
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
CHudTexture *CHudIcons::GetIcon( const char *szIcon )
|
||||||
|
{
|
||||||
|
int i = m_Icons.Find( szIcon );
|
||||||
|
if ( i == m_Icons.InvalidIndex() )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return m_Icons[ i ];
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: Gets texture handles for the hud icon
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void CHudIcons::SetupNewHudTexture( CHudTexture *t )
|
||||||
|
{
|
||||||
|
if ( t->bRenderUsingFont )
|
||||||
|
{
|
||||||
|
vgui::HScheme scheme = vgui::scheme()->GetScheme( "ClientScheme" );
|
||||||
|
t->hFont = vgui::scheme()->GetIScheme(scheme)->GetFont( t->szTextureFile, true );
|
||||||
|
t->rc.top = 0;
|
||||||
|
t->rc.left = 0;
|
||||||
|
t->rc.right = vgui::surface()->GetCharacterWidth( t->hFont, t->cCharacterInFont );
|
||||||
|
t->rc.bottom = vgui::surface()->GetFontTall( t->hFont );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Set up texture id and texture coordinates
|
||||||
|
t->textureId = vgui::surface()->CreateNewTextureID();
|
||||||
|
vgui::surface()->DrawSetTextureFile( t->textureId, t->szTextureFile, false, false );
|
||||||
|
|
||||||
|
int wide, tall;
|
||||||
|
vgui::surface()->DrawGetTextureSize( t->textureId, wide, tall );
|
||||||
|
|
||||||
|
t->texCoords[ 0 ] = (float)(t->rc.left + 0.5f) / (float)wide;
|
||||||
|
t->texCoords[ 1 ] = (float)(t->rc.top + 0.5f) / (float)tall;
|
||||||
|
t->texCoords[ 2 ] = (float)(t->rc.right - 0.5f) / (float)wide;
|
||||||
|
t->texCoords[ 3 ] = (float)(t->rc.bottom - 0.5f) / (float)tall;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void CHudIcons::RefreshHudTextures()
|
||||||
|
{
|
||||||
|
if ( !m_bHudTexturesLoaded )
|
||||||
|
{
|
||||||
|
Assert( 0 );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CUtlDict< CHudTexture *, int > textureList;
|
||||||
|
|
||||||
|
// check to see if we have sprites for this res; if not, step down
|
||||||
|
LoadHudTextures( textureList, "scripts/hud_textures", NULL );
|
||||||
|
LoadHudTextures( textureList, "scripts/mod_textures", NULL );
|
||||||
|
|
||||||
|
LoadHudTextures( textureList, "scripts/instructor_textures", NULL );
|
||||||
|
|
||||||
|
|
||||||
|
// fix up all the texture icons first
|
||||||
|
int c = textureList.Count();
|
||||||
|
for ( int index = 0; index < c; index++ )
|
||||||
|
{
|
||||||
|
CHudTexture *tex = textureList[ index ];
|
||||||
|
Assert( tex );
|
||||||
|
|
||||||
|
CHudTexture *icon = GetIcon( tex->szShortName );
|
||||||
|
if ( !icon )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Update file
|
||||||
|
Q_strncpy( icon->szTextureFile, tex->szTextureFile, sizeof( icon->szTextureFile ) );
|
||||||
|
|
||||||
|
if ( !icon->bRenderUsingFont )
|
||||||
|
{
|
||||||
|
// Update subrect
|
||||||
|
icon->rc = tex->rc;
|
||||||
|
|
||||||
|
// Keep existing texture id, but now update texture file and texture coordinates
|
||||||
|
vgui::surface()->DrawSetTextureFile( icon->textureId, icon->szTextureFile, false, false );
|
||||||
|
|
||||||
|
// Get new texture dimensions in case it changed
|
||||||
|
int wide, tall;
|
||||||
|
vgui::surface()->DrawGetTextureSize( icon->textureId, wide, tall );
|
||||||
|
|
||||||
|
// Assign coords
|
||||||
|
icon->texCoords[ 0 ] = (float)(icon->rc.left + 0.5f) / (float)wide;
|
||||||
|
icon->texCoords[ 1 ] = (float)(icon->rc.top + 0.5f) / (float)tall;
|
||||||
|
icon->texCoords[ 2 ] = (float)(icon->rc.right - 0.5f) / (float)wide;
|
||||||
|
icon->texCoords[ 3 ] = (float)(icon->rc.bottom - 0.5f) / (float)tall;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FreeHudTextureList( textureList );
|
||||||
|
|
||||||
|
// fixup all the font icons
|
||||||
|
vgui::HScheme scheme = vgui::scheme()->GetScheme( "ClientScheme" );
|
||||||
|
for (int i = m_Icons.First(); m_Icons.IsValidIndex(i); i = m_Icons.Next(i))
|
||||||
|
{
|
||||||
|
CHudTexture *icon = m_Icons[i];
|
||||||
|
if ( !icon )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Update file
|
||||||
|
if ( icon->bRenderUsingFont )
|
||||||
|
{
|
||||||
|
icon->hFont = vgui::scheme()->GetIScheme(scheme)->GetFont( icon->szTextureFile, true );
|
||||||
|
icon->rc.top = 0;
|
||||||
|
icon->rc.left = 0;
|
||||||
|
icon->rc.right = vgui::surface()->GetCharacterWidth( icon->hFont, icon->cCharacterInFont );
|
||||||
|
icon->rc.bottom = vgui::surface()->GetFontTall( icon->hFont );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static CHudIcons g_HudIcons;
|
||||||
|
|
||||||
|
CHudIcons &HudIcons()
|
||||||
|
{
|
||||||
|
return g_HudIcons;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -194,6 +194,37 @@ private:
|
|||||||
|
|
||||||
extern CHud gHUD;
|
extern CHud gHUD;
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: CHudIcons
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
class CHudIcons
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CHudIcons();
|
||||||
|
~CHudIcons();
|
||||||
|
|
||||||
|
void Init();
|
||||||
|
void Shutdown();
|
||||||
|
|
||||||
|
CHudTexture *GetIcon( const char *szIcon );
|
||||||
|
|
||||||
|
// loads a new icon into the list, without duplicates
|
||||||
|
CHudTexture *AddUnsearchableHudIconToList( CHudTexture& texture );
|
||||||
|
CHudTexture *AddSearchableHudIconToList( CHudTexture& texture );
|
||||||
|
|
||||||
|
void RefreshHudTextures();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
void SetupNewHudTexture( CHudTexture *t );
|
||||||
|
bool m_bHudTexturesLoaded;
|
||||||
|
// Global list of known icons
|
||||||
|
CUtlDict< CHudTexture *, int > m_Icons;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
CHudIcons &HudIcons();
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Global fonts used in the client DLL
|
// Global fonts used in the client DLL
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -31,12 +31,20 @@
|
|||||||
extern ISoundEmitterSystemBase *soundemitterbase;
|
extern ISoundEmitterSystemBase *soundemitterbase;
|
||||||
|
|
||||||
// Marked as FCVAR_USERINFO so that the server can cull CC messages before networking them down to us!!!
|
// Marked as FCVAR_USERINFO so that the server can cull CC messages before networking them down to us!!!
|
||||||
|
#ifdef MAPBASE
|
||||||
|
ConVar closecaption( "closecaption", "1", FCVAR_ARCHIVE | FCVAR_ARCHIVE_XBOX | FCVAR_USERINFO, "Enable close captioning." );
|
||||||
|
#else
|
||||||
ConVar closecaption( "closecaption", "0", FCVAR_ARCHIVE | FCVAR_ARCHIVE_XBOX | FCVAR_USERINFO, "Enable close captioning." );
|
ConVar closecaption( "closecaption", "0", FCVAR_ARCHIVE | FCVAR_ARCHIVE_XBOX | FCVAR_USERINFO, "Enable close captioning." );
|
||||||
|
#endif
|
||||||
extern ConVar cc_lang;
|
extern ConVar cc_lang;
|
||||||
static ConVar cc_linger_time( "cc_linger_time", "1.0", FCVAR_ARCHIVE, "Close caption linger time." );
|
static ConVar cc_linger_time( "cc_linger_time", "1.0", FCVAR_ARCHIVE, "Close caption linger time." );
|
||||||
static ConVar cc_predisplay_time( "cc_predisplay_time", "0.25", FCVAR_ARCHIVE, "Close caption delay before showing caption." );
|
static ConVar cc_predisplay_time( "cc_predisplay_time", "0.25", FCVAR_ARCHIVE, "Close caption delay before showing caption." );
|
||||||
static ConVar cc_captiontrace( "cc_captiontrace", "1", 0, "Show missing closecaptions (0 = no, 1 = devconsole, 2 = show in hud)" );
|
static ConVar cc_captiontrace( "cc_captiontrace", "1", 0, "Show missing closecaptions (0 = no, 1 = devconsole, 2 = show in hud)" );
|
||||||
|
#ifdef MAPBASE
|
||||||
|
static ConVar cc_subtitles( "cc_subtitles", "1", FCVAR_ARCHIVE | FCVAR_ARCHIVE_XBOX, "If set, don't show sound effect captions, just voice overs (i.e., won't help hearing impaired players)." );
|
||||||
|
#else
|
||||||
static ConVar cc_subtitles( "cc_subtitles", "0", FCVAR_ARCHIVE | FCVAR_ARCHIVE_XBOX, "If set, don't show sound effect captions, just voice overs (i.e., won't help hearing impaired players)." );
|
static ConVar cc_subtitles( "cc_subtitles", "0", FCVAR_ARCHIVE | FCVAR_ARCHIVE_XBOX, "If set, don't show sound effect captions, just voice overs (i.e., won't help hearing impaired players)." );
|
||||||
|
#endif
|
||||||
ConVar english( "english", "1", FCVAR_USERINFO, "If set to 1, running the english language set of assets." );
|
ConVar english( "english", "1", FCVAR_USERINFO, "If set to 1, running the english language set of assets." );
|
||||||
static ConVar cc_smallfontlength( "cc_smallfontlength", "300", 0, "If text stream is this long, force usage of small font size." );
|
static ConVar cc_smallfontlength( "cc_smallfontlength", "300", 0, "If text stream is this long, force usage of small font size." );
|
||||||
|
|
||||||
@ -2357,11 +2365,11 @@ bool CHudCloseCaption::AddAsyncWork( const char *tokenstream, bool bIsStream, fl
|
|||||||
char tokenname[ 512 ];
|
char tokenname[ 512 ];
|
||||||
tokenname[ 0 ] = 0;
|
tokenname[ 0 ] = 0;
|
||||||
const char *p = tokenstream;
|
const char *p = tokenstream;
|
||||||
p = nexttoken( tokenname, p, ' ' );
|
p = nexttoken( tokenname, p, ' ' , sizeof(tokenname) );
|
||||||
// p points to reset of sentence tokens, build up a unicode string from them...
|
// p points to reset of sentence tokens, build up a unicode string from them...
|
||||||
while ( p && Q_strlen( tokenname ) > 0 )
|
while ( p && Q_strlen( tokenname ) > 0 )
|
||||||
{
|
{
|
||||||
p = nexttoken( tokenname, p, ' ' );
|
p = nexttoken( tokenname, p, ' ' , sizeof(tokenname) );
|
||||||
|
|
||||||
if ( Q_strlen( tokenname ) == 0 )
|
if ( Q_strlen( tokenname ) == 0 )
|
||||||
break;
|
break;
|
||||||
@ -2396,7 +2404,7 @@ void CHudCloseCaption::ProcessSentenceCaptionStream( const char *tokenstream )
|
|||||||
|
|
||||||
const char *p = tokenstream;
|
const char *p = tokenstream;
|
||||||
|
|
||||||
p = nexttoken( tokenname, p, ' ' );
|
p = nexttoken( tokenname, p, ' ' , sizeof(tokenname) );
|
||||||
|
|
||||||
if ( Q_strlen( tokenname ) > 0 )
|
if ( Q_strlen( tokenname ) > 0 )
|
||||||
{
|
{
|
||||||
@ -2693,6 +2701,11 @@ CON_COMMAND_F_COMPLETION( cc_emit, "Emits a closed caption", 0, EmitCaptionCompl
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef MAPBASE // 1upD
|
||||||
|
if (!closecaption.GetBool())
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
CHudCloseCaption *hudCloseCaption = GET_HUDELEMENT( CHudCloseCaption );
|
CHudCloseCaption *hudCloseCaption = GET_HUDELEMENT( CHudCloseCaption );
|
||||||
if ( hudCloseCaption )
|
if ( hudCloseCaption )
|
||||||
{
|
{
|
||||||
|
@ -599,10 +599,39 @@ bool CHudHintKeyDisplay::SetHintText( const char *text )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
const char *key = engine->Key_LookupBinding( *binding == '+' ? binding + 1 : binding );
|
const char *key = engine->Key_LookupBinding( *binding == '+' ? binding + 1 : binding );
|
||||||
|
#ifdef MAPBASE
|
||||||
|
if ( !key )
|
||||||
|
{
|
||||||
|
const char *pszNotBound = VarArgs("< %s, not bound >", *binding == '+' ? binding + 1 : binding);
|
||||||
|
if (strchr(binding, '&'))
|
||||||
|
{
|
||||||
|
// "%walk&use%" >> "ALT + E"
|
||||||
|
char *token = strtok(binding, "&");
|
||||||
|
while (token)
|
||||||
|
{
|
||||||
|
const char *tokenkey = engine->Key_LookupBinding( *token == '+' ? token + 1 : token );
|
||||||
|
|
||||||
|
key = VarArgs("%s%s%s", key ? key : "", key ? " + " : "", tokenkey ? tokenkey : pszNotBound);
|
||||||
|
|
||||||
|
token = strtok(NULL, "&");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (binding[0] == '$')
|
||||||
|
{
|
||||||
|
// "%$COOL STRING DUDE%" >> "COOL STRING DUDE"
|
||||||
|
key = binding + 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
key = pszNotBound;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
if ( !key )
|
if ( !key )
|
||||||
{
|
{
|
||||||
key = "< not bound >";
|
key = "< not bound >";
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
Q_snprintf( friendlyName, sizeof(friendlyName), "#%s", key );
|
Q_snprintf( friendlyName, sizeof(friendlyName), "#%s", key );
|
||||||
Q_strupr( friendlyName );
|
Q_strupr( friendlyName );
|
||||||
|
2207
mp/src/game/client/hud_locator_target.cpp
Normal file
2207
mp/src/game/client/hud_locator_target.cpp
Normal file
File diff suppressed because it is too large
Load Diff
184
mp/src/game/client/hud_locator_target.h
Normal file
184
mp/src/game/client/hud_locator_target.h
Normal file
@ -0,0 +1,184 @@
|
|||||||
|
//====== Copyright © 1996-2008, Valve Corporation, All rights reserved. =======
|
||||||
|
//
|
||||||
|
// Purpose: Add entities to this system, and the Locator will maintain an arrow
|
||||||
|
// on the HUD that points to the entities when they are offscreen.
|
||||||
|
//
|
||||||
|
//=============================================================================
|
||||||
|
|
||||||
|
#ifndef L4D_HUD_LOCATOR_H
|
||||||
|
#define L4D_HUD_LOCATOR_H
|
||||||
|
#ifdef _WIN32
|
||||||
|
#pragma once
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#include "vgui_controls/PHandle.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define MAX_LOCATOR_BINDINGS_SHOWN 8
|
||||||
|
#define MAX_LOCATOR_TARGETS 10
|
||||||
|
#define LOCATOR_FLAGS_NONE 0x00000000
|
||||||
|
|
||||||
|
#define LOCATOR_ICON_FX_NONE 0x00000000
|
||||||
|
#define LOCATOR_ICON_FX_PULSE_SLOW 0x00000001
|
||||||
|
#define LOCATOR_ICON_FX_PULSE_FAST 0x00000002
|
||||||
|
#define LOCATOR_ICON_FX_PULSE_URGENT 0x00000004
|
||||||
|
#define LOCATOR_ICON_FX_ALPHA_SLOW 0x00000008
|
||||||
|
#define LOCATOR_ICON_FX_ALPHA_FAST 0x00000010
|
||||||
|
#define LOCATOR_ICON_FX_ALPHA_URGENT 0x00000020
|
||||||
|
#define LOCATOR_ICON_FX_SHAKE_NARROW 0x00000040
|
||||||
|
#define LOCATOR_ICON_FX_SHAKE_WIDE 0x00000080
|
||||||
|
#define LOCATOR_ICON_FX_STATIC 0x00000100 // This icon draws at a fixed location on the HUD.
|
||||||
|
#define LOCATOR_ICON_FX_NO_OFFSCREEN 0x00000200
|
||||||
|
#define LOCATOR_ICON_FX_FORCE_CAPTION 0x00000400 // Always draw the caption, even when the icon is occluded.
|
||||||
|
#define LOCATOR_ICON_FX_FADE_OUT 0x00000800 // Set when deactivated so it can smoothly vanish
|
||||||
|
#define LOCATOR_ICON_FX_FADE_IN 0x00001000 // Set when activated so it can smoothly appear
|
||||||
|
|
||||||
|
#include "tier1/UtlSymbol.h"
|
||||||
|
|
||||||
|
// See comments in UtlSymbol on why this is useful
|
||||||
|
DECLARE_PRIVATE_SYMBOLTYPE( CGameInstructorSymbol );
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// This class represents a single target to be tracked by the locator
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
class CLocatorTarget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool m_bOriginInScreenspace;
|
||||||
|
Vector m_vecOrigin; // The location in the world to draw on the locator
|
||||||
|
|
||||||
|
// ONLY the locator panel should fiddle with these fields.
|
||||||
|
bool m_isActive;
|
||||||
|
int m_serialNumber;
|
||||||
|
int m_frameLastUpdated;
|
||||||
|
bool m_bOnscreen;
|
||||||
|
bool m_bOccluded;
|
||||||
|
bool m_bVisible;
|
||||||
|
bool m_bIsDrawing;
|
||||||
|
float m_distFromPlayer;
|
||||||
|
CHudTexture *m_pIcon_onscreen;
|
||||||
|
CHudTexture *m_pIcon_offscreen;
|
||||||
|
int m_iBindingTick;
|
||||||
|
float m_flNextBindingTick;
|
||||||
|
float m_flNextOcclusionTest;
|
||||||
|
int m_iBindingChoicesCount;
|
||||||
|
const char *(m_pchBindingChoices[ MAX_LOCATOR_BINDINGS_SHOWN ]);
|
||||||
|
int m_iBindChoicesOriginalToken[ MAX_LOCATOR_BINDINGS_SHOWN ];
|
||||||
|
|
||||||
|
// Fields for drawing
|
||||||
|
int m_targetX; // screen X position of the actual target
|
||||||
|
int m_targetY; // screen Y position of the actual target
|
||||||
|
int m_iconX; // screen X position (top)
|
||||||
|
int m_iconY; // screen Y position (left)
|
||||||
|
int m_centerX; // screen X position (center)
|
||||||
|
int m_centerY; // screen Y position (center)
|
||||||
|
int m_wide; // draw width of icon (may be different from frame to frame as the icon's size animates, for instance)
|
||||||
|
int m_tall; // draw height of icon '' ''
|
||||||
|
float m_widthScale_onscreen; // for icons that are wider than standard
|
||||||
|
int m_alpha; //
|
||||||
|
float m_fadeStart; // time stamp when fade out started
|
||||||
|
float m_lerpStart; // time stamp when lerping started
|
||||||
|
float m_pulseStart; // time stamp when pulsing started
|
||||||
|
int m_declutterIndex; // sort order from the declutterer
|
||||||
|
int m_lastDeclutterIndex; // last sort order from the declutterer
|
||||||
|
int m_drawArrowDirection; // Whether to draw an arrow indicating this target is off-screen, also tells us which arrow to draw (left, up, etc.)
|
||||||
|
int m_captionWide; // How wide (pixels) my caption is.
|
||||||
|
bool m_bDrawControllerButton;
|
||||||
|
bool m_bDrawControllerButtonOffscreen;
|
||||||
|
int m_offsetX; // User-specified X offset which is applied in screenspace
|
||||||
|
int m_offsetY; // User-specified Y offset which is applied in screenspace
|
||||||
|
|
||||||
|
// Fields for interpolating icon position
|
||||||
|
float m_flTimeLerpDone; // How much time left before this icon arrives where it is supposed to be.
|
||||||
|
int m_lastXPos; // screen X position last frame
|
||||||
|
int m_lastYPos; // '' Y
|
||||||
|
|
||||||
|
CLocatorTarget( void );
|
||||||
|
void Activate( int serialNumber );
|
||||||
|
void Deactivate( bool bNoFade = false );
|
||||||
|
void Update();
|
||||||
|
|
||||||
|
int GetIconX( void );
|
||||||
|
int GetIconY( void );
|
||||||
|
int GetIconCenterX( void );
|
||||||
|
int GetIconCenterY( void );
|
||||||
|
int GetIconWidth( void );
|
||||||
|
int GetIconHeight( void );
|
||||||
|
|
||||||
|
void AddIconEffects( int add ) { m_iEffectsFlags |= add; }
|
||||||
|
void RemoveIconEffects( int remove ) { m_iEffectsFlags &= ~remove; }
|
||||||
|
int GetIconEffectsFlags() { return m_iEffectsFlags; }
|
||||||
|
void SetCaptionColor( Color col ) { m_captionColor = col; }
|
||||||
|
void SetCaptionColor( const char *pszCaptionColor );
|
||||||
|
bool IsStatic();
|
||||||
|
bool IsPresenting();
|
||||||
|
void StartTimedLerp();
|
||||||
|
void StartPresent();
|
||||||
|
void EndPresent();
|
||||||
|
|
||||||
|
void UpdateVguiTarget( void );
|
||||||
|
vgui::Panel *GetVguiTarget( void );
|
||||||
|
void SetVguiTargetName( const char *pchVguiTargetName );
|
||||||
|
const char *GetVguiTargetName( void ) { return m_szVguiTargetName.String(); }
|
||||||
|
void SetVguiTargetLookup( const char *pchVguiTargetLookup );
|
||||||
|
const char *GetVguiTargetLookup( void ) { return m_szVguiTargetLookup.String(); }
|
||||||
|
void SetVguiTargetEdge( int nVguiEdge );
|
||||||
|
int GetVguiTargetEdge( void ) const { return m_nVguiTargetEdge; }
|
||||||
|
|
||||||
|
void SetOnscreenIconTextureName( const char *pszTexture );
|
||||||
|
void SetOffscreenIconTextureName( const char *pszTexture );
|
||||||
|
void SetBinding( const char *pszBinding );
|
||||||
|
const char *UseBindingImage( char *pchIconTextureName, size_t bufSize );
|
||||||
|
|
||||||
|
const char *GetOnscreenIconTextureName() { return m_szOnscreenTexture.String(); }
|
||||||
|
const char *GetOffscreenIconTextureName() { return m_szOffscreenTexture.String(); }
|
||||||
|
const char *GetBinding() { return m_szBinding.String(); }
|
||||||
|
|
||||||
|
void SetVisible( bool bVisible );
|
||||||
|
bool IsVisible( void );
|
||||||
|
|
||||||
|
void SetCaptionText( const char *pszText, const char *pszParam );
|
||||||
|
const wchar_t *GetCaptionText( void ) { return (const wchar_t *)m_wszCaption.Base(); }
|
||||||
|
bool HasCaptionText( void ) { return m_wszCaption.Count() > 1; }
|
||||||
|
|
||||||
|
void DrawBindingName( const char *pchDrawName ) { m_pchDrawBindingName = pchDrawName; }
|
||||||
|
void DrawBindingNameOffscreen( const char *pchDrawName ) { m_pchDrawBindingNameOffscreen = pchDrawName; }
|
||||||
|
|
||||||
|
const char *DrawBindingName( void ) { return m_pchDrawBindingName; }
|
||||||
|
const char *DrawBindingNameOffscreen( void ) { return m_pchDrawBindingNameOffscreen; }
|
||||||
|
|
||||||
|
bool IsOnScreen() { return m_bOnscreen; }
|
||||||
|
bool IsOccluded() { return m_bOccluded; }
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
CGameInstructorSymbol m_szVguiTargetName;
|
||||||
|
CGameInstructorSymbol m_szVguiTargetLookup;
|
||||||
|
vgui::DHANDLE<vgui::Panel> m_hVguiTarget;
|
||||||
|
int m_nVguiTargetEdge;
|
||||||
|
|
||||||
|
CGameInstructorSymbol m_szOnscreenTexture;
|
||||||
|
CGameInstructorSymbol m_szOffscreenTexture;
|
||||||
|
CGameInstructorSymbol m_szBinding;
|
||||||
|
|
||||||
|
bool m_bWasControllerLast;
|
||||||
|
const char *m_pchDrawBindingName;
|
||||||
|
const char *m_pchDrawBindingNameOffscreen;
|
||||||
|
int m_iEffectsFlags;
|
||||||
|
CUtlVector< wchar_t > m_wszCaption;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Color m_captionColor;
|
||||||
|
#ifdef MAPBASE
|
||||||
|
Color m_bindingColor;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
extern int Locator_AddTarget();
|
||||||
|
extern void Locator_RemoveTarget( int hTarget );
|
||||||
|
CLocatorTarget *Locator_GetTargetFromHandle( int hTarget );
|
||||||
|
void Locator_ComputeTargetIconPositionFromHandle( int hTarget );
|
||||||
|
|
||||||
|
|
||||||
|
#endif // L4D_HUD_LOCATOR_H
|
@ -97,6 +97,15 @@ public:
|
|||||||
// Set flashlight light world flag
|
// Set flashlight light world flag
|
||||||
virtual void SetFlashlightLightWorld( ClientShadowHandle_t shadowHandle, bool bLightWorld ) = 0;
|
virtual void SetFlashlightLightWorld( ClientShadowHandle_t shadowHandle, bool bLightWorld ) = 0;
|
||||||
|
|
||||||
|
#ifdef ASW_PROJECTED_TEXTURES
|
||||||
|
virtual void GetFrustumExtents( ClientShadowHandle_t handle, Vector &vecMin, Vector &vecMax ) = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef DYNAMIC_RTT_SHADOWS
|
||||||
|
// Toggle shadow casting from world light sources
|
||||||
|
virtual void SetShadowFromWorldLightsEnabled( bool bEnable ) = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
virtual void SetShadowsDisabled( bool bDisabled ) = 0;
|
virtual void SetShadowsDisabled( bool bDisabled ) = 0;
|
||||||
|
|
||||||
virtual void ComputeShadowDepthTextures( const CViewSetup &pView ) = 0;
|
virtual void ComputeShadowDepthTextures( const CViewSetup &pView ) = 0;
|
||||||
|
@ -1219,6 +1219,9 @@ void CInput::CreateMove ( int sequence_number, float input_sample_frametime, boo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Let the move manager override anything it wants to.
|
// Let the move manager override anything it wants to.
|
||||||
|
#ifdef VGUI_SCREEN_FIX
|
||||||
|
cmd->buttons |= IN_VALIDVGUIINPUT;
|
||||||
|
#endif
|
||||||
if ( g_pClientMode->CreateMove( input_sample_frametime, cmd ) )
|
if ( g_pClientMode->CreateMove( input_sample_frametime, cmd ) )
|
||||||
{
|
{
|
||||||
// Get current view angles after the client mode tweaks with it
|
// Get current view angles after the client mode tweaks with it
|
||||||
|
93
mp/src/game/client/mapbase/c_func_clientclip.cpp
Normal file
93
mp/src/game/client/mapbase/c_func_clientclip.cpp
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
|
||||||
|
//
|
||||||
|
// Purpose:
|
||||||
|
//
|
||||||
|
//===========================================================================//
|
||||||
|
|
||||||
|
#include "cbase.h"
|
||||||
|
|
||||||
|
// memdbgon must be the last include file in a .cpp file!!!
|
||||||
|
#include "tier0/memdbgon.h"
|
||||||
|
|
||||||
|
|
||||||
|
class C_FuncClientClip : public C_BaseEntity
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DECLARE_CLASS( C_FuncClientClip, C_BaseEntity );
|
||||||
|
DECLARE_CLIENTCLASS();
|
||||||
|
|
||||||
|
void OnDataChanged( DataUpdateType_t type );
|
||||||
|
void ClientThink();
|
||||||
|
bool TestCollision( const Ray_t &ray, unsigned int mask, trace_t& trace );
|
||||||
|
|
||||||
|
bool m_bDisabled;
|
||||||
|
};
|
||||||
|
|
||||||
|
IMPLEMENT_CLIENTCLASS_DT( C_FuncClientClip, DT_FuncClientClip, CFuncClientClip )
|
||||||
|
RecvPropBool( RECVINFO( m_bDisabled ) ),
|
||||||
|
END_RECV_TABLE()
|
||||||
|
|
||||||
|
void C_FuncClientClip::OnDataChanged( DataUpdateType_t type )
|
||||||
|
{
|
||||||
|
BaseClass::OnDataChanged( type );
|
||||||
|
|
||||||
|
//if ( type == DATA_UPDATE_CREATED )
|
||||||
|
//{
|
||||||
|
SetSolid(GetMoveParent() ? SOLID_VPHYSICS : SOLID_BSP); // SOLID_VPHYSICS
|
||||||
|
//}
|
||||||
|
|
||||||
|
if ( !m_bDisabled )
|
||||||
|
{
|
||||||
|
VPhysicsDestroyObject();
|
||||||
|
VPhysicsInitShadow( true, true );
|
||||||
|
|
||||||
|
// Think constantly updates the shadow
|
||||||
|
if (GetMoveParent())
|
||||||
|
SetNextClientThink( CLIENT_THINK_ALWAYS );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Disabling
|
||||||
|
VPhysicsDestroyObject();
|
||||||
|
SetNextClientThink( CLIENT_THINK_NEVER );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void C_FuncClientClip::ClientThink()
|
||||||
|
{
|
||||||
|
// We shouldn't be thinking if we're disabled
|
||||||
|
Assert(!m_bDisabled);
|
||||||
|
|
||||||
|
if (VPhysicsGetObject())
|
||||||
|
{
|
||||||
|
// Constantly updates the shadow.
|
||||||
|
// This think function should really only be active when we're parented.
|
||||||
|
VPhysicsGetObject()->UpdateShadow( GetAbsOrigin(), GetAbsAngles(), false, TICK_INTERVAL );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// This should never happen...
|
||||||
|
VPhysicsInitShadow( true, true );
|
||||||
|
}
|
||||||
|
|
||||||
|
BaseClass::ClientThink();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool C_FuncClientClip::TestCollision( const Ray_t &ray, unsigned int mask, trace_t& trace )
|
||||||
|
{
|
||||||
|
if ( m_bDisabled )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if ( !VPhysicsGetObject() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
physcollision->TraceBox( ray, VPhysicsGetObject()->GetCollide(), GetAbsOrigin(), GetAbsAngles(), &trace );
|
||||||
|
|
||||||
|
if ( trace.DidHit() )
|
||||||
|
{
|
||||||
|
trace.surface.surfaceProps = VPhysicsGetObject()->GetMaterialIndex();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
226
mp/src/game/client/mapbase/c_func_fake_worldportal.cpp
Normal file
226
mp/src/game/client/mapbase/c_func_fake_worldportal.cpp
Normal file
@ -0,0 +1,226 @@
|
|||||||
|
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
|
||||||
|
//
|
||||||
|
// Purpose: Recreates Portal 2 linked_portal_door functionality using SDK code only.
|
||||||
|
// (basically a combination of point_camera and func_reflective_glass)
|
||||||
|
//
|
||||||
|
// $NoKeywords: $
|
||||||
|
//===========================================================================//
|
||||||
|
#include "cbase.h"
|
||||||
|
#include "view_shared.h"
|
||||||
|
#include "viewrender.h"
|
||||||
|
#include "c_func_fake_worldportal.h"
|
||||||
|
|
||||||
|
// memdbgon must be the last include file in a .cpp file!!!
|
||||||
|
#include "tier0/memdbgon.h"
|
||||||
|
|
||||||
|
IMPLEMENT_CLIENTCLASS_DT( C_FuncFakeWorldPortal, DT_FuncFakeWorldPortal, CFuncFakeWorldPortal )
|
||||||
|
|
||||||
|
RecvPropEHandle( RECVINFO( m_hTargetPlane ) ),
|
||||||
|
RecvPropVector( RECVINFO( m_PlaneAngles ) ),
|
||||||
|
RecvPropInt( RECVINFO( m_iSkyMode ) ),
|
||||||
|
RecvPropFloat( RECVINFO( m_flScale ) ),
|
||||||
|
RecvPropString( RECVINFO( m_iszRenderTarget ) ),
|
||||||
|
RecvPropEHandle( RECVINFO( m_hFogController ) ),
|
||||||
|
|
||||||
|
END_RECV_TABLE()
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Globals
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
C_EntityClassList<C_FuncFakeWorldPortal> g_FakeWorldPortalList;
|
||||||
|
template<> C_FuncFakeWorldPortal *C_EntityClassList<C_FuncFakeWorldPortal>::m_pClassList = NULL;
|
||||||
|
|
||||||
|
C_FuncFakeWorldPortal* GetFakeWorldPortalList()
|
||||||
|
{
|
||||||
|
return g_FakeWorldPortalList.m_pClassList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Constructor, destructor
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
C_FuncFakeWorldPortal::C_FuncFakeWorldPortal()
|
||||||
|
{
|
||||||
|
m_iszRenderTarget[0] = '\0';
|
||||||
|
|
||||||
|
g_FakeWorldPortalList.Insert( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
C_FuncFakeWorldPortal::~C_FuncFakeWorldPortal()
|
||||||
|
{
|
||||||
|
g_FakeWorldPortalList.Remove( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool C_FuncFakeWorldPortal::ShouldDraw()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Do we have a fake world portal in view?
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
C_FuncFakeWorldPortal *IsFakeWorldPortalInView( const CViewSetup& view, cplane_t &plane )
|
||||||
|
{
|
||||||
|
// Early out if no cameras
|
||||||
|
C_FuncFakeWorldPortal *pReflectiveGlass = GetFakeWorldPortalList();
|
||||||
|
if ( !pReflectiveGlass )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
Frustum_t frustum;
|
||||||
|
GeneratePerspectiveFrustum( view.origin, view.angles, view.zNear, view.zFar, view.fov, view.m_flAspectRatio, frustum );
|
||||||
|
|
||||||
|
cplane_t localPlane;
|
||||||
|
Vector vecOrigin, vecWorld, vecDelta, vecForward;
|
||||||
|
AngleVectors( view.angles, &vecForward, NULL, NULL );
|
||||||
|
|
||||||
|
for ( ; pReflectiveGlass != NULL; pReflectiveGlass = pReflectiveGlass->m_pNext )
|
||||||
|
{
|
||||||
|
if ( pReflectiveGlass->IsDormant() )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if ( pReflectiveGlass->m_iViewHideFlags & (1 << CurrentViewID()) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Vector vecMins, vecMaxs;
|
||||||
|
pReflectiveGlass->GetRenderBoundsWorldspace( vecMins, vecMaxs );
|
||||||
|
if ( R_CullBox( vecMins, vecMaxs, frustum ) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const model_t *pModel = pReflectiveGlass->GetModel();
|
||||||
|
const matrix3x4_t& mat = pReflectiveGlass->EntityToWorldTransform();
|
||||||
|
|
||||||
|
int nCount = modelinfo->GetBrushModelPlaneCount( pModel );
|
||||||
|
for ( int i = 0; i < nCount; ++i )
|
||||||
|
{
|
||||||
|
modelinfo->GetBrushModelPlane( pModel, i, localPlane, &vecOrigin );
|
||||||
|
|
||||||
|
MatrixTransformPlane( mat, localPlane, plane ); // Transform to world space
|
||||||
|
VectorTransform( vecOrigin, mat, vecWorld );
|
||||||
|
|
||||||
|
if ( view.origin.Dot( plane.normal ) <= plane.dist ) // Check for view behind plane
|
||||||
|
continue;
|
||||||
|
|
||||||
|
VectorSubtract( vecWorld, view.origin, vecDelta ); // Backface cull
|
||||||
|
if ( vecDelta.Dot( plane.normal ) >= 0 )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Must have valid plane
|
||||||
|
if ( !pReflectiveGlass->m_hTargetPlane )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
return pReflectiveGlass;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Iterates through fake world portals instead of just picking one
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
C_FuncFakeWorldPortal *NextFakeWorldPortal( C_FuncFakeWorldPortal *pStart, const CViewSetup& view, cplane_t &plane,
|
||||||
|
const Frustum_t &frustum )
|
||||||
|
{
|
||||||
|
// Early out if no cameras
|
||||||
|
C_FuncFakeWorldPortal *pReflectiveGlass = NULL;
|
||||||
|
if (!pStart)
|
||||||
|
pReflectiveGlass = GetFakeWorldPortalList();
|
||||||
|
else
|
||||||
|
pReflectiveGlass = pStart->m_pNext;
|
||||||
|
|
||||||
|
cplane_t localPlane;
|
||||||
|
Vector vecOrigin, vecWorld, vecDelta;
|
||||||
|
for ( ; pReflectiveGlass != NULL; pReflectiveGlass = pReflectiveGlass->m_pNext )
|
||||||
|
{
|
||||||
|
if ( pReflectiveGlass->IsDormant() )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if ( pReflectiveGlass->m_iViewHideFlags & (1 << CurrentViewID()) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Vector vecMins, vecMaxs;
|
||||||
|
pReflectiveGlass->GetRenderBoundsWorldspace( vecMins, vecMaxs );
|
||||||
|
if ( R_CullBox( vecMins, vecMaxs, frustum ) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const model_t *pModel = pReflectiveGlass->GetModel();
|
||||||
|
const matrix3x4_t& mat = pReflectiveGlass->EntityToWorldTransform();
|
||||||
|
|
||||||
|
int nCount = modelinfo->GetBrushModelPlaneCount( pModel );
|
||||||
|
for ( int i = 0; i < nCount; ++i )
|
||||||
|
{
|
||||||
|
modelinfo->GetBrushModelPlane( pModel, i, localPlane, &vecOrigin );
|
||||||
|
|
||||||
|
MatrixTransformPlane( mat, localPlane, plane ); // Transform to world space
|
||||||
|
VectorTransform( vecOrigin, mat, vecWorld );
|
||||||
|
|
||||||
|
if ( view.origin.Dot( plane.normal ) <= plane.dist ) // Check for view behind plane
|
||||||
|
continue;
|
||||||
|
|
||||||
|
VectorSubtract( vecWorld, view.origin, vecDelta ); // Backface cull
|
||||||
|
if ( vecDelta.Dot( plane.normal ) >= 0 )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Must have valid plane
|
||||||
|
if ( !pReflectiveGlass->m_hTargetPlane )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
return pReflectiveGlass;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void C_FuncFakeWorldPortal::OnDataChanged( DataUpdateType_t type )
|
||||||
|
{
|
||||||
|
// Reset render texture
|
||||||
|
m_pRenderTarget = NULL;
|
||||||
|
|
||||||
|
// Reset fog
|
||||||
|
m_pFog = NULL;
|
||||||
|
|
||||||
|
return BaseClass::OnDataChanged( type );
|
||||||
|
}
|
||||||
|
|
||||||
|
extern ITexture *GetWaterReflectionTexture( void );
|
||||||
|
|
||||||
|
ITexture *C_FuncFakeWorldPortal::RenderTarget()
|
||||||
|
{
|
||||||
|
if (m_iszRenderTarget[0] != '\0')
|
||||||
|
{
|
||||||
|
if (!m_pRenderTarget)
|
||||||
|
{
|
||||||
|
// We don't use a CTextureReference for this because we don't want to shut down the texture on removal/change
|
||||||
|
m_pRenderTarget = materials->FindTexture( m_iszRenderTarget, TEXTURE_GROUP_RENDER_TARGET );
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_pRenderTarget)
|
||||||
|
return m_pRenderTarget;
|
||||||
|
}
|
||||||
|
|
||||||
|
return GetWaterReflectionTexture();
|
||||||
|
}
|
||||||
|
|
||||||
|
fogparams_t *C_FuncFakeWorldPortal::GetFog()
|
||||||
|
{
|
||||||
|
if (m_pFog)
|
||||||
|
return m_pFog;
|
||||||
|
|
||||||
|
if (m_hFogController)
|
||||||
|
{
|
||||||
|
C_FogController *pFogController = dynamic_cast<C_FogController*>(m_hFogController.Get());
|
||||||
|
if (pFogController)
|
||||||
|
{
|
||||||
|
m_pFog = &pFogController->m_fog;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Warning("%s is not an env_fog_controller\n", m_hFogController->GetEntityName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
64
mp/src/game/client/mapbase/c_func_fake_worldportal.h
Normal file
64
mp/src/game/client/mapbase/c_func_fake_worldportal.h
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
|
||||||
|
//
|
||||||
|
// Purpose: Recreates Portal 2 linked_portal_door functionality using SDK code only.
|
||||||
|
// (basically a combination of point_camera and func_reflective_glass)
|
||||||
|
//
|
||||||
|
// $NoKeywords: $
|
||||||
|
//===========================================================================//
|
||||||
|
|
||||||
|
#ifndef C_FUNC_FAKE_WORLDPORTAL
|
||||||
|
#define C_FUNC_FAKE_WORLDPORTAL
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#pragma once
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct cplane_t;
|
||||||
|
class CViewSetup;
|
||||||
|
|
||||||
|
class C_FuncFakeWorldPortal : public C_BaseEntity
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DECLARE_CLASS( C_FuncFakeWorldPortal, C_BaseEntity );
|
||||||
|
DECLARE_CLIENTCLASS();
|
||||||
|
|
||||||
|
C_FuncFakeWorldPortal();
|
||||||
|
virtual ~C_FuncFakeWorldPortal();
|
||||||
|
|
||||||
|
virtual bool ShouldDraw();
|
||||||
|
virtual void OnDataChanged( DataUpdateType_t type );
|
||||||
|
|
||||||
|
SkyboxVisibility_t SkyMode() { return m_iSkyMode; }
|
||||||
|
|
||||||
|
ITexture *RenderTarget();
|
||||||
|
|
||||||
|
fogparams_t *GetFog();
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
EHANDLE m_hTargetPlane;
|
||||||
|
QAngle m_PlaneAngles;
|
||||||
|
SkyboxVisibility_t m_iSkyMode;
|
||||||
|
float m_flScale;
|
||||||
|
|
||||||
|
EHANDLE m_hFogController;
|
||||||
|
fogparams_t *m_pFog;
|
||||||
|
|
||||||
|
char m_iszRenderTarget[64];
|
||||||
|
ITexture *m_pRenderTarget;
|
||||||
|
|
||||||
|
C_FuncFakeWorldPortal *m_pNext;
|
||||||
|
};
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Do we have reflective glass in view? If so, what's the reflection plane?
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
C_FuncFakeWorldPortal *IsFakeWorldPortalInView( const CViewSetup& view, cplane_t &plane );
|
||||||
|
|
||||||
|
C_FuncFakeWorldPortal *NextFakeWorldPortal( C_FuncFakeWorldPortal *pStart, const CViewSetup& view, cplane_t &plane,
|
||||||
|
const Frustum_t &frustum );
|
||||||
|
|
||||||
|
|
||||||
|
#endif // C_FUNC_FAKE_WORLDPORTAL
|
||||||
|
|
||||||
|
|
103
mp/src/game/client/mapbase/c_point_glow.cpp
Normal file
103
mp/src/game/client/mapbase/c_point_glow.cpp
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============//
|
||||||
|
//
|
||||||
|
// Purpose: Mapbase off-shoot of tf_glow (created using SDK code only)
|
||||||
|
//
|
||||||
|
//===========================================================================//
|
||||||
|
|
||||||
|
#include "cbase.h"
|
||||||
|
#include "glow_outline_effect.h"
|
||||||
|
|
||||||
|
// memdbgon must be the last include file in a .cpp file!!!
|
||||||
|
#include "tier0/memdbgon.h"
|
||||||
|
|
||||||
|
|
||||||
|
class C_PointGlow : public C_BaseEntity
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DECLARE_CLASS( C_PointGlow, C_BaseEntity );
|
||||||
|
DECLARE_CLIENTCLASS();
|
||||||
|
|
||||||
|
~C_PointGlow();
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
GLOW_VIS_ALWAYS,
|
||||||
|
GLOW_VIS_NOT_WHEN_VISIBLE,
|
||||||
|
GLOW_VIS_ONLY_WHEN_VISIBLE,
|
||||||
|
};
|
||||||
|
|
||||||
|
void OnDataChanged( DataUpdateType_t type );
|
||||||
|
|
||||||
|
CGlowObject *GetGlowObject( void ){ return m_pGlowEffect; }
|
||||||
|
void UpdateGlowEffect( void );
|
||||||
|
void DestroyGlowEffect( void );
|
||||||
|
|
||||||
|
EHANDLE m_hGlowTarget;
|
||||||
|
color32 m_GlowColor;
|
||||||
|
|
||||||
|
bool m_bGlowDisabled;
|
||||||
|
CGlowObject *m_pGlowEffect;
|
||||||
|
};
|
||||||
|
|
||||||
|
IMPLEMENT_CLIENTCLASS_DT( C_PointGlow, DT_PointGlow, CPointGlow )
|
||||||
|
RecvPropEHandle( RECVINFO( m_hGlowTarget ) ),
|
||||||
|
RecvPropInt( RECVINFO( m_GlowColor ), 0, RecvProxy_IntToColor32 ),
|
||||||
|
RecvPropBool( RECVINFO( m_bGlowDisabled ) ),
|
||||||
|
END_RECV_TABLE()
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
C_PointGlow::~C_PointGlow()
|
||||||
|
{
|
||||||
|
DestroyGlowEffect();
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void C_PointGlow::OnDataChanged( DataUpdateType_t updateType )
|
||||||
|
{
|
||||||
|
BaseClass::OnDataChanged( updateType );
|
||||||
|
|
||||||
|
UpdateGlowEffect();
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void C_PointGlow::UpdateGlowEffect( void )
|
||||||
|
{
|
||||||
|
// destroy the existing effect
|
||||||
|
if ( m_pGlowEffect )
|
||||||
|
{
|
||||||
|
DestroyGlowEffect();
|
||||||
|
}
|
||||||
|
|
||||||
|
// create a new effect
|
||||||
|
if ( !m_bGlowDisabled )
|
||||||
|
{
|
||||||
|
Vector4D vecColor( m_GlowColor.r, m_GlowColor.g, m_GlowColor.b, m_GlowColor.a );
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
if (vecColor[i] == 0.0f)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
vecColor[i] /= 255.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pGlowEffect = new CGlowObject( m_hGlowTarget, vecColor.AsVector3D(), vecColor.w, true );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose:
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void C_PointGlow::DestroyGlowEffect( void )
|
||||||
|
{
|
||||||
|
if ( m_pGlowEffect )
|
||||||
|
{
|
||||||
|
delete m_pGlowEffect;
|
||||||
|
m_pGlowEffect = NULL;
|
||||||
|
}
|
||||||
|
}
|
@ -862,6 +862,85 @@ void CHudMessage::MsgFunc_HudMsg(bf_read &msg)
|
|||||||
// see tmessage.cpp why 512
|
// see tmessage.cpp why 512
|
||||||
msg.ReadString( (char*)pNetMessage->pMessage, 512 );
|
msg.ReadString( (char*)pNetMessage->pMessage, 512 );
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
//
|
||||||
|
// Mapbase adds a new data entry for custom fonts on entities like game_text.
|
||||||
|
// Some existing instances of this user message may not have this, so we have to make sure we have any bits left first.
|
||||||
|
//
|
||||||
|
if (msg.GetNumBitsLeft() > 0)
|
||||||
|
{
|
||||||
|
// Try to have VGui font names for each channel
|
||||||
|
static char szVGuiFontNames[MAX_NETMESSAGE][512];
|
||||||
|
msg.ReadString( szVGuiFontNames[channel], 512 );
|
||||||
|
if (szVGuiFontNames[channel][0] != '\0')
|
||||||
|
{
|
||||||
|
pNetMessage->pVGuiSchemeFontName = szVGuiFontNames[channel];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Mapbase adds a new data entry for breaking game_text into newline when it goes past the user's screen.
|
||||||
|
// Some existing instances of this user message may not have this, so we have to make sure we have any bits left first.
|
||||||
|
//
|
||||||
|
if (msg.GetNumBitsLeft() > 0)
|
||||||
|
{
|
||||||
|
int len = msg.ReadByte();
|
||||||
|
|
||||||
|
// This is supposed to work around a bug where certain aspect ratios cut off lengthy texts.
|
||||||
|
//int lineMax = 64 * ((float)ScreenWidth() / 1440.0f);
|
||||||
|
int lineMax = 100 / engine->GetScreenAspectRatio();
|
||||||
|
|
||||||
|
int lineMinBreak = lineMax * 0.9;
|
||||||
|
|
||||||
|
CGMsg( 2, CON_GROUP_CHOREO, "Line max is %i from an aspect ratio of %.3f (strlen %i)\n", lineMax, engine->GetScreenAspectRatio(), len );
|
||||||
|
|
||||||
|
char *curMessage = (char*)pNetMessage->pMessage;
|
||||||
|
char newMessage[512];
|
||||||
|
|
||||||
|
int cur = 0; // Current time on this line
|
||||||
|
int i = 0; // curMessage
|
||||||
|
int i2 = 0; // newMessage
|
||||||
|
for (i = 0; i < len; i++)
|
||||||
|
{
|
||||||
|
cur++;
|
||||||
|
newMessage[i2] = curMessage[i];
|
||||||
|
|
||||||
|
// Check if we're past the point in which we should break the line
|
||||||
|
if (cur >= lineMinBreak)
|
||||||
|
{
|
||||||
|
// Line break at the next space
|
||||||
|
if (curMessage[i] == ' ')
|
||||||
|
{
|
||||||
|
newMessage[i2] = '\n';
|
||||||
|
cur = 0;
|
||||||
|
}
|
||||||
|
else if (curMessage[i] == '\n')
|
||||||
|
{
|
||||||
|
// Already a newline here
|
||||||
|
cur = 0;
|
||||||
|
}
|
||||||
|
else if (cur >= lineMax)
|
||||||
|
{
|
||||||
|
// We're at the max and there's no space. Force a newline with a hyphen
|
||||||
|
newMessage[i2] = '-';
|
||||||
|
i2++;
|
||||||
|
newMessage[i2] = '\n';
|
||||||
|
i2++;
|
||||||
|
newMessage[i2] = curMessage[i];
|
||||||
|
cur = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
i2++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Null terminate
|
||||||
|
newMessage[i2] = '\0';
|
||||||
|
|
||||||
|
Q_strncpy( (char*)pNetMessage->pMessage, newMessage, 512 );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
MessageAdd( pNetMessage->pName );
|
MessageAdd( pNetMessage->pName );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,6 +234,14 @@ CPanelMetaClassMgrImp::CPanelMetaClassMgrImp() : m_PanelTypeDict( true, 0, 32 )
|
|||||||
|
|
||||||
CPanelMetaClassMgrImp::~CPanelMetaClassMgrImp()
|
CPanelMetaClassMgrImp::~CPanelMetaClassMgrImp()
|
||||||
{
|
{
|
||||||
|
#ifdef MAPBASE // VDC Memory Leak Fixes
|
||||||
|
while (m_MetaClassKeyValues.Count()>0)
|
||||||
|
{
|
||||||
|
if (m_MetaClassKeyValues[0])
|
||||||
|
m_MetaClassKeyValues[0]->deleteThis();
|
||||||
|
m_MetaClassKeyValues.RemoveAt(0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -308,8 +308,12 @@ void CSimpleEmitter::UpdateVelocity( SimpleParticle *pParticle, float timeDelta
|
|||||||
{
|
{
|
||||||
if (pParticle->m_iFlags & SIMPLE_PARTICLE_FLAG_WINDBLOWN)
|
if (pParticle->m_iFlags & SIMPLE_PARTICLE_FLAG_WINDBLOWN)
|
||||||
{
|
{
|
||||||
|
#ifdef MAPBASE
|
||||||
|
Vector vecWind = GetWindspeedAtLocation( pParticle->m_Pos );
|
||||||
|
#else
|
||||||
Vector vecWind;
|
Vector vecWind;
|
||||||
GetWindspeedAtTime( gpGlobals->curtime, vecWind );
|
GetWindspeedAtTime( gpGlobals->curtime, vecWind );
|
||||||
|
#endif
|
||||||
|
|
||||||
for ( int i = 0 ; i < 2 ; i++ )
|
for ( int i = 0 ; i < 2 ; i++ )
|
||||||
{
|
{
|
||||||
|
@ -30,6 +30,13 @@
|
|||||||
// memdbgon must be the last include file in a .cpp file!!!
|
// memdbgon must be the last include file in a .cpp file!!!
|
||||||
#include "tier0/memdbgon.h"
|
#include "tier0/memdbgon.h"
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// This turned out to be causing major issues with VPhysics collision.
|
||||||
|
// It's deactivated until a fix is found.
|
||||||
|
// See player_command.cpp as well.
|
||||||
|
//#define PLAYER_COMMAND_FIX 1
|
||||||
|
#endif
|
||||||
|
|
||||||
IPredictionSystem *IPredictionSystem::g_pPredictionSystems = NULL;
|
IPredictionSystem *IPredictionSystem::g_pPredictionSystems = NULL;
|
||||||
|
|
||||||
#if !defined( NO_ENTITY_PREDICTION )
|
#if !defined( NO_ENTITY_PREDICTION )
|
||||||
@ -909,9 +916,15 @@ void CPrediction::RunCommand( C_BasePlayer *player, CUserCmd *ucmd, IMoveHelper
|
|||||||
pVehicle->ProcessMovement( player, g_pMoveData );
|
pVehicle->ProcessMovement( player, g_pMoveData );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef PLAYER_COMMAND_FIX
|
||||||
|
RunPostThink( player );
|
||||||
|
|
||||||
|
FinishMove( player, ucmd, g_pMoveData );
|
||||||
|
#else
|
||||||
FinishMove( player, ucmd, g_pMoveData );
|
FinishMove( player, ucmd, g_pMoveData );
|
||||||
|
|
||||||
RunPostThink( player );
|
RunPostThink( player );
|
||||||
|
#endif
|
||||||
|
|
||||||
g_pGameMovement->FinishTrackPredictionErrors( player );
|
g_pGameMovement->FinishTrackPredictionErrors( player );
|
||||||
|
|
||||||
|
@ -24,7 +24,12 @@ VideoPanel::VideoPanel( unsigned int nXPos, unsigned int nYPos, unsigned int nHe
|
|||||||
m_nPlaybackHeight( 0 ),
|
m_nPlaybackHeight( 0 ),
|
||||||
m_bAllowAlternateMedia( allowAlternateMedia )
|
m_bAllowAlternateMedia( allowAlternateMedia )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
vgui::VPANEL pParent = enginevgui->GetPanel( PANEL_ROOT );
|
||||||
|
#else
|
||||||
vgui::VPANEL pParent = enginevgui->GetPanel( PANEL_GAMEUIDLL );
|
vgui::VPANEL pParent = enginevgui->GetPanel( PANEL_GAMEUIDLL );
|
||||||
|
#endif
|
||||||
SetParent( pParent );
|
SetParent( pParent );
|
||||||
SetVisible( false );
|
SetVisible( false );
|
||||||
|
|
||||||
@ -421,4 +426,4 @@ CON_COMMAND( playvideo_exitcommand, "Plays a video and fires and exit command wh
|
|||||||
Warning( "Unable to play video: %s\n", strFullpath );
|
Warning( "Unable to play video: %s\n", strFullpath );
|
||||||
engine->ClientCmd( pExitCommand );
|
engine->ClientCmd( pExitCommand );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,6 +126,9 @@ ConVar gl_clear( "gl_clear", "0");
|
|||||||
ConVar gl_clear_randomcolor( "gl_clear_randomcolor", "0", FCVAR_CHEAT, "Clear the back buffer to random colors every frame. Helps spot open seams in geometry." );
|
ConVar gl_clear_randomcolor( "gl_clear_randomcolor", "0", FCVAR_CHEAT, "Clear the back buffer to random colors every frame. Helps spot open seams in geometry." );
|
||||||
|
|
||||||
static ConVar r_farz( "r_farz", "-1", FCVAR_CHEAT, "Override the far clipping plane. -1 means to use the value in env_fog_controller." );
|
static ConVar r_farz( "r_farz", "-1", FCVAR_CHEAT, "Override the far clipping plane. -1 means to use the value in env_fog_controller." );
|
||||||
|
#ifdef MAPBASE
|
||||||
|
static ConVar r_nearz( "r_nearz", "-1", FCVAR_CHEAT, "Override the near clipping plane. -1 means to use the default value (usually 7)." );
|
||||||
|
#endif
|
||||||
static ConVar cl_demoviewoverride( "cl_demoviewoverride", "0", 0, "Override view during demo playback" );
|
static ConVar cl_demoviewoverride( "cl_demoviewoverride", "0", 0, "Override view during demo playback" );
|
||||||
|
|
||||||
|
|
||||||
@ -602,6 +605,11 @@ static QAngle s_DbgSetupAngles;
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
float CViewRender::GetZNear()
|
float CViewRender::GetZNear()
|
||||||
{
|
{
|
||||||
|
#ifdef MAPBASE
|
||||||
|
if (r_nearz.GetFloat() > 0)
|
||||||
|
return r_nearz.GetFloat();
|
||||||
|
#endif
|
||||||
|
|
||||||
return VIEW_NEARZ;
|
return VIEW_NEARZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -736,7 +744,11 @@ void CViewRender::SetUpViews()
|
|||||||
float flFOVOffset = fDefaultFov - view.fov;
|
float flFOVOffset = fDefaultFov - view.fov;
|
||||||
|
|
||||||
//Adjust the viewmodel's FOV to move with any FOV offsets on the viewer's end
|
//Adjust the viewmodel's FOV to move with any FOV offsets on the viewer's end
|
||||||
|
#ifdef MAPBASE
|
||||||
|
view.fovViewmodel = fabs(g_pClientMode->GetViewModelFOV()) - flFOVOffset;
|
||||||
|
#else
|
||||||
view.fovViewmodel = g_pClientMode->GetViewModelFOV() - flFOVOffset;
|
view.fovViewmodel = g_pClientMode->GetViewModelFOV() - flFOVOffset;
|
||||||
|
#endif
|
||||||
|
|
||||||
if ( UseVR() )
|
if ( UseVR() )
|
||||||
{
|
{
|
||||||
|
@ -13,8 +13,13 @@
|
|||||||
#include "materialsystem/materialsystem_config.h"
|
#include "materialsystem/materialsystem_config.h"
|
||||||
#include "tier1/callqueue.h"
|
#include "tier1/callqueue.h"
|
||||||
#include "colorcorrectionmgr.h"
|
#include "colorcorrectionmgr.h"
|
||||||
|
#include "postprocess_shared.h"
|
||||||
#include "view_scene.h"
|
#include "view_scene.h"
|
||||||
#include "c_world.h"
|
#include "c_world.h"
|
||||||
|
|
||||||
|
//Tony; new
|
||||||
|
#include "c_baseplayer.h"
|
||||||
|
|
||||||
#include "bitmap/tgawriter.h"
|
#include "bitmap/tgawriter.h"
|
||||||
#include "filesystem.h"
|
#include "filesystem.h"
|
||||||
#include "tier0/vprof.h"
|
#include "tier0/vprof.h"
|
||||||
@ -34,6 +39,15 @@ float g_flCustomAutoExposureMax = 0;
|
|||||||
float g_flCustomBloomScale = 0.0f;
|
float g_flCustomBloomScale = 0.0f;
|
||||||
float g_flCustomBloomScaleMinimum = 0.0f;
|
float g_flCustomBloomScaleMinimum = 0.0f;
|
||||||
|
|
||||||
|
// mapmaker controlled depth of field
|
||||||
|
bool g_bDOFEnabled = false;
|
||||||
|
float g_flDOFNearBlurDepth = 20.0f;
|
||||||
|
float g_flDOFNearFocusDepth = 100.0f;
|
||||||
|
float g_flDOFFarFocusDepth = 250.0f;
|
||||||
|
float g_flDOFFarBlurDepth = 1000.0f;
|
||||||
|
float g_flDOFNearBlurRadius = 0.0f;
|
||||||
|
float g_flDOFFarBlurRadius = 10.0f;
|
||||||
|
|
||||||
bool g_bFlashlightIsOn = false;
|
bool g_bFlashlightIsOn = false;
|
||||||
|
|
||||||
// hdr parameters
|
// hdr parameters
|
||||||
@ -289,9 +303,9 @@ void ApplyPostProcessingPasses(PostProcessingPass *pass_list, // table of effect
|
|||||||
pRenderContext->SetRenderTarget(NULL);
|
pRenderContext->SetRenderTarget(NULL);
|
||||||
int row=pcount/4;
|
int row=pcount/4;
|
||||||
int col=pcount %4;
|
int col=pcount %4;
|
||||||
int dest_width,dest_height;
|
int destwidth,destheight;
|
||||||
pRenderContext->GetRenderTargetDimensions( dest_width, dest_height );
|
pRenderContext->GetRenderTargetDimensions( destwidth, destheight );
|
||||||
pRenderContext->Viewport( 0, 0, dest_width, dest_height );
|
pRenderContext->Viewport( 0, 0, destwidth, destheight );
|
||||||
DrawClippedScreenSpaceRectangle(src_mat,10+col*220,10+row*220,
|
DrawClippedScreenSpaceRectangle(src_mat,10+col*220,10+row*220,
|
||||||
200,200,
|
200,200,
|
||||||
0,0,1,1,1,1,cb);
|
0,0,1,1,1,1,cb);
|
||||||
@ -332,7 +346,7 @@ PostProcessingPass HDRSimulate_NonHDR[] =
|
|||||||
PPP_END
|
PPP_END
|
||||||
};
|
};
|
||||||
|
|
||||||
static void SetRenderTargetAndViewPort(ITexture *rt)
|
void SetRenderTargetAndViewPort(ITexture *rt)
|
||||||
{
|
{
|
||||||
tmZone( TELEMETRY_LEVEL0, TMZF_NONE, "%s", __FUNCTION__ );
|
tmZone( TELEMETRY_LEVEL0, TMZF_NONE, "%s", __FUNCTION__ );
|
||||||
|
|
||||||
@ -765,7 +779,19 @@ static float GetCurrentBloomScale( void )
|
|||||||
{
|
{
|
||||||
// Use the appropriate bloom scale settings. Mapmakers's overrides the convar settings.
|
// Use the appropriate bloom scale settings. Mapmakers's overrides the convar settings.
|
||||||
float flCurrentBloomScale = 1.0f;
|
float flCurrentBloomScale = 1.0f;
|
||||||
if ( g_bUseCustomBloomScale )
|
|
||||||
|
//Tony; get the local player first..
|
||||||
|
C_BasePlayer *pLocalPlayer = NULL;
|
||||||
|
|
||||||
|
if ( ( gpGlobals->maxClients > 1 ) )
|
||||||
|
pLocalPlayer = (C_BasePlayer*)C_BasePlayer::GetLocalPlayer();
|
||||||
|
|
||||||
|
//Tony; in multiplayer, get the local player etc.
|
||||||
|
if ( (pLocalPlayer != NULL && pLocalPlayer->m_Local.m_TonemapParams.m_flAutoExposureMin > 0.0f) )
|
||||||
|
{
|
||||||
|
flCurrentBloomScale = pLocalPlayer->m_Local.m_TonemapParams.m_flAutoExposureMin;
|
||||||
|
}
|
||||||
|
else if ( g_bUseCustomBloomScale )
|
||||||
{
|
{
|
||||||
flCurrentBloomScale = g_flCustomBloomScale;
|
flCurrentBloomScale = g_flCustomBloomScale;
|
||||||
}
|
}
|
||||||
@ -778,8 +804,19 @@ static float GetCurrentBloomScale( void )
|
|||||||
|
|
||||||
static void GetExposureRange( float *flAutoExposureMin, float *flAutoExposureMax )
|
static void GetExposureRange( float *flAutoExposureMin, float *flAutoExposureMax )
|
||||||
{
|
{
|
||||||
|
//Tony; get the local player first..
|
||||||
|
C_BasePlayer *pLocalPlayer = NULL;
|
||||||
|
|
||||||
|
if ( ( gpGlobals->maxClients > 1 ) )
|
||||||
|
pLocalPlayer = (C_BasePlayer*)C_BasePlayer::GetLocalPlayer();
|
||||||
|
|
||||||
|
//Tony; in multiplayer, get the local player etc.
|
||||||
|
if ( (pLocalPlayer != NULL && pLocalPlayer->m_Local.m_TonemapParams.m_flAutoExposureMin > 0.0f) )
|
||||||
|
{
|
||||||
|
*flAutoExposureMin = pLocalPlayer->m_Local.m_TonemapParams.m_flAutoExposureMin;
|
||||||
|
}
|
||||||
// Get min
|
// Get min
|
||||||
if ( ( g_bUseCustomAutoExposureMin ) && ( g_flCustomAutoExposureMin > 0.0f ) )
|
else if ( ( g_bUseCustomAutoExposureMin ) && ( g_flCustomAutoExposureMin > 0.0f ) )
|
||||||
{
|
{
|
||||||
*flAutoExposureMin = g_flCustomAutoExposureMin;
|
*flAutoExposureMin = g_flCustomAutoExposureMin;
|
||||||
}
|
}
|
||||||
@ -788,8 +825,13 @@ static void GetExposureRange( float *flAutoExposureMin, float *flAutoExposureMax
|
|||||||
*flAutoExposureMin = mat_autoexposure_min.GetFloat();
|
*flAutoExposureMin = mat_autoexposure_min.GetFloat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Tony; in multiplayer, get the value from the local player, if it's set.
|
||||||
|
if ( (pLocalPlayer != NULL && pLocalPlayer->m_Local.m_TonemapParams.m_flAutoExposureMax > 0.0f) )
|
||||||
|
{
|
||||||
|
*flAutoExposureMax = pLocalPlayer->m_Local.m_TonemapParams.m_flAutoExposureMax;
|
||||||
|
}
|
||||||
// Get max
|
// Get max
|
||||||
if ( ( g_bUseCustomAutoExposureMax ) && ( g_flCustomAutoExposureMax > 0.0f ) )
|
else if ( ( g_bUseCustomAutoExposureMax ) && ( g_flCustomAutoExposureMax > 0.0f ) )
|
||||||
{
|
{
|
||||||
*flAutoExposureMax = g_flCustomAutoExposureMax;
|
*flAutoExposureMax = g_flCustomAutoExposureMax;
|
||||||
}
|
}
|
||||||
@ -1113,6 +1155,32 @@ void CLuminanceHistogramSystem::DisplayHistogram( void )
|
|||||||
pRenderContext->PopRenderTargetAndViewport();
|
pRenderContext->PopRenderTargetAndViewport();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Local contrast setting
|
||||||
|
PostProcessParameters_t s_LocalPostProcessParameters;
|
||||||
|
|
||||||
|
// view fade param settings
|
||||||
|
static Vector4D s_viewFadeColor;
|
||||||
|
static bool s_bViewFadeModulate;
|
||||||
|
|
||||||
|
static bool s_bOverridePostProcessParams = false;
|
||||||
|
|
||||||
|
void SetPostProcessParams( const PostProcessParameters_t* pPostProcessParameters )
|
||||||
|
{
|
||||||
|
if (!s_bOverridePostProcessParams)
|
||||||
|
s_LocalPostProcessParameters = *pPostProcessParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetPostProcessParams( const PostProcessParameters_t* pPostProcessParameters, bool bOverride )
|
||||||
|
{
|
||||||
|
s_bOverridePostProcessParams = bOverride;
|
||||||
|
s_LocalPostProcessParameters = *pPostProcessParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetViewFadeParams( byte r, byte g, byte b, byte a, bool bModulate )
|
||||||
|
{
|
||||||
|
s_viewFadeColor.Init( float( r ) / 255.0f, float( g ) / 255.0f, float( b ) / 255.0f, float( a ) / 255.0f );
|
||||||
|
s_bViewFadeModulate = bModulate;
|
||||||
|
}
|
||||||
|
|
||||||
static CLuminanceHistogramSystem g_HDR_HistogramSystem;
|
static CLuminanceHistogramSystem g_HDR_HistogramSystem;
|
||||||
|
|
||||||
@ -1208,15 +1276,32 @@ private:
|
|||||||
IMaterialVar *m_pMaterialParam_AAValues;
|
IMaterialVar *m_pMaterialParam_AAValues;
|
||||||
IMaterialVar *m_pMaterialParam_AAValues2;
|
IMaterialVar *m_pMaterialParam_AAValues2;
|
||||||
IMaterialVar *m_pMaterialParam_BloomEnable;
|
IMaterialVar *m_pMaterialParam_BloomEnable;
|
||||||
|
IMaterialVar *m_pMaterialParam_BloomAmount;
|
||||||
IMaterialVar *m_pMaterialParam_BloomUVTransform;
|
IMaterialVar *m_pMaterialParam_BloomUVTransform;
|
||||||
IMaterialVar *m_pMaterialParam_ColCorrectEnable;
|
IMaterialVar *m_pMaterialParam_ColCorrectEnable;
|
||||||
IMaterialVar *m_pMaterialParam_ColCorrectNumLookups;
|
IMaterialVar *m_pMaterialParam_ColCorrectNumLookups;
|
||||||
IMaterialVar *m_pMaterialParam_ColCorrectDefaultWeight;
|
IMaterialVar *m_pMaterialParam_ColCorrectDefaultWeight;
|
||||||
IMaterialVar *m_pMaterialParam_ColCorrectLookupWeights;
|
IMaterialVar *m_pMaterialParam_ColCorrectLookupWeights;
|
||||||
|
IMaterialVar *m_pMaterialParam_LocalContrastStrength;
|
||||||
|
IMaterialVar *m_pMaterialParam_LocalContrastEdgeStrength;
|
||||||
|
IMaterialVar *m_pMaterialParam_VignetteStart;
|
||||||
|
IMaterialVar *m_pMaterialParam_VignetteEnd;
|
||||||
|
IMaterialVar *m_pMaterialParam_VignetteBlurEnable;
|
||||||
|
IMaterialVar *m_pMaterialParam_VignetteBlurStrength;
|
||||||
|
IMaterialVar *m_pMaterialParam_FadeToBlackStrength;
|
||||||
|
IMaterialVar *m_pMaterialParam_DepthBlurFocalDistance;
|
||||||
|
IMaterialVar *m_pMaterialParam_DepthBlurStrength;
|
||||||
|
IMaterialVar *m_pMaterialParam_ScreenBlurStrength;
|
||||||
|
IMaterialVar *m_pMaterialParam_FilmGrainStrength;
|
||||||
|
IMaterialVar *m_pMaterialParam_VomitEnable;
|
||||||
|
IMaterialVar *m_pMaterialParam_VomitColor1;
|
||||||
|
IMaterialVar *m_pMaterialParam_VomitColor2;
|
||||||
|
IMaterialVar *m_pMaterialParam_FadeColor;
|
||||||
|
IMaterialVar *m_pMaterialParam_FadeType;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static IMaterial * SetupEnginePostMaterial( const Vector4D & fullViewportBloomUVs, const Vector4D & fullViewportFBUVs, const Vector2D & destTexSize,
|
static IMaterial * SetupEnginePostMaterial( const Vector4D & fullViewportBloomUVs, const Vector4D & fullViewportFBUVs, const Vector2D & destTexSize,
|
||||||
bool bPerformSoftwareAA, bool bPerformBloom, bool bPerformColCorrect, float flAAStrength );
|
bool bPerformSoftwareAA, bool bPerformBloom, bool bPerformColCorrect, float flAAStrength, float flBloomAmount );
|
||||||
static void SetupEnginePostMaterialAA( bool bPerformSoftwareAA, float flAAStrength );
|
static void SetupEnginePostMaterialAA( bool bPerformSoftwareAA, float flAAStrength );
|
||||||
static void SetupEnginePostMaterialTextureTransform( const Vector4D & fullViewportBloomUVs, const Vector4D & fullViewportFBUVs, Vector2D destTexSize );
|
static void SetupEnginePostMaterialTextureTransform( const Vector4D & fullViewportBloomUVs, const Vector4D & fullViewportFBUVs, Vector2D destTexSize );
|
||||||
|
|
||||||
@ -1225,12 +1310,14 @@ private:
|
|||||||
static float s_vBloomAAValues2[4];
|
static float s_vBloomAAValues2[4];
|
||||||
static float s_vBloomUVTransform[4];
|
static float s_vBloomUVTransform[4];
|
||||||
static int s_PostBloomEnable;
|
static int s_PostBloomEnable;
|
||||||
|
static float s_PostBloomAmount;
|
||||||
};
|
};
|
||||||
|
|
||||||
float CEnginePostMaterialProxy::s_vBloomAAValues[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
float CEnginePostMaterialProxy::s_vBloomAAValues[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||||
float CEnginePostMaterialProxy::s_vBloomAAValues2[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
float CEnginePostMaterialProxy::s_vBloomAAValues2[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||||
float CEnginePostMaterialProxy::s_vBloomUVTransform[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
float CEnginePostMaterialProxy::s_vBloomUVTransform[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||||
int CEnginePostMaterialProxy::s_PostBloomEnable = 1;
|
int CEnginePostMaterialProxy::s_PostBloomEnable = 1;
|
||||||
|
float CEnginePostMaterialProxy::s_PostBloomAmount = 1.0f;
|
||||||
|
|
||||||
CEnginePostMaterialProxy::CEnginePostMaterialProxy()
|
CEnginePostMaterialProxy::CEnginePostMaterialProxy()
|
||||||
{
|
{
|
||||||
@ -1238,10 +1325,22 @@ CEnginePostMaterialProxy::CEnginePostMaterialProxy()
|
|||||||
m_pMaterialParam_AAValues2 = NULL;
|
m_pMaterialParam_AAValues2 = NULL;
|
||||||
m_pMaterialParam_BloomUVTransform = NULL;
|
m_pMaterialParam_BloomUVTransform = NULL;
|
||||||
m_pMaterialParam_BloomEnable = NULL;
|
m_pMaterialParam_BloomEnable = NULL;
|
||||||
|
m_pMaterialParam_BloomAmount = NULL;
|
||||||
m_pMaterialParam_ColCorrectEnable = NULL;
|
m_pMaterialParam_ColCorrectEnable = NULL;
|
||||||
m_pMaterialParam_ColCorrectNumLookups = NULL;
|
m_pMaterialParam_ColCorrectNumLookups = NULL;
|
||||||
m_pMaterialParam_ColCorrectDefaultWeight = NULL;
|
m_pMaterialParam_ColCorrectDefaultWeight = NULL;
|
||||||
m_pMaterialParam_ColCorrectLookupWeights = NULL;
|
m_pMaterialParam_ColCorrectLookupWeights = NULL;
|
||||||
|
m_pMaterialParam_LocalContrastStrength = NULL;
|
||||||
|
m_pMaterialParam_LocalContrastEdgeStrength = NULL;
|
||||||
|
m_pMaterialParam_VignetteStart = NULL;
|
||||||
|
m_pMaterialParam_VignetteEnd = NULL;
|
||||||
|
m_pMaterialParam_VignetteBlurEnable = NULL;
|
||||||
|
m_pMaterialParam_VignetteBlurStrength = NULL;
|
||||||
|
m_pMaterialParam_FadeToBlackStrength = NULL;
|
||||||
|
m_pMaterialParam_DepthBlurFocalDistance = NULL;
|
||||||
|
m_pMaterialParam_DepthBlurStrength = NULL;
|
||||||
|
m_pMaterialParam_ScreenBlurStrength = NULL;
|
||||||
|
m_pMaterialParam_FilmGrainStrength = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CEnginePostMaterialProxy::~CEnginePostMaterialProxy()
|
CEnginePostMaterialProxy::~CEnginePostMaterialProxy()
|
||||||
@ -1252,15 +1351,32 @@ CEnginePostMaterialProxy::~CEnginePostMaterialProxy()
|
|||||||
bool CEnginePostMaterialProxy::Init( IMaterial *pMaterial, KeyValues *pKeyValues )
|
bool CEnginePostMaterialProxy::Init( IMaterial *pMaterial, KeyValues *pKeyValues )
|
||||||
{
|
{
|
||||||
bool bFoundVar = false;
|
bool bFoundVar = false;
|
||||||
|
|
||||||
m_pMaterialParam_AAValues = pMaterial->FindVar( "$AAInternal1", &bFoundVar, false );
|
m_pMaterialParam_AAValues = pMaterial->FindVar( "$AAInternal1", &bFoundVar, false );
|
||||||
m_pMaterialParam_AAValues2 = pMaterial->FindVar( "$AAInternal3", &bFoundVar, false );
|
m_pMaterialParam_AAValues2 = pMaterial->FindVar( "$AAInternal3", &bFoundVar, false );
|
||||||
m_pMaterialParam_BloomUVTransform = pMaterial->FindVar( "$AAInternal2", &bFoundVar, false );
|
m_pMaterialParam_BloomUVTransform = pMaterial->FindVar( "$AAInternal2", &bFoundVar, false );
|
||||||
m_pMaterialParam_BloomEnable = pMaterial->FindVar( "$bloomEnable", &bFoundVar, false );
|
m_pMaterialParam_BloomEnable = pMaterial->FindVar( "$bloomEnable", &bFoundVar, false );
|
||||||
|
m_pMaterialParam_BloomAmount = pMaterial->FindVar( "$bloomAmount", &bFoundVar, false );
|
||||||
m_pMaterialParam_ColCorrectEnable = pMaterial->FindVar( "$colCorrectEnable", &bFoundVar, false );
|
m_pMaterialParam_ColCorrectEnable = pMaterial->FindVar( "$colCorrectEnable", &bFoundVar, false );
|
||||||
m_pMaterialParam_ColCorrectNumLookups = pMaterial->FindVar( "$colCorrect_NumLookups", &bFoundVar, false );
|
m_pMaterialParam_ColCorrectNumLookups = pMaterial->FindVar( "$colCorrect_NumLookups", &bFoundVar, false );
|
||||||
m_pMaterialParam_ColCorrectDefaultWeight = pMaterial->FindVar( "$colCorrect_DefaultWeight", &bFoundVar, false );
|
m_pMaterialParam_ColCorrectDefaultWeight = pMaterial->FindVar( "$colCorrect_DefaultWeight", &bFoundVar, false );
|
||||||
m_pMaterialParam_ColCorrectLookupWeights = pMaterial->FindVar( "$colCorrect_LookupWeights", &bFoundVar, false );
|
m_pMaterialParam_ColCorrectLookupWeights = pMaterial->FindVar( "$colCorrect_LookupWeights", &bFoundVar, false );
|
||||||
|
m_pMaterialParam_LocalContrastStrength = pMaterial->FindVar( "$localContrastScale", &bFoundVar, false );
|
||||||
|
m_pMaterialParam_LocalContrastEdgeStrength = pMaterial->FindVar( "$localContrastEdgeScale", &bFoundVar, false );
|
||||||
|
m_pMaterialParam_VignetteStart = pMaterial->FindVar( "$localContrastVignetteStart", &bFoundVar, false );
|
||||||
|
m_pMaterialParam_VignetteEnd = pMaterial->FindVar( "$localContrastVignetteEnd", &bFoundVar, false );
|
||||||
|
m_pMaterialParam_VignetteBlurEnable = pMaterial->FindVar( "$blurredVignetteEnable", &bFoundVar, false );
|
||||||
|
m_pMaterialParam_VignetteBlurStrength = pMaterial->FindVar( "$blurredVignetteScale", &bFoundVar, false );
|
||||||
|
m_pMaterialParam_FadeToBlackStrength = pMaterial->FindVar( "$fadeToBlackScale", &bFoundVar, false );
|
||||||
|
m_pMaterialParam_DepthBlurFocalDistance = pMaterial->FindVar( "$depthBlurFocalDistance", &bFoundVar, false );
|
||||||
|
m_pMaterialParam_DepthBlurStrength = pMaterial->FindVar( "$depthBlurStrength", &bFoundVar, false );
|
||||||
|
m_pMaterialParam_ScreenBlurStrength = pMaterial->FindVar( "$screenBlurStrength", &bFoundVar, false );
|
||||||
|
m_pMaterialParam_FilmGrainStrength = pMaterial->FindVar( "$noiseScale", &bFoundVar, false );
|
||||||
|
m_pMaterialParam_VomitEnable = pMaterial->FindVar( "$vomitEnable", &bFoundVar, false );
|
||||||
|
m_pMaterialParam_VomitColor1 = pMaterial->FindVar( "$vomitColor1", &bFoundVar, false );
|
||||||
|
m_pMaterialParam_VomitColor2 = pMaterial->FindVar( "$vomitColor2", &bFoundVar, false );
|
||||||
|
m_pMaterialParam_FadeColor = pMaterial->FindVar( "$fadeColor", &bFoundVar, false );
|
||||||
|
m_pMaterialParam_FadeType = pMaterial->FindVar( "$fade", &bFoundVar, false );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1278,6 +1394,56 @@ void CEnginePostMaterialProxy::OnBind( C_BaseEntity *pEnt )
|
|||||||
|
|
||||||
if ( m_pMaterialParam_BloomEnable )
|
if ( m_pMaterialParam_BloomEnable )
|
||||||
m_pMaterialParam_BloomEnable->SetIntValue( s_PostBloomEnable );
|
m_pMaterialParam_BloomEnable->SetIntValue( s_PostBloomEnable );
|
||||||
|
|
||||||
|
if ( m_pMaterialParam_BloomAmount )
|
||||||
|
m_pMaterialParam_BloomAmount->SetFloatValue( s_PostBloomAmount );
|
||||||
|
|
||||||
|
if ( m_pMaterialParam_LocalContrastStrength )
|
||||||
|
m_pMaterialParam_LocalContrastStrength->SetFloatValue( s_LocalPostProcessParameters.m_flParameters[ PPPN_LOCAL_CONTRAST_STRENGTH ] );
|
||||||
|
|
||||||
|
if ( m_pMaterialParam_LocalContrastEdgeStrength )
|
||||||
|
m_pMaterialParam_LocalContrastEdgeStrength->SetFloatValue( s_LocalPostProcessParameters.m_flParameters[ PPPN_LOCAL_CONTRAST_EDGE_STRENGTH ] );
|
||||||
|
|
||||||
|
if ( m_pMaterialParam_VignetteStart )
|
||||||
|
m_pMaterialParam_VignetteStart->SetFloatValue( s_LocalPostProcessParameters.m_flParameters[ PPPN_VIGNETTE_START ] );
|
||||||
|
|
||||||
|
if ( m_pMaterialParam_VignetteEnd )
|
||||||
|
m_pMaterialParam_VignetteEnd->SetFloatValue( s_LocalPostProcessParameters.m_flParameters[ PPPN_VIGNETTE_END ] );
|
||||||
|
|
||||||
|
if ( m_pMaterialParam_VignetteBlurEnable )
|
||||||
|
m_pMaterialParam_VignetteBlurEnable->SetIntValue( s_LocalPostProcessParameters.m_flParameters[ PPPN_VIGNETTE_BLUR_STRENGTH ] > 0.0f ? 1 : 0 );
|
||||||
|
|
||||||
|
if ( m_pMaterialParam_VignetteBlurStrength )
|
||||||
|
m_pMaterialParam_VignetteBlurStrength->SetFloatValue( s_LocalPostProcessParameters.m_flParameters[ PPPN_VIGNETTE_BLUR_STRENGTH ] );
|
||||||
|
|
||||||
|
if ( m_pMaterialParam_FadeToBlackStrength )
|
||||||
|
m_pMaterialParam_FadeToBlackStrength->SetFloatValue( s_LocalPostProcessParameters.m_flParameters[ PPPN_FADE_TO_BLACK_STRENGTH ] );
|
||||||
|
|
||||||
|
if ( m_pMaterialParam_DepthBlurFocalDistance )
|
||||||
|
m_pMaterialParam_DepthBlurFocalDistance->SetFloatValue( s_LocalPostProcessParameters.m_flParameters[ PPPN_DEPTH_BLUR_FOCAL_DISTANCE ] );
|
||||||
|
|
||||||
|
if ( m_pMaterialParam_DepthBlurStrength )
|
||||||
|
m_pMaterialParam_DepthBlurStrength->SetFloatValue( s_LocalPostProcessParameters.m_flParameters[ PPPN_DEPTH_BLUR_STRENGTH ] );
|
||||||
|
|
||||||
|
if ( m_pMaterialParam_ScreenBlurStrength )
|
||||||
|
m_pMaterialParam_ScreenBlurStrength->SetFloatValue( s_LocalPostProcessParameters.m_flParameters[ PPPN_SCREEN_BLUR_STRENGTH ] );
|
||||||
|
|
||||||
|
if ( m_pMaterialParam_FilmGrainStrength )
|
||||||
|
m_pMaterialParam_FilmGrainStrength->SetFloatValue( s_LocalPostProcessParameters.m_flParameters[ PPPN_FILM_GRAIN_STRENGTH ] );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if ( m_pMaterialParam_FadeType )
|
||||||
|
{
|
||||||
|
int nFadeType = ( s_bViewFadeModulate ) ? 2 : 1;
|
||||||
|
nFadeType = ( s_viewFadeColor[3] > 0.0f ) ? nFadeType : 0;
|
||||||
|
m_pMaterialParam_FadeType->SetIntValue( nFadeType );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( m_pMaterialParam_FadeColor )
|
||||||
|
{
|
||||||
|
m_pMaterialParam_FadeColor->SetVecValue( s_viewFadeColor.Base(), 4 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IMaterial *CEnginePostMaterialProxy::GetMaterial()
|
IMaterial *CEnginePostMaterialProxy::GetMaterial()
|
||||||
@ -1350,26 +1516,29 @@ void CEnginePostMaterialProxy::SetupEnginePostMaterialTextureTransform( const Ve
|
|||||||
}
|
}
|
||||||
|
|
||||||
IMaterial * CEnginePostMaterialProxy::SetupEnginePostMaterial( const Vector4D & fullViewportBloomUVs, const Vector4D & fullViewportFBUVs, const Vector2D & destTexSize,
|
IMaterial * CEnginePostMaterialProxy::SetupEnginePostMaterial( const Vector4D & fullViewportBloomUVs, const Vector4D & fullViewportFBUVs, const Vector2D & destTexSize,
|
||||||
bool bPerformSoftwareAA, bool bPerformBloom, bool bPerformColCorrect, float flAAStrength )
|
bool bPerformSoftwareAA, bool bPerformBloom, bool bPerformColCorrect, float flAAStrength, float flBloomAmount )
|
||||||
{
|
{
|
||||||
// Shouldn't get here if none of the effects are enabled
|
// Shouldn't get here if none of the effects are enabled
|
||||||
Assert( bPerformSoftwareAA || bPerformBloom || bPerformColCorrect );
|
Assert( bPerformSoftwareAA || bPerformBloom || bPerformColCorrect );
|
||||||
|
|
||||||
s_PostBloomEnable = bPerformBloom ? 1 : 0;
|
s_PostBloomEnable = bPerformBloom ? 1 : 0;
|
||||||
|
s_PostBloomAmount = flBloomAmount;
|
||||||
|
|
||||||
SetupEnginePostMaterialAA( bPerformSoftwareAA, flAAStrength );
|
SetupEnginePostMaterialAA( bPerformSoftwareAA, flAAStrength );
|
||||||
|
|
||||||
if ( bPerformSoftwareAA || bPerformColCorrect )
|
//if ( bPerformSoftwareAA || bPerformColCorrect )
|
||||||
{
|
{
|
||||||
SetupEnginePostMaterialTextureTransform( fullViewportBloomUVs, fullViewportFBUVs, destTexSize );
|
SetupEnginePostMaterialTextureTransform( fullViewportBloomUVs, fullViewportFBUVs, destTexSize );
|
||||||
return materials->FindMaterial( "dev/engine_post", TEXTURE_GROUP_OTHER, true);
|
return materials->FindMaterial( "dev/engine_post", TEXTURE_GROUP_OTHER, true);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Just use the old bloomadd material (which uses additive blending, unlike engine_post)
|
// Just use the old bloomadd material (which uses additive blending, unlike engine_post)
|
||||||
// NOTE: this path is what gets used for DX8 (which cannot enable AA or col-correction)
|
// NOTE: this path is what gets used for DX8 (which cannot enable AA or col-correction)
|
||||||
return materials->FindMaterial( "dev/bloomadd", TEXTURE_GROUP_OTHER, true);
|
return materials->FindMaterial( "dev/bloomadd", TEXTURE_GROUP_OTHER, true);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPOSE_INTERFACE( CEnginePostMaterialProxy, IMaterialProxy, "engine_post" IMATERIAL_PROXY_INTERFACE_VERSION );
|
EXPOSE_INTERFACE( CEnginePostMaterialProxy, IMaterialProxy, "engine_post" IMATERIAL_PROXY_INTERFACE_VERSION );
|
||||||
@ -1520,6 +1689,28 @@ void DumpTGAofRenderTarget( const int width, const int height, const char *pFile
|
|||||||
|
|
||||||
static bool s_bScreenEffectTextureIsUpdated = false;
|
static bool s_bScreenEffectTextureIsUpdated = false;
|
||||||
|
|
||||||
|
// WARNING: This function sets rendertarget and viewport. Save and restore is left to the caller.
|
||||||
|
static void DownsampleFBQuarterSize( IMatRenderContext *pRenderContext, int nSrcWidth, int nSrcHeight, ITexture* pDest,
|
||||||
|
bool bFloatHDR = false )
|
||||||
|
{
|
||||||
|
Assert( pRenderContext );
|
||||||
|
Assert( pDest );
|
||||||
|
|
||||||
|
IMaterial *downsample_mat = materials->FindMaterial( bFloatHDR ? "dev/downsample" : "dev/downsample_non_hdr", TEXTURE_GROUP_OTHER, true );
|
||||||
|
|
||||||
|
// *Everything* in here relies on the small RTs being exactly 1/4 the full FB res
|
||||||
|
Assert( pDest->GetActualWidth() == nSrcWidth / 4 );
|
||||||
|
Assert( pDest->GetActualHeight() == nSrcHeight / 4 );
|
||||||
|
|
||||||
|
// downsample fb to rt0
|
||||||
|
SetRenderTargetAndViewPort( pDest );
|
||||||
|
// note the -2's below. Thats because we are downsampling on each axis and the shader
|
||||||
|
// accesses pixels on both sides of the source coord
|
||||||
|
pRenderContext->DrawScreenSpaceRectangle( downsample_mat, 0, 0, nSrcWidth/4, nSrcHeight/4,
|
||||||
|
0, 0, nSrcWidth-2, nSrcHeight-2,
|
||||||
|
nSrcWidth, nSrcHeight );
|
||||||
|
}
|
||||||
|
|
||||||
static void Generate8BitBloomTexture( IMatRenderContext *pRenderContext, float flBloomScale,
|
static void Generate8BitBloomTexture( IMatRenderContext *pRenderContext, float flBloomScale,
|
||||||
int x, int y, int w, int h )
|
int x, int y, int w, int h )
|
||||||
{
|
{
|
||||||
@ -1582,7 +1773,7 @@ static void Generate8BitBloomTexture( IMatRenderContext *pRenderContext, float f
|
|||||||
// Gaussian blur y rt1 to rt0
|
// Gaussian blur y rt1 to rt0
|
||||||
SetRenderTargetAndViewPort( dest_rt0 );
|
SetRenderTargetAndViewPort( dest_rt0 );
|
||||||
IMaterialVar *pBloomAmountVar = yblur_mat->FindVar( "$bloomamount", NULL );
|
IMaterialVar *pBloomAmountVar = yblur_mat->FindVar( "$bloomamount", NULL );
|
||||||
pBloomAmountVar->SetFloatValue( flBloomScale );
|
pBloomAmountVar->SetFloatValue( 1.0f ); // the bloom amount is now applied in engine_post or bloomadd materials
|
||||||
pRenderContext->DrawScreenSpaceRectangle( yblur_mat, 0, 0, nSrcWidth / 4, nSrcHeight / 4,
|
pRenderContext->DrawScreenSpaceRectangle( yblur_mat, 0, 0, nSrcWidth / 4, nSrcHeight / 4,
|
||||||
0, 0, nSrcWidth / 4 - 1, nSrcHeight / 4 - 1,
|
0, 0, nSrcWidth / 4 - 1, nSrcHeight / 4 - 1,
|
||||||
nSrcWidth / 4, nSrcHeight / 4 );
|
nSrcWidth / 4, nSrcHeight / 4 );
|
||||||
@ -2325,7 +2516,7 @@ void DoEnginePostProcessing( int x, int y, int w, int h, bool bFlashlightIsOn, b
|
|||||||
|
|
||||||
// bloom, software-AA and colour-correction (applied in 1 pass, after generation of the bloom texture)
|
// bloom, software-AA and colour-correction (applied in 1 pass, after generation of the bloom texture)
|
||||||
bool bPerformSoftwareAA = IsX360() && ( engine->GetDXSupportLevel() >= 90 ) && ( flAAStrength != 0.0f );
|
bool bPerformSoftwareAA = IsX360() && ( engine->GetDXSupportLevel() >= 90 ) && ( flAAStrength != 0.0f );
|
||||||
bool bPerformBloom = !bPostVGui && ( flBloomScale > 0.0f ) && ( engine->GetDXSupportLevel() >= 90 );
|
bool bPerformBloom = true; //!bPostVGui && ( flBloomScale > 0.0f ) && ( engine->GetDXSupportLevel() >= 90 );
|
||||||
bool bPerformColCorrect = !bPostVGui &&
|
bool bPerformColCorrect = !bPostVGui &&
|
||||||
( g_pMaterialSystemHardwareConfig->GetDXSupportLevel() >= 90) &&
|
( g_pMaterialSystemHardwareConfig->GetDXSupportLevel() >= 90) &&
|
||||||
( g_pMaterialSystemHardwareConfig->GetHDRType() != HDR_TYPE_FLOAT ) &&
|
( g_pMaterialSystemHardwareConfig->GetHDRType() != HDR_TYPE_FLOAT ) &&
|
||||||
@ -2385,9 +2576,9 @@ void DoEnginePostProcessing( int x, int y, int w, int h, bool bFlashlightIsOn, b
|
|||||||
partialViewportPostDestRect.height -= 0.50f*fullViewportPostDestRect.height;
|
partialViewportPostDestRect.height -= 0.50f*fullViewportPostDestRect.height;
|
||||||
|
|
||||||
// This math interprets texel coords as being at corner pixel centers (*not* at corner vertices):
|
// This math interprets texel coords as being at corner pixel centers (*not* at corner vertices):
|
||||||
Vector2D uvScale( 1.0f - ( (w / 2) / (float)(w - 1) ),
|
Vector2D uvScaleCorner( 1.0f - ( (w / 2) / (float)(w - 1) ),
|
||||||
1.0f - ( (h / 2) / (float)(h - 1) ) );
|
1.0f - ( (h / 2) / (float)(h - 1) ) );
|
||||||
CenterScaleQuadUVs( partialViewportPostSrcCorners, uvScale );
|
CenterScaleQuadUVs( partialViewportPostSrcCorners, uvScaleCorner );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Temporary hack... Color correction was crashing on the first frame
|
// Temporary hack... Color correction was crashing on the first frame
|
||||||
@ -2403,7 +2594,7 @@ void DoEnginePostProcessing( int x, int y, int w, int h, bool bFlashlightIsOn, b
|
|||||||
{
|
{
|
||||||
// Perform post-processing in one combined pass
|
// Perform post-processing in one combined pass
|
||||||
|
|
||||||
IMaterial *post_mat = CEnginePostMaterialProxy::SetupEnginePostMaterial( fullViewportPostSrcCorners, fullViewportPostDestCorners, destTexSize, bPerformSoftwareAA, bPerformBloom, bPerformColCorrect, flAAStrength );
|
IMaterial *post_mat = CEnginePostMaterialProxy::SetupEnginePostMaterial( fullViewportPostSrcCorners, fullViewportPostDestCorners, destTexSize, bPerformSoftwareAA, bPerformBloom, bPerformColCorrect, flAAStrength, flBloomScale );
|
||||||
|
|
||||||
if (bSplitScreenHDR)
|
if (bSplitScreenHDR)
|
||||||
{
|
{
|
||||||
@ -2431,7 +2622,7 @@ void DoEnginePostProcessing( int x, int y, int w, int h, bool bFlashlightIsOn, b
|
|||||||
// Perform post-processing in three separate passes
|
// Perform post-processing in three separate passes
|
||||||
if ( bPerformSoftwareAA )
|
if ( bPerformSoftwareAA )
|
||||||
{
|
{
|
||||||
IMaterial *aa_mat = CEnginePostMaterialProxy::SetupEnginePostMaterial( fullViewportPostSrcCorners, fullViewportPostDestCorners, destTexSize, bPerformSoftwareAA, false, false, flAAStrength );
|
IMaterial *aa_mat = CEnginePostMaterialProxy::SetupEnginePostMaterial( fullViewportPostSrcCorners, fullViewportPostDestCorners, destTexSize, bPerformSoftwareAA, false, false, flAAStrength, flBloomScale );
|
||||||
|
|
||||||
if (bSplitScreenHDR)
|
if (bSplitScreenHDR)
|
||||||
{
|
{
|
||||||
@ -2456,7 +2647,7 @@ void DoEnginePostProcessing( int x, int y, int w, int h, bool bFlashlightIsOn, b
|
|||||||
|
|
||||||
if ( bPerformBloom )
|
if ( bPerformBloom )
|
||||||
{
|
{
|
||||||
IMaterial *bloom_mat = CEnginePostMaterialProxy::SetupEnginePostMaterial( fullViewportPostSrcCorners, fullViewportPostDestCorners, destTexSize, false, bPerformBloom, false, flAAStrength );
|
IMaterial *bloom_mat = CEnginePostMaterialProxy::SetupEnginePostMaterial( fullViewportPostSrcCorners, fullViewportPostDestCorners, destTexSize, false, bPerformBloom, false, flAAStrength, flBloomScale );
|
||||||
|
|
||||||
if (bSplitScreenHDR)
|
if (bSplitScreenHDR)
|
||||||
{
|
{
|
||||||
@ -2487,7 +2678,7 @@ void DoEnginePostProcessing( int x, int y, int w, int h, bool bFlashlightIsOn, b
|
|||||||
UpdateScreenEffectTexture( 0, x, y, w, h, false, &actualRect );
|
UpdateScreenEffectTexture( 0, x, y, w, h, false, &actualRect );
|
||||||
}
|
}
|
||||||
|
|
||||||
IMaterial *colcorrect_mat = CEnginePostMaterialProxy::SetupEnginePostMaterial( fullViewportPostSrcCorners, fullViewportPostDestCorners, destTexSize, false, false, bPerformColCorrect, flAAStrength );
|
IMaterial *colcorrect_mat = CEnginePostMaterialProxy::SetupEnginePostMaterial( fullViewportPostSrcCorners, fullViewportPostDestCorners, destTexSize, false, false, bPerformColCorrect, flAAStrength, flBloomScale );
|
||||||
|
|
||||||
if (bSplitScreenHDR)
|
if (bSplitScreenHDR)
|
||||||
{
|
{
|
||||||
@ -2635,6 +2826,7 @@ void DoEnginePostProcessing( int x, int y, int w, int h, bool bFlashlightIsOn, b
|
|||||||
|
|
||||||
// Motion Blur Material Proxy =========================================================================================
|
// Motion Blur Material Proxy =========================================================================================
|
||||||
static float g_vMotionBlurValues[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
static float g_vMotionBlurValues[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||||
|
static float g_vMotionBlurViewportValues[4] = { 0.0f, 0.0f, 1.0f, 1.0f };
|
||||||
class CMotionBlurMaterialProxy : public CEntityMaterialProxy
|
class CMotionBlurMaterialProxy : public CEntityMaterialProxy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -2646,6 +2838,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
IMaterialVar *m_pMaterialParam;
|
IMaterialVar *m_pMaterialParam;
|
||||||
|
IMaterialVar *m_pMaterialParamViewport;
|
||||||
};
|
};
|
||||||
|
|
||||||
CMotionBlurMaterialProxy::CMotionBlurMaterialProxy()
|
CMotionBlurMaterialProxy::CMotionBlurMaterialProxy()
|
||||||
@ -2666,6 +2859,10 @@ bool CMotionBlurMaterialProxy::Init( IMaterial *pMaterial, KeyValues *pKeyValues
|
|||||||
if ( bFoundVar == false)
|
if ( bFoundVar == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
m_pMaterialParamViewport = pMaterial->FindVar( "$MotionBlurViewportInternal", &bFoundVar, false );
|
||||||
|
if ( bFoundVar == false)
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2675,6 +2872,11 @@ void CMotionBlurMaterialProxy::OnBind( C_BaseEntity *pEnt )
|
|||||||
{
|
{
|
||||||
m_pMaterialParam->SetVecValue( g_vMotionBlurValues, 4 );
|
m_pMaterialParam->SetVecValue( g_vMotionBlurValues, 4 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( m_pMaterialParamViewport != NULL )
|
||||||
|
{
|
||||||
|
m_pMaterialParamViewport->SetVecValue( g_vMotionBlurViewportValues, 4 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IMaterial *CMotionBlurMaterialProxy::GetMaterial()
|
IMaterial *CMotionBlurMaterialProxy::GetMaterial()
|
||||||
@ -2691,24 +2893,49 @@ EXPOSE_INTERFACE( CMotionBlurMaterialProxy, IMaterialProxy, "MotionBlur" IMATERI
|
|||||||
// Image-space Motion Blur ============================================================================================
|
// Image-space Motion Blur ============================================================================================
|
||||||
//=====================================================================================================================
|
//=====================================================================================================================
|
||||||
ConVar mat_motion_blur_enabled( "mat_motion_blur_enabled", "1", FCVAR_ARCHIVE );
|
ConVar mat_motion_blur_enabled( "mat_motion_blur_enabled", "1", FCVAR_ARCHIVE );
|
||||||
|
|
||||||
ConVar mat_motion_blur_forward_enabled( "mat_motion_blur_forward_enabled", "0" );
|
ConVar mat_motion_blur_forward_enabled( "mat_motion_blur_forward_enabled", "0" );
|
||||||
ConVar mat_motion_blur_falling_min( "mat_motion_blur_falling_min", "10.0" );
|
ConVar mat_motion_blur_falling_min( "mat_motion_blur_falling_min", "10.0" );
|
||||||
|
|
||||||
ConVar mat_motion_blur_falling_max( "mat_motion_blur_falling_max", "20.0" );
|
ConVar mat_motion_blur_falling_max( "mat_motion_blur_falling_max", "20.0" );
|
||||||
ConVar mat_motion_blur_falling_intensity( "mat_motion_blur_falling_intensity", "1.0" );
|
ConVar mat_motion_blur_falling_intensity( "mat_motion_blur_falling_intensity", "1.0" );
|
||||||
//ConVar mat_motion_blur_roll_intensity( "mat_motion_blur_roll_intensity", "1.0" );
|
//ConVar mat_motion_blur_roll_intensity( "mat_motion_blur_roll_intensity", "1.0" );
|
||||||
ConVar mat_motion_blur_rotation_intensity( "mat_motion_blur_rotation_intensity", "1.0" );
|
ConVar mat_motion_blur_rotation_intensity( "mat_motion_blur_rotation_intensity", "1.0" );
|
||||||
ConVar mat_motion_blur_strength( "mat_motion_blur_strength", "1.0" );
|
ConVar mat_motion_blur_strength( "mat_motion_blur_strength", "1.0" );
|
||||||
|
|
||||||
void DoImageSpaceMotionBlur( const CViewSetup &view, int x, int y, int w, int h )
|
struct MotionBlurHistory_t
|
||||||
{
|
{
|
||||||
#ifdef CSS_PERF_TEST
|
MotionBlurHistory_t()
|
||||||
return;
|
{
|
||||||
#endif
|
m_flLastTimeUpdate = 0.0f;
|
||||||
if ( ( !mat_motion_blur_enabled.GetInt() ) || ( g_pMaterialSystemHardwareConfig->GetDXSupportLevel() < 90 ) )
|
m_flPreviousPitch = 0.0f;
|
||||||
|
m_flPreviousYaw = 0.0f;
|
||||||
|
m_vPreviousPositon.Init( 0.0f, 0.0f, 0.0f );
|
||||||
|
m_mPreviousFrameBasisVectors;
|
||||||
|
m_flNoRotationalMotionBlurUntil = 0.0f;
|
||||||
|
SetIdentityMatrix( m_mPreviousFrameBasisVectors );
|
||||||
|
}
|
||||||
|
|
||||||
|
float m_flLastTimeUpdate;
|
||||||
|
float m_flPreviousPitch;
|
||||||
|
float m_flPreviousYaw;
|
||||||
|
Vector m_vPreviousPositon;
|
||||||
|
matrix3x4_t m_mPreviousFrameBasisVectors;
|
||||||
|
float m_flNoRotationalMotionBlurUntil;
|
||||||
|
};
|
||||||
|
|
||||||
|
void DoImageSpaceMotionBlur( const CViewSetup &viewSetup )
|
||||||
|
{
|
||||||
|
if ( !mat_motion_blur_enabled.GetInt() )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int x = viewSetup.x;
|
||||||
|
int y = viewSetup.y;
|
||||||
|
int w = viewSetup.width;
|
||||||
|
int h = viewSetup.height;
|
||||||
|
|
||||||
//======================================================================================================//
|
//======================================================================================================//
|
||||||
// Get these convars here to make it easier to remove them later and to default each client differently //
|
// Get these convars here to make it easier to remove them later and to default each client differently //
|
||||||
//======================================================================================================//
|
//======================================================================================================//
|
||||||
@ -2727,22 +2954,19 @@ void DoImageSpaceMotionBlur( const CViewSetup &view, int x, int y, int w, int h
|
|||||||
//=====================//
|
//=====================//
|
||||||
// Previous frame data //
|
// Previous frame data //
|
||||||
//=====================//
|
//=====================//
|
||||||
static float s_flLastTimeUpdate = 0.0f;
|
static MotionBlurHistory_t history;
|
||||||
static float s_flPreviousPitch = 0.0f;
|
|
||||||
static float s_flPreviousYaw = 0.0f;
|
|
||||||
static float s_vPreviousPositon[3] = { 0.0f, 0.0f, 0.0f };
|
|
||||||
static matrix3x4_t s_mPreviousFrameBasisVectors;
|
|
||||||
static float s_flNoRotationalMotionBlurUntil = 0.0f;
|
|
||||||
//float vPreviousSideVec[3] = { s_mPreviousFrameBasisVectors[0][1], s_mPreviousFrameBasisVectors[1][1], s_mPreviousFrameBasisVectors[2][1] };
|
//float vPreviousSideVec[3] = { s_mPreviousFrameBasisVectors[0][1], s_mPreviousFrameBasisVectors[1][1], s_mPreviousFrameBasisVectors[2][1] };
|
||||||
//float vPreviousForwardVec[3] = { s_mPreviousFrameBasisVectors[0][0], s_mPreviousFrameBasisVectors[1][0], s_mPreviousFrameBasisVectors[2][0] };
|
//float vPreviousForwardVec[3] = { s_mPreviousFrameBasisVectors[0][0], s_mPreviousFrameBasisVectors[1][0], s_mPreviousFrameBasisVectors[2][0] };
|
||||||
//float vPreviousUpVec[3] = { s_mPreviousFrameBasisVectors[0][2], s_mPreviousFrameBasisVectors[1][2], s_mPreviousFrameBasisVectors[2][2] };
|
//float vPreviousUpVec[3] = { s_mPreviousFrameBasisVectors[0][2], s_mPreviousFrameBasisVectors[1][2], s_mPreviousFrameBasisVectors[2][2] };
|
||||||
|
|
||||||
float flTimeElapsed = gpGlobals->realtime - s_flLastTimeUpdate;
|
float flTimeElapsed = gpGlobals->realtime - history.m_flLastTimeUpdate;
|
||||||
|
|
||||||
|
|
||||||
//===================================//
|
//===================================//
|
||||||
// Get current pitch & wrap to +-180 //
|
// Get current pitch & wrap to +-180 //
|
||||||
//===================================//
|
//===================================//
|
||||||
float flCurrentPitch = view.angles[PITCH];
|
float flCurrentPitch = viewSetup.angles[PITCH];
|
||||||
while ( flCurrentPitch > 180.0f )
|
while ( flCurrentPitch > 180.0f )
|
||||||
flCurrentPitch -= 360.0f;
|
flCurrentPitch -= 360.0f;
|
||||||
while ( flCurrentPitch < -180.0f )
|
while ( flCurrentPitch < -180.0f )
|
||||||
@ -2751,35 +2975,39 @@ void DoImageSpaceMotionBlur( const CViewSetup &view, int x, int y, int w, int h
|
|||||||
//=================================//
|
//=================================//
|
||||||
// Get current yaw & wrap to +-180 //
|
// Get current yaw & wrap to +-180 //
|
||||||
//=================================//
|
//=================================//
|
||||||
float flCurrentYaw = view.angles[YAW];
|
float flCurrentYaw = viewSetup.angles[YAW];
|
||||||
while ( flCurrentYaw > 180.0f )
|
while ( flCurrentYaw > 180.0f )
|
||||||
flCurrentYaw -= 360.0f;
|
flCurrentYaw -= 360.0f;
|
||||||
while ( flCurrentYaw < -180.0f )
|
while ( flCurrentYaw < -180.0f )
|
||||||
flCurrentYaw += 360.0f;
|
flCurrentYaw += 360.0f;
|
||||||
|
|
||||||
//engine->Con_NPrintf( 0, "Blur Pitch: %6.2f Yaw: %6.2f", flCurrentPitch, flCurrentYaw );
|
|
||||||
//engine->Con_NPrintf( 1, "Blur FOV: %6.2f Aspect: %6.2f Ortho: %s", view.fov, view.m_flAspectRatio, view.m_bOrtho ? "Yes" : "No" );
|
|
||||||
|
/*engine->Con_NPrintf( 0, "Blur Pitch: %6.2f Yaw: %6.2f", flCurrentPitch, flCurrentYaw );
|
||||||
|
engine->Con_NPrintf( 1, "Blur FOV: %6.2f Aspect: %6.2f Ortho: %s", view.fov, view.m_flAspectRatio, view.m_bOrtho ? "Yes" : "No" );
|
||||||
|
engine->Con_NPrintf( 2, "View Angles: %6.2f %6.2f %6.2f", XYZ(view.angles) );*/
|
||||||
|
|
||||||
//===========================//
|
//===========================//
|
||||||
// Get current basis vectors //
|
// Get current basis vectors //
|
||||||
//===========================//
|
//===========================//
|
||||||
matrix3x4_t mCurrentBasisVectors;
|
matrix3x4_t mCurrentBasisVectors;
|
||||||
AngleMatrix( view.angles, mCurrentBasisVectors );
|
AngleMatrix( viewSetup.angles, mCurrentBasisVectors );
|
||||||
|
|
||||||
float vCurrentSideVec[3] = { mCurrentBasisVectors[0][1], mCurrentBasisVectors[1][1], mCurrentBasisVectors[2][1] };
|
|
||||||
float vCurrentForwardVec[3] = { mCurrentBasisVectors[0][0], mCurrentBasisVectors[1][0], mCurrentBasisVectors[2][0] };
|
Vector vCurrentSideVec( mCurrentBasisVectors[0][1], mCurrentBasisVectors[1][1], mCurrentBasisVectors[2][1] );
|
||||||
//float vCurrentUpVec[3] = { mCurrentBasisVectors[0][2], mCurrentBasisVectors[1][2], mCurrentBasisVectors[2][2] };
|
Vector vCurrentForwardVec( mCurrentBasisVectors[0][0], mCurrentBasisVectors[1][0], mCurrentBasisVectors[2][0] );
|
||||||
|
//Vector vCurrentUpVec( mCurrentBasisVectors[0][2], mCurrentBasisVectors[1][2], mCurrentBasisVectors[2][2] );
|
||||||
|
|
||||||
//======================//
|
//======================//
|
||||||
// Get current position //
|
// Get current position //
|
||||||
//======================//
|
//======================//
|
||||||
float vCurrentPosition[3] = { view.origin.x, view.origin.y, view.origin.z };
|
Vector vCurrentPosition = viewSetup.origin;
|
||||||
|
|
||||||
//===============================================================//
|
//===============================================================//
|
||||||
// Evaluate change in position to determine if we need to update //
|
// Evaluate change in position to determine if we need to update //
|
||||||
//===============================================================//
|
//===============================================================//
|
||||||
float vPositionChange[3] = { 0.0f, 0.0f, 0.0f };
|
Vector vPositionChange( 0.0f, 0.0f, 0.0f );
|
||||||
VectorSubtract( s_vPreviousPositon, vCurrentPosition, vPositionChange );
|
VectorSubtract( history.m_vPreviousPositon, vCurrentPosition, vPositionChange );
|
||||||
if ( ( VectorLength( vPositionChange ) > 30.0f ) && ( flTimeElapsed >= 0.5f ) )
|
if ( ( VectorLength( vPositionChange ) > 30.0f ) && ( flTimeElapsed >= 0.5f ) )
|
||||||
{
|
{
|
||||||
//=======================================================//
|
//=======================================================//
|
||||||
@ -2793,7 +3021,7 @@ void DoImageSpaceMotionBlur( const CViewSetup &view, int x, int y, int w, int h
|
|||||||
g_vMotionBlurValues[2] = 0.0f;
|
g_vMotionBlurValues[2] = 0.0f;
|
||||||
g_vMotionBlurValues[3] = 0.0f;
|
g_vMotionBlurValues[3] = 0.0f;
|
||||||
}
|
}
|
||||||
else if ( flTimeElapsed > ( 1.0f / 15.0f ) )
|
else if ( ( flTimeElapsed > ( 1.0f / 15.0f ) ) )
|
||||||
{
|
{
|
||||||
//==========================================//
|
//==========================================//
|
||||||
// If slower than 15 fps, don't motion blur //
|
// If slower than 15 fps, don't motion blur //
|
||||||
@ -2803,7 +3031,7 @@ void DoImageSpaceMotionBlur( const CViewSetup &view, int x, int y, int w, int h
|
|||||||
g_vMotionBlurValues[2] = 0.0f;
|
g_vMotionBlurValues[2] = 0.0f;
|
||||||
g_vMotionBlurValues[3] = 0.0f;
|
g_vMotionBlurValues[3] = 0.0f;
|
||||||
}
|
}
|
||||||
else if ( VectorLength( vPositionChange ) > 50.0f )
|
else if ( ( VectorLength( vPositionChange ) > 50.0f ) )
|
||||||
{
|
{
|
||||||
//================================================================================//
|
//================================================================================//
|
||||||
// We moved a far distance in a frame, use the same motion blur as last frame //
|
// We moved a far distance in a frame, use the same motion blur as last frame //
|
||||||
@ -2811,7 +3039,7 @@ void DoImageSpaceMotionBlur( const CViewSetup &view, int x, int y, int w, int h
|
|||||||
//================================================================================//
|
//================================================================================//
|
||||||
//engine->Con_NPrintf( 8, " Position changed %f units @ %.2f time ", VectorLength( vPositionChange ), gpGlobals->realtime );
|
//engine->Con_NPrintf( 8, " Position changed %f units @ %.2f time ", VectorLength( vPositionChange ), gpGlobals->realtime );
|
||||||
|
|
||||||
s_flNoRotationalMotionBlurUntil = gpGlobals->realtime + 1.0f; // Wait a second until the portal craziness calms down
|
history.m_flNoRotationalMotionBlurUntil = gpGlobals->realtime + 1.0f; // Wait a second until the portal craziness calms down
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2819,8 +3047,8 @@ void DoImageSpaceMotionBlur( const CViewSetup &view, int x, int y, int w, int h
|
|||||||
// Normal update path //
|
// Normal update path //
|
||||||
//====================//
|
//====================//
|
||||||
// Compute horizontal and vertical fov
|
// Compute horizontal and vertical fov
|
||||||
float flHorizontalFov = view.fov;
|
float flHorizontalFov = viewSetup.fov;
|
||||||
float flVerticalFov = ( view.m_flAspectRatio <= 0.0f ) ? ( view.fov ) : ( view.fov / view.m_flAspectRatio );
|
float flVerticalFov = ( viewSetup.m_flAspectRatio <= 0.0f ) ? ( viewSetup.fov ) : ( viewSetup.fov / viewSetup.m_flAspectRatio );
|
||||||
//engine->Con_NPrintf( 2, "Horizontal Fov: %6.2f Vertical Fov: %6.2f", flHorizontalFov, flVerticalFov );
|
//engine->Con_NPrintf( 2, "Horizontal Fov: %6.2f Vertical Fov: %6.2f", flHorizontalFov, flVerticalFov );
|
||||||
|
|
||||||
//=====================//
|
//=====================//
|
||||||
@ -2836,10 +3064,10 @@ void DoImageSpaceMotionBlur( const CViewSetup &view, int x, int y, int w, int h
|
|||||||
// Yaw (Compensate for circle strafe) //
|
// Yaw (Compensate for circle strafe) //
|
||||||
//====================================//
|
//====================================//
|
||||||
float flSideDotMotion = DotProduct( vCurrentSideVec, vPositionChange );
|
float flSideDotMotion = DotProduct( vCurrentSideVec, vPositionChange );
|
||||||
float flYawDiffOriginal = s_flPreviousYaw - flCurrentYaw;
|
float flYawDiffOriginal = history.m_flPreviousYaw - flCurrentYaw;
|
||||||
if ( ( ( s_flPreviousYaw - flCurrentYaw > 180.0f ) || ( s_flPreviousYaw - flCurrentYaw < -180.0f ) ) &&
|
if ( ( ( history.m_flPreviousYaw - flCurrentYaw > 180.0f ) || ( history.m_flPreviousYaw - flCurrentYaw < -180.0f ) ) &&
|
||||||
( ( s_flPreviousYaw + flCurrentYaw > -180.0f ) && ( s_flPreviousYaw + flCurrentYaw < 180.0f ) ) )
|
( ( history.m_flPreviousYaw + flCurrentYaw > -180.0f ) && ( history.m_flPreviousYaw + flCurrentYaw < 180.0f ) ) )
|
||||||
flYawDiffOriginal = s_flPreviousYaw + flCurrentYaw;
|
flYawDiffOriginal = history.m_flPreviousYaw + flCurrentYaw;
|
||||||
|
|
||||||
float flYawDiffAdjusted = flYawDiffOriginal + ( flSideDotMotion / 3.0f ); // Yes, 3.0 is a magic number, sue me
|
float flYawDiffAdjusted = flYawDiffOriginal + ( flSideDotMotion / 3.0f ); // Yes, 3.0 is a magic number, sue me
|
||||||
|
|
||||||
@ -2859,7 +3087,7 @@ void DoImageSpaceMotionBlur( const CViewSetup &view, int x, int y, int w, int h
|
|||||||
// Pitch (Compensate for forward motion) //
|
// Pitch (Compensate for forward motion) //
|
||||||
//=======================================//
|
//=======================================//
|
||||||
float flPitchCompensateMask = 1.0f - ( ( 1.0f - fabs( vCurrentForwardVec[2] ) ) * ( 1.0f - fabs( vCurrentForwardVec[2] ) ) );
|
float flPitchCompensateMask = 1.0f - ( ( 1.0f - fabs( vCurrentForwardVec[2] ) ) * ( 1.0f - fabs( vCurrentForwardVec[2] ) ) );
|
||||||
float flPitchDiffOriginal = s_flPreviousPitch - flCurrentPitch;
|
float flPitchDiffOriginal = history.m_flPreviousPitch - flCurrentPitch;
|
||||||
float flPitchDiffAdjusted = flPitchDiffOriginal;
|
float flPitchDiffAdjusted = flPitchDiffOriginal;
|
||||||
|
|
||||||
if ( flCurrentPitch > 0.0f )
|
if ( flCurrentPitch > 0.0f )
|
||||||
@ -2909,24 +3137,21 @@ void DoImageSpaceMotionBlur( const CViewSetup &view, int x, int y, int w, int h
|
|||||||
//===============================================================//
|
//===============================================================//
|
||||||
// Dampen motion blur from 100%-0% as fps drops from 50fps-30fps //
|
// Dampen motion blur from 100%-0% as fps drops from 50fps-30fps //
|
||||||
//===============================================================//
|
//===============================================================//
|
||||||
if ( !IsX360() ) // I'm not doing this on the 360 yet since I can't test it
|
float flSlowFps = 30.0f;
|
||||||
{
|
float flFastFps = 50.0f;
|
||||||
float flSlowFps = 30.0f;
|
float flCurrentFps = ( flTimeElapsed > 0.0f ) ? ( 1.0f / flTimeElapsed ) : 0.0f;
|
||||||
float flFastFps = 50.0f;
|
float flDampenFactor = clamp( ( ( flCurrentFps - flSlowFps ) / ( flFastFps - flSlowFps ) ), 0.0f, 1.0f );
|
||||||
float flCurrentFps = ( flTimeElapsed > 0.0f ) ? ( 1.0f / flTimeElapsed ) : 0.0f;
|
|
||||||
float flDampenFactor = clamp( ( ( flCurrentFps - flSlowFps ) / ( flFastFps - flSlowFps ) ), 0.0f, 1.0f );
|
|
||||||
|
|
||||||
//engine->Con_NPrintf( 4, "gpGlobals->realtime %.2f gpGlobals->curtime %.2f", gpGlobals->realtime, gpGlobals->curtime );
|
//engine->Con_NPrintf( 4, "gpGlobals->realtime %.2f gpGlobals->curtime %.2f", gpGlobals->realtime, gpGlobals->curtime );
|
||||||
//engine->Con_NPrintf( 5, "flCurrentFps %.2f", flCurrentFps );
|
//engine->Con_NPrintf( 5, "flCurrentFps %.2f", flCurrentFps );
|
||||||
//engine->Con_NPrintf( 7, "flTimeElapsed %.2f", flTimeElapsed );
|
//engine->Con_NPrintf( 7, "flTimeElapsed %.2f", flTimeElapsed );
|
||||||
|
|
||||||
g_vMotionBlurValues[0] *= flDampenFactor;
|
g_vMotionBlurValues[0] *= flDampenFactor;
|
||||||
g_vMotionBlurValues[1] *= flDampenFactor;
|
g_vMotionBlurValues[1] *= flDampenFactor;
|
||||||
g_vMotionBlurValues[2] *= flDampenFactor;
|
g_vMotionBlurValues[2] *= flDampenFactor;
|
||||||
g_vMotionBlurValues[3] *= flDampenFactor;
|
g_vMotionBlurValues[3] *= flDampenFactor;
|
||||||
|
|
||||||
//engine->Con_NPrintf( 6, "Dampen: %.2f", flDampenFactor );
|
//engine->Con_NPrintf( 6, "Dampen: %.2f", flDampenFactor );
|
||||||
}
|
|
||||||
|
|
||||||
//engine->Con_NPrintf( 6, "Final values: { %6.2f%%, %6.2f%%, %6.2f%%, %6.2f%% }", g_vMotionBlurValues[0]*100.0f, g_vMotionBlurValues[1]*100.0f, g_vMotionBlurValues[2]*100.0f, g_vMotionBlurValues[3]*100.0f );
|
//engine->Con_NPrintf( 6, "Final values: { %6.2f%%, %6.2f%%, %6.2f%%, %6.2f%% }", g_vMotionBlurValues[0]*100.0f, g_vMotionBlurValues[1]*100.0f, g_vMotionBlurValues[2]*100.0f, g_vMotionBlurValues[3]*100.0f );
|
||||||
}
|
}
|
||||||
@ -2934,7 +3159,7 @@ void DoImageSpaceMotionBlur( const CViewSetup &view, int x, int y, int w, int h
|
|||||||
//============================================//
|
//============================================//
|
||||||
// Zero out blur if still in that time window //
|
// Zero out blur if still in that time window //
|
||||||
//============================================//
|
//============================================//
|
||||||
if ( gpGlobals->realtime < s_flNoRotationalMotionBlurUntil )
|
if ( gpGlobals->realtime < history.m_flNoRotationalMotionBlurUntil )
|
||||||
{
|
{
|
||||||
//engine->Con_NPrintf( 9, " No Rotation @ %f ", gpGlobals->realtime );
|
//engine->Con_NPrintf( 9, " No Rotation @ %f ", gpGlobals->realtime );
|
||||||
|
|
||||||
@ -2945,17 +3170,60 @@ void DoImageSpaceMotionBlur( const CViewSetup &view, int x, int y, int w, int h
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s_flNoRotationalMotionBlurUntil = 0.0f;
|
history.m_flNoRotationalMotionBlurUntil = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
//====================================//
|
//====================================//
|
||||||
// Store current frame for next frame //
|
// Store current frame for next frame //
|
||||||
//====================================//
|
//====================================//
|
||||||
VectorCopy( vCurrentPosition, s_vPreviousPositon );
|
VectorCopy( vCurrentPosition, history.m_vPreviousPositon );
|
||||||
s_mPreviousFrameBasisVectors = mCurrentBasisVectors;
|
history.m_mPreviousFrameBasisVectors = mCurrentBasisVectors;
|
||||||
s_flPreviousPitch = flCurrentPitch;
|
history.m_flPreviousPitch = flCurrentPitch;
|
||||||
s_flPreviousYaw = flCurrentYaw;
|
history.m_flPreviousYaw = flCurrentYaw;
|
||||||
s_flLastTimeUpdate = gpGlobals->realtime;
|
history.m_flLastTimeUpdate = gpGlobals->realtime;
|
||||||
|
}
|
||||||
|
|
||||||
|
//engine->Con_NPrintf( 6, "Final values: { %6.2f%%, %6.2f%%, %6.2f%%, %6.2f%% }", g_vMotionBlurValues[0]*100.0f, g_vMotionBlurValues[1]*100.0f, g_vMotionBlurValues[2]*100.0f, g_vMotionBlurValues[3]*100.0f );
|
||||||
|
|
||||||
|
//==========================================//
|
||||||
|
// Set global g_vMotionBlurViewportValues[] //
|
||||||
|
//==========================================//
|
||||||
|
if ( true )
|
||||||
|
{
|
||||||
|
ITexture *pSrc = materials->FindTexture( "_rt_FullFrameFB", TEXTURE_GROUP_RENDER_TARGET );
|
||||||
|
float flSrcWidth = ( float )pSrc->GetActualWidth();
|
||||||
|
float flSrcHeight = ( float )pSrc->GetActualHeight();
|
||||||
|
|
||||||
|
// NOTE #1: float4 stored as ( minx, miny, maxy, maxx )...z&w have been swapped to save pixel shader instructions
|
||||||
|
// NOTE #2: This code should definitely work for 2 players (horizontal or vertical), or 4 players (4 corners), but
|
||||||
|
// it might have to be modified if we ever want to support other split screen configurations
|
||||||
|
|
||||||
|
int nOffset; // Offset by one pixel to land in the correct half
|
||||||
|
|
||||||
|
// Left
|
||||||
|
nOffset = ( x > 0 ) ? 1 : 0;
|
||||||
|
g_vMotionBlurViewportValues[0] = ( float )( x + nOffset ) / ( flSrcWidth - 1 );
|
||||||
|
|
||||||
|
// Right
|
||||||
|
nOffset = ( x < ( flSrcWidth - 1 ) ) ? -1 : 0;
|
||||||
|
g_vMotionBlurViewportValues[3] = ( float )( x + w + nOffset ) / ( flSrcWidth - 1 );
|
||||||
|
|
||||||
|
// Top
|
||||||
|
nOffset = ( y > 0 ) ? 1 : 0; // Offset by one pixel to land in the correct half
|
||||||
|
g_vMotionBlurViewportValues[1] = ( float )( y + nOffset ) / ( flSrcHeight - 1 );
|
||||||
|
|
||||||
|
// Bottom
|
||||||
|
nOffset = ( y < ( flSrcHeight - 1 ) ) ? -1 : 0;
|
||||||
|
g_vMotionBlurViewportValues[2] = ( float )( y + h + nOffset ) / ( flSrcHeight - 1 );
|
||||||
|
|
||||||
|
// Only allow clamping to happen in the middle of the screen, so nudge the clamp values out if they're on the border of the screen
|
||||||
|
for ( int i = 0; i < 4; i++ )
|
||||||
|
{
|
||||||
|
if ( g_vMotionBlurViewportValues[i] <= 0.0f )
|
||||||
|
g_vMotionBlurViewportValues[i] = -1.0f;
|
||||||
|
else if ( g_vMotionBlurViewportValues[i] >= 1.0f )
|
||||||
|
g_vMotionBlurViewportValues[i] = 2.0f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================================================================================//
|
//=============================================================================================//
|
||||||
@ -2968,13 +3236,10 @@ void DoImageSpaceMotionBlur( const CViewSetup &view, int x, int y, int w, int h
|
|||||||
ITexture *pSrc = materials->FindTexture( "_rt_FullFrameFB", TEXTURE_GROUP_RENDER_TARGET );
|
ITexture *pSrc = materials->FindTexture( "_rt_FullFrameFB", TEXTURE_GROUP_RENDER_TARGET );
|
||||||
int nSrcWidth = pSrc->GetActualWidth();
|
int nSrcWidth = pSrc->GetActualWidth();
|
||||||
int nSrcHeight = pSrc->GetActualHeight();
|
int nSrcHeight = pSrc->GetActualHeight();
|
||||||
int dest_width, dest_height, nDummy;
|
int nViewportWidth, nViewportHeight, nDummy;
|
||||||
pRenderContext->GetViewport( nDummy, nDummy, dest_width, dest_height );
|
pRenderContext->GetViewport( nDummy, nDummy, nViewportWidth, nViewportHeight );
|
||||||
|
|
||||||
if ( g_pMaterialSystemHardwareConfig->GetHDRType() != HDR_TYPE_FLOAT )
|
UpdateScreenEffectTexture( 0, x, y, w, h, false );
|
||||||
{
|
|
||||||
UpdateScreenEffectTexture( 0, x, y, w, h, true ); // Do we need to check if we already did this?
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get material pointer
|
// Get material pointer
|
||||||
IMaterial *pMatMotionBlur = materials->FindMaterial( "dev/motion_blur", TEXTURE_GROUP_OTHER, true );
|
IMaterial *pMatMotionBlur = materials->FindMaterial( "dev/motion_blur", TEXTURE_GROUP_OTHER, true );
|
||||||
@ -2986,14 +3251,200 @@ void DoImageSpaceMotionBlur( const CViewSetup &view, int x, int y, int w, int h
|
|||||||
{
|
{
|
||||||
pRenderContext->DrawScreenSpaceRectangle(
|
pRenderContext->DrawScreenSpaceRectangle(
|
||||||
pMatMotionBlur,
|
pMatMotionBlur,
|
||||||
0, 0, dest_width, dest_height,
|
0, 0, nViewportWidth, nViewportHeight,
|
||||||
0, 0, nSrcWidth-1, nSrcHeight-1,
|
x, y, x + w-1, y + h-1,
|
||||||
nSrcWidth, nSrcHeight, GetClientWorldEntity()->GetClientRenderable() );
|
nSrcWidth, nSrcHeight, GetClientWorldEntity()->GetClientRenderable() );
|
||||||
|
|
||||||
if ( g_bDumpRenderTargets )
|
|
||||||
{
|
|
||||||
DumpTGAofRenderTarget( dest_width, dest_height, "MotionBlur" );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=====================================================================================================================
|
||||||
|
// Depth of field =====================================================================================================
|
||||||
|
//=====================================================================================================================
|
||||||
|
ConVar mat_dof_enabled( "mat_dof_enabled", "1" );
|
||||||
|
ConVar mat_dof_override( "mat_dof_override", "0" );
|
||||||
|
ConVar mat_dof_near_blur_depth( "mat_dof_near_blur_depth", "20.0" );
|
||||||
|
ConVar mat_dof_near_focus_depth( "mat_dof_near_focus_depth", "100.0" );
|
||||||
|
ConVar mat_dof_far_focus_depth( "mat_dof_far_focus_depth", "250.0" );
|
||||||
|
ConVar mat_dof_far_blur_depth( "mat_dof_far_blur_depth", "1000.0" );
|
||||||
|
ConVar mat_dof_near_blur_radius( "mat_dof_near_blur_radius", "0.0" );
|
||||||
|
ConVar mat_dof_far_blur_radius( "mat_dof_far_blur_radius", "10.0" );
|
||||||
|
ConVar mat_dof_quality( "mat_dof_quality", "3" );
|
||||||
|
|
||||||
|
static float GetNearBlurDepth()
|
||||||
|
{
|
||||||
|
return mat_dof_override.GetBool() ? mat_dof_near_blur_depth.GetFloat() : g_flDOFNearBlurDepth;
|
||||||
|
}
|
||||||
|
|
||||||
|
static float GetNearFocusDepth()
|
||||||
|
{
|
||||||
|
return mat_dof_override.GetBool() ? mat_dof_near_focus_depth.GetFloat() : g_flDOFNearFocusDepth;
|
||||||
|
}
|
||||||
|
|
||||||
|
static float GetFarFocusDepth()
|
||||||
|
{
|
||||||
|
return mat_dof_override.GetBool() ? mat_dof_far_focus_depth.GetFloat() : g_flDOFFarFocusDepth;
|
||||||
|
}
|
||||||
|
|
||||||
|
static float GetFarBlurDepth()
|
||||||
|
{
|
||||||
|
return mat_dof_override.GetBool() ? mat_dof_far_blur_depth.GetFloat() : g_flDOFFarBlurDepth;
|
||||||
|
}
|
||||||
|
|
||||||
|
static float GetNearBlurRadius()
|
||||||
|
{
|
||||||
|
return mat_dof_override.GetBool() ? mat_dof_near_blur_radius.GetFloat() : g_flDOFNearBlurRadius;
|
||||||
|
}
|
||||||
|
|
||||||
|
static float GetFarBlurRadius()
|
||||||
|
{
|
||||||
|
return mat_dof_override.GetBool() ? mat_dof_far_blur_radius.GetFloat() : g_flDOFFarBlurRadius;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsDepthOfFieldEnabled()
|
||||||
|
{
|
||||||
|
const CViewSetup *pViewSetup = view->GetViewSetup();
|
||||||
|
if ( !pViewSetup )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if ( g_pMaterialSystemHardwareConfig->GetDXSupportLevel() < 92 )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if ( !mat_dof_enabled.GetBool() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if ( mat_dof_override.GetBool() == true )
|
||||||
|
{
|
||||||
|
return mat_dof_enabled.GetBool();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return g_bDOFEnabled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline bool SetMaterialVarFloat( IMaterial* pMat, const char* pVarName, float flValue )
|
||||||
|
{
|
||||||
|
Assert( pMat != NULL );
|
||||||
|
Assert( pVarName != NULL );
|
||||||
|
if ( pMat == NULL || pVarName == NULL )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool bFound = false;
|
||||||
|
IMaterialVar* pVar = pMat->FindVar( pVarName, &bFound );
|
||||||
|
if ( bFound )
|
||||||
|
{
|
||||||
|
pVar->SetFloatValue( flValue );
|
||||||
|
}
|
||||||
|
|
||||||
|
return bFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline bool SetMaterialVarInt( IMaterial* pMat, const char* pVarName, int nValue )
|
||||||
|
{
|
||||||
|
Assert( pMat != NULL );
|
||||||
|
Assert( pVarName != NULL );
|
||||||
|
if ( pMat == NULL || pVarName == NULL )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool bFound = false;
|
||||||
|
IMaterialVar* pVar = pMat->FindVar( pVarName, &bFound );
|
||||||
|
if ( bFound )
|
||||||
|
{
|
||||||
|
pVar->SetIntValue( nValue );
|
||||||
|
}
|
||||||
|
|
||||||
|
return bFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DoDepthOfField( const CViewSetup &viewSetup )
|
||||||
|
{
|
||||||
|
if ( !IsDepthOfFieldEnabled() )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy from backbuffer to _rt_FullFrameFB
|
||||||
|
UpdateScreenEffectTexture( 0, viewSetup.x, viewSetup.y, viewSetup.width, viewSetup.height, false ); // Do we need to check if we already did this?
|
||||||
|
|
||||||
|
CMatRenderContextPtr pRenderContext( materials );
|
||||||
|
|
||||||
|
ITexture *pSrc = materials->FindTexture( "_rt_FullFrameFB", TEXTURE_GROUP_RENDER_TARGET );
|
||||||
|
int nSrcWidth = pSrc->GetActualWidth();
|
||||||
|
int nSrcHeight = pSrc->GetActualHeight();
|
||||||
|
|
||||||
|
int nViewportWidth = 0;
|
||||||
|
int nViewportHeight = 0;
|
||||||
|
int nDummy = 0;
|
||||||
|
pRenderContext->GetViewport( nDummy, nDummy, nViewportWidth, nViewportHeight );
|
||||||
|
|
||||||
|
if ( mat_dof_quality.GetInt() < 2 )
|
||||||
|
{
|
||||||
|
/////////////////////////////////////
|
||||||
|
// Downsample backbuffer to 1/4 size
|
||||||
|
/////////////////////////////////////
|
||||||
|
|
||||||
|
// Update downsampled framebuffer. TODO: Don't do this again for the bloom if we already did it here...
|
||||||
|
pRenderContext->PushRenderTargetAndViewport();
|
||||||
|
ITexture *dest_rt0 = materials->FindTexture( "_rt_SmallFB0", TEXTURE_GROUP_RENDER_TARGET );
|
||||||
|
|
||||||
|
// *Everything* in here relies on the small RTs being exactly 1/4 the full FB res
|
||||||
|
Assert( dest_rt0->GetActualWidth() == pSrc->GetActualWidth() / 4 );
|
||||||
|
Assert( dest_rt0->GetActualHeight() == pSrc->GetActualHeight() / 4 );
|
||||||
|
|
||||||
|
// Downsample fb to rt0
|
||||||
|
DownsampleFBQuarterSize( pRenderContext, nSrcWidth, nSrcHeight, dest_rt0, true );
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// Additional blur using 3x3 gaussian
|
||||||
|
//////////////////////////////////////
|
||||||
|
|
||||||
|
IMaterial *pMat = materials->FindMaterial( "dev/blurgaussian_3x3", TEXTURE_GROUP_OTHER, true );
|
||||||
|
|
||||||
|
if ( pMat == NULL )
|
||||||
|
return;
|
||||||
|
|
||||||
|
SetMaterialVarFloat( pMat, "$c0_x", 0.5f / (float)dest_rt0->GetActualWidth() );
|
||||||
|
SetMaterialVarFloat( pMat, "$c0_y", 0.5f / (float)dest_rt0->GetActualHeight() );
|
||||||
|
SetMaterialVarFloat( pMat, "$c1_x", -0.5f / (float)dest_rt0->GetActualWidth() );
|
||||||
|
SetMaterialVarFloat( pMat, "$c1_y", 0.5f / (float)dest_rt0->GetActualHeight() );
|
||||||
|
|
||||||
|
ITexture *dest_rt1 = materials->FindTexture( "_rt_SmallFB1", TEXTURE_GROUP_RENDER_TARGET );
|
||||||
|
SetRenderTargetAndViewPort( dest_rt1 );
|
||||||
|
|
||||||
|
pRenderContext->DrawScreenSpaceRectangle(
|
||||||
|
pMat, 0, 0, nSrcWidth/4, nSrcHeight/4,
|
||||||
|
0, 0, dest_rt0->GetActualWidth()-1, dest_rt0->GetActualHeight()-1,
|
||||||
|
dest_rt0->GetActualWidth(), dest_rt0->GetActualHeight() );
|
||||||
|
|
||||||
|
pRenderContext->PopRenderTargetAndViewport();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Render depth-of-field quad
|
||||||
|
IMaterial *pMatDOF = materials->FindMaterial( "dev/depth_of_field", TEXTURE_GROUP_OTHER, true );
|
||||||
|
|
||||||
|
if ( pMatDOF == NULL )
|
||||||
|
return;
|
||||||
|
|
||||||
|
SetMaterialVarFloat( pMatDOF, "$nearPlane", viewSetup.zNear );
|
||||||
|
SetMaterialVarFloat( pMatDOF, "$farPlane", viewSetup.zFar );
|
||||||
|
|
||||||
|
// pull from convars/globals
|
||||||
|
SetMaterialVarFloat( pMatDOF, "$nearBlurDepth", GetNearBlurDepth() );
|
||||||
|
SetMaterialVarFloat( pMatDOF, "$nearFocusDepth", GetNearFocusDepth() );
|
||||||
|
SetMaterialVarFloat( pMatDOF, "$farFocusDepth", GetFarFocusDepth() );
|
||||||
|
SetMaterialVarFloat( pMatDOF, "$farBlurDepth", GetFarBlurDepth() );
|
||||||
|
SetMaterialVarFloat( pMatDOF, "$nearBlurRadius", GetNearBlurRadius() );
|
||||||
|
SetMaterialVarFloat( pMatDOF, "$farBlurRadius", GetFarBlurRadius() );
|
||||||
|
SetMaterialVarInt( pMatDOF, "$quality", mat_dof_quality.GetInt() );
|
||||||
|
|
||||||
|
pRenderContext->DrawScreenSpaceRectangle(
|
||||||
|
pMatDOF,
|
||||||
|
0, 0, nViewportWidth, nViewportHeight,
|
||||||
|
0, 0, nSrcWidth-1, nSrcHeight-1,
|
||||||
|
nSrcWidth, nSrcHeight, GetClientWorldEntity()->GetClientRenderable() );
|
||||||
|
}
|
||||||
|
@ -11,8 +11,20 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct PostProcessParameters_t;
|
||||||
|
|
||||||
void DoEnginePostProcessing( int x, int y, int w, int h, bool bFlashlightIsOn, bool bPostVGui = false );
|
void DoEnginePostProcessing( int x, int y, int w, int h, bool bFlashlightIsOn, bool bPostVGui = false );
|
||||||
void DoImageSpaceMotionBlur( const CViewSetup &view, int x, int y, int w, int h );
|
void DoImageSpaceMotionBlur( const CViewSetup &viewSetup );
|
||||||
void DumpTGAofRenderTarget( const int width, const int height, const char *pFilename );
|
void DumpTGAofRenderTarget( const int width, const int height, const char *pFilename );
|
||||||
|
|
||||||
|
void SetRenderTargetAndViewPort( ITexture *rt );
|
||||||
|
|
||||||
|
bool IsDepthOfFieldEnabled();
|
||||||
|
void DoDepthOfField( const CViewSetup &view );
|
||||||
|
|
||||||
|
void SetPostProcessParams( const PostProcessParameters_t* pPostProcessParameters );
|
||||||
|
void SetPostProcessParams( const PostProcessParameters_t* pPostProcessParameters, bool override );
|
||||||
|
|
||||||
|
void SetViewFadeParams( byte r, byte g, byte b, byte a, bool bModulate );
|
||||||
|
|
||||||
#endif // VIEWPOSTPROCESS_H
|
#endif // VIEWPOSTPROCESS_H
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -37,6 +37,10 @@ class CReplayScreenshotTaker;
|
|||||||
class CStunEffect;
|
class CStunEffect;
|
||||||
#endif // HL2_EPISODIC
|
#endif // HL2_EPISODIC
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
class C_FuncFakeWorldPortal;
|
||||||
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Data specific to intro mode to control rendering.
|
// Data specific to intro mode to control rendering.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -51,11 +55,22 @@ struct IntroData_t
|
|||||||
bool m_bDrawPrimary;
|
bool m_bDrawPrimary;
|
||||||
Vector m_vecCameraView;
|
Vector m_vecCameraView;
|
||||||
QAngle m_vecCameraViewAngles;
|
QAngle m_vecCameraViewAngles;
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// Used for ortho views
|
||||||
|
CHandle<C_PointCamera> m_hCameraEntity;
|
||||||
|
#endif
|
||||||
float m_playerViewFOV;
|
float m_playerViewFOV;
|
||||||
CUtlVector<IntroDataBlendPass_t> m_Passes;
|
CUtlVector<IntroDataBlendPass_t> m_Passes;
|
||||||
|
|
||||||
// Fade overriding for the intro
|
// Fade overriding for the intro
|
||||||
float m_flCurrentFadeColor[4];
|
float m_flCurrentFadeColor[4];
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
// Draws the skybox.
|
||||||
|
bool m_bDrawSky;
|
||||||
|
// Draws the skybox in the secondary camera as well.
|
||||||
|
bool m_bDrawSky2;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
// Robin, make this point at something to get intro mode.
|
// Robin, make this point at something to get intro mode.
|
||||||
@ -436,6 +451,12 @@ private:
|
|||||||
bool DrawOneMonitor( ITexture *pRenderTarget, int cameraNum, C_PointCamera *pCameraEnt, const CViewSetup &cameraView, C_BasePlayer *localPlayer,
|
bool DrawOneMonitor( ITexture *pRenderTarget, int cameraNum, C_PointCamera *pCameraEnt, const CViewSetup &cameraView, C_BasePlayer *localPlayer,
|
||||||
int x, int y, int width, int height );
|
int x, int y, int width, int height );
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
bool DrawFakeWorldPortal( ITexture *pRenderTarget, C_FuncFakeWorldPortal *pCameraEnt, const CViewSetup &cameraView, C_BasePlayer *localPlayer,
|
||||||
|
int x, int y, int width, int height,
|
||||||
|
const CViewSetup &mainView, cplane_t &ourPlane );
|
||||||
|
#endif
|
||||||
|
|
||||||
// Drawing primitives
|
// Drawing primitives
|
||||||
bool ShouldDrawViewModel( bool drawViewmodel );
|
bool ShouldDrawViewModel( bool drawViewmodel );
|
||||||
void DrawViewModels( const CViewSetup &view, bool drawViewmodel );
|
void DrawViewModels( const CViewSetup &view, bool drawViewmodel );
|
||||||
@ -452,7 +473,11 @@ private:
|
|||||||
// Water-related methods
|
// Water-related methods
|
||||||
void DrawWorldAndEntities( bool drawSkybox, const CViewSetup &view, int nClearFlags, ViewCustomVisibility_t *pCustomVisibility = NULL );
|
void DrawWorldAndEntities( bool drawSkybox, const CViewSetup &view, int nClearFlags, ViewCustomVisibility_t *pCustomVisibility = NULL );
|
||||||
|
|
||||||
|
#ifdef MAPBASE
|
||||||
|
virtual void ViewDrawScene_Intro( const CViewSetup &view, int nClearFlags, const IntroData_t &introData, bool bDrew3dSkybox = false, SkyboxVisibility_t nSkyboxVisible = SKYBOX_NOT_VISIBLE, bool bDrawViewModel = false, ViewCustomVisibility_t *pCustomVisibility = NULL );
|
||||||
|
#else
|
||||||
virtual void ViewDrawScene_Intro( const CViewSetup &view, int nClearFlags, const IntroData_t &introData );
|
virtual void ViewDrawScene_Intro( const CViewSetup &view, int nClearFlags, const IntroData_t &introData );
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef PORTAL
|
#ifdef PORTAL
|
||||||
// Intended for use in the middle of another ViewDrawScene call, this allows stencils to be drawn after opaques but before translucents are drawn in the main view.
|
// Intended for use in the middle of another ViewDrawScene call, this allows stencils to be drawn after opaques but before translucents are drawn in the main view.
|
||||||
|
615
mp/src/game/client/vscript_client.cpp
Normal file
615
mp/src/game/client/vscript_client.cpp
Normal file
@ -0,0 +1,615 @@
|
|||||||
|
//========== Copyright © 2008, Valve Corporation, All rights reserved. ========
|
||||||
|
//
|
||||||
|
// Purpose:
|
||||||
|
//
|
||||||
|
//=============================================================================
|
||||||
|
|
||||||
|
#include "cbase.h"
|
||||||
|
#include "vscript_client.h"
|
||||||
|
#include "icommandline.h"
|
||||||
|
#include "tier1/utlbuffer.h"
|
||||||
|
#include "tier1/fmtstr.h"
|
||||||
|
#include "filesystem.h"
|
||||||
|
#include "characterset.h"
|
||||||
|
#include "isaverestore.h"
|
||||||
|
#include "gamerules.h"
|
||||||
|
#include "vscript_client.nut"
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
#include "mapbase/matchers.h"
|
||||||
|
#include "c_world.h"
|
||||||
|
#include "proxyentity.h"
|
||||||
|
#include "materialsystem/imaterial.h"
|
||||||
|
#include "materialsystem/imaterialvar.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern IScriptManager *scriptmanager;
|
||||||
|
extern ScriptClassDesc_t * GetScriptDesc( CBaseEntity * );
|
||||||
|
|
||||||
|
// #define VMPROFILE 1
|
||||||
|
|
||||||
|
#ifdef VMPROFILE
|
||||||
|
|
||||||
|
#define VMPROF_START float debugStartTime = Plat_FloatTime();
|
||||||
|
#define VMPROF_SHOW( funcname, funcdesc ) DevMsg("***VSCRIPT PROFILE***: %s %s: %6.4f milliseconds\n", (##funcname), (##funcdesc), (Plat_FloatTime() - debugStartTime)*1000.0 );
|
||||||
|
|
||||||
|
#else // !VMPROFILE
|
||||||
|
|
||||||
|
#define VMPROF_START
|
||||||
|
#define VMPROF_SHOW
|
||||||
|
|
||||||
|
#endif // VMPROFILE
|
||||||
|
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: A clientside variant of CScriptEntityIterator.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
class CScriptClientEntityIterator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
HSCRIPT First() { return Next(NULL); }
|
||||||
|
|
||||||
|
HSCRIPT Next( HSCRIPT hStartEntity )
|
||||||
|
{
|
||||||
|
return ToHScript( ClientEntityList().NextBaseEntity( ToEnt( hStartEntity ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
HSCRIPT CreateByClassname( const char *className )
|
||||||
|
{
|
||||||
|
return ToHScript( CreateEntityByName( className ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
HSCRIPT FindByClassname( HSCRIPT hStartEntity, const char *szName )
|
||||||
|
{
|
||||||
|
const CEntInfo *pInfo = hStartEntity ? ClientEntityList().GetEntInfoPtr( ToEnt( hStartEntity )->GetRefEHandle() )->m_pNext : ClientEntityList().FirstEntInfo();
|
||||||
|
for ( ;pInfo; pInfo = pInfo->m_pNext )
|
||||||
|
{
|
||||||
|
C_BaseEntity *ent = (C_BaseEntity *)pInfo->m_pEntity;
|
||||||
|
if ( !ent )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if ( Matcher_Match( szName, ent->GetClassname() ) )
|
||||||
|
return ToHScript( ent );
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
HSCRIPT FindByName( HSCRIPT hStartEntity, const char *szName )
|
||||||
|
{
|
||||||
|
const CEntInfo *pInfo = hStartEntity ? ClientEntityList().GetEntInfoPtr( ToEnt( hStartEntity )->GetRefEHandle() )->m_pNext : ClientEntityList().FirstEntInfo();
|
||||||
|
for ( ;pInfo; pInfo = pInfo->m_pNext )
|
||||||
|
{
|
||||||
|
C_BaseEntity *ent = (C_BaseEntity *)pInfo->m_pEntity;
|
||||||
|
if ( !ent )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if ( Matcher_Match( szName, ent->GetEntityName() ) )
|
||||||
|
return ToHScript( ent );
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
} g_ScriptEntityIterator;
|
||||||
|
|
||||||
|
BEGIN_SCRIPTDESC_ROOT_NAMED( CScriptClientEntityIterator, "CEntities", SCRIPT_SINGLETON "The global list of entities" )
|
||||||
|
DEFINE_SCRIPTFUNC( First, "Begin an iteration over the list of entities" )
|
||||||
|
DEFINE_SCRIPTFUNC( Next, "Continue an iteration over the list of entities, providing reference to a previously found entity" )
|
||||||
|
DEFINE_SCRIPTFUNC( CreateByClassname, "Creates an entity by classname" )
|
||||||
|
DEFINE_SCRIPTFUNC( FindByClassname, "Find entities by class name. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search" )
|
||||||
|
DEFINE_SCRIPTFUNC( FindByName, "Find entities by name. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search" )
|
||||||
|
END_SCRIPTDESC();
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: A base class for VScript-utilizing clientside classes which can persist
|
||||||
|
// across levels, requiring their scripts to be shut down manually.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
abstract_class IClientScriptPersistable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void TermScript() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
CUtlVector<IClientScriptPersistable*> g_ScriptPersistableList;
|
||||||
|
|
||||||
|
#define SCRIPT_MAT_PROXY_MAX_VARS 8
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: A material proxy which runs a VScript and allows it to read/write
|
||||||
|
// to material variables.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
class CScriptMaterialProxy : public IMaterialProxy, public IClientScriptPersistable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CScriptMaterialProxy();
|
||||||
|
virtual ~CScriptMaterialProxy();
|
||||||
|
|
||||||
|
virtual void Release( void );
|
||||||
|
virtual bool Init( IMaterial *pMaterial, KeyValues *pKeyValues );
|
||||||
|
virtual void OnBind( void *pRenderable );
|
||||||
|
virtual IMaterial *GetMaterial() { return NULL; }
|
||||||
|
|
||||||
|
// Proxies can persist across levels and aren't bound to a loaded map.
|
||||||
|
// The VM, however, is bound to the loaded map, so the proxy's script variables persisting
|
||||||
|
// causes problems when they're used in a new level with a new VM.
|
||||||
|
// As a result, we call InitScript() and TermScript() during OnBind and when the level is unloaded respectively.
|
||||||
|
bool InitScript();
|
||||||
|
void TermScript();
|
||||||
|
|
||||||
|
bool ValidateIndex(int i)
|
||||||
|
{
|
||||||
|
if (i > SCRIPT_MAT_PROXY_MAX_VARS || i < 0)
|
||||||
|
{
|
||||||
|
CGWarning( 0, CON_GROUP_VSCRIPT, "VScriptProxy: %i out of range", i );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *GetVarString( int i );
|
||||||
|
int GetVarInt( int i );
|
||||||
|
float GetVarFloat( int i );
|
||||||
|
const Vector& GetVarVector( int i );
|
||||||
|
|
||||||
|
void SetVarString( int i, const char *value );
|
||||||
|
void SetVarInt( int i, int value );
|
||||||
|
void SetVarFloat( int i, float value );
|
||||||
|
void SetVarVector( int i, const Vector &value );
|
||||||
|
|
||||||
|
private:
|
||||||
|
IMaterialVar *m_MaterialVars[SCRIPT_MAT_PROXY_MAX_VARS];
|
||||||
|
|
||||||
|
// Save the keyvalue string for InitScript()
|
||||||
|
char m_szFilePath[MAX_PATH];
|
||||||
|
|
||||||
|
CScriptScope m_ScriptScope;
|
||||||
|
HSCRIPT m_hScriptInstance;
|
||||||
|
HSCRIPT m_hFuncOnBind;
|
||||||
|
};
|
||||||
|
|
||||||
|
BEGIN_SCRIPTDESC_ROOT_NAMED( CScriptMaterialProxy, "CScriptMaterialProxy", "Material proxy for VScript" )
|
||||||
|
DEFINE_SCRIPTFUNC( GetVarString, "Gets a material var's string value" )
|
||||||
|
DEFINE_SCRIPTFUNC( GetVarInt, "Gets a material var's int value" )
|
||||||
|
DEFINE_SCRIPTFUNC( GetVarFloat, "Gets a material var's float value" )
|
||||||
|
DEFINE_SCRIPTFUNC( GetVarVector, "Gets a material var's vector value" )
|
||||||
|
DEFINE_SCRIPTFUNC( SetVarString, "Sets a material var's string value" )
|
||||||
|
DEFINE_SCRIPTFUNC( SetVarInt, "Sets a material var's int value" )
|
||||||
|
DEFINE_SCRIPTFUNC( SetVarFloat, "Sets a material var's float value" )
|
||||||
|
DEFINE_SCRIPTFUNC( SetVarVector, "Sets a material var's vector value" )
|
||||||
|
END_SCRIPTDESC();
|
||||||
|
|
||||||
|
CScriptMaterialProxy::CScriptMaterialProxy()
|
||||||
|
{
|
||||||
|
m_hScriptInstance = NULL;
|
||||||
|
m_hFuncOnBind = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
CScriptMaterialProxy::~CScriptMaterialProxy()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Cleanup
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void CScriptMaterialProxy::Release( void )
|
||||||
|
{
|
||||||
|
if ( m_hScriptInstance && g_pScriptVM )
|
||||||
|
{
|
||||||
|
g_pScriptVM->RemoveInstance( m_hScriptInstance );
|
||||||
|
m_hScriptInstance = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete this;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CScriptMaterialProxy::Init( IMaterial *pMaterial, KeyValues *pKeyValues )
|
||||||
|
{
|
||||||
|
for (KeyValues *pKey = pKeyValues->GetFirstSubKey(); pKey != NULL; pKey = pKey->GetNextKey())
|
||||||
|
{
|
||||||
|
// Get each variable we're looking for
|
||||||
|
if (Q_strnicmp( pKey->GetName(), "var", 3 ) == 0)
|
||||||
|
{
|
||||||
|
int index = atoi(pKey->GetName() + 3);
|
||||||
|
if (index > SCRIPT_MAT_PROXY_MAX_VARS)
|
||||||
|
{
|
||||||
|
Warning("VScript material proxy only supports 8 vars (not %i)\n", index);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool foundVar;
|
||||||
|
m_MaterialVars[index] = pMaterial->FindVar( pKey->GetString(), &foundVar );
|
||||||
|
|
||||||
|
// Don't init if we didn't find the var
|
||||||
|
if (!foundVar)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (FStrEq( pKey->GetName(), "scriptfile" ))
|
||||||
|
{
|
||||||
|
Q_strncpy( m_szFilePath, pKey->GetString(), sizeof( m_szFilePath ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CScriptMaterialProxy::InitScript()
|
||||||
|
{
|
||||||
|
if (!m_ScriptScope.IsInitialized())
|
||||||
|
{
|
||||||
|
if (scriptmanager == NULL)
|
||||||
|
{
|
||||||
|
ExecuteOnce(DevMsg("Cannot execute script because scripting is disabled (-scripting)\n"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_pScriptVM == NULL)
|
||||||
|
{
|
||||||
|
ExecuteOnce(DevMsg(" Cannot execute script because there is no available VM\n"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* iszScriptId = (char*)stackalloc( 1024 );
|
||||||
|
g_pScriptVM->GenerateUniqueKey("VScriptProxy", iszScriptId, 1024);
|
||||||
|
|
||||||
|
m_hScriptInstance = g_pScriptVM->RegisterInstance( GetScriptDescForClass( CScriptMaterialProxy ), this );
|
||||||
|
g_pScriptVM->SetInstanceUniqeId( m_hScriptInstance, iszScriptId );
|
||||||
|
|
||||||
|
bool bResult = m_ScriptScope.Init( iszScriptId );
|
||||||
|
|
||||||
|
if (!bResult)
|
||||||
|
{
|
||||||
|
CGMsg( 1, CON_GROUP_VSCRIPT, "VScriptProxy couldn't create ScriptScope!\n" );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_pScriptVM->SetValue( m_ScriptScope, "self", m_hScriptInstance );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't init if we can't run the script
|
||||||
|
if (!VScriptRunScript( m_szFilePath, m_ScriptScope, true ))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_hFuncOnBind = m_ScriptScope.LookupFunction( "OnBind" );
|
||||||
|
|
||||||
|
if (!m_hFuncOnBind)
|
||||||
|
{
|
||||||
|
// Don't init if we can't find our func
|
||||||
|
Warning("VScript material proxy can't find OnBind function\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_ScriptPersistableList.AddToTail( this );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CScriptMaterialProxy::TermScript()
|
||||||
|
{
|
||||||
|
if ( m_hScriptInstance )
|
||||||
|
{
|
||||||
|
g_pScriptVM->RemoveInstance( m_hScriptInstance );
|
||||||
|
m_hScriptInstance = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_hFuncOnBind = NULL;
|
||||||
|
|
||||||
|
m_ScriptScope.Term();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CScriptMaterialProxy::OnBind( void *pRenderable )
|
||||||
|
{
|
||||||
|
if( !pRenderable )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (m_hFuncOnBind != NULL)
|
||||||
|
{
|
||||||
|
IClientRenderable *pRend = ( IClientRenderable* )pRenderable;
|
||||||
|
C_BaseEntity *pEnt = pRend->GetIClientUnknown()->GetBaseEntity();
|
||||||
|
if ( pEnt )
|
||||||
|
{
|
||||||
|
g_pScriptVM->SetValue( m_ScriptScope, "entity", pEnt->GetScriptInstance() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Needs to register as a null value so the script doesn't break if it looks for an entity
|
||||||
|
g_pScriptVM->SetValue( m_ScriptScope, "entity", SCRIPT_VARIANT_NULL );
|
||||||
|
}
|
||||||
|
|
||||||
|
m_ScriptScope.Call( m_hFuncOnBind, NULL );
|
||||||
|
|
||||||
|
g_pScriptVM->ClearValue( m_ScriptScope, "entity" );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// The VM might not exist if we do it from Init(), so we have to do it here.
|
||||||
|
// TODO: We have no handling for if this fails, how do you cancel a proxy?
|
||||||
|
if (InitScript())
|
||||||
|
OnBind( pRenderable );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *CScriptMaterialProxy::GetVarString( int i )
|
||||||
|
{
|
||||||
|
if (!ValidateIndex( i ) || !m_MaterialVars[i])
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return m_MaterialVars[i]->GetStringValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
int CScriptMaterialProxy::GetVarInt( int i )
|
||||||
|
{
|
||||||
|
if (!ValidateIndex( i ) || !m_MaterialVars[i])
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return m_MaterialVars[i]->GetIntValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
float CScriptMaterialProxy::GetVarFloat( int i )
|
||||||
|
{
|
||||||
|
if (!ValidateIndex( i ) || !m_MaterialVars[i])
|
||||||
|
return 0.0f;
|
||||||
|
|
||||||
|
return m_MaterialVars[i]->GetFloatValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
const Vector& CScriptMaterialProxy::GetVarVector( int i )
|
||||||
|
{
|
||||||
|
if (!ValidateIndex( i ) || !m_MaterialVars[i])
|
||||||
|
return vec3_origin;
|
||||||
|
|
||||||
|
if (m_MaterialVars[i]->GetType() != MATERIAL_VAR_TYPE_VECTOR)
|
||||||
|
return vec3_origin;
|
||||||
|
|
||||||
|
// This is really bad. Too bad!
|
||||||
|
return *(reinterpret_cast<const Vector*>(m_MaterialVars[i]->GetVecValue()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CScriptMaterialProxy::SetVarString( int i, const char *value )
|
||||||
|
{
|
||||||
|
if (!ValidateIndex( i ) || !m_MaterialVars[i])
|
||||||
|
return;
|
||||||
|
|
||||||
|
return m_MaterialVars[i]->SetStringValue( value );
|
||||||
|
}
|
||||||
|
|
||||||
|
void CScriptMaterialProxy::SetVarInt( int i, int value )
|
||||||
|
{
|
||||||
|
if (!ValidateIndex( i ) || !m_MaterialVars[i])
|
||||||
|
return;
|
||||||
|
|
||||||
|
return m_MaterialVars[i]->SetIntValue( value );
|
||||||
|
}
|
||||||
|
|
||||||
|
void CScriptMaterialProxy::SetVarFloat( int i, float value )
|
||||||
|
{
|
||||||
|
if (!ValidateIndex( i ) || !m_MaterialVars[i])
|
||||||
|
return;
|
||||||
|
|
||||||
|
return m_MaterialVars[i]->SetFloatValue( value );
|
||||||
|
}
|
||||||
|
|
||||||
|
void CScriptMaterialProxy::SetVarVector( int i, const Vector &value )
|
||||||
|
{
|
||||||
|
if (!ValidateIndex( i ) || !m_MaterialVars[i])
|
||||||
|
return;
|
||||||
|
|
||||||
|
return m_MaterialVars[i]->SetVecValue( value.Base(), 3 );
|
||||||
|
}
|
||||||
|
|
||||||
|
EXPOSE_INTERFACE( CScriptMaterialProxy, IMaterialProxy, "VScriptProxy" IMATERIAL_PROXY_INTERFACE_VERSION );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
static float Time()
|
||||||
|
{
|
||||||
|
return gpGlobals->curtime;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *GetMapName()
|
||||||
|
{
|
||||||
|
return engine->GetLevelName();
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *DoUniqueString( const char *pszBase )
|
||||||
|
{
|
||||||
|
static char szBuf[512];
|
||||||
|
g_pScriptVM->GenerateUniqueKey( pszBase, szBuf, ARRAYSIZE(szBuf) );
|
||||||
|
return szBuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DoIncludeScript( const char *pszScript, HSCRIPT hScope )
|
||||||
|
{
|
||||||
|
if ( !VScriptRunScript( pszScript, hScope, true ) )
|
||||||
|
{
|
||||||
|
g_pScriptVM->RaiseException( CFmtStr( "Failed to include script \"%s\"", ( pszScript ) ? pszScript : "unknown" ) );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VScriptClientInit()
|
||||||
|
{
|
||||||
|
VMPROF_START
|
||||||
|
|
||||||
|
if( scriptmanager != NULL )
|
||||||
|
{
|
||||||
|
ScriptLanguage_t scriptLanguage = SL_DEFAULT;
|
||||||
|
|
||||||
|
char const *pszScriptLanguage;
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
if (GetClientWorldEntity()->GetScriptLanguage() != SL_NONE)
|
||||||
|
{
|
||||||
|
// Allow world entity to override script language
|
||||||
|
scriptLanguage = GetClientWorldEntity()->GetScriptLanguage();
|
||||||
|
|
||||||
|
// Less than SL_NONE means the script language should literally be none
|
||||||
|
if (scriptLanguage < SL_NONE)
|
||||||
|
scriptLanguage = SL_NONE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
if ( CommandLine()->CheckParm( "-scriptlang", &pszScriptLanguage ) )
|
||||||
|
{
|
||||||
|
if( !Q_stricmp(pszScriptLanguage, "gamemonkey") )
|
||||||
|
{
|
||||||
|
scriptLanguage = SL_GAMEMONKEY;
|
||||||
|
}
|
||||||
|
else if( !Q_stricmp(pszScriptLanguage, "squirrel") )
|
||||||
|
{
|
||||||
|
scriptLanguage = SL_SQUIRREL;
|
||||||
|
}
|
||||||
|
else if( !Q_stricmp(pszScriptLanguage, "python") )
|
||||||
|
{
|
||||||
|
scriptLanguage = SL_PYTHON;
|
||||||
|
}
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
else if( !Q_stricmp(pszScriptLanguage, "lua") )
|
||||||
|
{
|
||||||
|
scriptLanguage = SL_LUA;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CGWarning( 1, CON_GROUP_VSCRIPT, "-scriptlang does not recognize a language named '%s'. virtual machine did NOT start.\n", pszScriptLanguage );
|
||||||
|
scriptLanguage = SL_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if( scriptLanguage != SL_NONE )
|
||||||
|
{
|
||||||
|
if ( g_pScriptVM == NULL )
|
||||||
|
g_pScriptVM = scriptmanager->CreateVM( scriptLanguage );
|
||||||
|
|
||||||
|
if( g_pScriptVM )
|
||||||
|
{
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
CGMsg( 0, CON_GROUP_VSCRIPT, "VSCRIPT CLIENT: Started VScript virtual machine using script language '%s'\n", g_pScriptVM->GetLanguageName() );
|
||||||
|
#else
|
||||||
|
Log( "VSCRIPT: Started VScript virtual machine using script language '%s'\n", g_pScriptVM->GetLanguageName() );
|
||||||
|
#endif
|
||||||
|
ScriptRegisterFunction( g_pScriptVM, GetMapName, "Get the name of the map.");
|
||||||
|
ScriptRegisterFunction( g_pScriptVM, Time, "Get the current server time" );
|
||||||
|
ScriptRegisterFunction( g_pScriptVM, DoIncludeScript, "Execute a script (internal)" );
|
||||||
|
|
||||||
|
if ( GameRules() )
|
||||||
|
{
|
||||||
|
GameRules()->RegisterScriptFunctions();
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
g_pScriptVM->RegisterAllClasses();
|
||||||
|
g_pScriptVM->RegisterAllEnums();
|
||||||
|
|
||||||
|
g_pScriptVM->RegisterInstance( &g_ScriptEntityIterator, "Entities" );
|
||||||
|
|
||||||
|
IGameSystem::RegisterVScriptAllSystems();
|
||||||
|
|
||||||
|
RegisterSharedScriptConstants();
|
||||||
|
RegisterSharedScriptFunctions();
|
||||||
|
#else
|
||||||
|
//g_pScriptVM->RegisterInstance( &g_ScriptEntityIterator, "Entities" );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (scriptLanguage == SL_SQUIRREL)
|
||||||
|
{
|
||||||
|
g_pScriptVM->Run( g_Script_vscript_client );
|
||||||
|
}
|
||||||
|
|
||||||
|
VScriptRunScript( "mapspawn", false );
|
||||||
|
|
||||||
|
VMPROF_SHOW( pszScriptLanguage, "virtual machine startup" );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CGWarning( 1, CON_GROUP_VSCRIPT, "VM Did not start!\n" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CGWarning( 0, CON_GROUP_VSCRIPT, "\nVSCRIPT: Scripting is disabled.\n" );
|
||||||
|
}
|
||||||
|
g_pScriptVM = NULL;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VScriptClientTerm()
|
||||||
|
{
|
||||||
|
if( g_pScriptVM != NULL )
|
||||||
|
{
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
// Things like proxies can persist across levels, so we have to shut down their scripts manually
|
||||||
|
for (int i = g_ScriptPersistableList.Count()-1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
if (g_ScriptPersistableList[i])
|
||||||
|
{
|
||||||
|
g_ScriptPersistableList[i]->TermScript();
|
||||||
|
g_ScriptPersistableList.FastRemove( i );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if( g_pScriptVM )
|
||||||
|
{
|
||||||
|
scriptmanager->DestroyVM( g_pScriptVM );
|
||||||
|
g_pScriptVM = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class CVScriptGameSystem : public CAutoGameSystemPerFrame
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// Inherited from IAutoServerSystem
|
||||||
|
virtual void LevelInitPreEntity( void )
|
||||||
|
{
|
||||||
|
m_bAllowEntityCreationInScripts = true;
|
||||||
|
#ifndef MAPBASE_VSCRIPT // Now initted in C_World
|
||||||
|
VScriptClientInit();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void LevelInitPostEntity( void )
|
||||||
|
{
|
||||||
|
m_bAllowEntityCreationInScripts = false;
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
if (g_pScriptVM)
|
||||||
|
{
|
||||||
|
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||||
|
if (pPlayer)
|
||||||
|
{
|
||||||
|
g_pScriptVM->SetValue( "player", pPlayer->GetScriptInstance() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void LevelShutdownPostEntity( void )
|
||||||
|
{
|
||||||
|
VScriptClientTerm();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void FrameUpdatePostEntityThink()
|
||||||
|
{
|
||||||
|
if ( g_pScriptVM )
|
||||||
|
g_pScriptVM->Frame( gpGlobals->frametime );
|
||||||
|
}
|
||||||
|
|
||||||
|
bool m_bAllowEntityCreationInScripts;
|
||||||
|
};
|
||||||
|
|
||||||
|
CVScriptGameSystem g_VScriptGameSystem;
|
||||||
|
|
||||||
|
bool IsEntityCreationAllowedInScripts( void )
|
||||||
|
{
|
||||||
|
return g_VScriptGameSystem.m_bAllowEntityCreationInScripts;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
26
mp/src/game/client/vscript_client.h
Normal file
26
mp/src/game/client/vscript_client.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
//========== Copyright © 2008, Valve Corporation, All rights reserved. ========
|
||||||
|
//
|
||||||
|
// Purpose:
|
||||||
|
//
|
||||||
|
//=============================================================================
|
||||||
|
|
||||||
|
#ifndef VSCRIPT_CLIENT_H
|
||||||
|
#define VSCRIPT_CLIENT_H
|
||||||
|
|
||||||
|
#include "vscript/ivscript.h"
|
||||||
|
#include "vscript_shared.h"
|
||||||
|
|
||||||
|
#if defined( _WIN32 )
|
||||||
|
#pragma once
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern IScriptVM * g_pScriptVM;
|
||||||
|
|
||||||
|
// Only allow scripts to create entities during map initialization
|
||||||
|
bool IsEntityCreationAllowedInScripts( void );
|
||||||
|
|
||||||
|
#ifdef MAPBASE_VSCRIPT
|
||||||
|
extern IScriptManager * scriptmanager;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // VSCRIPT_CLIENT_H
|
22
mp/src/game/client/vscript_client.nut
Normal file
22
mp/src/game/client/vscript_client.nut
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
static char g_Script_vscript_client[] = R"vscript(
|
||||||
|
//========== Copyright © 2008, Valve Corporation, All rights reserved. ========
|
||||||
|
//
|
||||||
|
// Purpose:
|
||||||
|
//
|
||||||
|
//=============================================================================
|
||||||
|
|
||||||
|
function UniqueString( string = "" )
|
||||||
|
{
|
||||||
|
return DoUniqueString( string.tostring() );
|
||||||
|
}
|
||||||
|
|
||||||
|
function IncludeScript( name, scope = null )
|
||||||
|
{
|
||||||
|
if ( scope == null )
|
||||||
|
{
|
||||||
|
scope = this;
|
||||||
|
}
|
||||||
|
return ::DoIncludeScript( name, scope );
|
||||||
|
}
|
||||||
|
|
||||||
|
)vscript";
|
@ -252,9 +252,14 @@ int CBaseHudWeaponSelection::KeyInput( int down, ButtonCode_t keynum, const char
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( down >= 1 && keynum >= KEY_1 && keynum <= KEY_9 )
|
//Tony; check 0 as well, otherwise you have to have 0 bound to slot10 no matter what.
|
||||||
|
if ( down >= 1 && keynum >= KEY_0 && keynum <= KEY_9 )
|
||||||
{
|
{
|
||||||
if ( HandleHudMenuInput( keynum - KEY_0 ) )
|
//Tony; 0 is actually '10' (slot10)
|
||||||
|
if (keynum == KEY_0)
|
||||||
|
keynum = KEY_A; //Dealing with button codes, so just use KEY_A, which is equal to 11 anyway.
|
||||||
|
|
||||||
|
if ( HandleHudMenuInput( keynum - 1 ) )
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user