mirror of
https://github.com/ptitSeb/Serious-Engine
synced 2024-11-22 10:20:26 +01:00
Merge branch 'master' of https://github.com/ptitSeb/Serious-Engine
This commit is contained in:
commit
feb12b02d4
10
.gitignore
vendored
10
.gitignore
vendored
|
@ -33,6 +33,10 @@
|
||||||
Build/
|
Build/
|
||||||
Debug/
|
Debug/
|
||||||
|
|
||||||
|
# custom user build dirs
|
||||||
|
/*build*
|
||||||
|
/Sources/*build*
|
||||||
|
|
||||||
# Visual Studio
|
# Visual Studio
|
||||||
*.vs
|
*.vs
|
||||||
*.opendb
|
*.opendb
|
||||||
|
@ -70,20 +74,22 @@ Sources/Entities/*.cpp
|
||||||
# Other generated files:
|
# Other generated files:
|
||||||
Sources/Engine/Ska/smcScan.cpp
|
Sources/Engine/Ska/smcScan.cpp
|
||||||
Sources/Engine/Ska/smcPars.h
|
Sources/Engine/Ska/smcPars.h
|
||||||
|
Sources/Engine/Ska/smcPars.hpp
|
||||||
Sources/Engine/Ska/smcPars.cpp
|
Sources/Engine/Ska/smcPars.cpp
|
||||||
Sources/Engine/Base/Parser.cpp
|
Sources/Engine/Base/Parser.cpp
|
||||||
Sources/Engine/Base/Parser.h
|
Sources/Engine/Base/Parser.h
|
||||||
|
Sources/Engine/Base/Parser.hpp
|
||||||
Sources/Engine/Base/Scanner.cpp
|
Sources/Engine/Base/Scanner.cpp
|
||||||
Sources/Ecc/Parser.cpp
|
Sources/Ecc/Parser.cpp
|
||||||
Sources/Ecc/Parser.h
|
Sources/Ecc/Parser.h
|
||||||
|
Sources/Ecc/Parser.hpp
|
||||||
Sources/Ecc/Scanner.cpp
|
Sources/Ecc/Scanner.cpp
|
||||||
Sources/SeriousSkaStudio/Parser.cpp
|
Sources/SeriousSkaStudio/Parser.cpp
|
||||||
Sources/SeriousSkaStudio/Parser.h
|
Sources/SeriousSkaStudio/Parser.h
|
||||||
|
Sources/SeriousSkaStudio/Parser.hpp
|
||||||
Sources/SeriousSkaStudio/Scanner.cpp
|
Sources/SeriousSkaStudio/Scanner.cpp
|
||||||
|
|
||||||
# vim swap files
|
# vim swap files
|
||||||
*.swp
|
*.swp
|
||||||
*.swo
|
*.swo
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
ModEXT.txt
|
|
49
README.md
49
README.md
|
@ -28,12 +28,61 @@ These have been modified to run correctly under the recent version of Windows. (
|
||||||
Building
|
Building
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
### Windows
|
||||||
|
|
||||||
To build Serious Engine 1, you'll need Visual Studio 2013 or 2015, Professional or Community edition ( https://www.visualstudio.com/post-download-vs?sku=community ).
|
To build Serious Engine 1, you'll need Visual Studio 2013 or 2015, Professional or Community edition ( https://www.visualstudio.com/post-download-vs?sku=community ).
|
||||||
|
|
||||||
Do not use spaces in the path to the solution.
|
Do not use spaces in the path to the solution.
|
||||||
|
|
||||||
Once you've installed Visual Studio and (optionally) DirectX8 SDK, you can build the engine solution (`/Sources/All.sln`). Press F7 or Build -> Build solution. The libraries and executables will be put into `\Bin\` directory (or `\Bin\Debug\` if you are using the Debug configuration).
|
Once you've installed Visual Studio and (optionally) DirectX8 SDK, you can build the engine solution (`/Sources/All.sln`). Press F7 or Build -> Build solution. The libraries and executables will be put into `\Bin\` directory (or `\Bin\Debug\` if you are using the Debug configuration).
|
||||||
|
|
||||||
|
### Linux
|
||||||
|
|
||||||
|
#### Setting up the repository
|
||||||
|
|
||||||
|
Type this in your terminal:
|
||||||
|
|
||||||
|
```
|
||||||
|
git clone https://github.com/rcgordon/Serious-Engine.git
|
||||||
|
cd Serious-Engine
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Copy official game data (optional)
|
||||||
|
|
||||||
|
If you have access to a copy of the game (either by CD or through Steam),
|
||||||
|
you can copy the *.gro files from the game directory to the repository.
|
||||||
|
|
||||||
|
#### Building (only for SS:TSE)
|
||||||
|
|
||||||
|
Type this in your terminal:
|
||||||
|
|
||||||
|
```
|
||||||
|
Sources/build-linux64.sh # use build-linux32.sh for 32-bits
|
||||||
|
cp Sources/cmake-build/ssam Bin/
|
||||||
|
cp Sources/cmake-build/Debug/* Bin/Debug/
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Building (only for SS:TFE)
|
||||||
|
|
||||||
|
Same as SS:SE, but note the following:
|
||||||
|
|
||||||
|
- Before running build-linux64.sh, modify the file by passing `-DTFE=TRUE` to cmake.
|
||||||
|
- After building, you need to copy 'ssam**-tfe**' instead of 'ssam', as shown:
|
||||||
|
|
||||||
|
```
|
||||||
|
cp Sources/cmake-build/ssam-tfe Bin/
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Running
|
||||||
|
|
||||||
|
Type this in your terminal:
|
||||||
|
|
||||||
|
```
|
||||||
|
Bin/ssam
|
||||||
|
```
|
||||||
|
|
||||||
|
(or `ssam-tfe` if you are running TFE)
|
||||||
|
|
||||||
Optional features
|
Optional features
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
|
|
@ -110,21 +110,19 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||||
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -Os -fno-unsafe-math-optimizations")
|
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -Os -fno-unsafe-math-optimizations")
|
||||||
|
|
||||||
# TODO fix these warnings
|
# TODO fix these warnings
|
||||||
add_compile_options(-Wno-sign-compare)
|
|
||||||
add_compile_options(-Wno-switch)
|
add_compile_options(-Wno-switch)
|
||||||
|
add_compile_options(-Wno-char-subscripts)
|
||||||
add_compile_options(-Wno-unknown-pragmas)
|
add_compile_options(-Wno-unknown-pragmas)
|
||||||
add_compile_options(-Wno-unused-variable)
|
add_compile_options(-Wno-unused-variable) # TODO: maybe only enable this for Entities
|
||||||
add_compile_options(-Wno-unused-value)
|
add_compile_options(-Wno-unused-value) # same here (the Scripts generate tons of unused variables and values)
|
||||||
add_compile_options(-Wno-reorder)
|
add_compile_options(-Wno-missing-braces)
|
||||||
add_compile_options(-Wno-unused-but-set-variable)
|
add_compile_options(-Wno-overloaded-virtual)
|
||||||
add_compile_options(-Wno-parentheses)
|
add_compile_options(-Wno-invalid-offsetof)
|
||||||
MESSAGE(WARNING, "re-enable some of the warnings some day!")
|
MESSAGE(WARNING, "re-enable some of the warnings some day!")
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
|
||||||
# !!! FIXME: turn a bunch of these off, this is just for now. I hope. --ryan.
|
# !!! FIXME: turn a bunch of these off, this is just for now. I hope. --ryan.
|
||||||
add_compile_options(-Wno-tautological-undefined-compare)
|
|
||||||
add_compile_options(-Wno-c++11-compat-deprecated-writable-strings)
|
add_compile_options(-Wno-c++11-compat-deprecated-writable-strings)
|
||||||
add_compile_options(-Wno-logical-op-parentheses) # FIXME: this too should be re-enabled
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MACOSX)
|
if(MACOSX)
|
||||||
|
@ -188,13 +186,20 @@ else()
|
||||||
set(DEBUGSUFFIX "")
|
set(DEBUGSUFFIX "")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# This should not be needed anymore, but might be faster on 32bit x86
|
option(USE_ASM "Use ASM code" TRUE)
|
||||||
option(USE_I386_ASM "Use X86 ASM" FALSE)
|
if (USE_ASM)
|
||||||
|
MESSAGE(STATUS "Using assembler code (when available)")
|
||||||
|
else()
|
||||||
|
add_definitions(-DUSE_PORTABLE_C=1)
|
||||||
|
MESSAGE(STATUS "Using portable C instead of all ASM")
|
||||||
|
endif()
|
||||||
|
|
||||||
if (USE_I386_ASM)
|
option(USE_I386_NASM_ASM "Use i386 nasm ASM code" FALSE)
|
||||||
|
|
||||||
|
if (USE_ASM AND USE_I386_NASM_ASM)
|
||||||
# You need the Netwide Assembler (NASM) to build this on Intel systems.
|
# You need the Netwide Assembler (NASM) to build this on Intel systems.
|
||||||
# http://nasm.sf.net/
|
# http://nasm.sf.net/
|
||||||
add_definitions(-DUSE_I386_ASM=1)
|
add_definitions(-DUSE_I386_NASM_ASM=1)
|
||||||
if (MACOSX)
|
if (MACOSX)
|
||||||
set(ASMOBJFMT "macho")
|
set(ASMOBJFMT "macho")
|
||||||
list(APPEND ASMFLAGS --prefix _)
|
list(APPEND ASMFLAGS --prefix _)
|
||||||
|
@ -203,10 +208,9 @@ if (USE_I386_ASM)
|
||||||
else()
|
else()
|
||||||
set(ASMOBJFMT "elf")
|
set(ASMOBJFMT "elf")
|
||||||
endif()
|
endif()
|
||||||
MESSAGE(STATUS "Using i386 assembler")
|
MESSAGE(STATUS "Using i386 nasm ASM")
|
||||||
else()
|
else()
|
||||||
add_definitions(-DUSE_PORTABLE_C=1)
|
MESSAGE(STATUS "Not using i386 nasm ASM")
|
||||||
MESSAGE(STATUS "Using portable C instead of ASM")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
option(PANDORA "Compile for Pandora" FALSE)
|
option(PANDORA "Compile for Pandora" FALSE)
|
||||||
|
@ -655,7 +659,7 @@ add_dependencies(${SHADERSLIB} ParseEntities)
|
||||||
add_parser_and_scanner("Engine/Base/Parser" "Engine/Base/Scanner")
|
add_parser_and_scanner("Engine/Base/Parser" "Engine/Base/Scanner")
|
||||||
add_parser_and_scanner("Engine/Ska/smcPars" "Engine/Ska/smcScan")
|
add_parser_and_scanner("Engine/Ska/smcPars" "Engine/Ska/smcScan")
|
||||||
|
|
||||||
if (USE_I386_ASM)
|
if (USE_I386_NASM_ASM)
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT "SoundMixer386.o"
|
OUTPUT "SoundMixer386.o"
|
||||||
MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/Engine/Sound/SoundMixer386.asm"
|
MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/Engine/Sound/SoundMixer386.asm"
|
||||||
|
|
|
@ -173,16 +173,14 @@ BOOL CAnimData::IsAutoFreed(void)
|
||||||
// Reference counting functions
|
// Reference counting functions
|
||||||
void CAnimData::AddReference(void)
|
void CAnimData::AddReference(void)
|
||||||
{
|
{
|
||||||
if (this!=NULL) {
|
ASSERT(this!=NULL);
|
||||||
MarkUsed();
|
MarkUsed();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAnimData::RemReference(void)
|
void CAnimData::RemReference(void)
|
||||||
{
|
{
|
||||||
if (this!=NULL) {
|
ASSERT(this!=NULL);
|
||||||
RemReference_internal();
|
RemReference_internal();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAnimData::RemReference_internal(void)
|
void CAnimData::RemReference_internal(void)
|
||||||
|
@ -296,13 +294,13 @@ void CAnimData::LoadFromScript_t( CTStream *File, CListHead *pFrameFileList) //
|
||||||
char ld_line[ 128];
|
char ld_line[ 128];
|
||||||
CTmpListHead TempAnimationList;
|
CTmpListHead TempAnimationList;
|
||||||
SLONG lc;
|
SLONG lc;
|
||||||
BOOL ret_val;
|
//BOOL ret_val;
|
||||||
|
|
||||||
//ASSERT( ad_Anims == NULL);
|
//ASSERT( ad_Anims == NULL);
|
||||||
// clears possible animations
|
// clears possible animations
|
||||||
CAnimData::Clear();
|
CAnimData::Clear();
|
||||||
|
|
||||||
ret_val = TRUE;
|
//ret_val = TRUE;
|
||||||
FOREVER
|
FOREVER
|
||||||
{
|
{
|
||||||
// Repeat reading of one line of script file until it is not empty or comment
|
// Repeat reading of one line of script file until it is not empty or comment
|
||||||
|
@ -617,7 +615,7 @@ CAnimObject::CAnimObject(void)
|
||||||
/* Destructor. */
|
/* Destructor. */
|
||||||
CAnimObject::~CAnimObject(void)
|
CAnimObject::~CAnimObject(void)
|
||||||
{
|
{
|
||||||
ao_AnimData->RemReference();
|
if(ao_AnimData != NULL) ao_AnimData->RemReference();
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy from another object of same class
|
// copy from another object of same class
|
||||||
|
@ -820,9 +818,9 @@ BOOL CAnimObject::IsUpToDate(const CUpdateable &ud) const
|
||||||
void CAnimObject::SetData(CAnimData *pAD)
|
void CAnimObject::SetData(CAnimData *pAD)
|
||||||
{
|
{
|
||||||
// mark new data as referenced once more
|
// mark new data as referenced once more
|
||||||
pAD->AddReference();
|
if(pAD != NULL) pAD->AddReference();
|
||||||
// mark old data as referenced once less
|
// mark old data as referenced once less
|
||||||
ao_AnimData->RemReference();
|
if(ao_AnimData != NULL) ao_AnimData->RemReference();
|
||||||
// remember new data
|
// remember new data
|
||||||
ao_AnimData = pAD;
|
ao_AnimData = pAD;
|
||||||
if( pAD != NULL) StartAnim( 0);
|
if( pAD != NULL) StartAnim( 0);
|
||||||
|
@ -904,14 +902,14 @@ void CAnimObject::PlayAnim(INDEX iNew, ULONG ulFlags)
|
||||||
class COneAnim *pCOA = &ao_AnimData->ad_Anims[ao_iCurrentAnim];
|
class COneAnim *pCOA = &ao_AnimData->ad_Anims[ao_iCurrentAnim];
|
||||||
TIME tmNow = _pTimer->CurrentTick();
|
TIME tmNow = _pTimer->CurrentTick();
|
||||||
TIME tmLength = GetCurrentAnimLength();
|
TIME tmLength = GetCurrentAnimLength();
|
||||||
FLOAT fFrame = ((_pTimer->CurrentTick() - ao_tmAnimStart)/pCOA->oa_SecsPerFrame);
|
FLOAT fFrame = ((tmNow - ao_tmAnimStart)/pCOA->oa_SecsPerFrame);
|
||||||
INDEX iFrame = INDEX(fFrame);
|
INDEX iFrame = INDEX(fFrame);
|
||||||
FLOAT fFract = fFrame-iFrame;
|
FLOAT fFract = fFrame-iFrame;
|
||||||
iFrame = ClipFrame(iFrame);
|
iFrame = ClipFrame(iFrame);
|
||||||
TIME tmPassed = (iFrame+fFract)*pCOA->oa_SecsPerFrame;
|
TIME tmPassed = (iFrame+fFract)*pCOA->oa_SecsPerFrame;
|
||||||
TIME tmLeft = tmLength-tmPassed;
|
TIME tmLeft = tmLength-tmPassed;
|
||||||
// set time ahead to end of the current animation
|
// set time ahead to end of the current animation
|
||||||
ao_tmAnimStart = _pTimer->CurrentTick()+tmLeft;
|
ao_tmAnimStart = tmNow+tmLeft;
|
||||||
// remember last animation
|
// remember last animation
|
||||||
ao_iLastAnim = ao_iCurrentAnim;
|
ao_iLastAnim = ao_iCurrentAnim;
|
||||||
// set new animation number
|
// set new animation number
|
||||||
|
|
|
@ -61,18 +61,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#define PLATFORM_LINUX 1
|
#define PLATFORM_LINUX 1
|
||||||
#endif
|
#endif
|
||||||
#elif (defined __APPLE__)
|
#elif (defined __APPLE__)
|
||||||
#include "TargetConditionals.h"
|
|
||||||
#if TARGET_OS_MAC
|
|
||||||
#define PLATFORM_MACOSX 1
|
#define PLATFORM_MACOSX 1
|
||||||
#else
|
|
||||||
#error "Unsupported apple platform"
|
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
#warning "UNKNOWN PLATFORM IDENTIFIED!!!!"
|
#warning "UNKNOWN PLATFORM IDENTIFIED!!!!"
|
||||||
#define PLATFORM_UNKNOWN 1
|
#define PLATFORM_UNKNOWN 1
|
||||||
#warning "USING PORTABLE C!!!"
|
#endif
|
||||||
#define USE_PORTABLE_C
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if PLATFORM_LINUX || PLATFORM_MACOSX
|
#if PLATFORM_LINUX || PLATFORM_MACOSX
|
||||||
#ifndef PLATFORM_UNIX
|
#ifndef PLATFORM_UNIX
|
||||||
|
|
|
@ -64,7 +64,7 @@ inline void CRC_AddFLOAT(ULONG &ulCRC, FLOAT f)
|
||||||
// add memory block to a CRC value
|
// add memory block to a CRC value
|
||||||
inline void CRC_AddBlock(ULONG &ulCRC, UBYTE *pubBlock, ULONG ulSize)
|
inline void CRC_AddBlock(ULONG &ulCRC, UBYTE *pubBlock, ULONG ulSize)
|
||||||
{
|
{
|
||||||
for( INDEX i=0; i<ulSize; i++) CRC_AddBYTE( ulCRC, pubBlock[i]);
|
for( INDEX i=0; (ULONG)i<ulSize; i++) CRC_AddBYTE( ulCRC, pubBlock[i]);
|
||||||
};
|
};
|
||||||
|
|
||||||
// end crc calculation
|
// end crc calculation
|
||||||
|
|
|
@ -44,9 +44,7 @@ CConsole::CConsole(void)
|
||||||
// Destructor.
|
// Destructor.
|
||||||
CConsole::~CConsole(void)
|
CConsole::~CConsole(void)
|
||||||
{
|
{
|
||||||
if (this==NULL) {
|
ASSERT(this!=NULL);
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (con_fLog!=NULL) {
|
if (con_fLog!=NULL) {
|
||||||
fclose(con_fLog);
|
fclose(con_fLog);
|
||||||
con_fLog = NULL;
|
con_fLog = NULL;
|
||||||
|
@ -102,25 +100,19 @@ void CConsole::Initialize(const CTFileName &fnmLog, INDEX ctCharsPerLine, INDEX
|
||||||
// Get current console buffer.
|
// Get current console buffer.
|
||||||
const char *CConsole::GetBuffer(void)
|
const char *CConsole::GetBuffer(void)
|
||||||
{
|
{
|
||||||
if (this==NULL) {
|
ASSERT(this!=NULL);
|
||||||
return "";
|
|
||||||
}
|
|
||||||
return con_strBuffer+(con_ctLines-con_ctLinesPrinted)*(con_ctCharsPerLine+1);
|
return con_strBuffer+(con_ctLines-con_ctLinesPrinted)*(con_ctCharsPerLine+1);
|
||||||
}
|
}
|
||||||
INDEX CConsole::GetBufferSize(void)
|
INDEX CConsole::GetBufferSize(void)
|
||||||
{
|
{
|
||||||
if (this==NULL) {
|
ASSERT(this!=NULL);
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return (con_ctCharsPerLine+1)*con_ctLines+1;
|
return (con_ctCharsPerLine+1)*con_ctLines+1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Discard timing info for last lines
|
// Discard timing info for last lines
|
||||||
void CConsole::DiscardLastLineTimes(void)
|
void CConsole::DiscardLastLineTimes(void)
|
||||||
{
|
{
|
||||||
if (this==NULL) {
|
ASSERT(this!=NULL);
|
||||||
return;
|
|
||||||
}
|
|
||||||
for(INDEX i=0; i<con_ctLines; i++) {
|
for(INDEX i=0; i<con_ctLines; i++) {
|
||||||
con_atmLines[i] = -10000.0f;
|
con_atmLines[i] = -10000.0f;
|
||||||
}
|
}
|
||||||
|
@ -129,9 +121,7 @@ void CConsole::DiscardLastLineTimes(void)
|
||||||
// Get number of lines newer than given time
|
// Get number of lines newer than given time
|
||||||
INDEX CConsole::NumberOfLinesAfter(TIME tmLast)
|
INDEX CConsole::NumberOfLinesAfter(TIME tmLast)
|
||||||
{
|
{
|
||||||
if (this==NULL) {
|
ASSERT(this!=NULL);
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
// clamp console variable
|
// clamp console variable
|
||||||
con_iLastLines = Clamp( con_iLastLines, 0, (INDEX)CONSOLE_MAXLASTLINES);
|
con_iLastLines = Clamp( con_iLastLines, 0, (INDEX)CONSOLE_MAXLASTLINES);
|
||||||
// find number of last console lines to be displayed on screen
|
// find number of last console lines to be displayed on screen
|
||||||
|
@ -146,9 +136,7 @@ INDEX CConsole::NumberOfLinesAfter(TIME tmLast)
|
||||||
// Get one of last lines
|
// Get one of last lines
|
||||||
CTString CConsole::GetLastLine(INDEX iLine)
|
CTString CConsole::GetLastLine(INDEX iLine)
|
||||||
{
|
{
|
||||||
if (this==NULL) {
|
ASSERT(this!=NULL);
|
||||||
return "";
|
|
||||||
}
|
|
||||||
if (iLine>=con_ctLinesPrinted) {
|
if (iLine>=con_ctLinesPrinted) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -166,9 +154,7 @@ CTString CConsole::GetLastLine(INDEX iLine)
|
||||||
// clear one given line in buffer
|
// clear one given line in buffer
|
||||||
void CConsole::ClearLine(INDEX iLine)
|
void CConsole::ClearLine(INDEX iLine)
|
||||||
{
|
{
|
||||||
if (this==NULL) {
|
ASSERT(this!=NULL);
|
||||||
return;
|
|
||||||
}
|
|
||||||
// line must be valid
|
// line must be valid
|
||||||
ASSERT(iLine>=0 && iLine<con_ctLines);
|
ASSERT(iLine>=0 && iLine<con_ctLines);
|
||||||
// get start of line
|
// get start of line
|
||||||
|
@ -183,9 +169,7 @@ void CConsole::ClearLine(INDEX iLine)
|
||||||
// scroll buffer up, discarding lines at the start
|
// scroll buffer up, discarding lines at the start
|
||||||
void CConsole::ScrollBufferUp(INDEX ctLines)
|
void CConsole::ScrollBufferUp(INDEX ctLines)
|
||||||
{
|
{
|
||||||
if (this==NULL) {
|
ASSERT(this!=NULL);
|
||||||
return;
|
|
||||||
}
|
|
||||||
ASSERT(ctLines>0 && ctLines<con_ctLines);
|
ASSERT(ctLines>0 && ctLines<con_ctLines);
|
||||||
// move buffer up
|
// move buffer up
|
||||||
memmove(
|
memmove(
|
||||||
|
@ -207,9 +191,7 @@ void CConsole::ScrollBufferUp(INDEX ctLines)
|
||||||
// Add a line of text to console
|
// Add a line of text to console
|
||||||
void CConsole::PutString(const char *strString)
|
void CConsole::PutString(const char *strString)
|
||||||
{
|
{
|
||||||
if (this==NULL) {
|
ASSERT(this!=NULL);
|
||||||
return;
|
|
||||||
}
|
|
||||||
// synchronize access to console
|
// synchronize access to console
|
||||||
CTSingleLock slConsole(&con_csConsole, TRUE);
|
CTSingleLock slConsole(&con_csConsole, TRUE);
|
||||||
|
|
||||||
|
@ -265,9 +247,7 @@ void CConsole::PutString(const char *strString)
|
||||||
// Close console log file buffers (call only when force-exiting!)
|
// Close console log file buffers (call only when force-exiting!)
|
||||||
void CConsole::CloseLog(void)
|
void CConsole::CloseLog(void)
|
||||||
{
|
{
|
||||||
if (this==NULL) {
|
ASSERT(this!=NULL);
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (con_fLog!=NULL) {
|
if (con_fLog!=NULL) {
|
||||||
fclose(con_fLog);
|
fclose(con_fLog);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,8 +40,8 @@ BOOL CListHead::IsValid(void) const
|
||||||
{
|
{
|
||||||
ASSERT(this!=NULL);
|
ASSERT(this!=NULL);
|
||||||
ASSERT(lh_NULL == NULL);
|
ASSERT(lh_NULL == NULL);
|
||||||
ASSERT((lh_Head == (CListNode *) &lh_NULL) && (lh_Tail == (CListNode *) &lh_Head)
|
ASSERT(((lh_Head == (CListNode *) &lh_NULL) && (lh_Tail == (CListNode *) &lh_Head))
|
||||||
|| lh_Tail->IsValid() && lh_Head->IsValid() );
|
|| (lh_Tail->IsValid() && lh_Head->IsValid()) );
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ BOOL CListNode::IsValid(void) const
|
||||||
ASSERT((ln_Pred==NULL && ln_Succ==NULL) || (ln_Pred!=NULL && ln_Succ!=NULL));
|
ASSERT((ln_Pred==NULL && ln_Succ==NULL) || (ln_Pred!=NULL && ln_Succ!=NULL));
|
||||||
// it is valid if it is cleared or if it is linked
|
// it is valid if it is cleared or if it is linked
|
||||||
return (ln_Pred==NULL && ln_Succ==NULL)
|
return (ln_Pred==NULL && ln_Succ==NULL)
|
||||||
|| (ln_Pred->ln_Succ == this) && (ln_Succ->ln_Pred == this);
|
|| ((ln_Pred->ln_Succ == this) && (ln_Succ->ln_Pred == this));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -21,24 +21,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
template class CStaticArray<CProfileCounter>;
|
template class CStaticArray<CProfileCounter>;
|
||||||
template class CStaticArray<CProfileTimer>;
|
template class CStaticArray<CProfileTimer>;
|
||||||
|
|
||||||
#if (defined USE_PORTABLE_C)
|
#if (defined PLATFORM_UNIX) && !defined(__GNU_INLINE_X86_32__)
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline __int64 ReadTSC_profile(void)
|
static inline __int64 ReadTSC_profile(void)
|
||||||
{
|
{
|
||||||
#if (defined USE_PORTABLE_C)
|
#if (defined __MSVC_INLINE__)
|
||||||
#ifdef __arm__
|
|
||||||
struct timespec tv;
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &tv);
|
|
||||||
return( (((__int64) tv.tv_sec) * 1000) + (((__int64) tv.tv_nsec) / 1000000) );
|
|
||||||
#else
|
|
||||||
struct timeval tv;
|
|
||||||
gettimeofday(&tv, NULL);
|
|
||||||
return( (((__int64) tv.tv_sec) * 1000) + (((__int64) tv.tv_usec) / 1000) );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#elif (defined __MSVC_INLINE__)
|
|
||||||
__int64 mmRet;
|
__int64 mmRet;
|
||||||
__asm {
|
__asm {
|
||||||
rdtsc
|
rdtsc
|
||||||
|
@ -47,7 +36,7 @@ static inline __int64 ReadTSC_profile(void)
|
||||||
}
|
}
|
||||||
return mmRet;
|
return mmRet;
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
__int64 mmRet;
|
__int64 mmRet;
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"rdtsc \n\t"
|
"rdtsc \n\t"
|
||||||
|
@ -60,7 +49,16 @@ static inline __int64 ReadTSC_profile(void)
|
||||||
return(mmRet);
|
return(mmRet);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error Please implement for your platform/compiler.
|
#ifdef __arm__
|
||||||
|
struct timespec tv;
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &tv);
|
||||||
|
return( (((__int64) tv.tv_sec) * 1000) + (((__int64) tv.tv_nsec) / 1000000) );
|
||||||
|
#else
|
||||||
|
struct timeval tv;
|
||||||
|
gettimeofday(&tv, NULL);
|
||||||
|
return( (((__int64) tv.tv_sec) * 1000) + (((__int64) tv.tv_usec) / 1000) );
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -252,6 +252,10 @@ static int _iMouseZ = 0;
|
||||||
static BOOL _bWheelUp = FALSE;
|
static BOOL _bWheelUp = FALSE;
|
||||||
static BOOL _bWheelDn = FALSE;
|
static BOOL _bWheelDn = FALSE;
|
||||||
|
|
||||||
|
// emulate Win32: A single mouse wheel rotation
|
||||||
|
// is +120 (upwards) or -120 (downwards)
|
||||||
|
#define MOUSE_SCROLL_INTERVAL 120
|
||||||
|
|
||||||
CTCriticalSection csInput;
|
CTCriticalSection csInput;
|
||||||
|
|
||||||
// which keys are pressed, as recorded by message interception (by KIDs)
|
// which keys are pressed, as recorded by message interception (by KIDs)
|
||||||
|
@ -328,10 +332,7 @@ static void sdl_event_handler(const SDL_Event *event)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_MOUSEWHEEL:
|
case SDL_MOUSEWHEEL:
|
||||||
if (event->wheel.y > 0)
|
_iMouseZ += event->wheel.y * MOUSE_SCROLL_INTERVAL;
|
||||||
_abKeysPressed[KID_MOUSEWHEELUP] = TRUE;
|
|
||||||
else if (event->wheel.y < 0)
|
|
||||||
_abKeysPressed[KID_MOUSEWHEELDOWN] = TRUE;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
|
@ -724,6 +725,7 @@ void CInput::GetInput(BOOL bPreScan)
|
||||||
// clear button's buffer
|
// clear button's buffer
|
||||||
memset( inp_ubButtonsBuffer, 0, sizeof( inp_ubButtonsBuffer));
|
memset( inp_ubButtonsBuffer, 0, sizeof( inp_ubButtonsBuffer));
|
||||||
|
|
||||||
|
const Uint8 *keystate = SDL_GetKeyboardState(NULL);
|
||||||
// for each Key
|
// for each Key
|
||||||
for (INDEX iKey=0; iKey<ARRAYCOUNT(_akcKeys); iKey++) {
|
for (INDEX iKey=0; iKey<ARRAYCOUNT(_akcKeys); iKey++) {
|
||||||
const KeyConversion &kc = _akcKeys[iKey];
|
const KeyConversion &kc = _akcKeys[iKey];
|
||||||
|
@ -732,11 +734,11 @@ void CInput::GetInput(BOOL bPreScan)
|
||||||
//INDEX iScan = kc.kc_iScanCode;
|
//INDEX iScan = kc.kc_iScanCode;
|
||||||
INDEX iVirt = kc.kc_iVirtKey;
|
INDEX iVirt = kc.kc_iVirtKey;
|
||||||
// if reading async keystate
|
// if reading async keystate
|
||||||
if (inp_iKeyboardReadingMethod==0) {
|
if (0/*inp_iKeyboardReadingMethod==0*/) {
|
||||||
// if there is a valid virtkey
|
// if there is a valid virtkey
|
||||||
if (iVirt>=0) {
|
if (iVirt>=0) {
|
||||||
// is state is pressed
|
// is state is pressed
|
||||||
if (SDL_GetKeyboardState(NULL)[SDL_GetScancodeFromKey((SDL_Keycode)iVirt)]) {
|
if (keystate[SDL_GetScancodeFromKey((SDL_Keycode)iVirt)]) {
|
||||||
// mark it as pressed
|
// mark it as pressed
|
||||||
inp_ubButtonsBuffer[iKID] = 0xFF;
|
inp_ubButtonsBuffer[iKID] = 0xFF;
|
||||||
}
|
}
|
||||||
|
@ -753,10 +755,6 @@ void CInput::GetInput(BOOL bPreScan)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset this every frame (since we explicitly ignore the button-up events).
|
|
||||||
_abKeysPressed[KID_MOUSEWHEELUP] = FALSE;
|
|
||||||
_abKeysPressed[KID_MOUSEWHEELDOWN] = FALSE;
|
|
||||||
|
|
||||||
// read mouse position
|
// read mouse position
|
||||||
#ifdef USE_MOUSEWARP
|
#ifdef USE_MOUSEWARP
|
||||||
int iMx, iMy;
|
int iMx, iMy;
|
||||||
|
@ -825,17 +823,16 @@ void CInput::GetInput(BOOL bPreScan)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
|
||||||
// if not pre-scanning
|
// if not pre-scanning
|
||||||
if (!bPreScan) {
|
if (!bPreScan) {
|
||||||
// detect wheel up/down movement
|
// detect wheel up/down movement
|
||||||
_bWheelDn = FALSE;
|
|
||||||
if (_iMouseZ>0) {
|
if (_iMouseZ>0) {
|
||||||
if (_bWheelUp) {
|
if (_bWheelUp) {
|
||||||
inp_ubButtonsBuffer[KID_MOUSEWHEELUP] = 0x00;
|
inp_ubButtonsBuffer[KID_MOUSEWHEELUP] = 0x00;
|
||||||
} else {
|
} else {
|
||||||
inp_ubButtonsBuffer[KID_MOUSEWHEELUP] = 0xFF;
|
inp_ubButtonsBuffer[KID_MOUSEWHEELUP] = 0xFF;
|
||||||
_iMouseZ = ClampDn(_iMouseZ-120, 0);
|
_iMouseZ = ClampDn(_iMouseZ-MOUSE_SCROLL_INTERVAL, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_bWheelUp = inp_ubButtonsBuffer[KID_MOUSEWHEELUP];
|
_bWheelUp = inp_ubButtonsBuffer[KID_MOUSEWHEELUP];
|
||||||
|
@ -844,12 +841,11 @@ void CInput::GetInput(BOOL bPreScan)
|
||||||
inp_ubButtonsBuffer[KID_MOUSEWHEELDOWN] = 0x00;
|
inp_ubButtonsBuffer[KID_MOUSEWHEELDOWN] = 0x00;
|
||||||
} else {
|
} else {
|
||||||
inp_ubButtonsBuffer[KID_MOUSEWHEELDOWN] = 0xFF;
|
inp_ubButtonsBuffer[KID_MOUSEWHEELDOWN] = 0xFF;
|
||||||
_iMouseZ = ClampUp(_iMouseZ+120, 0);
|
_iMouseZ = ClampUp(_iMouseZ+MOUSE_SCROLL_INTERVAL, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_bWheelDn = inp_ubButtonsBuffer[KID_MOUSEWHEELDOWN];
|
_bWheelDn = inp_ubButtonsBuffer[KID_MOUSEWHEELDOWN];
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
inp_bLastPrescan = bPreScan;
|
inp_bLastPrescan = bPreScan;
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@ CDynamicStackArray<CTString> _shell_astrTempStrings;
|
||||||
CDynamicStackArray<CTString> _shell_astrExtStrings;
|
CDynamicStackArray<CTString> _shell_astrExtStrings;
|
||||||
CDynamicStackArray<FLOAT> _shell_afExtFloats;
|
CDynamicStackArray<FLOAT> _shell_afExtFloats;
|
||||||
|
|
||||||
static const char *strCommandLine = "";
|
//static const char *strCommandLine = "";
|
||||||
|
|
||||||
FLOAT tmp_af[10] = { 0 };
|
FLOAT tmp_af[10] = { 0 };
|
||||||
INDEX tmp_ai[10] = { 0 };
|
INDEX tmp_ai[10] = { 0 };
|
||||||
|
|
|
@ -169,7 +169,13 @@ void InitStreams(void)
|
||||||
}
|
}
|
||||||
// find eventual extension for the mod's dlls
|
// find eventual extension for the mod's dlls
|
||||||
_strModExt = "";
|
_strModExt = "";
|
||||||
LoadStringVar(CTString("ModExt.txt"), _strModExt);
|
// DG: apparently both ModEXT.txt and ModExt.txt exist in the wild.
|
||||||
|
CTFileName tmp;
|
||||||
|
if(ExpandFilePath(EFP_READ, CTString("ModEXT.txt"), tmp) != EFP_NONE) {
|
||||||
|
LoadStringVar(CTString("ModEXT.txt"), _strModExt);
|
||||||
|
} else {
|
||||||
|
LoadStringVar(CTString("ModExt.txt"), _strModExt);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
CPrintF(TRANSV("Loading group files...\n"));
|
CPrintF(TRANSV("Loading group files...\n"));
|
||||||
|
@ -934,7 +940,7 @@ void CTFileStream::Create_t(const CTFileName &fnFileName,
|
||||||
}
|
}
|
||||||
|
|
||||||
CTFileName fnmFullFileName;
|
CTFileName fnmFullFileName;
|
||||||
INDEX iFile = ExpandFilePath(EFP_WRITE, fnFileNameAbsolute, fnmFullFileName);
|
/* INDEX iFile = */ ExpandFilePath(EFP_WRITE, fnFileNameAbsolute, fnmFullFileName);
|
||||||
|
|
||||||
// check parameters
|
// check parameters
|
||||||
ASSERT(strlen(fnFileNameAbsolute)>0);
|
ASSERT(strlen(fnFileNameAbsolute)>0);
|
||||||
|
@ -1317,7 +1323,7 @@ BOOL FileExistsForWriting(const CTFileName &fnmFile)
|
||||||
}
|
}
|
||||||
// expand the filename to full path for writing
|
// expand the filename to full path for writing
|
||||||
CTFileName fnmFullFileName;
|
CTFileName fnmFullFileName;
|
||||||
INDEX iFile = ExpandFilePath(EFP_WRITE, fnmFile, fnmFullFileName);
|
/* INDEX iFile = */ ExpandFilePath(EFP_WRITE, fnmFile, fnmFullFileName);
|
||||||
|
|
||||||
// check if it exists
|
// check if it exists
|
||||||
FILE *f = fopen(fnmFullFileName, "rb");
|
FILE *f = fopen(fnmFullFileName, "rb");
|
||||||
|
@ -1433,7 +1439,7 @@ static INDEX ExpandFilePath_read(ULONG ulType, const CTFileName &fnmFile, CTFile
|
||||||
{
|
{
|
||||||
// search for the file in zips
|
// search for the file in zips
|
||||||
INDEX iFileInZip = UNZIPGetFileIndex(fnmFile);
|
INDEX iFileInZip = UNZIPGetFileIndex(fnmFile);
|
||||||
const BOOL userdir_not_basedir = (_fnmUserDir != _fnmApplicationPath);
|
//const BOOL userdir_not_basedir = (_fnmUserDir != _fnmApplicationPath);
|
||||||
|
|
||||||
// if a mod is active
|
// if a mod is active
|
||||||
if (_fnmMod!="") {
|
if (_fnmMod!="") {
|
||||||
|
|
|
@ -29,7 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#include <Engine/Base/Priority.inl>
|
#include <Engine/Base/Priority.inl>
|
||||||
|
|
||||||
// !!! FIXME: use SDL timer code instead and rdtsc never?
|
// !!! FIXME: use SDL timer code instead and rdtsc never?
|
||||||
#if (USE_PORTABLE_C)
|
#if (defined PLATFORM_UNIX) && !defined(__GNU_INLINE_X86_32__)
|
||||||
#define USE_GETTIMEOFDAY 1
|
#define USE_GETTIMEOFDAY 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ static inline __int64 ReadTSC(void)
|
||||||
}
|
}
|
||||||
return mmRet;
|
return mmRet;
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
__int64 mmRet;
|
__int64 mmRet;
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"rdtsc \n\t"
|
"rdtsc \n\t"
|
||||||
|
@ -161,8 +161,8 @@ void CTimer_TimerFunc_internal(void)
|
||||||
CTimerValue tvTimeNow = _pTimer->GetHighPrecisionTimer();
|
CTimerValue tvTimeNow = _pTimer->GetHighPrecisionTimer();
|
||||||
TIME tmTickNow = _pTimer->tm_RealTimeTimer;
|
TIME tmTickNow = _pTimer->tm_RealTimeTimer;
|
||||||
// calculate how long has passed since we have last been on time
|
// calculate how long has passed since we have last been on time
|
||||||
TIME tmTimeDelay = (TIME)(tvTimeNow - _pTimer->tm_tvLastTimeOnTime).GetSeconds();
|
//TIME tmTimeDelay = (TIME)(tvTimeNow - _pTimer->tm_tvLastTimeOnTime).GetSeconds();
|
||||||
TIME tmTickDelay = (tmTickNow - _pTimer->tm_tmLastTickOnTime);
|
//TIME tmTickDelay = (tmTickNow - _pTimer->tm_tmLastTickOnTime);
|
||||||
|
|
||||||
_sfStats.StartTimer(CStatForm::STI_TIMER);
|
_sfStats.StartTimer(CStatForm::STI_TIMER);
|
||||||
// if we are keeping up to time (more or less)
|
// if we are keeping up to time (more or less)
|
||||||
|
@ -209,13 +209,14 @@ Uint32 CTimer_TimerFunc_SDL(Uint32 interval, void* param)
|
||||||
|
|
||||||
#pragma inline_depth()
|
#pragma inline_depth()
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef PLATFORM_WIN32 // DG: not used on other platforms
|
||||||
#define MAX_MEASURE_TRIES 5
|
#define MAX_MEASURE_TRIES 5
|
||||||
static INDEX _aiTries[MAX_MEASURE_TRIES];
|
static INDEX _aiTries[MAX_MEASURE_TRIES];
|
||||||
|
|
||||||
// Get processor speed in Hertz
|
// Get processor speed in Hertz
|
||||||
static __int64 GetCPUSpeedHz(void)
|
static __int64 GetCPUSpeedHz(void)
|
||||||
{
|
{
|
||||||
#ifdef PLATFORM_WIN32
|
|
||||||
// get the frequency of the 'high' precision timer
|
// get the frequency of the 'high' precision timer
|
||||||
__int64 llTimerFrequency;
|
__int64 llTimerFrequency;
|
||||||
BOOL bPerformanceCounterPresent = QueryPerformanceFrequency((LARGE_INTEGER*)&llTimerFrequency);
|
BOOL bPerformanceCounterPresent = QueryPerformanceFrequency((LARGE_INTEGER*)&llTimerFrequency);
|
||||||
|
@ -296,14 +297,8 @@ static __int64 GetCPUSpeedHz(void)
|
||||||
// use measured value
|
// use measured value
|
||||||
return (__int64)slSpeedRead*1000000;
|
return (__int64)slSpeedRead*1000000;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
|
|
||||||
STUBBED("I hope this isn't critical...");
|
|
||||||
return(1);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#endif // PLATFORM_WIN32
|
||||||
|
|
||||||
|
|
||||||
#if PLATFORM_MACOSX
|
#if PLATFORM_MACOSX
|
||||||
|
|
|
@ -108,6 +108,30 @@ MY_STATIC_ASSERT(size_tSize, sizeof(size_t) == sizeof(void*));
|
||||||
#define ASMSYM(x) #x
|
#define ASMSYM(x) #x
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* should we enable inline asm? */
|
||||||
|
#ifndef USE_PORTABLE_C
|
||||||
|
#if defined(__MSVC_INLINE__)
|
||||||
|
/* the build system selected __MSVC_INLINE__ */
|
||||||
|
#elif defined(__GNU_INLINE_X86_32__)
|
||||||
|
/* the build system selected __GNU_INLINE_X86_32__ */
|
||||||
|
#elif defined(_MSC_VER) && defined(_M_IX86)
|
||||||
|
#define __MSVC_INLINE__
|
||||||
|
#elif defined (__GNUC__) && defined(__i386)
|
||||||
|
#define __GNU_INLINE_X86_32__
|
||||||
|
#elif defined (__GNUC__) && defined(__x86_64__)
|
||||||
|
#define __GNU_INLINE_X86_64__
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__GNU_INLINE_X86_32__) || defined(__GNU_INLINE_X86_64__)
|
||||||
|
#define __GNU_INLINE_X86__
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__GNU_INLINE_X86__)
|
||||||
|
#define FPU_REGS "st", "st(1)", "st(2)", "st(3)", "st(4)", "st(5)", "st(6)", "st(7)"
|
||||||
|
#define MMX_REGS "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef PLATFORM_UNIX /* rcg10042001 */
|
#ifdef PLATFORM_UNIX /* rcg10042001 */
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -133,25 +157,6 @@ MY_STATIC_ASSERT(size_tSize, sizeof(size_t) == sizeof(void*));
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ((defined __GNUC__) && (!defined __GNU_INLINE__))
|
|
||||||
#define __GNU_INLINE__
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (defined __INTEL_COMPILER)
|
|
||||||
#if ((!defined __GNU_INLINE__) && (!defined __MSVC_INLINE__))
|
|
||||||
#error Please define __GNU_INLINE__ or __MSVC_INLINE__ with Intel C++.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ((defined __GNU_INLINE__) && (defined __MSVC_INLINE__))
|
|
||||||
#error Define either __GNU_INLINE__ or __MSVC_INLINE__ with Intel C++.
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__GNU_INLINE__) && defined(__i386__)
|
|
||||||
#define FPU_REGS "st", "st(1)", "st(2)", "st(3)", "st(4)", "st(5)", "st(6)", "st(7)"
|
|
||||||
#define MMX_REGS "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef PAGESIZE
|
#ifndef PAGESIZE
|
||||||
#define PAGESIZE 4096
|
#define PAGESIZE 4096
|
||||||
#endif
|
#endif
|
||||||
|
@ -229,10 +234,7 @@ MY_STATIC_ASSERT(size_tSize, sizeof(size_t) == sizeof(void*));
|
||||||
|
|
||||||
inline ULONG _rotl(ULONG ul, int bits)
|
inline ULONG _rotl(ULONG ul, int bits)
|
||||||
{
|
{
|
||||||
#if (defined USE_PORTABLE_C)
|
#if (defined __GNU_INLINE_X86_32__)
|
||||||
// DG: according to http://blog.regehr.org/archives/1063 this is fast
|
|
||||||
return (ul<<bits) | (ul>>(-bits&31));
|
|
||||||
#elif (defined __GNU_INLINE__)
|
|
||||||
// This, on the other hand, is wicked fast. :)
|
// This, on the other hand, is wicked fast. :)
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"roll %%cl, %%eax \n\t"
|
"roll %%cl, %%eax \n\t"
|
||||||
|
@ -254,7 +256,8 @@ MY_STATIC_ASSERT(size_tSize, sizeof(size_t) == sizeof(void*));
|
||||||
return(ul);
|
return(ul);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error need inline asm for your platform.
|
// DG: according to http://blog.regehr.org/archives/1063 this is fast
|
||||||
|
return (ul<<bits) | (ul>>(-bits&31));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -675,15 +678,45 @@ inline void Clear(float i) {};
|
||||||
inline void Clear(double i) {};
|
inline void Clear(double i) {};
|
||||||
inline void Clear(void *pv) {};
|
inline void Clear(void *pv) {};
|
||||||
|
|
||||||
// These macros are not safe to use unless data is UNSIGNED!
|
// DG: screw macros, use inline functions instead - they're even safe for signed values
|
||||||
#define BYTESWAP16_unsigned(x) ((((x)>>8)&0xff)+ (((x)<<8)&0xff00))
|
inline UWORD BYTESWAP16_unsigned(UWORD x)
|
||||||
#define BYTESWAP32_unsigned(x) (((x)>>24) + (((x)>>8)&0xff00) + (((x)<<8)&0xff0000) + ((x)<<24))
|
{
|
||||||
|
#ifdef __GNUC__ // GCC and clang have a builtin that hopefully does the most efficient thing
|
||||||
|
return __builtin_bswap16(x);
|
||||||
|
#else
|
||||||
|
return (((x)>>8)&0xff)+ (((x)<<8)&0xff00);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ULONG BYTESWAP32_unsigned(ULONG x)
|
||||||
|
{
|
||||||
|
#ifdef __GNUC__ // GCC and clang have a builtin that hopefully does the most efficient thing
|
||||||
|
return __builtin_bswap32(x);
|
||||||
|
#else
|
||||||
|
return ((x)>>24) + (((x)>>8)&0xff00) + (((x)<<8)&0xff0000) + ((x)<<24);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
inline __uint64 BYTESWAP64_unsigned(__uint64 x)
|
||||||
|
{
|
||||||
|
#ifdef __GNUC__ // GCC and clang have a builtin that hopefully does the most efficient thing
|
||||||
|
return __builtin_bswap64(x);
|
||||||
|
#else
|
||||||
|
ULONG l = BYTESWAP32_unsigned((ULONG)(val & 0xFFFFFFFF));
|
||||||
|
ULONG h = BYTESWAP32_unsigned((ULONG)((val >> 32) & 0xFFFFFFFF));
|
||||||
|
return (((__uint64)l) << 32) | ((__uint64)h);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// rcg03242004
|
// rcg03242004
|
||||||
#if PLATFORM_LITTLEENDIAN
|
#if PLATFORM_LITTLEENDIAN
|
||||||
#define BYTESWAP(x)
|
#define BYTESWAP(x)
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
// TODO: DG: the following stuff could probably be updated to use the functions above properly,
|
||||||
|
// which should make lots of cases easier. As I don't have a big endian machine I can't test,
|
||||||
|
// so I won't touch this for now.
|
||||||
|
|
||||||
static inline void BYTESWAP(UWORD &val)
|
static inline void BYTESWAP(UWORD &val)
|
||||||
{
|
{
|
||||||
#if __POWERPC__
|
#if __POWERPC__
|
||||||
|
|
|
@ -509,7 +509,7 @@ CBrushPolygon &CBrushPolygon::CopyPolygon(CBrushPolygon &bp)
|
||||||
bpo_boxBoundingBox=bp.bpo_boxBoundingBox;
|
bpo_boxBoundingBox=bp.bpo_boxBoundingBox;
|
||||||
bpo_pbscSector=bp.bpo_pbscSector;
|
bpo_pbscSector=bp.bpo_pbscSector;
|
||||||
bpo_rsOtherSideSectors.Clear();
|
bpo_rsOtherSideSectors.Clear();
|
||||||
bpo_lhShadingInfos;
|
//bpo_lhShadingInfos; // don't copy or anything, it's a CListHead which must not be copied
|
||||||
bpo_iInWorld=bp.bpo_iInWorld;
|
bpo_iInWorld=bp.bpo_iInWorld;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,8 +53,8 @@ CBrushSector::CBrushSector(void)
|
||||||
, bsc_ulFlags2(0)
|
, bsc_ulFlags2(0)
|
||||||
, bsc_ulTempFlags(0)
|
, bsc_ulTempFlags(0)
|
||||||
, bsc_ulVisFlags(0)
|
, bsc_ulVisFlags(0)
|
||||||
, bsc_strName("")
|
|
||||||
, bsc_bspBSPTree(*new DOUBLEbsptree3D)
|
, bsc_bspBSPTree(*new DOUBLEbsptree3D)
|
||||||
|
, bsc_strName("")
|
||||||
{
|
{
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -622,9 +622,9 @@ void CBrushSector::TriangularizeMarkedPolygons( void)
|
||||||
bpoNew.bpo_abpePolygonEdges[2].bpe_pbedEdge = &abedEdgesNew[iEdge+2];
|
bpoNew.bpo_abpePolygonEdges[2].bpe_pbedEdge = &abedEdgesNew[iEdge+2];
|
||||||
bpoNew.bpo_abpePolygonEdges[2].bpe_bReverse = FALSE;
|
bpoNew.bpo_abpePolygonEdges[2].bpe_bReverse = FALSE;
|
||||||
|
|
||||||
CBrushEdge &edg0 = *bpoNew.bpo_abpePolygonEdges[0].bpe_pbedEdge;
|
//CBrushEdge &edg0 = *bpoNew.bpo_abpePolygonEdges[0].bpe_pbedEdge;
|
||||||
CBrushEdge &edg1 = *bpoNew.bpo_abpePolygonEdges[1].bpe_pbedEdge;
|
//CBrushEdge &edg1 = *bpoNew.bpo_abpePolygonEdges[1].bpe_pbedEdge;
|
||||||
CBrushEdge &edg2 = *bpoNew.bpo_abpePolygonEdges[2].bpe_pbedEdge;
|
//CBrushEdge &edg2 = *bpoNew.bpo_abpePolygonEdges[2].bpe_pbedEdge;
|
||||||
|
|
||||||
// set brush vertex ptrs
|
// set brush vertex ptrs
|
||||||
bpoNew.bpo_apbvxTriangleVertices.New(3);
|
bpoNew.bpo_apbvxTriangleVertices.New(3);
|
||||||
|
|
|
@ -562,9 +562,9 @@ void CBrushShadowMap::CheckLayersUpToDate(void)
|
||||||
CBrushShadowLayer &bsl = *itbsl;
|
CBrushShadowLayer &bsl = *itbsl;
|
||||||
if( bsl.bsl_ulFlags&BSLF_ALLDARK) continue;
|
if( bsl.bsl_ulFlags&BSLF_ALLDARK) continue;
|
||||||
// light source must be valid
|
// light source must be valid
|
||||||
|
ASSERT( bsl.bsl_plsLightSource!=NULL);
|
||||||
|
if( bsl.bsl_plsLightSource==NULL) continue;
|
||||||
CLightSource &ls = *bsl.bsl_plsLightSource;
|
CLightSource &ls = *bsl.bsl_plsLightSource;
|
||||||
ASSERT( &ls!=NULL);
|
|
||||||
if( &ls==NULL) continue;
|
|
||||||
// if the layer is not up to date
|
// if the layer is not up to date
|
||||||
if( bsl.bsl_colLastAnim != ls.GetLightColor()) {
|
if( bsl.bsl_colLastAnim != ls.GetLightColor()) {
|
||||||
// invalidate entire shadow map
|
// invalidate entire shadow map
|
||||||
|
@ -581,9 +581,9 @@ BOOL CBrushShadowMap::HasDynamicLayers(void)
|
||||||
// for each layer
|
// for each layer
|
||||||
FOREACHINLIST( CBrushShadowLayer, bsl_lnInShadowMap, bsm_lhLayers, itbsl)
|
FOREACHINLIST( CBrushShadowLayer, bsl_lnInShadowMap, bsm_lhLayers, itbsl)
|
||||||
{ // light source must be valid
|
{ // light source must be valid
|
||||||
|
ASSERT( itbsl->bsl_plsLightSource!=NULL);
|
||||||
|
if( itbsl->bsl_plsLightSource==NULL) continue;
|
||||||
CLightSource &ls = *itbsl->bsl_plsLightSource;
|
CLightSource &ls = *itbsl->bsl_plsLightSource;
|
||||||
ASSERT( &ls!=NULL);
|
|
||||||
if( &ls==NULL) continue;
|
|
||||||
// if the layer is dynamic, it has
|
// if the layer is dynamic, it has
|
||||||
if( ls.ls_ulFlags&LSF_DYNAMIC) return TRUE;
|
if( ls.ls_ulFlags&LSF_DYNAMIC) return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -605,7 +605,7 @@ BOOL CBrushShadowMap::IsShadowFlat( COLOR &colFlat)
|
||||||
COLOR col;
|
COLOR col;
|
||||||
UBYTE ubR,ubG,ubB, ubR1,ubG1,ubB1;
|
UBYTE ubR,ubG,ubB, ubR1,ubG1,ubB1;
|
||||||
SLONG slR=0,slG=0,slB=0;
|
SLONG slR=0,slG=0,slB=0;
|
||||||
INDEX ctPointLights=0;
|
//INDEX ctPointLights=0;
|
||||||
CBrushPolygon *pbpo = GetBrushPolygon();
|
CBrushPolygon *pbpo = GetBrushPolygon();
|
||||||
|
|
||||||
// if the shadowmap is not using the shading mode
|
// if the shadowmap is not using the shading mode
|
||||||
|
|
|
@ -337,7 +337,7 @@ void CTriangularizer::MakeEdgesForTriangularization(void)
|
||||||
// get number of edges in polygon
|
// get number of edges in polygon
|
||||||
INDEX ctEdges = tr_abpeOriginalEdges.Count();
|
INDEX ctEdges = tr_abpeOriginalEdges.Count();
|
||||||
// create that much edges in the array
|
// create that much edges in the array
|
||||||
CBrushEdge *pbedEdges = tr_abedEdges.New(ctEdges);
|
/* CBrushEdge *pbedEdges = */ tr_abedEdges.New(ctEdges);
|
||||||
|
|
||||||
tr_abedEdges.Lock();
|
tr_abedEdges.Lock();
|
||||||
|
|
||||||
|
@ -480,7 +480,7 @@ void CTriangularizer::FindExistingTriangleEdges(void)
|
||||||
|
|
||||||
// for each edge
|
// for each edge
|
||||||
FOREACHINDYNAMICARRAY(tr_abedEdges, CBrushEdge, itbed) {
|
FOREACHINDYNAMICARRAY(tr_abedEdges, CBrushEdge, itbed) {
|
||||||
CBrushEdge *pbed = itbed;
|
//CBrushEdge *pbed = itbed;
|
||||||
|
|
||||||
// if it is the bottom edge of the triangle
|
// if it is the bottom edge of the triangle
|
||||||
if (tr_pbedBottom == itbed) {
|
if (tr_pbedBottom == itbed) {
|
||||||
|
@ -517,7 +517,7 @@ BOOL CTriangularizer::CheckTriangleAgainstEdges(void)
|
||||||
{
|
{
|
||||||
// for each edge
|
// for each edge
|
||||||
FOREACHINDYNAMICARRAY(tr_abedEdges, CBrushEdge, itbed) {
|
FOREACHINDYNAMICARRAY(tr_abedEdges, CBrushEdge, itbed) {
|
||||||
CBrushEdge *pbed = itbed;
|
//CBrushEdge *pbed = itbed;
|
||||||
|
|
||||||
// if it is the bottom edge of the triangle
|
// if it is the bottom edge of the triangle
|
||||||
if (tr_pbedBottom == itbed) {
|
if (tr_pbedBottom == itbed) {
|
||||||
|
|
|
@ -1009,8 +1009,8 @@ functions:
|
||||||
}
|
}
|
||||||
// find current breathing parameters
|
// find current breathing parameters
|
||||||
BOOL bCanBreathe =
|
BOOL bCanBreathe =
|
||||||
(ctUp.ct_ulFlags&CTF_BREATHABLE_LUNGS) && (en_ulPhysicsFlags&EPF_HASLUNGS) ||
|
((ctUp.ct_ulFlags&CTF_BREATHABLE_LUNGS) && (en_ulPhysicsFlags&EPF_HASLUNGS)) ||
|
||||||
(ctUp.ct_ulFlags&CTF_BREATHABLE_GILLS) && (en_ulPhysicsFlags&EPF_HASGILLS);
|
((ctUp.ct_ulFlags&CTF_BREATHABLE_GILLS) && (en_ulPhysicsFlags&EPF_HASGILLS));
|
||||||
TIME tmNow = _pTimer->CurrentTick();
|
TIME tmNow = _pTimer->CurrentTick();
|
||||||
TIME tmBreathDelay = tmNow-en_tmLastBreathed;
|
TIME tmBreathDelay = tmNow-en_tmLastBreathed;
|
||||||
// if entity can breathe now
|
// if entity can breathe now
|
||||||
|
@ -1207,8 +1207,8 @@ functions:
|
||||||
|
|
||||||
// if polygon's steepness is too high
|
// if polygon's steepness is too high
|
||||||
CSurfaceType &stReference = en_pwoWorld->wo_astSurfaceTypes[pbpo->bpo_bppProperties.bpp_ubSurfaceType];
|
CSurfaceType &stReference = en_pwoWorld->wo_astSurfaceTypes[pbpo->bpo_bppProperties.bpp_ubSurfaceType];
|
||||||
if (fCos>=-stReference.st_fClimbSlopeCos&&fCos<0
|
if ((fCos >= -stReference.st_fClimbSlopeCos && fCos<0)
|
||||||
||stReference.st_ulFlags&STF_SLIDEDOWNSLOPE) {
|
|| stReference.st_ulFlags&STF_SLIDEDOWNSLOPE) {
|
||||||
// it cannot be below
|
// it cannot be below
|
||||||
_pfPhysicsProfile.StopTimer((INDEX) CPhysicsProfile::PTI_ISSTANDINGONPOLYGON);
|
_pfPhysicsProfile.StopTimer((INDEX) CPhysicsProfile::PTI_ISSTANDINGONPOLYGON);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -1529,11 +1529,11 @@ out:;
|
||||||
// going up or
|
// going up or
|
||||||
iStep==0 ||
|
iStep==0 ||
|
||||||
// going forward and hit stairs or
|
// going forward and hit stairs or
|
||||||
iStep==1 && bHitStairsNow ||
|
(iStep==1 && bHitStairsNow) ||
|
||||||
// going down and ends on something that is not high slope
|
// going down and ends on something that is not high slope
|
||||||
iStep==2 &&
|
(iStep==2 &&
|
||||||
(vHitPlane%en_vGravityDir<-stHit.st_fClimbSlopeCos ||
|
(vHitPlane%en_vGravityDir<-stHit.st_fClimbSlopeCos ||
|
||||||
bHitStairsNow);
|
bHitStairsNow));
|
||||||
|
|
||||||
// if early clip is allowed
|
// if early clip is allowed
|
||||||
if (bEarlyClipAllowed || bSlidingAllowed) {
|
if (bEarlyClipAllowed || bSlidingAllowed) {
|
||||||
|
@ -2322,8 +2322,8 @@ out:;
|
||||||
FLOAT fPlaneYAbs = Abs(fPlaneY);
|
FLOAT fPlaneYAbs = Abs(fPlaneY);
|
||||||
FLOAT fFriction = stReference.st_fFriction;
|
FLOAT fFriction = stReference.st_fFriction;
|
||||||
// if on a steep slope
|
// if on a steep slope
|
||||||
if (fPlaneY>=-stReference.st_fClimbSlopeCos&&fPlaneY<0
|
if ((fPlaneY>=-stReference.st_fClimbSlopeCos&&fPlaneY<0)
|
||||||
||(stReference.st_ulFlags&STF_SLIDEDOWNSLOPE)&&fPlaneY>-0.99f) {
|
||((stReference.st_ulFlags&STF_SLIDEDOWNSLOPE)&&fPlaneY>-0.99f)) {
|
||||||
en_ulPhysicsFlags|=EPF_ONSTEEPSLOPE;
|
en_ulPhysicsFlags|=EPF_ONSTEEPSLOPE;
|
||||||
// accellerate horizontaly towards desired absolute translation
|
// accellerate horizontaly towards desired absolute translation
|
||||||
AddAccelerationOnPlane2(
|
AddAccelerationOnPlane2(
|
||||||
|
@ -2737,8 +2737,8 @@ out:;
|
||||||
/* old */ FLOAT fPlaneYAbs = Abs(fPlaneY);
|
/* old */ FLOAT fPlaneYAbs = Abs(fPlaneY);
|
||||||
/* old */ FLOAT fFriction = stReference.st_fFriction;
|
/* old */ FLOAT fFriction = stReference.st_fFriction;
|
||||||
/* old */ // if on a steep slope
|
/* old */ // if on a steep slope
|
||||||
/* old */ if (fPlaneY>=-stReference.st_fClimbSlopeCos&&fPlaneY<0
|
/* old */ if ((fPlaneY>=-stReference.st_fClimbSlopeCos&&fPlaneY<0)
|
||||||
/* old */ ||(stReference.st_ulFlags&STF_SLIDEDOWNSLOPE)&&fPlaneY>-0.99f) {
|
/* old */ ||((stReference.st_ulFlags&STF_SLIDEDOWNSLOPE)&&fPlaneY>-0.99f)) {
|
||||||
/* old */ en_ulPhysicsFlags|=EPF_ONSTEEPSLOPE;
|
/* old */ en_ulPhysicsFlags|=EPF_ONSTEEPSLOPE;
|
||||||
/* old */ // accellerate horizontaly towards desired absolute translation
|
/* old */ // accellerate horizontaly towards desired absolute translation
|
||||||
/* old */ AddAccelerationOnPlane2(
|
/* old */ AddAccelerationOnPlane2(
|
||||||
|
@ -2863,7 +2863,7 @@ out:;
|
||||||
|
|
||||||
_pfPhysicsProfile.IncrementCounter((INDEX) CPhysicsProfile::PCI_DOMOVING);
|
_pfPhysicsProfile.IncrementCounter((INDEX) CPhysicsProfile::PCI_DOMOVING);
|
||||||
|
|
||||||
FLOAT fTickQuantum=_pTimer->TickQuantum; // used for normalizing from SI units to game ticks
|
//FLOAT fTickQuantum=_pTimer->TickQuantum; // used for normalizing from SI units to game ticks
|
||||||
|
|
||||||
// if rotation and translation are synchronized
|
// if rotation and translation are synchronized
|
||||||
if (en_ulPhysicsFlags&EPF_RT_SYNCHRONIZED) {
|
if (en_ulPhysicsFlags&EPF_RT_SYNCHRONIZED) {
|
||||||
|
@ -2878,7 +2878,7 @@ out:;
|
||||||
if ((en_ulPhysicsFlags&EPF_ONBLOCK_MASK)==EPF_ONBLOCK_PUSH) {
|
if ((en_ulPhysicsFlags&EPF_ONBLOCK_MASK)==EPF_ONBLOCK_PUSH) {
|
||||||
penPusher = this;
|
penPusher = this;
|
||||||
}
|
}
|
||||||
BOOL bMoveSuccessfull = TryToMove(penPusher, TRUE, TRUE);
|
/* BOOL bMoveSuccessfull = */ TryToMove(penPusher, TRUE, TRUE);
|
||||||
|
|
||||||
// if rotation and translation are asynchronious
|
// if rotation and translation are asynchronious
|
||||||
} else {
|
} else {
|
||||||
|
|
94
Sources/Engine/Engine.cpp
Normal file → Executable file
94
Sources/Engine/Engine.cpp
Normal file → Executable file
|
@ -67,7 +67,9 @@ CTCriticalSection zip_csLock; // critical section for access to zlib functions
|
||||||
|
|
||||||
|
|
||||||
// to keep system gamma table
|
// to keep system gamma table
|
||||||
|
#ifdef PLATFORM_WIN32 // DG: other platforms don't (currently?) use this
|
||||||
static UWORD auwSystemGamma[256*3];
|
static UWORD auwSystemGamma[256*3];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// OS info
|
// OS info
|
||||||
|
@ -125,14 +127,10 @@ BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReser
|
||||||
|
|
||||||
static void DetectCPU(void)
|
static void DetectCPU(void)
|
||||||
{
|
{
|
||||||
#if (defined USE_PORTABLE_C) // rcg10072001
|
char strVendor[12+1] = { 0 };
|
||||||
CPrintF(TRANSV(" (No CPU detection in this binary.)\n"));
|
|
||||||
|
|
||||||
#else
|
|
||||||
char strVendor[12+1];
|
|
||||||
strVendor[12] = 0;
|
strVendor[12] = 0;
|
||||||
ULONG ulTFMS;
|
ULONG ulTFMS = 0;
|
||||||
ULONG ulFeatures;
|
ULONG ulFeatures = 0;
|
||||||
|
|
||||||
#if (defined __MSVC_INLINE__)
|
#if (defined __MSVC_INLINE__)
|
||||||
// test MMX presence and update flag
|
// test MMX presence and update flag
|
||||||
|
@ -148,43 +146,47 @@ static void DetectCPU(void)
|
||||||
mov dword ptr [ulFeatures], edx
|
mov dword ptr [ulFeatures], edx
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86__)
|
||||||
|
ULONG eax, ebx, ecx, edx;
|
||||||
// test MMX presence and update flag
|
// test MMX presence and update flag
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"pushl %%ebx \n\t"
|
#if (defined __GNU_INLINE_X86_64__)
|
||||||
"xorl %%eax,%%eax \n\t" // request for basic id
|
|
||||||
"cpuid \n\t"
|
"cpuid \n\t"
|
||||||
"movl %%ebx, (%%esi) \n\t"
|
: "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
|
||||||
"movl %%edx, 4(%%esi) \n\t"
|
#else
|
||||||
"movl %%ecx, 8(%%esi) \n\t"
|
"movl %%ebx, %%esi \n\t"
|
||||||
"popl %%ebx \n\t"
|
"cpuid \n\t"
|
||||||
: // no specific outputs.
|
"xchgl %%ebx, %%esi \n\t"
|
||||||
: "S" (strVendor)
|
: "=a" (eax), "=S" (ebx), "=c" (ecx), "=d" (edx)
|
||||||
: "eax", "ecx", "edx", "memory"
|
#endif
|
||||||
|
: "a" (0) // request for basic id
|
||||||
);
|
);
|
||||||
|
memcpy(strVendor + 0, &ebx, 4);
|
||||||
// need to break this into a separate asm block, since I'm clobbering
|
memcpy(strVendor + 4, &edx, 4);
|
||||||
// too many registers. There's something to be said for letting MSVC
|
memcpy(strVendor + 8, &ecx, 4);
|
||||||
// figure out where on the stack your locals are resting, but yeah,
|
|
||||||
// I know, that's x86-specific anyhow...
|
|
||||||
// !!! FIXME: can probably do this right with modern GCC.
|
|
||||||
|
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"pushl %%ebx \n\t"
|
#if (defined __GNU_INLINE_X86_64__)
|
||||||
"movl $1, %%eax \n\t" // request for TFMS feature flags
|
"cpuid \n\t"
|
||||||
"cpuid \n\t"
|
: "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
|
||||||
"mov %%eax, (%%esi) \n\t" // remember type, family, model and stepping
|
#else
|
||||||
"mov %%edx, (%%edi) \n\t"
|
"movl %%ebx, %%esi \n\t"
|
||||||
"popl %%ebx \n\t"
|
"cpuid \n\t"
|
||||||
: // no specific outputs.
|
"xchgl %%ebx, %%esi \n\t"
|
||||||
: "S" (&ulTFMS), "D" (&ulFeatures)
|
: "=a" (eax), "=S" (ebx), "=c" (ecx), "=d" (edx)
|
||||||
: "eax", "ecx", "edx", "memory"
|
#endif
|
||||||
|
: "a" (1) // request for TFMS feature flags
|
||||||
);
|
);
|
||||||
|
ulTFMS = eax;
|
||||||
|
ulFeatures = edx;
|
||||||
|
|
||||||
#else
|
|
||||||
#error Please implement for your platform or define USE_PORTABLE_C.
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (ulTFMS == 0) {
|
||||||
|
CPrintF(TRANSV(" (No CPU detection in this binary.)\n"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
INDEX iType = (ulTFMS>>12)&0x3;
|
INDEX iType = (ulTFMS>>12)&0x3;
|
||||||
INDEX iFamily = (ulTFMS>> 8)&0xF;
|
INDEX iFamily = (ulTFMS>> 8)&0xF;
|
||||||
INDEX iModel = (ulTFMS>> 4)&0xF;
|
INDEX iModel = (ulTFMS>> 4)&0xF;
|
||||||
|
@ -212,11 +214,12 @@ static void DetectCPU(void)
|
||||||
sys_iCPUStepping = iStepping;
|
sys_iCPUStepping = iStepping;
|
||||||
sys_bCPUHasMMX = bMMX!=0;
|
sys_bCPUHasMMX = bMMX!=0;
|
||||||
sys_bCPUHasCMOV = bCMOV!=0;
|
sys_bCPUHasCMOV = bCMOV!=0;
|
||||||
|
#ifdef PLATFORM_PANDORA
|
||||||
|
sys_iCPUMHz = 400; // conservative, ARM -> x86 cpu translation is not 1 to 1.
|
||||||
|
#else
|
||||||
sys_iCPUMHz = INDEX(_pTimer->tm_llCPUSpeedHZ/1E6);
|
sys_iCPUMHz = INDEX(_pTimer->tm_llCPUSpeedHZ/1E6);
|
||||||
|
#endif
|
||||||
if( !bMMX) FatalError( TRANS("MMX support required but not present!"));
|
if( !bMMX) FatalError( TRANS("MMX support required but not present!"));
|
||||||
|
|
||||||
#endif // defined USE_PORTABLE_C
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DetectCPUWrapper(void)
|
static void DetectCPUWrapper(void)
|
||||||
|
@ -398,7 +401,19 @@ static void SetupMemoryManager(void)
|
||||||
sys_iRAMSwap = ms.dwTotalPageFile/MB;
|
sys_iRAMSwap = ms.dwTotalPageFile/MB;
|
||||||
|
|
||||||
#elif (defined PLATFORM_UNIX)
|
#elif (defined PLATFORM_UNIX)
|
||||||
|
#ifdef PLATFORM_PANDORA
|
||||||
|
sys_iRAMPhys = 256; // conservative here, there is 256MB models and 512MB...
|
||||||
|
FILE* esrev = fopen("/etc/powervr-esrev", "r");
|
||||||
|
if (esrev) {
|
||||||
|
int rev = 0;
|
||||||
|
fscanf(esrev,"%d", &rev);
|
||||||
|
if (rev==3 || rev==5)
|
||||||
|
sys_iRAMPhys = 512;
|
||||||
|
fclose(esrev);
|
||||||
|
};
|
||||||
|
#else
|
||||||
sys_iRAMPhys = 1; // !!! FIXME: This is bad. Bad. BAD.
|
sys_iRAMPhys = 1; // !!! FIXME: This is bad. Bad. BAD.
|
||||||
|
#endif
|
||||||
sys_iRAMSwap = 1;
|
sys_iRAMSwap = 1;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
@ -820,7 +835,7 @@ ENGINE_API void SE_UpdateWindowHandle( HWND hwndMain)
|
||||||
_bFullScreen = _pGfx!=NULL && (_pGfx->gl_ulFlags&GLF_FULLSCREEN);
|
_bFullScreen = _pGfx!=NULL && (_pGfx->gl_ulFlags&GLF_FULLSCREEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef PLATFORM_WIN32
|
||||||
static BOOL TouchBlock(UBYTE *pubMemoryBlock, INDEX ctBlockSize)
|
static BOOL TouchBlock(UBYTE *pubMemoryBlock, INDEX ctBlockSize)
|
||||||
{
|
{
|
||||||
#if (defined __MSC_VER)
|
#if (defined __MSC_VER)
|
||||||
|
@ -858,12 +873,13 @@ touchLoop:
|
||||||
// !!! More importantly, will this help if the system is paging to disk
|
// !!! More importantly, will this help if the system is paging to disk
|
||||||
// !!! like mad anyhow? Leaving this as a no-op for most systems seems safe
|
// !!! like mad anyhow? Leaving this as a no-op for most systems seems safe
|
||||||
// !!! to me. --ryan.
|
// !!! to me. --ryan.
|
||||||
|
// DG: put this into #ifdef PLATFORM_WIN32 because otherwise the function is not called anyway
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
#endif // PLATFORM_WIN32
|
||||||
|
|
||||||
// pretouch all memory commited by process
|
// pretouch all memory commited by process
|
||||||
BOOL _bNeedPretouch = FALSE;
|
BOOL _bNeedPretouch = FALSE;
|
||||||
|
|
|
@ -186,7 +186,7 @@ CEntity::~CEntity(void)
|
||||||
}
|
}
|
||||||
// clear entity type
|
// clear entity type
|
||||||
en_RenderType = RT_NONE;
|
en_RenderType = RT_NONE;
|
||||||
en_pecClass->RemReference();
|
if(en_pecClass != NULL) en_pecClass->RemReference();
|
||||||
en_pecClass = NULL;
|
en_pecClass = NULL;
|
||||||
|
|
||||||
en_fSpatialClassificationRadius = -1.0f;
|
en_fSpatialClassificationRadius = -1.0f;
|
||||||
|
@ -481,7 +481,7 @@ void CEntity::GetCollisionBoxParameters(INDEX iBox, FLOATaabbox3D &box, INDEX &i
|
||||||
if(en_RenderType==RT_SKAMODEL || en_RenderType==RT_SKAEDITORMODEL) {
|
if(en_RenderType==RT_SKAMODEL || en_RenderType==RT_SKAEDITORMODEL) {
|
||||||
box.minvect = GetModelInstance()->GetCollisionBoxMin(iBox);
|
box.minvect = GetModelInstance()->GetCollisionBoxMin(iBox);
|
||||||
box.maxvect = GetModelInstance()->GetCollisionBoxMax(iBox);
|
box.maxvect = GetModelInstance()->GetCollisionBoxMax(iBox);
|
||||||
FLOATaabbox3D boxNS = box;
|
//FLOATaabbox3D boxNS = box;
|
||||||
box.StretchByVector(GetModelInstance()->mi_vStretch);
|
box.StretchByVector(GetModelInstance()->mi_vStretch);
|
||||||
iEquality = GetModelInstance()->GetCollisionBoxDimensionEquality(iBox);
|
iEquality = GetModelInstance()->GetCollisionBoxDimensionEquality(iBox);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1833,7 +1833,7 @@ void CEntity::FindSectorsAroundEntity(void)
|
||||||
|
|
||||||
// for each brush in the world
|
// for each brush in the world
|
||||||
FOREACHINDYNAMICARRAY(en_pwoWorld->wo_baBrushes.ba_abrBrushes, CBrush3D, itbr) {
|
FOREACHINDYNAMICARRAY(en_pwoWorld->wo_baBrushes.ba_abrBrushes, CBrush3D, itbr) {
|
||||||
CBrush3D &br=*itbr;
|
//CBrush3D &br=*itbr;
|
||||||
// if the brush entity is not zoning
|
// if the brush entity is not zoning
|
||||||
if (itbr->br_penEntity==NULL || !(itbr->br_penEntity->en_ulFlags&ENF_ZONING)) {
|
if (itbr->br_penEntity==NULL || !(itbr->br_penEntity->en_ulFlags&ENF_ZONING)) {
|
||||||
// skip it
|
// skip it
|
||||||
|
@ -1925,9 +1925,9 @@ void CEntity::FindSectorsAroundEntityNear(void)
|
||||||
// (use more detailed testing for moving brushes)
|
// (use more detailed testing for moving brushes)
|
||||||
(en_RenderType!=RT_BRUSH||
|
(en_RenderType!=RT_BRUSH||
|
||||||
// oriented box touches box of sector
|
// oriented box touches box of sector
|
||||||
(oboxEntity.HasContactWith(FLOATobbox3D(pbsc->bsc_boxBoundingBox)))&&
|
((oboxEntity.HasContactWith(FLOATobbox3D(pbsc->bsc_boxBoundingBox)))&&
|
||||||
// oriented box is in bsp
|
// oriented box is in bsp
|
||||||
(pbsc->bsc_bspBSPTree.TestBox(oboxdEntity)>=0));
|
(pbsc->bsc_bspBSPTree.TestBox(oboxdEntity)>=0)));
|
||||||
// if it is not
|
// if it is not
|
||||||
if (!bIn) {
|
if (!bIn) {
|
||||||
// if it has link
|
// if it has link
|
||||||
|
@ -2036,10 +2036,7 @@ static CStaticStackArray<CSentEvent> _aseSentEvents; // delayed events
|
||||||
/* Send an event to this entity. */
|
/* Send an event to this entity. */
|
||||||
void CEntity::SendEvent(const CEntityEvent &ee)
|
void CEntity::SendEvent(const CEntityEvent &ee)
|
||||||
{
|
{
|
||||||
if (this==NULL) {
|
ASSERT(this!=NULL);
|
||||||
ASSERT(FALSE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
CSentEvent &se = _aseSentEvents.Push();
|
CSentEvent &se = _aseSentEvents.Push();
|
||||||
se.se_penEntity = this;
|
se.se_penEntity = this;
|
||||||
se.se_peeEvent = ((CEntityEvent&)ee).MakeCopy(); // discard const qualifier
|
se.se_peeEvent = ((CEntityEvent&)ee).MakeCopy(); // discard const qualifier
|
||||||
|
@ -3104,11 +3101,11 @@ void CEntity::InflictRangeDamage(CEntity *penInflictor, enum DamageType dmtType,
|
||||||
FLOAT3D vHitPos;
|
FLOAT3D vHitPos;
|
||||||
FLOAT fMinD;
|
FLOAT fMinD;
|
||||||
if (
|
if (
|
||||||
(en.en_RenderType==RT_MODEL || en.en_RenderType==RT_EDITORMODEL ||
|
((en.en_RenderType==RT_MODEL || en.en_RenderType==RT_EDITORMODEL ||
|
||||||
en.en_RenderType==RT_SKAMODEL || en.en_RenderType==RT_SKAEDITORMODEL )&&
|
en.en_RenderType==RT_SKAMODEL || en.en_RenderType==RT_SKAEDITORMODEL )&&
|
||||||
CheckModelRangeDamage(en, vCenter, fMinD, vHitPos) ||
|
CheckModelRangeDamage(en, vCenter, fMinD, vHitPos)) ||
|
||||||
(en.en_RenderType==RT_BRUSH)&&
|
((en.en_RenderType==RT_BRUSH)&&
|
||||||
CheckBrushRangeDamage(en, vCenter, fMinD, vHitPos)) {
|
CheckBrushRangeDamage(en, vCenter, fMinD, vHitPos))) {
|
||||||
|
|
||||||
// find damage ammount
|
// find damage ammount
|
||||||
FLOAT fAmmount = IntensityAtDistance(fDamageAmmount, fHotSpotRange, fFallOffRange, fMinD);
|
FLOAT fAmmount = IntensityAtDistance(fDamageAmmount, fHotSpotRange, fFallOffRange, fMinD);
|
||||||
|
@ -3146,7 +3143,7 @@ void CEntity::InflictBoxDamage(CEntity *penInflictor, enum DamageType dmtType,
|
||||||
if (en.en_pciCollisionInfo==NULL) {
|
if (en.en_pciCollisionInfo==NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
CCollisionInfo *pci = en.en_pciCollisionInfo;
|
//CCollisionInfo *pci = en.en_pciCollisionInfo;
|
||||||
// if entity is not allowed to execute now
|
// if entity is not allowed to execute now
|
||||||
if (!en.IsAllowedForPrediction()) {
|
if (!en.IsAllowedForPrediction()) {
|
||||||
// do nothing
|
// do nothing
|
||||||
|
|
|
@ -670,42 +670,41 @@ BOOL ENGINE_API IsDerivedFromClass(CEntity *pen, const char *pstrClassName);
|
||||||
|
|
||||||
// all standard smart pointer functions are here as inlines
|
// all standard smart pointer functions are here as inlines
|
||||||
inline CEntityPointer::CEntityPointer(void) : ep_pen(NULL) {};
|
inline CEntityPointer::CEntityPointer(void) : ep_pen(NULL) {};
|
||||||
inline CEntityPointer::~CEntityPointer(void) { ep_pen->RemReference(); };
|
inline CEntityPointer::~CEntityPointer(void) { if(ep_pen != NULL) ep_pen->RemReference(); };
|
||||||
inline CEntityPointer::CEntityPointer(const CEntityPointer &penOther) : ep_pen(penOther.ep_pen) {
|
inline CEntityPointer::CEntityPointer(const CEntityPointer &penOther) : ep_pen(penOther.ep_pen) {
|
||||||
ep_pen->AddReference(); };
|
if(ep_pen != NULL) ep_pen->AddReference(); };
|
||||||
inline CEntityPointer::CEntityPointer(CEntity *pen) : ep_pen(pen) {
|
inline CEntityPointer::CEntityPointer(CEntity *pen) : ep_pen(pen) {
|
||||||
ep_pen->AddReference(); };
|
if(ep_pen != NULL) ep_pen->AddReference(); };
|
||||||
inline const CEntityPointer &CEntityPointer::operator=(CEntity *pen) {
|
inline const CEntityPointer &CEntityPointer::operator=(CEntity *pen) {
|
||||||
pen->AddReference(); // must first add, then remove!
|
if(pen != NULL) pen->AddReference(); // must first add, then remove!
|
||||||
ep_pen->RemReference();
|
if(ep_pen != NULL) ep_pen->RemReference();
|
||||||
ep_pen = pen;
|
ep_pen = pen;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
inline const CEntityPointer &CEntityPointer::operator=(const CEntityPointer &penOther) {
|
inline const CEntityPointer &CEntityPointer::operator=(const CEntityPointer &penOther) {
|
||||||
penOther.ep_pen->AddReference(); // must first add, then remove!
|
if(penOther.ep_pen != NULL) penOther.ep_pen->AddReference(); // must first add, then remove!
|
||||||
ep_pen->RemReference();
|
if(ep_pen != NULL) ep_pen->RemReference();
|
||||||
ep_pen = penOther.ep_pen;
|
ep_pen = penOther.ep_pen;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
inline CEntity* CEntityPointer::operator->(void) const { return ep_pen; }
|
inline CEntity* CEntityPointer::operator->(void) const { return ep_pen; }
|
||||||
|
inline CEntity* CEntityPointer::get(void) const { return ep_pen; }
|
||||||
inline CEntityPointer::operator CEntity*(void) const { return ep_pen; }
|
inline CEntityPointer::operator CEntity*(void) const { return ep_pen; }
|
||||||
inline CEntity& CEntityPointer::operator*(void) const { return *ep_pen; }
|
inline CEntity& CEntityPointer::operator*(void) const { return *ep_pen; }
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
// Reference counting functions
|
// Reference counting functions
|
||||||
inline void CEntity::AddReference(void) {
|
inline void CEntity::AddReference(void) {
|
||||||
if (this!=NULL) {
|
ASSERT(this!=NULL);
|
||||||
ASSERT(en_ctReferences>=0);
|
ASSERT(en_ctReferences>=0);
|
||||||
en_ctReferences++;
|
en_ctReferences++;
|
||||||
}
|
|
||||||
};
|
};
|
||||||
inline void CEntity::RemReference(void) {
|
inline void CEntity::RemReference(void) {
|
||||||
if (this!=NULL) {
|
ASSERT(this!=NULL);
|
||||||
ASSERT(en_ctReferences>0);
|
ASSERT(en_ctReferences>0);
|
||||||
en_ctReferences--;
|
en_ctReferences--;
|
||||||
if(en_ctReferences==0) {
|
if(en_ctReferences==0) {
|
||||||
delete this;
|
delete this;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -64,14 +64,12 @@ CEntityClass::~CEntityClass(void)
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
// Reference counting functions
|
// Reference counting functions
|
||||||
void CEntityClass::AddReference(void) {
|
void CEntityClass::AddReference(void) {
|
||||||
if (this!=NULL) {
|
ASSERT(this!=NULL);
|
||||||
MarkUsed();
|
MarkUsed();
|
||||||
}
|
|
||||||
};
|
};
|
||||||
void CEntityClass::RemReference(void) {
|
void CEntityClass::RemReference(void) {
|
||||||
if (this!=NULL) {
|
ASSERT(this!=NULL);
|
||||||
_pEntityClassStock->Release(this);
|
_pEntityClassStock->Release(this);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -452,7 +452,7 @@ void CWorld::CopyEntities(CWorld &woOther, CDynamicContainer<CEntity> &cenToCopy
|
||||||
|
|
||||||
// for each of the created entities
|
// for each of the created entities
|
||||||
{FOREACHINSTATICARRAY(_aprRemaps, CPointerRemapping, itpr) {
|
{FOREACHINSTATICARRAY(_aprRemaps, CPointerRemapping, itpr) {
|
||||||
CEntity *penOriginal = itpr->pr_penOriginal;
|
//CEntity *penOriginal = itpr->pr_penOriginal;
|
||||||
CEntity *penCopy = itpr->pr_penCopy;
|
CEntity *penCopy = itpr->pr_penCopy;
|
||||||
if (_bReinitEntitiesWhileCopying) {
|
if (_bReinitEntitiesWhileCopying) {
|
||||||
// init the new copy
|
// init the new copy
|
||||||
|
@ -469,7 +469,7 @@ void CWorld::CopyEntities(CWorld &woOther, CDynamicContainer<CEntity> &cenToCopy
|
||||||
|
|
||||||
// for each of the created entities
|
// for each of the created entities
|
||||||
{FOREACHINSTATICARRAY(_aprRemaps, CPointerRemapping, itpr) {
|
{FOREACHINSTATICARRAY(_aprRemaps, CPointerRemapping, itpr) {
|
||||||
CEntity *penOriginal = itpr->pr_penOriginal;
|
//CEntity *penOriginal = itpr->pr_penOriginal;
|
||||||
CEntity *penCopy = itpr->pr_penCopy;
|
CEntity *penCopy = itpr->pr_penCopy;
|
||||||
|
|
||||||
// if this is a brush
|
// if this is a brush
|
||||||
|
@ -718,7 +718,7 @@ void CWorld::CopyEntitiesToPredictors(CDynamicContainer<CEntity> &cenToCopy)
|
||||||
|
|
||||||
// for each of the created entities
|
// for each of the created entities
|
||||||
{FOREACHINSTATICARRAY(_aprRemaps, CPointerRemapping, itpr) {
|
{FOREACHINSTATICARRAY(_aprRemaps, CPointerRemapping, itpr) {
|
||||||
CEntity *penOriginal = itpr->pr_penOriginal;
|
//CEntity *penOriginal = itpr->pr_penOriginal;
|
||||||
CEntity *penCopy = itpr->pr_penCopy;
|
CEntity *penCopy = itpr->pr_penCopy;
|
||||||
|
|
||||||
// if this is a brush
|
// if this is a brush
|
||||||
|
|
|
@ -35,6 +35,7 @@ public:
|
||||||
inline const CEntityPointer &operator=(CEntity *pen);
|
inline const CEntityPointer &operator=(CEntity *pen);
|
||||||
inline const CEntityPointer &operator=(const CEntityPointer &penOther);
|
inline const CEntityPointer &operator=(const CEntityPointer &penOther);
|
||||||
inline CEntity* operator->(void) const;
|
inline CEntity* operator->(void) const;
|
||||||
|
inline CEntity* get(void) const;
|
||||||
inline operator CEntity*(void) const;
|
inline operator CEntity*(void) const;
|
||||||
inline CEntity& operator*(void) const;
|
inline CEntity& operator*(void) const;
|
||||||
};
|
};
|
||||||
|
|
|
@ -96,7 +96,7 @@ void CEntity::WriteEntityPointer_t(CTStream *ostrm, CEntityPointer pen)
|
||||||
void CEntity::ReadProperties_t(CTStream &istrm) // throw char *
|
void CEntity::ReadProperties_t(CTStream &istrm) // throw char *
|
||||||
{
|
{
|
||||||
istrm.ExpectID_t("PRPS"); // 'properties'
|
istrm.ExpectID_t("PRPS"); // 'properties'
|
||||||
CDLLEntityClass *pdecDLLClass = en_pecClass->ec_pdecDLLClass;
|
//CDLLEntityClass *pdecDLLClass = en_pecClass->ec_pdecDLLClass;
|
||||||
INDEX ctProperties;
|
INDEX ctProperties;
|
||||||
// read number of properties (note that this doesn't have to be same as number
|
// read number of properties (note that this doesn't have to be same as number
|
||||||
// of properties in the class (class might have changed))
|
// of properties in the class (class might have changed))
|
||||||
|
@ -104,7 +104,7 @@ void CEntity::ReadProperties_t(CTStream &istrm) // throw char *
|
||||||
|
|
||||||
// for all saved properties
|
// for all saved properties
|
||||||
for(INDEX iProperty=0; iProperty<ctProperties; iProperty++) {
|
for(INDEX iProperty=0; iProperty<ctProperties; iProperty++) {
|
||||||
pdecDLLClass->dec_ctProperties;
|
//pdecDLLClass->dec_ctProperties;
|
||||||
// read packed identifier
|
// read packed identifier
|
||||||
ULONG ulIDAndType;
|
ULONG ulIDAndType;
|
||||||
istrm>>ulIDAndType;
|
istrm>>ulIDAndType;
|
||||||
|
|
|
@ -34,6 +34,7 @@ extern const D3DDEVTYPE d3dDevType;
|
||||||
// list of all modes avaliable through CDS
|
// list of all modes avaliable through CDS
|
||||||
static CListHead _lhCDSModes;
|
static CListHead _lhCDSModes;
|
||||||
|
|
||||||
|
#ifdef PLATFORM_WIN32 // DG: all this code is (currently?) only used for windows.
|
||||||
class CResolution {
|
class CResolution {
|
||||||
public:
|
public:
|
||||||
PIX re_pixSizeI;
|
PIX re_pixSizeI;
|
||||||
|
@ -74,8 +75,6 @@ static CResolution _areResolutions[] =
|
||||||
static const INDEX MAX_RESOLUTIONS = sizeof(_areResolutions)/sizeof(_areResolutions[0]);
|
static const INDEX MAX_RESOLUTIONS = sizeof(_areResolutions)/sizeof(_areResolutions[0]);
|
||||||
|
|
||||||
|
|
||||||
#ifdef PLATFORM_WIN32
|
|
||||||
|
|
||||||
// initialize CDS support (enumerate modes at startup)
|
// initialize CDS support (enumerate modes at startup)
|
||||||
void CGfxLibrary::InitAPIs(void)
|
void CGfxLibrary::InitAPIs(void)
|
||||||
{
|
{
|
||||||
|
@ -240,7 +239,7 @@ void CGfxLibrary::InitAPIs(void)
|
||||||
|
|
||||||
// fill OpenGL adapter info
|
// fill OpenGL adapter info
|
||||||
CDisplayAdapter *pda;
|
CDisplayAdapter *pda;
|
||||||
INDEX iResolution;
|
//INDEX iResolution;
|
||||||
|
|
||||||
gl_gaAPI[GAT_OGL].ga_ctAdapters = 1;
|
gl_gaAPI[GAT_OGL].ga_ctAdapters = 1;
|
||||||
gl_gaAPI[GAT_OGL].ga_iCurrentAdapter = 0;
|
gl_gaAPI[GAT_OGL].ga_iCurrentAdapter = 0;
|
||||||
|
|
|
@ -33,7 +33,7 @@ static PIX _pixSizeI;
|
||||||
static PIX _pixSizeJ;
|
static PIX _pixSizeJ;
|
||||||
static CTimerValue _tv;
|
static CTimerValue _tv;
|
||||||
static BOOL _bBlend = FALSE;
|
static BOOL _bBlend = FALSE;
|
||||||
static BOOL _bVisible = FALSE;
|
//static BOOL _bVisible = FALSE;
|
||||||
static BOOL _bTexture = FALSE;
|
static BOOL _bTexture = FALSE;
|
||||||
static BOOL _bDepth = FALSE;
|
static BOOL _bDepth = FALSE;
|
||||||
static BOOL _bMultiTexture = FALSE;
|
static BOOL _bMultiTexture = FALSE;
|
||||||
|
|
|
@ -247,30 +247,7 @@ COLOR MulColors( COLOR col1, COLOR col2)
|
||||||
if( col2==0xFFFFFFFF) return col1;
|
if( col2==0xFFFFFFFF) return col1;
|
||||||
if( col1==0 || col2==0) return 0;
|
if( col1==0 || col2==0) return 0;
|
||||||
|
|
||||||
#if (defined USE_PORTABLE_C)
|
#if (defined __MSVC_INLINE__)
|
||||||
// !!! FIXME: This...is not fast.
|
|
||||||
union
|
|
||||||
{
|
|
||||||
COLOR col;
|
|
||||||
UBYTE bytes[4];
|
|
||||||
} conv1;
|
|
||||||
|
|
||||||
union
|
|
||||||
{
|
|
||||||
COLOR col;
|
|
||||||
UBYTE bytes[4];
|
|
||||||
} conv2;
|
|
||||||
|
|
||||||
conv1.col = col1;
|
|
||||||
conv2.col = col2;
|
|
||||||
conv1.bytes[0] = (UBYTE) ((((DWORD) conv1.bytes[0]) * ((DWORD) conv2.bytes[0])) / 255);
|
|
||||||
conv1.bytes[1] = (UBYTE) ((((DWORD) conv1.bytes[1]) * ((DWORD) conv2.bytes[1])) / 255);
|
|
||||||
conv1.bytes[2] = (UBYTE) ((((DWORD) conv1.bytes[2]) * ((DWORD) conv2.bytes[2])) / 255);
|
|
||||||
conv1.bytes[3] = (UBYTE) ((((DWORD) conv1.bytes[3]) * ((DWORD) conv2.bytes[3])) / 255);
|
|
||||||
|
|
||||||
return(conv1.col);
|
|
||||||
|
|
||||||
#elif (defined __MSVC_INLINE__)
|
|
||||||
COLOR colRet;
|
COLOR colRet;
|
||||||
__asm {
|
__asm {
|
||||||
xor ebx,ebx
|
xor ebx,ebx
|
||||||
|
@ -347,7 +324,7 @@ COLOR MulColors( COLOR col1, COLOR col2)
|
||||||
}
|
}
|
||||||
return colRet;
|
return colRet;
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
COLOR colRet;
|
COLOR colRet;
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"pushl %%ebx \n\t"
|
"pushl %%ebx \n\t"
|
||||||
|
@ -433,20 +410,6 @@ COLOR MulColors( COLOR col1, COLOR col2)
|
||||||
|
|
||||||
return colRet;
|
return colRet;
|
||||||
#else
|
#else
|
||||||
#error please fill in inline assembly for your platform.
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// fast color additon function - RES = clamp (1ST + 2ND)
|
|
||||||
COLOR AddColors( COLOR col1, COLOR col2)
|
|
||||||
{
|
|
||||||
if( col1==0) return col2;
|
|
||||||
if( col2==0) return col1;
|
|
||||||
if( col1==0xFFFFFFFF || col2==0xFFFFFFFF) return 0xFFFFFFFF;
|
|
||||||
COLOR colRet;
|
|
||||||
|
|
||||||
#if (defined USE_PORTABLE_C)
|
|
||||||
// !!! FIXME: This...is not fast.
|
// !!! FIXME: This...is not fast.
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
|
@ -459,19 +422,28 @@ COLOR AddColors( COLOR col1, COLOR col2)
|
||||||
COLOR col;
|
COLOR col;
|
||||||
UBYTE bytes[4];
|
UBYTE bytes[4];
|
||||||
} conv2;
|
} conv2;
|
||||||
#define MINVAL(a, b) ((a)>(b))?(b):(a)
|
|
||||||
|
|
||||||
conv1.col = col1;
|
conv1.col = col1;
|
||||||
conv2.col = col2;
|
conv2.col = col2;
|
||||||
conv1.bytes[0] = (UBYTE) MINVAL((((WORD) conv1.bytes[0]) + ((WORD) conv2.bytes[0])) , 255);
|
conv1.bytes[0] = (UBYTE) ((((DWORD) conv1.bytes[0]) * ((DWORD) conv2.bytes[0])) / 255);
|
||||||
conv1.bytes[1] = (UBYTE) MINVAL((((WORD) conv1.bytes[1]) + ((WORD) conv2.bytes[1])) , 255);
|
conv1.bytes[1] = (UBYTE) ((((DWORD) conv1.bytes[1]) * ((DWORD) conv2.bytes[1])) / 255);
|
||||||
conv1.bytes[2] = (UBYTE) MINVAL((((WORD) conv1.bytes[2]) + ((WORD) conv2.bytes[2])) , 255);
|
conv1.bytes[2] = (UBYTE) ((((DWORD) conv1.bytes[2]) * ((DWORD) conv2.bytes[2])) / 255);
|
||||||
conv1.bytes[3] = (UBYTE) MINVAL((((WORD) conv1.bytes[3]) + ((WORD) conv2.bytes[3])) , 255);
|
conv1.bytes[3] = (UBYTE) ((((DWORD) conv1.bytes[3]) * ((DWORD) conv2.bytes[3])) / 255);
|
||||||
#undef MINVAL
|
|
||||||
|
|
||||||
colRet = conv1.col;
|
return(conv1.col);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#elif (defined __MSVC_INLINE__)
|
|
||||||
|
// fast color additon function - RES = clamp (1ST + 2ND)
|
||||||
|
COLOR AddColors( COLOR col1, COLOR col2)
|
||||||
|
{
|
||||||
|
if( col1==0) return col2;
|
||||||
|
if( col2==0) return col1;
|
||||||
|
if( col1==0xFFFFFFFF || col2==0xFFFFFFFF) return 0xFFFFFFFF;
|
||||||
|
COLOR colRet;
|
||||||
|
|
||||||
|
#if (defined __MSVC_INLINE__)
|
||||||
__asm {
|
__asm {
|
||||||
xor ebx,ebx
|
xor ebx,ebx
|
||||||
mov esi,255
|
mov esi,255
|
||||||
|
@ -535,7 +507,7 @@ COLOR AddColors( COLOR col1, COLOR col2)
|
||||||
mov D [colRet],ebx
|
mov D [colRet],ebx
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
ULONG tmp;
|
ULONG tmp;
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
// if xbx is "r", gcc runs out of regs in -fPIC + -fno-omit-fp :(
|
// if xbx is "r", gcc runs out of regs in -fPIC + -fno-omit-fp :(
|
||||||
|
@ -608,7 +580,29 @@ COLOR AddColors( COLOR col1, COLOR col2)
|
||||||
);
|
);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error please fill in inline assembly for your platform.
|
// !!! FIXME: This...is not fast.
|
||||||
|
union
|
||||||
|
{
|
||||||
|
COLOR col;
|
||||||
|
UBYTE bytes[4];
|
||||||
|
} conv1;
|
||||||
|
|
||||||
|
union
|
||||||
|
{
|
||||||
|
COLOR col;
|
||||||
|
UBYTE bytes[4];
|
||||||
|
} conv2;
|
||||||
|
#define MINVAL(a, b) ((a)>(b))?(b):(a)
|
||||||
|
|
||||||
|
conv1.col = col1;
|
||||||
|
conv2.col = col2;
|
||||||
|
conv1.bytes[0] = (UBYTE) MINVAL((((WORD) conv1.bytes[0]) + ((WORD) conv2.bytes[0])) , 255);
|
||||||
|
conv1.bytes[1] = (UBYTE) MINVAL((((WORD) conv1.bytes[1]) + ((WORD) conv2.bytes[1])) , 255);
|
||||||
|
conv1.bytes[2] = (UBYTE) MINVAL((((WORD) conv1.bytes[2]) + ((WORD) conv2.bytes[2])) , 255);
|
||||||
|
conv1.bytes[3] = (UBYTE) MINVAL((((WORD) conv1.bytes[3]) + ((WORD) conv2.bytes[3])) , 255);
|
||||||
|
#undef MINVAL
|
||||||
|
|
||||||
|
colRet = conv1.col;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return colRet;
|
return colRet;
|
||||||
|
@ -619,14 +613,7 @@ COLOR AddColors( COLOR col1, COLOR col2)
|
||||||
// multiple conversion from OpenGL color to DirectX color
|
// multiple conversion from OpenGL color to DirectX color
|
||||||
extern void abgr2argb( ULONG *pulSrc, ULONG *pulDst, INDEX ct)
|
extern void abgr2argb( ULONG *pulSrc, ULONG *pulDst, INDEX ct)
|
||||||
{
|
{
|
||||||
#if (defined USE_PORTABLE_C)
|
#if (defined __MSVC_INLINE__)
|
||||||
//#error write me.
|
|
||||||
for (int i=0; i<ct; i++) {
|
|
||||||
ULONG tmp = pulSrc[i];
|
|
||||||
pulDst[i] = (tmp&0xff00ff00) | ((tmp&0x00ff0000)>>16) | ((tmp&0x000000ff)<<16);
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif (defined __MSVC_INLINE__)
|
|
||||||
__asm {
|
__asm {
|
||||||
mov esi,dword ptr [pulSrc]
|
mov esi,dword ptr [pulSrc]
|
||||||
mov edi,dword ptr [pulDst]
|
mov edi,dword ptr [pulDst]
|
||||||
|
@ -678,12 +665,12 @@ colSkip2:
|
||||||
mov dword ptr [edi],eax
|
mov dword ptr [edi],eax
|
||||||
colSkip1:
|
colSkip1:
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
|
||||||
STUBBED("convert to inline asm.");
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error please fill in inline assembly for your platform.
|
for (int i=0; i<ct; i++) {
|
||||||
|
ULONG tmp = pulSrc[i];
|
||||||
|
pulDst[i] = (tmp&0xff00ff00) | ((tmp&0x00ff0000)>>16) | ((tmp&0x000000ff)<<16);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -204,19 +204,7 @@ ENGINE_API extern COLOR AddColors( COLOR col1, COLOR col2); // fast color addito
|
||||||
__forceinline ULONG ByteSwap( ULONG ul)
|
__forceinline ULONG ByteSwap( ULONG ul)
|
||||||
{
|
{
|
||||||
/* rcg10052001 Platform-wrappers. */
|
/* rcg10052001 Platform-wrappers. */
|
||||||
#if (defined USE_PORTABLE_C)
|
#if (defined __MSVC_INLINE__)
|
||||||
ul = ( ((ul << 24) ) |
|
|
||||||
((ul << 8) & 0x00FF0000) |
|
|
||||||
((ul >> 8) & 0x0000FF00) |
|
|
||||||
((ul >> 24) ) );
|
|
||||||
|
|
||||||
#if (defined PLATFORM_BIGENDIAN)
|
|
||||||
BYTESWAP(ul); // !!! FIXME: May not be right!
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return(ul);
|
|
||||||
|
|
||||||
#elif (defined __MSVC_INLINE__)
|
|
||||||
ULONG ulRet;
|
ULONG ulRet;
|
||||||
__asm {
|
__asm {
|
||||||
mov eax,dword ptr [ul]
|
mov eax,dword ptr [ul]
|
||||||
|
@ -225,7 +213,7 @@ __forceinline ULONG ByteSwap( ULONG ul)
|
||||||
}
|
}
|
||||||
return ulRet;
|
return ulRet;
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"bswapl %%eax \n\t"
|
"bswapl %%eax \n\t"
|
||||||
: "=a" (ul)
|
: "=a" (ul)
|
||||||
|
@ -234,16 +222,22 @@ __forceinline ULONG ByteSwap( ULONG ul)
|
||||||
return(ul);
|
return(ul);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error please define for your platform.
|
ul = ( ((ul << 24) ) |
|
||||||
|
((ul << 8) & 0x00FF0000) |
|
||||||
|
((ul >> 8) & 0x0000FF00) |
|
||||||
|
((ul >> 24) ) );
|
||||||
|
|
||||||
|
#if (defined PLATFORM_BIGENDIAN)
|
||||||
|
BYTESWAP(ul); // !!! FIXME: May not be right!
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return(ul);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
__forceinline ULONG rgba2argb( ULONG ul)
|
__forceinline ULONG rgba2argb( ULONG ul)
|
||||||
{
|
{
|
||||||
#if (defined USE_PORTABLE_C)
|
#if (defined __MSVC_INLINE__)
|
||||||
return( (ul << 24) | (ul >> 8) );
|
|
||||||
|
|
||||||
#elif (defined __MSVC_INLINE__)
|
|
||||||
ULONG ulRet;
|
ULONG ulRet;
|
||||||
__asm {
|
__asm {
|
||||||
mov eax,dword ptr [ul]
|
mov eax,dword ptr [ul]
|
||||||
|
@ -252,7 +246,7 @@ __forceinline ULONG rgba2argb( ULONG ul)
|
||||||
}
|
}
|
||||||
return ulRet;
|
return ulRet;
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
ULONG ulRet;
|
ULONG ulRet;
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"rorl $8, %%eax \n\t"
|
"rorl $8, %%eax \n\t"
|
||||||
|
@ -263,21 +257,14 @@ __forceinline ULONG rgba2argb( ULONG ul)
|
||||||
return ulRet;
|
return ulRet;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error please define for your platform.
|
return (ul << 24) | (ul >> 8);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
__forceinline ULONG abgr2argb( COLOR col)
|
__forceinline ULONG abgr2argb( COLOR col)
|
||||||
{
|
{
|
||||||
#if (defined USE_PORTABLE_C)
|
#if (defined __MSVC_INLINE__)
|
||||||
// this could be simplified, this is just a safe conversion from asm code
|
|
||||||
col = ( ((col << 24) ) |
|
|
||||||
((col << 8) & 0x00FF0000) |
|
|
||||||
((col >> 8) & 0x0000FF00) |
|
|
||||||
((col >> 24) ) );
|
|
||||||
return( (col << 24) | (col >> 8) );
|
|
||||||
|
|
||||||
#elif (defined __MSVC_INLINE__)
|
|
||||||
ULONG ulRet;
|
ULONG ulRet;
|
||||||
__asm {
|
__asm {
|
||||||
mov eax,dword ptr [col]
|
mov eax,dword ptr [col]
|
||||||
|
@ -287,7 +274,7 @@ __forceinline ULONG abgr2argb( COLOR col)
|
||||||
}
|
}
|
||||||
return ulRet;
|
return ulRet;
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
ULONG ulRet;
|
ULONG ulRet;
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"bswapl %%eax \n\t"
|
"bswapl %%eax \n\t"
|
||||||
|
@ -299,7 +286,13 @@ __forceinline ULONG abgr2argb( COLOR col)
|
||||||
return ulRet;
|
return ulRet;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error please define for your platform.
|
// this could be simplified, this is just a safe conversion from asm code
|
||||||
|
col = ( ((col << 24) ) |
|
||||||
|
((col << 8) & 0x00FF0000) |
|
||||||
|
((col >> 8) & 0x0000FF00) |
|
||||||
|
((col >> 24) ) );
|
||||||
|
return( (col << 24) | (col >> 8) );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,10 +304,7 @@ extern void abgr2argb( ULONG *pulSrc, ULONG *pulDst, INDEX ct);
|
||||||
// fast memory copy of ULONGs
|
// fast memory copy of ULONGs
|
||||||
inline void CopyLongs( ULONG *pulSrc, ULONG *pulDst, INDEX ctLongs)
|
inline void CopyLongs( ULONG *pulSrc, ULONG *pulDst, INDEX ctLongs)
|
||||||
{
|
{
|
||||||
#if ((defined USE_PORTABLE_C) || (PLATFORM_MACOSX))
|
#if (defined __MSVC_INLINE__)
|
||||||
memcpy( pulDst, pulSrc, ctLongs*4);
|
|
||||||
|
|
||||||
#elif (defined __MSVC_INLINE__)
|
|
||||||
__asm {
|
__asm {
|
||||||
cld
|
cld
|
||||||
mov esi,dword ptr [pulSrc]
|
mov esi,dword ptr [pulSrc]
|
||||||
|
@ -322,23 +312,8 @@ inline void CopyLongs( ULONG *pulSrc, ULONG *pulDst, INDEX ctLongs)
|
||||||
mov ecx,dword ptr [ctLongs]
|
mov ecx,dword ptr [ctLongs]
|
||||||
rep movsd
|
rep movsd
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
|
||||||
// I haven't benchmarked it, but in many cases, memcpy() becomes an
|
|
||||||
// inline (asm?) macro on GNU platforms, so this might not be a
|
|
||||||
// speed gain at all over the USE_PORTABLE_C version.
|
|
||||||
// You Have Been Warned. --ryan.
|
|
||||||
__asm__ __volatile__ (
|
|
||||||
"cld \n\t"
|
|
||||||
"rep \n\t"
|
|
||||||
"movsd \n\t"
|
|
||||||
: "=S" (pulSrc), "=D" (pulDst), "=c" (ctLongs)
|
|
||||||
: "S" (pulSrc), "D" (pulDst), "c" (ctLongs)
|
|
||||||
: "cc", "memory"
|
|
||||||
);
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
# error Please fill this in for your platform.
|
memcpy( pulDst, pulSrc, ctLongs*4);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -346,11 +321,7 @@ inline void CopyLongs( ULONG *pulSrc, ULONG *pulDst, INDEX ctLongs)
|
||||||
// fast memory set of ULONGs
|
// fast memory set of ULONGs
|
||||||
inline void StoreLongs( ULONG ulVal, ULONG *pulDst, INDEX ctLongs)
|
inline void StoreLongs( ULONG ulVal, ULONG *pulDst, INDEX ctLongs)
|
||||||
{
|
{
|
||||||
#if (defined USE_PORTABLE_C)
|
#if (defined __MSVC_INLINE__)
|
||||||
for( INDEX i=0; i<ctLongs; i++)
|
|
||||||
pulDst[i] = ulVal;
|
|
||||||
|
|
||||||
#elif (defined __MSVC_INLINE__)
|
|
||||||
__asm {
|
__asm {
|
||||||
cld
|
cld
|
||||||
mov eax,dword ptr [ulVal]
|
mov eax,dword ptr [ulVal]
|
||||||
|
@ -359,7 +330,7 @@ inline void StoreLongs( ULONG ulVal, ULONG *pulDst, INDEX ctLongs)
|
||||||
rep stosd
|
rep stosd
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"cld \n\t"
|
"cld \n\t"
|
||||||
"rep \n\t"
|
"rep \n\t"
|
||||||
|
@ -370,7 +341,9 @@ inline void StoreLongs( ULONG ulVal, ULONG *pulDst, INDEX ctLongs)
|
||||||
);
|
);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
# error Please fill this in for your platform.
|
for( INDEX i=0; i<ctLongs; i++)
|
||||||
|
pulDst[i] = ulVal;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -799,7 +799,7 @@ void CDrawPort::Fill( PIX pixI, PIX pixJ, PIX pixWidth, PIX pixHeight,
|
||||||
// thru OpenGL
|
// thru OpenGL
|
||||||
gfxResetArrays();
|
gfxResetArrays();
|
||||||
GFXVertex *pvtx = _avtxCommon.Push(4);
|
GFXVertex *pvtx = _avtxCommon.Push(4);
|
||||||
GFXTexCoord *ptex = _atexCommon.Push(4);
|
/* GFXTexCoord *ptex = */ _atexCommon.Push(4);
|
||||||
GFXColor *pcol = _acolCommon.Push(4);
|
GFXColor *pcol = _acolCommon.Push(4);
|
||||||
const GFXColor glcolUL(colUL); const GFXColor glcolUR(colUR);
|
const GFXColor glcolUL(colUL); const GFXColor glcolUR(colUR);
|
||||||
const GFXColor glcolDL(colDL); const GFXColor glcolDR(colDR);
|
const GFXColor glcolDL(colDL); const GFXColor glcolDR(colDR);
|
||||||
|
@ -1617,7 +1617,7 @@ void CDrawPort::AddTriangle( const FLOAT fI0, const FLOAT fJ0,
|
||||||
const GFXColor glCol( AdjustColor( col, _slTexHueShift, _slTexSaturation));
|
const GFXColor glCol( AdjustColor( col, _slTexHueShift, _slTexSaturation));
|
||||||
const INDEX iStart = _avtxCommon.Count();
|
const INDEX iStart = _avtxCommon.Count();
|
||||||
GFXVertex *pvtx = _avtxCommon.Push(3);
|
GFXVertex *pvtx = _avtxCommon.Push(3);
|
||||||
GFXTexCoord *ptex = _atexCommon.Push(3);
|
/* GFXTexCoord *ptex = */ _atexCommon.Push(3);
|
||||||
GFXColor *pcol = _acolCommon.Push(3);
|
GFXColor *pcol = _acolCommon.Push(3);
|
||||||
INDEX *pelm = _aiCommonElements.Push(3);
|
INDEX *pelm = _aiCommonElements.Push(3);
|
||||||
pvtx[0].x = fI0; pvtx[0].y = fJ0; pvtx[0].z = 0;
|
pvtx[0].x = fI0; pvtx[0].y = fJ0; pvtx[0].z = 0;
|
||||||
|
@ -1699,7 +1699,7 @@ void CDrawPort::BlendScreen(void)
|
||||||
// set arrays
|
// set arrays
|
||||||
gfxResetArrays();
|
gfxResetArrays();
|
||||||
GFXVertex *pvtx = _avtxCommon.Push(4);
|
GFXVertex *pvtx = _avtxCommon.Push(4);
|
||||||
GFXTexCoord *ptex = _atexCommon.Push(4);
|
/* GFXTexCoord *ptex = */ _atexCommon.Push(4);
|
||||||
GFXColor *pcol = _acolCommon.Push(4);
|
GFXColor *pcol = _acolCommon.Push(4);
|
||||||
const INDEX iW = dp_Width;
|
const INDEX iW = dp_Width;
|
||||||
const INDEX iH = dp_Height;
|
const INDEX iH = dp_Height;
|
||||||
|
|
|
@ -38,16 +38,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#define W word ptr
|
#define W word ptr
|
||||||
#define B byte ptr
|
#define B byte ptr
|
||||||
|
|
||||||
#if (defined USE_PORTABLE_C)
|
|
||||||
#define ASMOPT 0
|
|
||||||
#elif (defined __MSVC_INLINE__)
|
|
||||||
#define ASMOPT 1
|
|
||||||
#elif (defined __GNU_INLINE__)
|
|
||||||
#define ASMOPT 1
|
|
||||||
#else
|
|
||||||
#define ASMOPT 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MAXTEXUNITS 4
|
#define MAXTEXUNITS 4
|
||||||
#define SHADOWTEXTURE 3
|
#define SHADOWTEXTURE 3
|
||||||
|
|
||||||
|
@ -153,8 +143,7 @@ void AddElements( ScenePolygon *pspo)
|
||||||
const INDEX ctElems = pspo->spo_ctElements;
|
const INDEX ctElems = pspo->spo_ctElements;
|
||||||
INDEX *piDst = _aiElements.Push(ctElems);
|
INDEX *piDst = _aiElements.Push(ctElems);
|
||||||
|
|
||||||
#if (ASMOPT == 1)
|
#if (defined __MSVC_INLINE__)
|
||||||
#if (defined __MSVC_INLINE__)
|
|
||||||
__asm {
|
__asm {
|
||||||
mov eax,D [pspo]
|
mov eax,D [pspo]
|
||||||
mov ecx,D [ctElems]
|
mov ecx,D [ctElems]
|
||||||
|
@ -184,7 +173,7 @@ elemRest:
|
||||||
mov D [edi],eax
|
mov D [edi],eax
|
||||||
elemDone:
|
elemDone:
|
||||||
}
|
}
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"movl %[ctElems], %%ecx \n\t"
|
"movl %[ctElems], %%ecx \n\t"
|
||||||
"movl %[piDst], %%edi \n\t"
|
"movl %[piDst], %%edi \n\t"
|
||||||
|
@ -219,11 +208,6 @@ elemDone:
|
||||||
"cc", "memory"
|
"cc", "memory"
|
||||||
);
|
);
|
||||||
|
|
||||||
#else
|
|
||||||
#error Please write inline ASM for your platform.
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
const INDEX iVtx0Pass = pspo->spo_iVtx0Pass;
|
const INDEX iVtx0Pass = pspo->spo_iVtx0Pass;
|
||||||
const INDEX *piSrc = pspo->spo_piElements;
|
const INDEX *piSrc = pspo->spo_piElements;
|
||||||
|
@ -495,9 +479,7 @@ static void RSBinToGroups( ScenePolygon *pspoFirst)
|
||||||
// determine maximum used groups
|
// determine maximum used groups
|
||||||
ASSERT( _ctGroupsCount);
|
ASSERT( _ctGroupsCount);
|
||||||
|
|
||||||
#if ASMOPT == 1
|
#if (defined __MSVC_INLINE__)
|
||||||
|
|
||||||
#if (defined __MSVC_INLINE__)
|
|
||||||
__asm {
|
__asm {
|
||||||
mov eax,2
|
mov eax,2
|
||||||
bsr ecx,D [_ctGroupsCount]
|
bsr ecx,D [_ctGroupsCount]
|
||||||
|
@ -505,7 +487,7 @@ static void RSBinToGroups( ScenePolygon *pspoFirst)
|
||||||
mov D [_ctGroupsCount],eax
|
mov D [_ctGroupsCount],eax
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"movl $2, %%eax \n\t"
|
"movl $2, %%eax \n\t"
|
||||||
"bsrl (%%esi), %%ecx \n\t"
|
"bsrl (%%esi), %%ecx \n\t"
|
||||||
|
@ -516,24 +498,28 @@ static void RSBinToGroups( ScenePolygon *pspoFirst)
|
||||||
: "eax", "ecx", "cc", "memory"
|
: "eax", "ecx", "cc", "memory"
|
||||||
);
|
);
|
||||||
|
|
||||||
#else
|
|
||||||
#error Please write inline ASM for your platform.
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
// emulate x86's bsr opcode...not fast. :/
|
// emulate x86's bsr opcode...
|
||||||
register DWORD val = _ctGroupsCount;
|
|
||||||
register INDEX bsr = 31;
|
// GCC and clang have an architecture-independent intrinsic for this
|
||||||
if (val != 0)
|
// (it counts leading zeros starting at MSB and is undefined for 0)
|
||||||
{
|
#ifdef __GNUC__
|
||||||
while (bsr > 0)
|
INDEX bsr = 31;
|
||||||
{
|
if(_ctGroupsCount != 0) bsr -= __builtin_clz(_ctGroupsCount);
|
||||||
if (val & (1l << bsr))
|
else bsr = 0;
|
||||||
break;
|
#else // another compiler - doing it manually.. not fast. :/
|
||||||
bsr--;
|
register DWORD val = _ctGroupsCount;
|
||||||
}
|
register INDEX bsr = 31;
|
||||||
}
|
if (val != 0)
|
||||||
|
{
|
||||||
|
while (bsr > 0)
|
||||||
|
{
|
||||||
|
if (val & (1l << bsr))
|
||||||
|
break;
|
||||||
|
bsr--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
_ctGroupsCount = 2 << bsr;
|
_ctGroupsCount = 2 << bsr;
|
||||||
#endif
|
#endif
|
||||||
|
@ -830,6 +816,7 @@ static void RSSetTextureCoords( ScenePolygon *pspoGroup, INDEX iLayer, INDEX iUn
|
||||||
// generate tex coord for all scene polygons in list
|
// generate tex coord for all scene polygons in list
|
||||||
const FLOATmatrix3D &mViewer = _ppr->pr_ViewerRotationMatrix;
|
const FLOATmatrix3D &mViewer = _ppr->pr_ViewerRotationMatrix;
|
||||||
const INDEX iMappingOffset = iLayer * sizeof(CMappingVectors);
|
const INDEX iMappingOffset = iLayer * sizeof(CMappingVectors);
|
||||||
|
(void)iMappingOffset; // shut up compiler, this is used if inline ASM is used
|
||||||
|
|
||||||
for( ScenePolygon *pspo=pspoGroup; pspo!=NULL; pspo=pspo->spo_pspoSucc)
|
for( ScenePolygon *pspo=pspoGroup; pspo!=NULL; pspo=pspo->spo_pspoSucc)
|
||||||
{
|
{
|
||||||
|
@ -858,10 +845,7 @@ static void RSSetTextureCoords( ScenePolygon *pspoGroup, INDEX iLayer, INDEX iUn
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// !!! FIXME: rcg11232001 This inline conversion is broken. Use the
|
#if (defined __MSVC_INLINE__)
|
||||||
// !!! FIXME: rcg11232001 C version for now with GCC.
|
|
||||||
#if ((ASMOPT == 1) && (!defined __GNU_INLINE__) && (!defined __INTEL_COMPILER))
|
|
||||||
#if (defined __MSVC_INLINE__)
|
|
||||||
__asm {
|
__asm {
|
||||||
mov esi,D [pspo]
|
mov esi,D [pspo]
|
||||||
mov edi,D [iMappingOffset]
|
mov edi,D [iMappingOffset]
|
||||||
|
@ -915,7 +899,7 @@ vtxLoop:
|
||||||
/*
|
/*
|
||||||
// !!! FIXME: rcg11232001 This inline conversion is broken. Use the
|
// !!! FIXME: rcg11232001 This inline conversion is broken. Use the
|
||||||
// !!! FIXME: rcg11232001 C version for now on Linux.
|
// !!! FIXME: rcg11232001 C version for now on Linux.
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
STUBBED("debug this");
|
STUBBED("debug this");
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"0: \n\t" // vtxLoop
|
"0: \n\t" // vtxLoop
|
||||||
|
@ -956,11 +940,6 @@ vtxLoop:
|
||||||
);
|
);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#else
|
|
||||||
#error Please write inline ASM for your platform.
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
// diffuse mapping
|
// diffuse mapping
|
||||||
|
@ -2001,7 +1980,7 @@ void RenderSceneBackground(CDrawPort *pDP, COLOR col)
|
||||||
// set arrays
|
// set arrays
|
||||||
gfxResetArrays();
|
gfxResetArrays();
|
||||||
GFXVertex *pvtx = _avtxCommon.Push(4);
|
GFXVertex *pvtx = _avtxCommon.Push(4);
|
||||||
GFXTexCoord *ptex = _atexCommon.Push(4);
|
/* GFXTexCoord *ptex = */ _atexCommon.Push(4);
|
||||||
GFXColor *pcol = _acolCommon.Push(4);
|
GFXColor *pcol = _acolCommon.Push(4);
|
||||||
pvtx[0].x = 0; pvtx[0].y = 0; pvtx[0].z = 1;
|
pvtx[0].x = 0; pvtx[0].y = 0; pvtx[0].z = 1;
|
||||||
pvtx[1].x = 0; pvtx[1].y = iH; pvtx[1].z = 1;
|
pvtx[1].x = 0; pvtx[1].y = iH; pvtx[1].z = 1;
|
||||||
|
|
|
@ -67,18 +67,7 @@ ULONG PrepareTexture( UBYTE *pubTexture, PIX pixSizeI, PIX pixSizeJ)
|
||||||
// need to upload from RGBA format
|
// need to upload from RGBA format
|
||||||
const PIX pixTextureSize = pixSizeI*pixSizeJ;
|
const PIX pixTextureSize = pixSizeI*pixSizeJ;
|
||||||
|
|
||||||
#if (defined USE_PORTABLE_C)
|
#if (defined __MSVC_INLINE__)
|
||||||
const UBYTE* src = pubTexture;
|
|
||||||
DWORD* dst = (DWORD*)(pubTexture+pixTextureSize);
|
|
||||||
for (int i=0; i<pixTextureSize; i++) {
|
|
||||||
const DWORD tmp = ((DWORD)*src) | 0xFFFFFF00;
|
|
||||||
*dst = ((tmp << 24) & 0xff000000 ) | ((tmp << 8) & 0x00ff0000 ) |
|
|
||||||
((tmp >> 8) & 0x0000ff00 ) | ((tmp >> 24) & 0x000000ff );
|
|
||||||
src++;
|
|
||||||
dst++;
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif (defined __MSVC_INLINE__)
|
|
||||||
__asm {
|
__asm {
|
||||||
mov esi,D [pubTexture]
|
mov esi,D [pubTexture]
|
||||||
mov edi,D [pubTexture]
|
mov edi,D [pubTexture]
|
||||||
|
@ -95,7 +84,7 @@ pixLoop:
|
||||||
jnz pixLoop
|
jnz pixLoop
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"movl %[pubTexture], %%esi \n\t"
|
"movl %[pubTexture], %%esi \n\t"
|
||||||
"movl %[pixTextureSize], %%ecx \n\t"
|
"movl %[pixTextureSize], %%ecx \n\t"
|
||||||
|
@ -115,10 +104,17 @@ pixLoop:
|
||||||
: "eax", "ecx", "esi", "edi", "cc", "memory"
|
: "eax", "ecx", "esi", "edi", "cc", "memory"
|
||||||
);
|
);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error Write inline ASM for your platform.
|
const UBYTE* src = pubTexture;
|
||||||
|
DWORD* dst = (DWORD*)(pubTexture+pixTextureSize);
|
||||||
|
for (int i=0; i<pixTextureSize; i++) {
|
||||||
|
const DWORD tmp = ((DWORD)*src) | 0xFFFFFF00;
|
||||||
|
*dst = BYTESWAP32_unsigned((ULONG)tmp);
|
||||||
|
src++;
|
||||||
|
dst++;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// determine internal format
|
// determine internal format
|
||||||
extern INDEX gap_bAllowGrayTextures;
|
extern INDEX gap_bAllowGrayTextures;
|
||||||
|
@ -278,7 +274,7 @@ void StartFog( CFogParameters &fp, const FLOAT3D &vViewPosAbs, const FLOATmatrix
|
||||||
// exp fog
|
// exp fog
|
||||||
case AT_EXP: {
|
case AT_EXP: {
|
||||||
// calculate linear step for the fog parameter
|
// calculate linear step for the fog parameter
|
||||||
FLOAT fT = 0.0f;
|
//FLOAT fT = 0.0f;
|
||||||
FLOAT fTStep = 1.0f/pixSizeL*fFar*fDensity*fA;
|
FLOAT fTStep = 1.0f/pixSizeL*fFar*fDensity*fA;
|
||||||
// fog is exp(-t) function of fog parameter, now calculate
|
// fog is exp(-t) function of fog parameter, now calculate
|
||||||
// step (actually multiplication) for the fog
|
// step (actually multiplication) for the fog
|
||||||
|
@ -291,7 +287,7 @@ void StartFog( CFogParameters &fp, const FLOAT3D &vViewPosAbs, const FLOATmatrix
|
||||||
} break;
|
} break;
|
||||||
case AT_EXP2: {
|
case AT_EXP2: {
|
||||||
// calculate linear step for the fog parameter
|
// calculate linear step for the fog parameter
|
||||||
FLOAT fT = 0.0f;
|
//FLOAT fT = 0.0f;
|
||||||
FLOAT fTStep = 1.0f/pixSizeL*fFar*fDensity*fA;
|
FLOAT fTStep = 1.0f/pixSizeL*fFar*fDensity*fA;
|
||||||
// fog is exp(-t^2) function of fog parameter, now calculate
|
// fog is exp(-t^2) function of fog parameter, now calculate
|
||||||
// first and second order step (actually multiplication) for the fog
|
// first and second order step (actually multiplication) for the fog
|
||||||
|
|
|
@ -99,7 +99,7 @@ void CFontData::Read_t( CTStream *inFile) // throw char *
|
||||||
SetCharSpacing(+1);
|
SetCharSpacing(+1);
|
||||||
SetLineSpacing(+1);
|
SetLineSpacing(+1);
|
||||||
SetSpaceWidth(0.5f);
|
SetSpaceWidth(0.5f);
|
||||||
fd_fcdFontCharData[' '].fcd_pixStart = 0;
|
fd_fcdFontCharData[(int)' '].fcd_pixStart = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFontData::Write_t( CTStream *outFile) // throw char *
|
void CFontData::Write_t( CTStream *outFile) // throw char *
|
||||||
|
@ -201,7 +201,7 @@ void CFontData::Make_t( const CTFileName &fnTexture, PIX pixCharWidth, PIX pixCh
|
||||||
iLetter++; // skip carriage return
|
iLetter++; // skip carriage return
|
||||||
}
|
}
|
||||||
// set default space width
|
// set default space width
|
||||||
fd_fcdFontCharData[' '].fcd_pixStart = 0;
|
fd_fcdFontCharData[(int)' '].fcd_pixStart = 0;
|
||||||
SetSpaceWidth(0.5f);
|
SetSpaceWidth(0.5f);
|
||||||
|
|
||||||
// all done
|
// all done
|
||||||
|
|
|
@ -71,7 +71,7 @@ public:
|
||||||
inline void SetFixedWidth(void) { fd_bFixedWidth = TRUE; };
|
inline void SetFixedWidth(void) { fd_bFixedWidth = TRUE; };
|
||||||
inline void SetVariableWidth(void) { fd_bFixedWidth = FALSE; };
|
inline void SetVariableWidth(void) { fd_bFixedWidth = FALSE; };
|
||||||
inline void SetSpaceWidth( FLOAT fWidthRatio) { // relative to char cell width (1/2 is default)
|
inline void SetSpaceWidth( FLOAT fWidthRatio) { // relative to char cell width (1/2 is default)
|
||||||
fd_fcdFontCharData[' '].fcd_pixEnd = (PIX)(fd_pixCharWidth*fWidthRatio); }
|
fd_fcdFontCharData[(int)' '].fcd_pixEnd = (PIX)(fd_pixCharWidth*fWidthRatio); }
|
||||||
|
|
||||||
void Read_t( CTStream *inFile); // throw char *
|
void Read_t( CTStream *inFile); // throw char *
|
||||||
void Write_t( CTStream *outFile); // throw char *
|
void Write_t( CTStream *outFile); // throw char *
|
||||||
|
|
|
@ -91,7 +91,9 @@ extern BOOL CVA_bModels;
|
||||||
static FLOAT _fLastBrightness, _fLastContrast, _fLastGamma;
|
static FLOAT _fLastBrightness, _fLastContrast, _fLastGamma;
|
||||||
static FLOAT _fLastBiasR, _fLastBiasG, _fLastBiasB;
|
static FLOAT _fLastBiasR, _fLastBiasG, _fLastBiasB;
|
||||||
static INDEX _iLastLevels;
|
static INDEX _iLastLevels;
|
||||||
|
#ifdef PLATFORM_WIN32 // DG: not used on other platforms
|
||||||
static UWORD _auwGammaTable[256*3];
|
static UWORD _auwGammaTable[256*3];
|
||||||
|
#endif
|
||||||
|
|
||||||
// table for clipping [-512..+1024] to [0..255]
|
// table for clipping [-512..+1024] to [0..255]
|
||||||
static UBYTE aubClipByte[256*2+ 256 +256*3];
|
static UBYTE aubClipByte[256*2+ 256 +256*3];
|
||||||
|
@ -805,7 +807,7 @@ extern BOOL ProbeMode( CTimerValue tvLast)
|
||||||
extern void UncacheShadows(void)
|
extern void UncacheShadows(void)
|
||||||
{
|
{
|
||||||
// mute all sounds
|
// mute all sounds
|
||||||
_pSound->Mute();
|
if(_pSound != NULL) _pSound->Mute();
|
||||||
// prepare new saturation factors for shadowmaps
|
// prepare new saturation factors for shadowmaps
|
||||||
gfx_fSaturation = ClampDn( gfx_fSaturation, 0.0f);
|
gfx_fSaturation = ClampDn( gfx_fSaturation, 0.0f);
|
||||||
shd_fSaturation = ClampDn( shd_fSaturation, 0.0f);
|
shd_fSaturation = ClampDn( shd_fSaturation, 0.0f);
|
||||||
|
@ -1213,6 +1215,7 @@ void CGfxLibrary::Init(void)
|
||||||
// !!! FIXME : rcg11232001 Scripts/CustomOptions/GFX-AdvancedRendering.cfg
|
// !!! FIXME : rcg11232001 Scripts/CustomOptions/GFX-AdvancedRendering.cfg
|
||||||
// !!! FIXME : rcg11232001 references non-existing cvars, so I'm adding
|
// !!! FIXME : rcg11232001 references non-existing cvars, so I'm adding
|
||||||
// !!! FIXME : rcg11232001 them here for now.
|
// !!! FIXME : rcg11232001 them here for now.
|
||||||
|
// FXME: DG: so why are they commented out?
|
||||||
// _pShell->DeclareSymbol("persistent user INDEX mdl_bRenderBump;", (void *) &mdl_bRenderBump);
|
// _pShell->DeclareSymbol("persistent user INDEX mdl_bRenderBump;", (void *) &mdl_bRenderBump);
|
||||||
// _pShell->DeclareSymbol("persistent user FLOAT ogl_fTextureAnisotropy;", (void *) &ogl_fTextureAnisotropy);
|
// _pShell->DeclareSymbol("persistent user FLOAT ogl_fTextureAnisotropy;", (void *) &ogl_fTextureAnisotropy);
|
||||||
_pShell->DeclareSymbol("persistent user FLOAT tex_fNormalSize;", (void *) &tex_fNormalSize);
|
_pShell->DeclareSymbol("persistent user FLOAT tex_fNormalSize;", (void *) &tex_fNormalSize);
|
||||||
|
@ -1609,11 +1612,10 @@ void CGfxLibrary::UnlockDrawPort( CDrawPort *pdpToUnlock)
|
||||||
/* Create a new window canvas. */
|
/* Create a new window canvas. */
|
||||||
void CGfxLibrary::CreateWindowCanvas(void *hWnd, CViewPort **ppvpNew, CDrawPort **ppdpNew)
|
void CGfxLibrary::CreateWindowCanvas(void *hWnd, CViewPort **ppvpNew, CDrawPort **ppdpNew)
|
||||||
{
|
{
|
||||||
RECT rectWindow; // rectangle for the client area of the window
|
|
||||||
|
|
||||||
// get the dimensions from the window
|
// get the dimensions from the window
|
||||||
// !!! FIXME : rcg11052001 Abstract this.
|
// !!! FIXME : rcg11052001 Abstract this.
|
||||||
#ifdef PLATFORM_WIN32
|
#ifdef PLATFORM_WIN32
|
||||||
|
RECT rectWindow; // rectangle for the client area of the window
|
||||||
GetClientRect( (HWND)hWnd, &rectWindow);
|
GetClientRect( (HWND)hWnd, &rectWindow);
|
||||||
const PIX pixWidth = rectWindow.right - rectWindow.left;
|
const PIX pixWidth = rectWindow.right - rectWindow.left;
|
||||||
const PIX pixHeight = rectWindow.bottom - rectWindow.top;
|
const PIX pixHeight = rectWindow.bottom - rectWindow.top;
|
||||||
|
@ -1627,7 +1629,7 @@ void CGfxLibrary::CreateWindowCanvas(void *hWnd, CViewPort **ppvpNew, CDrawPort
|
||||||
*ppvpNew = NULL;
|
*ppvpNew = NULL;
|
||||||
*ppdpNew = NULL;
|
*ppdpNew = NULL;
|
||||||
// create a new viewport
|
// create a new viewport
|
||||||
if (*ppvpNew = new CViewPort( pixWidth, pixHeight, (HWND)hWnd)) {
|
if((*ppvpNew = new CViewPort( pixWidth, pixHeight, (HWND)hWnd))) {
|
||||||
// and it's drawport
|
// and it's drawport
|
||||||
*ppdpNew = &(*ppvpNew)->vp_Raster.ra_MainDrawPort;
|
*ppdpNew = &(*ppvpNew)->vp_Raster.ra_MainDrawPort;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1802,7 +1804,9 @@ INDEX _ctProbeShdU = 0;
|
||||||
INDEX _ctProbeShdB = 0;
|
INDEX _ctProbeShdB = 0;
|
||||||
INDEX _ctFullShdU = 0;
|
INDEX _ctFullShdU = 0;
|
||||||
SLONG _slFullShdUBytes = 0;
|
SLONG _slFullShdUBytes = 0;
|
||||||
|
#ifdef PLATFORM_WIN32 // only used there
|
||||||
static BOOL GenerateGammaTable(void);
|
static BOOL GenerateGammaTable(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -2064,7 +2068,7 @@ void CGfxLibrary::UnlockRaster( CRaster *praToUnlock)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef PLATFORM_WIN32 // DG: only used on windows
|
||||||
// generates gamma table and returns true if gamma table has been changed
|
// generates gamma table and returns true if gamma table has been changed
|
||||||
static BOOL GenerateGammaTable(void)
|
static BOOL GenerateGammaTable(void)
|
||||||
{
|
{
|
||||||
|
@ -2140,7 +2144,7 @@ static BOOL GenerateGammaTable(void)
|
||||||
// done
|
// done
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
#endif // PLATFORM_WIN32
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
|
@ -505,9 +505,9 @@ extern void SetTBufferEffect( BOOL bEnable)
|
||||||
if( ogl_iTBufferEffect==0 || _pGfx->go_ctSampleBuffers<2 || !bEnable) pglDisable( GL_MULTISAMPLE_3DFX);
|
if( ogl_iTBufferEffect==0 || _pGfx->go_ctSampleBuffers<2 || !bEnable) pglDisable( GL_MULTISAMPLE_3DFX);
|
||||||
else {
|
else {
|
||||||
pglEnable( GL_MULTISAMPLE_3DFX);
|
pglEnable( GL_MULTISAMPLE_3DFX);
|
||||||
UINT uiMask = 0xFFFFFFFF;
|
//UINT uiMask = 0xFFFFFFFF;
|
||||||
// set one buffer in case of motion-blur
|
// set one buffer in case of motion-blur
|
||||||
if( ogl_iTBufferEffect==2) uiMask = (1UL) << _pGfx->go_iCurrentWriteBuffer;
|
//if( ogl_iTBufferEffect==2) uiMask = (1UL) << _pGfx->go_iCurrentWriteBuffer;
|
||||||
//pglTBufferMask3DFX(uiMask);
|
//pglTBufferMask3DFX(uiMask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,32 +169,7 @@ void UploadTexture_OGL( ULONG *pulTexture, PIX pixSizeU, PIX pixSizeV,
|
||||||
if( pixSizeV==0) pixSizeV=1;
|
if( pixSizeV==0) pixSizeV=1;
|
||||||
pixSize = pixSizeU*pixSizeV;
|
pixSize = pixSizeU*pixSizeV;
|
||||||
|
|
||||||
#if (defined USE_PORTABLE_C)
|
#if (defined __MSVC_INLINE__)
|
||||||
// Basically average every other pixel...
|
|
||||||
UWORD w = 0;
|
|
||||||
UBYTE *dptr = (UBYTE *) pulDst;
|
|
||||||
UBYTE *sptr = (UBYTE *) pulSrc;
|
|
||||||
#if 0
|
|
||||||
pixSize *= 4;
|
|
||||||
for (PIX i = 0; i < pixSize; i++)
|
|
||||||
{
|
|
||||||
*dptr = (UBYTE) ( (((UWORD) sptr[0]) + ((UWORD) sptr[1])) >> 1 );
|
|
||||||
dptr++;
|
|
||||||
sptr += 2;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
for (PIX i = 0; i < pixSize; i++)
|
|
||||||
{
|
|
||||||
for (PIX j = 0; j < 4; j++)
|
|
||||||
{
|
|
||||||
*dptr = (UBYTE) ( (((UWORD) sptr[0]) + ((UWORD) sptr[4])) >> 1 );
|
|
||||||
dptr++;
|
|
||||||
sptr++;
|
|
||||||
}
|
|
||||||
sptr += 4;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#elif (defined __MSVC_INLINE__)
|
|
||||||
__asm {
|
__asm {
|
||||||
pxor mm0,mm0
|
pxor mm0,mm0
|
||||||
mov esi,D [pulSrc]
|
mov esi,D [pulSrc]
|
||||||
|
@ -216,7 +191,7 @@ void UploadTexture_OGL( ULONG *pulTexture, PIX pixSizeU, PIX pixSizeV,
|
||||||
emms
|
emms
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"pxor %%mm0,%%mm0 \n\t"
|
"pxor %%mm0,%%mm0 \n\t"
|
||||||
"movl %[pulSrc],%%esi \n\t"
|
"movl %[pulSrc],%%esi \n\t"
|
||||||
|
@ -244,7 +219,30 @@ void UploadTexture_OGL( ULONG *pulTexture, PIX pixSizeU, PIX pixSizeV,
|
||||||
);
|
);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error Please write inline ASM for your platform.
|
// Basically average every other pixel...
|
||||||
|
//UWORD w = 0;
|
||||||
|
UBYTE *dptr = (UBYTE *) pulDst;
|
||||||
|
UBYTE *sptr = (UBYTE *) pulSrc;
|
||||||
|
#if 0
|
||||||
|
pixSize *= 4;
|
||||||
|
for (PIX i = 0; i < pixSize; i++)
|
||||||
|
{
|
||||||
|
*dptr = (UBYTE) ( (((UWORD) sptr[0]) + ((UWORD) sptr[1])) >> 1 );
|
||||||
|
dptr++;
|
||||||
|
sptr += 2;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
for (PIX i = 0; i < pixSize; i++)
|
||||||
|
{
|
||||||
|
for (PIX j = 0; j < 4; j++)
|
||||||
|
{
|
||||||
|
*dptr = (UBYTE) ( (((UWORD) sptr[0]) + ((UWORD) sptr[4])) >> 1 );
|
||||||
|
dptr++;
|
||||||
|
sptr++;
|
||||||
|
}
|
||||||
|
sptr += 4;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// upload mipmap
|
// upload mipmap
|
||||||
|
|
|
@ -72,7 +72,7 @@ FLOAT GFX_fLastF = 0;
|
||||||
INDEX GFX_ctVertices = 0;
|
INDEX GFX_ctVertices = 0;
|
||||||
|
|
||||||
// for D3D: mark need for clipping (when wants to be disable but cannot be because of user clip plane)
|
// for D3D: mark need for clipping (when wants to be disable but cannot be because of user clip plane)
|
||||||
static BOOL _bWantsClipping = TRUE;
|
//static BOOL _bWantsClipping = TRUE;
|
||||||
// current color mask (for Get... function)
|
// current color mask (for Get... function)
|
||||||
static ULONG _ulCurrentColorMask = (CT_RMASK|CT_GMASK|CT_BMASK|CT_AMASK);
|
static ULONG _ulCurrentColorMask = (CT_RMASK|CT_GMASK|CT_BMASK|CT_AMASK);
|
||||||
// locking state for OGL
|
// locking state for OGL
|
||||||
|
@ -81,7 +81,7 @@ static BOOL _bCVAReallyLocked = FALSE;
|
||||||
// clip plane and last view matrix for D3D
|
// clip plane and last view matrix for D3D
|
||||||
FLOAT D3D_afClipPlane[4] = {0,0,0,0};
|
FLOAT D3D_afClipPlane[4] = {0,0,0,0};
|
||||||
FLOAT D3D_afViewMatrix[16] = {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0};
|
FLOAT D3D_afViewMatrix[16] = {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0};
|
||||||
static FLOAT _afActiveClipPlane[4] = {0,0,0,0};
|
//static FLOAT _afActiveClipPlane[4] = {0,0,0,0};
|
||||||
|
|
||||||
// Truform/N-Patches
|
// Truform/N-Patches
|
||||||
INDEX truform_iLevel = -1;
|
INDEX truform_iLevel = -1;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -78,6 +78,7 @@ static __forceinline CTStream &operator>>(CTStream &strm, PCXHeader &t) {
|
||||||
return strm;
|
return strm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0 // DG: unused.
|
||||||
static __forceinline CTStream &operator<<(CTStream &strm, const PCXHeader &t) {
|
static __forceinline CTStream &operator<<(CTStream &strm, const PCXHeader &t) {
|
||||||
strm<<t.MagicID;
|
strm<<t.MagicID;
|
||||||
strm<<t.Version;
|
strm<<t.Version;
|
||||||
|
@ -99,6 +100,7 @@ static __forceinline CTStream &operator<<(CTStream &strm, const PCXHeader &t) {
|
||||||
strm.Write_t(t.Filler, sizeof (t.Filler));
|
strm.Write_t(t.Filler, sizeof (t.Filler));
|
||||||
return strm;
|
return strm;
|
||||||
}
|
}
|
||||||
|
#endif // 0
|
||||||
|
|
||||||
// TARGA header structure
|
// TARGA header structure
|
||||||
struct TGAHeader
|
struct TGAHeader
|
||||||
|
@ -129,6 +131,7 @@ static __forceinline CTStream &operator>>(CTStream &strm, TGAHeader &t) {
|
||||||
return(strm);
|
return(strm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0 // DG: unused.
|
||||||
static __forceinline CTStream &operator<<(CTStream &strm, const TGAHeader &t) {
|
static __forceinline CTStream &operator<<(CTStream &strm, const TGAHeader &t) {
|
||||||
strm<<t.IdLength;
|
strm<<t.IdLength;
|
||||||
strm<<t.ColorMapType;
|
strm<<t.ColorMapType;
|
||||||
|
@ -142,6 +145,7 @@ static __forceinline CTStream &operator<<(CTStream &strm, const TGAHeader &t) {
|
||||||
strm<<t.Descriptor;
|
strm<<t.Descriptor;
|
||||||
return(strm);
|
return(strm);
|
||||||
}
|
}
|
||||||
|
#endif // 0 (unused)
|
||||||
|
|
||||||
|
|
||||||
/******************************************************
|
/******************************************************
|
||||||
|
|
|
@ -89,20 +89,14 @@ extern void (__stdcall *pglPNTrianglesfATI)( GLenum pname, GLfloat param);
|
||||||
inline void glCOLOR( COLOR col)
|
inline void glCOLOR( COLOR col)
|
||||||
{
|
{
|
||||||
/* rcg10052001 Platform-wrappers. */
|
/* rcg10052001 Platform-wrappers. */
|
||||||
#if (defined USE_PORTABLE_C)
|
#if (defined __MSVC_INLINE__)
|
||||||
col = ( ((col << 24) ) |
|
|
||||||
((col << 8) & 0x00FF0000) |
|
|
||||||
((col >> 8) & 0x0000FF00) |
|
|
||||||
((col >> 24) ) );
|
|
||||||
|
|
||||||
#elif (defined __MSVC_INLINE__)
|
|
||||||
__asm {
|
__asm {
|
||||||
mov eax,dword ptr [col]
|
mov eax,dword ptr [col]
|
||||||
bswap eax
|
bswap eax
|
||||||
mov dword ptr [col],eax
|
mov dword ptr [col],eax
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"bswapl %%eax \n\t"
|
"bswapl %%eax \n\t"
|
||||||
: "=a" (col)
|
: "=a" (col)
|
||||||
|
@ -110,7 +104,11 @@ inline void glCOLOR( COLOR col)
|
||||||
);
|
);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error please define for your platform.
|
col = ( ((col << 24) ) |
|
||||||
|
((col << 8) & 0x00FF0000) |
|
||||||
|
((col >> 8) & 0x0000FF00) |
|
||||||
|
((col >> 24) ) );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pglColor4ubv((GLubyte*)&col);
|
pglColor4ubv((GLubyte*)&col);
|
||||||
|
|
|
@ -89,14 +89,13 @@ void *CGfxLibrary::OGL_GetProcAddress(const char *procname)
|
||||||
// prepares pixel format for OpenGL context
|
// prepares pixel format for OpenGL context
|
||||||
BOOL CGfxLibrary::SetupPixelFormat_OGL( HDC hdc, BOOL bReport/*=FALSE*/)
|
BOOL CGfxLibrary::SetupPixelFormat_OGL( HDC hdc, BOOL bReport/*=FALSE*/)
|
||||||
{
|
{
|
||||||
SDL_Window *window = (SDL_Window *) hdc;
|
//SDL_Window *window = (SDL_Window *) hdc;
|
||||||
const DisplayDepth dd = gl_dmCurrentDisplayMode.dm_ddDepth;
|
const DisplayDepth dd = gl_dmCurrentDisplayMode.dm_ddDepth;
|
||||||
|
|
||||||
// clamp depth/stencil values
|
// clamp depth/stencil values
|
||||||
extern INDEX gap_iDepthBits;
|
extern INDEX gap_iDepthBits;
|
||||||
extern INDEX gap_iStencilBits;
|
extern INDEX gap_iStencilBits;
|
||||||
if( gap_iDepthBits <12) gap_iDepthBits = 0;
|
if( gap_iDepthBits <22) gap_iDepthBits = 16; // this includes 0; 16 is a safe default
|
||||||
else if( gap_iDepthBits <22) gap_iDepthBits = 16;
|
|
||||||
else if( gap_iDepthBits <28) gap_iDepthBits = 24;
|
else if( gap_iDepthBits <28) gap_iDepthBits = 24;
|
||||||
else gap_iDepthBits = 32;
|
else gap_iDepthBits = 32;
|
||||||
if( gap_iStencilBits<3) gap_iStencilBits = 0;
|
if( gap_iStencilBits<3) gap_iStencilBits = 0;
|
||||||
|
|
|
@ -843,6 +843,7 @@ void CTextureData::Read_t( CTStream *inFile)
|
||||||
*inFile >> ctEffectSources;
|
*inFile >> ctEffectSources;
|
||||||
// add requested number of members to effect source array
|
// add requested number of members to effect source array
|
||||||
CTextureEffectSource *pEffectSources = td_ptegEffect->teg_atesEffectSources.New( ctEffectSources);
|
CTextureEffectSource *pEffectSources = td_ptegEffect->teg_atesEffectSources.New( ctEffectSources);
|
||||||
|
(void)pEffectSources;
|
||||||
|
|
||||||
// read whole dynamic array of effect sources
|
// read whole dynamic array of effect sources
|
||||||
FOREACHINDYNAMICARRAY( td_ptegEffect->teg_atesEffectSources, CTextureEffectSource, itEffectSource)
|
FOREACHINDYNAMICARRAY( td_ptegEffect->teg_atesEffectSources, CTextureEffectSource, itEffectSource)
|
||||||
|
|
|
@ -32,11 +32,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#define W word ptr
|
#define W word ptr
|
||||||
#define B byte ptr
|
#define B byte ptr
|
||||||
|
|
||||||
#if (defined USE_PORTABLE_C)
|
#if (defined __MSVC_INLINE__)
|
||||||
#define ASMOPT 0
|
|
||||||
#elif (defined __MSVC_INLINE__)
|
|
||||||
#define ASMOPT 1
|
#define ASMOPT 1
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
#define ASMOPT 1
|
#define ASMOPT 1
|
||||||
#else
|
#else
|
||||||
#define ASMOPT 0
|
#define ASMOPT 0
|
||||||
|
@ -1285,8 +1283,7 @@ static void RenderWater(void)
|
||||||
{ // SUB-SAMPLING
|
{ // SUB-SAMPLING
|
||||||
SLONG slHeightMapStep, slHeightRowStep;
|
SLONG slHeightMapStep, slHeightRowStep;
|
||||||
|
|
||||||
#if ASMOPT == 1
|
#if (defined __MSVC_INLINE__)
|
||||||
#if (defined __MSVC_INLINE__)
|
|
||||||
__asm {
|
__asm {
|
||||||
push ebx
|
push ebx
|
||||||
bsf ecx,D [_pixTexWidth]
|
bsf ecx,D [_pixTexWidth]
|
||||||
|
@ -1357,7 +1354,7 @@ pixLoop:
|
||||||
pop ebx
|
pop ebx
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
// rcg12152001 needed extra registers. :(
|
// rcg12152001 needed extra registers. :(
|
||||||
_slHeightMapStep_renderWater = slHeightMapStep;
|
_slHeightMapStep_renderWater = slHeightMapStep;
|
||||||
_pixBaseWidth_renderWater = pixBaseWidth;
|
_pixBaseWidth_renderWater = pixBaseWidth;
|
||||||
|
@ -1460,10 +1457,6 @@ pixLoop:
|
||||||
"cc", "memory"
|
"cc", "memory"
|
||||||
);
|
);
|
||||||
|
|
||||||
#else
|
|
||||||
#error fill in for your platform.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
PIX pixPos, pixDU, pixDV;
|
PIX pixPos, pixDU, pixDV;
|
||||||
|
@ -1626,7 +1619,7 @@ pixLoop2:
|
||||||
pop ebx
|
pop ebx
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"bsfl %[pixBaseWidth], %%eax \n\t"
|
"bsfl %[pixBaseWidth], %%eax \n\t"
|
||||||
"movl $32, %%edx \n\t"
|
"movl $32, %%edx \n\t"
|
||||||
|
@ -2146,7 +2139,7 @@ pixLoop4:
|
||||||
pop ebx
|
pop ebx
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"bsfl %[pixBaseWidth], %%eax \n\t"
|
"bsfl %[pixBaseWidth], %%eax \n\t"
|
||||||
"movl $32, %%edx \n\t"
|
"movl $32, %%edx \n\t"
|
||||||
|
@ -2922,9 +2915,9 @@ static void AnimateFire( SLONG slDensity)
|
||||||
// use only one buffer (otherwise it's not working)
|
// use only one buffer (otherwise it's not working)
|
||||||
UBYTE *pubNew = (UBYTE*)_ptdEffect->td_pubBuffer2;
|
UBYTE *pubNew = (UBYTE*)_ptdEffect->td_pubBuffer2;
|
||||||
SLONG slBufferMask = _pixBufferWidth*_pixBufferHeight -1;
|
SLONG slBufferMask = _pixBufferWidth*_pixBufferHeight -1;
|
||||||
SLONG slColumnModulo = _pixBufferWidth*(_pixBufferHeight-2) -1;
|
|
||||||
|
|
||||||
#if ASMOPT == 1
|
#if ASMOPT == 1
|
||||||
|
SLONG slColumnModulo = _pixBufferWidth*(_pixBufferHeight-2) -1;
|
||||||
|
|
||||||
#if (defined __MSVC_INLINE__)
|
#if (defined __MSVC_INLINE__)
|
||||||
__asm {
|
__asm {
|
||||||
|
@ -2976,7 +2969,7 @@ pixDone:
|
||||||
pop ebx
|
pop ebx
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"movl %[slColumnModulo], %%edx \n\t"
|
"movl %[slColumnModulo], %%edx \n\t"
|
||||||
"movl %[slBufferMask], %%ecx \n\t"
|
"movl %[slBufferMask], %%ecx \n\t"
|
||||||
|
@ -3119,7 +3112,7 @@ pixLoopF:
|
||||||
jnz rowLoopF
|
jnz rowLoopF
|
||||||
pop ebx
|
pop ebx
|
||||||
}
|
}
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
_pubHeat_RenderPlasmaFire = pubHeat; // ran out of registers. :/
|
_pubHeat_RenderPlasmaFire = pubHeat; // ran out of registers. :/
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"movl %[slHeatRowStep], %%eax \n\t"
|
"movl %[slHeatRowStep], %%eax \n\t"
|
||||||
|
|
|
@ -329,8 +329,8 @@ void CLayerMaker::SpreadShadowMaskOutwards(void)
|
||||||
PIX pixLayerMinV = lm_pixLayerMinV>>iMipmap;
|
PIX pixLayerMinV = lm_pixLayerMinV>>iMipmap;
|
||||||
PIX pixLayerSizeU = lm_pixLayerSizeU>>iMipmap;
|
PIX pixLayerSizeU = lm_pixLayerSizeU>>iMipmap;
|
||||||
PIX pixLayerSizeV = lm_pixLayerSizeV>>iMipmap;
|
PIX pixLayerSizeV = lm_pixLayerSizeV>>iMipmap;
|
||||||
PIX pixSizeU = lm_pixSizeU>>iMipmap;
|
//PIX pixSizeU = lm_pixSizeU>>iMipmap;
|
||||||
PIX pixSizeV = lm_pixSizeV>>iMipmap;
|
//PIX pixSizeV = lm_pixSizeV>>iMipmap;
|
||||||
PIX pixSizeULog2 = FastLog2(lm_pixSizeU)-iMipmap;
|
PIX pixSizeULog2 = FastLog2(lm_pixSizeU)-iMipmap;
|
||||||
UBYTE *pubLayer = lm_pubLayer+lm_mmtLayer.mmt_aslOffsets[iMipmap];
|
UBYTE *pubLayer = lm_pubLayer+lm_mmtLayer.mmt_aslOffsets[iMipmap];
|
||||||
UBYTE *pubPolygonMask = lm_pubPolygonMask+lm_mmtPolygonMask.mmt_aslOffsets[iMipmap];
|
UBYTE *pubPolygonMask = lm_pubPolygonMask+lm_mmtPolygonMask.mmt_aslOffsets[iMipmap];
|
||||||
|
@ -419,8 +419,8 @@ void CLayerMaker::SpreadShadowMaskInwards(void)
|
||||||
PIX pixLayerMinV = lm_pixLayerMinV>>iMipmap;
|
PIX pixLayerMinV = lm_pixLayerMinV>>iMipmap;
|
||||||
PIX pixLayerSizeU = lm_pixLayerSizeU>>iMipmap;
|
PIX pixLayerSizeU = lm_pixLayerSizeU>>iMipmap;
|
||||||
PIX pixLayerSizeV = lm_pixLayerSizeV>>iMipmap;
|
PIX pixLayerSizeV = lm_pixLayerSizeV>>iMipmap;
|
||||||
PIX pixSizeU = lm_pixSizeU>>iMipmap;
|
//PIX pixSizeU = lm_pixSizeU>>iMipmap;
|
||||||
PIX pixSizeV = lm_pixSizeV>>iMipmap;
|
//PIX pixSizeV = lm_pixSizeV>>iMipmap;
|
||||||
PIX pixSizeULog2 = FastLog2(lm_pixSizeU)-iMipmap;
|
PIX pixSizeULog2 = FastLog2(lm_pixSizeU)-iMipmap;
|
||||||
UBYTE *pubLayer = lm_pubLayer+lm_mmtLayer.mmt_aslOffsets[iMipmap];
|
UBYTE *pubLayer = lm_pubLayer+lm_mmtLayer.mmt_aslOffsets[iMipmap];
|
||||||
UBYTE *pubPolygonMask = lm_pubPolygonMask+lm_mmtPolygonMask.mmt_aslOffsets[iMipmap];
|
UBYTE *pubPolygonMask = lm_pubPolygonMask+lm_mmtPolygonMask.mmt_aslOffsets[iMipmap];
|
||||||
|
@ -526,7 +526,7 @@ void CLayerMaker::MakePolygonMask(void)
|
||||||
UBYTE *pub = lm_pubPolygonMask;
|
UBYTE *pub = lm_pubPolygonMask;
|
||||||
// for each mip-map
|
// for each mip-map
|
||||||
for (INDEX iMipmap=0; iMipmap<lm_mmtPolygonMask.mmt_ctMipmaps; iMipmap++) {
|
for (INDEX iMipmap=0; iMipmap<lm_mmtPolygonMask.mmt_ctMipmaps; iMipmap++) {
|
||||||
UBYTE *pubForSaving = pub;
|
//UBYTE *pubForSaving = pub;
|
||||||
// start at the first pixel
|
// start at the first pixel
|
||||||
FLOAT3D vRow = lm_vO+(lm_vStepU+lm_vStepV)*(FLOAT(1<<iMipmap)/2.0f);
|
FLOAT3D vRow = lm_vO+(lm_vStepU+lm_vStepV)*(FLOAT(1<<iMipmap)/2.0f);
|
||||||
// for each pixel in the shadow map
|
// for each pixel in the shadow map
|
||||||
|
@ -565,8 +565,8 @@ void CLayerMaker::MakePolygonMask(void)
|
||||||
// flip shadow mask around V axis (for parallel lights)
|
// flip shadow mask around V axis (for parallel lights)
|
||||||
void CLayerMaker::FlipShadowMask(INDEX iMip)
|
void CLayerMaker::FlipShadowMask(INDEX iMip)
|
||||||
{
|
{
|
||||||
PIX pixLayerMinU = lm_pixLayerMinU>>iMip;
|
//PIX pixLayerMinU = lm_pixLayerMinU>>iMip;
|
||||||
PIX pixLayerMinV = lm_pixLayerMinV>>iMip;
|
//PIX pixLayerMinV = lm_pixLayerMinV>>iMip;
|
||||||
PIX pixLayerSizeU = lm_pixLayerSizeU>>iMip;
|
PIX pixLayerSizeU = lm_pixLayerSizeU>>iMip;
|
||||||
PIX pixLayerSizeV = lm_pixLayerSizeV>>iMip;
|
PIX pixLayerSizeV = lm_pixLayerSizeV>>iMip;
|
||||||
UBYTE *pubLayer = lm_pubLayer+lm_mmtLayer.mmt_aslOffsets[iMip];
|
UBYTE *pubLayer = lm_pubLayer+lm_mmtLayer.mmt_aslOffsets[iMip];
|
||||||
|
@ -632,7 +632,7 @@ ULONG CLayerMaker::MakeShadowMask(CBrushShadowLayer *pbsl)
|
||||||
|
|
||||||
// allocate shadow mask for the light (+8 is safety wall for fast conversions)
|
// allocate shadow mask for the light (+8 is safety wall for fast conversions)
|
||||||
lm_pubLayer = (UBYTE *)AllocMemory(lm_mmtLayer.mmt_slTotalSize+8);
|
lm_pubLayer = (UBYTE *)AllocMemory(lm_mmtLayer.mmt_slTotalSize+8);
|
||||||
const FLOAT fEpsilon = (1<<lm_iMipLevel)/1024.0f;
|
//const FLOAT fEpsilon = (1<<lm_iMipLevel)/1024.0f;
|
||||||
|
|
||||||
ULONG ulLighted=BSLF_ALLLIGHT|BSLF_ALLDARK;
|
ULONG ulLighted=BSLF_ALLLIGHT|BSLF_ALLDARK;
|
||||||
// if this polygon requires exact shadows
|
// if this polygon requires exact shadows
|
||||||
|
|
|
@ -40,16 +40,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#define W word ptr
|
#define W word ptr
|
||||||
#define B byte ptr
|
#define B byte ptr
|
||||||
|
|
||||||
#if (defined USE_PORTABLE_C)
|
|
||||||
#define ASMOPT 0
|
|
||||||
#elif (defined __MSVC_INLINE__)
|
|
||||||
#define ASMOPT 1
|
|
||||||
#elif (defined __GNU_INLINE__)
|
|
||||||
#define ASMOPT 1
|
|
||||||
#else
|
|
||||||
#define ASMOPT 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern INDEX shd_bFineQuality;
|
extern INDEX shd_bFineQuality;
|
||||||
extern INDEX shd_iFiltering;
|
extern INDEX shd_iFiltering;
|
||||||
extern INDEX shd_iDithering;
|
extern INDEX shd_iDithering;
|
||||||
|
@ -138,6 +128,7 @@ static inline void IncrementByteWithClip( UBYTE &ub, SLONG slAdd)
|
||||||
ub = pubClipByte[(SLONG)ub+slAdd];
|
ub = pubClipByte[(SLONG)ub+slAdd];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0 // DG: unused.
|
||||||
// increment a color without overflowing it
|
// increment a color without overflowing it
|
||||||
static inline void IncrementColorWithClip( UBYTE &ubR, UBYTE &ubG, UBYTE &ubB,
|
static inline void IncrementColorWithClip( UBYTE &ubR, UBYTE &ubG, UBYTE &ubB,
|
||||||
SLONG slR, SLONG slG, SLONG slB)
|
SLONG slR, SLONG slG, SLONG slB)
|
||||||
|
@ -146,6 +137,7 @@ static inline void IncrementColorWithClip( UBYTE &ubR, UBYTE &ubG, UBYTE &ubB,
|
||||||
IncrementByteWithClip( ubG, slG);
|
IncrementByteWithClip( ubG, slG);
|
||||||
IncrementByteWithClip( ubB, slB);
|
IncrementByteWithClip( ubB, slB);
|
||||||
}
|
}
|
||||||
|
#endif // 0 (unused)
|
||||||
|
|
||||||
// add the intensity to the pixel
|
// add the intensity to the pixel
|
||||||
inline void CLayerMixer::AddToCluster( UBYTE *pub)
|
inline void CLayerMixer::AddToCluster( UBYTE *pub)
|
||||||
|
@ -286,12 +278,11 @@ void CLayerMixer::AddAmbientPoint(void)
|
||||||
// prepare some local variables
|
// prepare some local variables
|
||||||
mmDDL2oDU_AddAmbientPoint = _slDDL2oDU;
|
mmDDL2oDU_AddAmbientPoint = _slDDL2oDU;
|
||||||
mmDDL2oDV_AddAmbientPoint = _slDDL2oDV;
|
mmDDL2oDV_AddAmbientPoint = _slDDL2oDV;
|
||||||
ULONG ulLightRGB = ByteSwap(lm_colLight);
|
ULONG ulLightRGB = ByteSwap(lm_colLight); // FIXME: shouldn't this be used in plain C impl too?
|
||||||
_slLightMax<<=7;
|
_slLightMax<<=7;
|
||||||
_slLightStep>>=1;
|
_slLightStep>>=1;
|
||||||
|
|
||||||
#if (ASMOPT == 1)
|
#if (defined __MSVC_INLINE__)
|
||||||
#if (defined __MSVC_INLINE__)
|
|
||||||
__asm {
|
__asm {
|
||||||
// prepare interpolants
|
// prepare interpolants
|
||||||
movd mm0,D [_slL2Row]
|
movd mm0,D [_slL2Row]
|
||||||
|
@ -364,7 +355,7 @@ skipPixel:
|
||||||
emms
|
emms
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
ULONG tmp1, tmp2;
|
ULONG tmp1, tmp2;
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
// prepare interpolants
|
// prepare interpolants
|
||||||
|
@ -439,10 +430,6 @@ skipPixel:
|
||||||
: FPU_REGS, MMX_REGS, "eax", "ecx", "edi", "cc", "memory"
|
: FPU_REGS, MMX_REGS, "eax", "ecx", "edi", "cc", "memory"
|
||||||
);
|
);
|
||||||
|
|
||||||
#else
|
|
||||||
#error Write inline asm for your platform.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
// !!! FIXME WARNING: I have not checked this code, and it could be
|
// !!! FIXME WARNING: I have not checked this code, and it could be
|
||||||
|
@ -491,13 +478,12 @@ void CLayerMixer::AddAmbientMaskPoint( UBYTE *pubMask, UBYTE ubMask)
|
||||||
// prepare some local variables
|
// prepare some local variables
|
||||||
mmDDL2oDU_addAmbientMaskPoint = _slDDL2oDU;
|
mmDDL2oDU_addAmbientMaskPoint = _slDDL2oDU;
|
||||||
mmDDL2oDV_addAmbientMaskPoint = _slDDL2oDV;
|
mmDDL2oDV_addAmbientMaskPoint = _slDDL2oDV;
|
||||||
ULONG ulLightRGB = ByteSwap(lm_colLight);
|
ULONG ulLightRGB = ByteSwap(lm_colLight); // FIXME: shouldn't this be used in plain C impl too?
|
||||||
_slLightMax<<=7;
|
_slLightMax<<=7;
|
||||||
_slLightStep>>=1;
|
_slLightStep>>=1;
|
||||||
|
|
||||||
|
|
||||||
#if (ASMOPT == 1)
|
#if (defined __MSVC_INLINE__)
|
||||||
#if (defined __MSVC_INLINE__)
|
|
||||||
__asm {
|
__asm {
|
||||||
// prepare interpolants
|
// prepare interpolants
|
||||||
movd mm0,D [_slL2Row]
|
movd mm0,D [_slL2Row]
|
||||||
|
@ -576,7 +562,7 @@ skipPixel:
|
||||||
emms
|
emms
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
ULONG tmp1, tmp2;
|
ULONG tmp1, tmp2;
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
// prepare interpolants
|
// prepare interpolants
|
||||||
|
@ -660,10 +646,6 @@ skipPixel:
|
||||||
"cc", "memory"
|
"cc", "memory"
|
||||||
);
|
);
|
||||||
|
|
||||||
#else
|
|
||||||
#error Please write inline assembly for your platform.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else // Portable C version...
|
#else // Portable C version...
|
||||||
|
|
||||||
UBYTE* pubLayer = (UBYTE*)_pulLayer;
|
UBYTE* pubLayer = (UBYTE*)_pulLayer;
|
||||||
|
@ -674,7 +656,7 @@ skipPixel:
|
||||||
for( PIX pixU=0; pixU<_iPixCt; pixU++)
|
for( PIX pixU=0; pixU<_iPixCt; pixU++)
|
||||||
{
|
{
|
||||||
// if the point is not masked
|
// if the point is not masked
|
||||||
if( *pubMask & ubMask && (slL2Point<FTOX)) {
|
if( (*pubMask & ubMask) && (slL2Point<FTOX)) {
|
||||||
SLONG slL = (slL2Point>>SHIFTX)&(SQRTTABLESIZE-1); // and is just for degenerate cases
|
SLONG slL = (slL2Point>>SHIFTX)&(SQRTTABLESIZE-1); // and is just for degenerate cases
|
||||||
SLONG slIntensity = _slLightMax;
|
SLONG slIntensity = _slLightMax;
|
||||||
slL = aubSqrt[slL];
|
slL = aubSqrt[slL];
|
||||||
|
@ -719,12 +701,11 @@ void CLayerMixer::AddDiffusionPoint(void)
|
||||||
// prepare some local variables
|
// prepare some local variables
|
||||||
mmDDL2oDU_AddDiffusionPoint = _slDDL2oDU;
|
mmDDL2oDU_AddDiffusionPoint = _slDDL2oDU;
|
||||||
mmDDL2oDV_AddDiffusionPoint = _slDDL2oDV;
|
mmDDL2oDV_AddDiffusionPoint = _slDDL2oDV;
|
||||||
ULONG ulLightRGB = ByteSwap(lm_colLight);
|
ULONG ulLightRGB = ByteSwap(lm_colLight); // FIXME: shouldn't this be used in plain C impl too?
|
||||||
_slLightMax<<=7;
|
_slLightMax<<=7;
|
||||||
_slLightStep>>=1;
|
_slLightStep>>=1;
|
||||||
|
|
||||||
#if ASMOPT == 1
|
#if (defined __MSVC_INLINE__)
|
||||||
#if (defined __MSVC_INLINE__)
|
|
||||||
__asm {
|
__asm {
|
||||||
// prepare interpolants
|
// prepare interpolants
|
||||||
movd mm0,D [_slL2Row]
|
movd mm0,D [_slL2Row]
|
||||||
|
@ -796,7 +777,7 @@ skipPixel:
|
||||||
emms
|
emms
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
ULONG tmp1, tmp2;
|
ULONG tmp1, tmp2;
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
// prepare interpolants
|
// prepare interpolants
|
||||||
|
@ -871,10 +852,6 @@ skipPixel:
|
||||||
: FPU_REGS, MMX_REGS, "eax", "ecx", "edi", "cc", "memory"
|
: FPU_REGS, MMX_REGS, "eax", "ecx", "edi", "cc", "memory"
|
||||||
);
|
);
|
||||||
|
|
||||||
#else
|
|
||||||
#error Write inline assembly for your platform.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
// for each pixel in the shadow map
|
// for each pixel in the shadow map
|
||||||
UBYTE* pubLayer = (UBYTE*)_pulLayer;
|
UBYTE* pubLayer = (UBYTE*)_pulLayer;
|
||||||
|
@ -925,12 +902,11 @@ void CLayerMixer::AddDiffusionMaskPoint( UBYTE *pubMask, UBYTE ubMask)
|
||||||
// prepare some local variables
|
// prepare some local variables
|
||||||
mmDDL2oDU_AddDiffusionMaskPoint = _slDDL2oDU;
|
mmDDL2oDU_AddDiffusionMaskPoint = _slDDL2oDU;
|
||||||
mmDDL2oDV_AddDiffusionMaskPoint = _slDDL2oDV;
|
mmDDL2oDV_AddDiffusionMaskPoint = _slDDL2oDV;
|
||||||
ULONG ulLightRGB = ByteSwap(lm_colLight);
|
ULONG ulLightRGB = ByteSwap(lm_colLight); // FIXME: shouldn't this be used in plain C impl too?
|
||||||
_slLightMax<<=7;
|
_slLightMax<<=7;
|
||||||
_slLightStep>>=1;
|
_slLightStep>>=1;
|
||||||
|
|
||||||
#if (ASMOPT == 1)
|
#if (defined __MSVC_INLINE__)
|
||||||
#if (defined __MSVC_INLINE__)
|
|
||||||
__asm {
|
__asm {
|
||||||
// prepare interpolants
|
// prepare interpolants
|
||||||
movd mm0,D [_slL2Row]
|
movd mm0,D [_slL2Row]
|
||||||
|
@ -1008,7 +984,7 @@ skipPixel:
|
||||||
emms
|
emms
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
ULONG tmp1, tmp2;
|
ULONG tmp1, tmp2;
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
// prepare interpolants
|
// prepare interpolants
|
||||||
|
@ -1091,11 +1067,6 @@ skipPixel:
|
||||||
"cc", "memory"
|
"cc", "memory"
|
||||||
);
|
);
|
||||||
|
|
||||||
#else
|
|
||||||
#error Write inline ASM for your platform.
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
// for each pixel in the shadow map
|
// for each pixel in the shadow map
|
||||||
|
@ -1107,7 +1078,7 @@ skipPixel:
|
||||||
for( PIX pixU=0; pixU<_iPixCt; pixU++)
|
for( PIX pixU=0; pixU<_iPixCt; pixU++)
|
||||||
{
|
{
|
||||||
// if the point is not masked
|
// if the point is not masked
|
||||||
if( *pubMask&ubMask && (slL2Point<FTOX)) {
|
if( (*pubMask & ubMask) && (slL2Point<FTOX)) {
|
||||||
SLONG sl1oL = (slL2Point>>SHIFTX)&(SQRTTABLESIZE-1); // and is just for degenerate cases
|
SLONG sl1oL = (slL2Point>>SHIFTX)&(SQRTTABLESIZE-1); // and is just for degenerate cases
|
||||||
sl1oL = auw1oSqrt[sl1oL];
|
sl1oL = auw1oSqrt[sl1oL];
|
||||||
SLONG slIntensity = _slLightMax;
|
SLONG slIntensity = _slLightMax;
|
||||||
|
@ -1201,8 +1172,7 @@ BOOL CLayerMixer::PrepareOneLayerPoint( CBrushShadowLayer *pbsl, BOOL bNoMask)
|
||||||
FLOAT fDL2oDV = fDDL2oDV + 2*(lm_vStepV%v00);
|
FLOAT fDL2oDV = fDDL2oDV + 2*(lm_vStepV%v00);
|
||||||
//_v00 = v00;
|
//_v00 = v00;
|
||||||
|
|
||||||
#if ((ASMOPT == 1) && (!defined __GNU_INLINE__))
|
#if (defined __MSVC_INLINE__)
|
||||||
#if (defined __MSVC_INLINE__)
|
|
||||||
__asm {
|
__asm {
|
||||||
fld D [fDDL2oDU]
|
fld D [fDDL2oDU]
|
||||||
fadd D [fDDL2oDU]
|
fadd D [fDDL2oDU]
|
||||||
|
@ -1230,12 +1200,6 @@ BOOL CLayerMixer::PrepareOneLayerPoint( CBrushShadowLayer *pbsl, BOOL bNoMask)
|
||||||
fistp D [_slDDL2oDV]
|
fistp D [_slDDL2oDV]
|
||||||
fistp D [_slDDL2oDU]
|
fistp D [_slDDL2oDU]
|
||||||
}
|
}
|
||||||
#elif (defined __GNU_INLINE__)
|
|
||||||
STUBBED("inline asm.");
|
|
||||||
#else
|
|
||||||
#error Please write inline assembly for your platform.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
fDDL2oDU *= 2;
|
fDDL2oDU *= 2;
|
||||||
fDDL2oDV *= 2;
|
fDDL2oDV *= 2;
|
||||||
|
@ -1321,8 +1285,7 @@ void CLayerMixer::AddOneLayerGradient( CGradientParameters &gp)
|
||||||
_pulLayer = lm_pulShadowMap;
|
_pulLayer = lm_pulShadowMap;
|
||||||
FLOAT fStart = Clamp( fGr00-(fDGroDJ+fDGroDI)*0.5f, 0.0f, 1.0f);
|
FLOAT fStart = Clamp( fGr00-(fDGroDJ+fDGroDI)*0.5f, 0.0f, 1.0f);
|
||||||
|
|
||||||
#if ((ASMOPT == 1) && (!defined __GNU_INLINE__))
|
#if (defined __MSVC_INLINE__)
|
||||||
#if (defined __MSVC_INLINE__)
|
|
||||||
__int64 mmRowAdv;
|
__int64 mmRowAdv;
|
||||||
SLONG fixGRow = (fGr00-(fDGroDJ+fDGroDI)*0.5f)*32767.0f; // 16:15
|
SLONG fixGRow = (fGr00-(fDGroDJ+fDGroDI)*0.5f)*32767.0f; // 16:15
|
||||||
SLONG slModulo = (lm_pixCanvasSizeU-lm_pixPolygonSizeU) *BYTES_PER_TEXEL;
|
SLONG slModulo = (lm_pixCanvasSizeU-lm_pixPolygonSizeU) *BYTES_PER_TEXEL;
|
||||||
|
@ -1436,14 +1399,6 @@ rowNext:
|
||||||
rowDone:
|
rowDone:
|
||||||
emms
|
emms
|
||||||
}
|
}
|
||||||
#elif (defined __GNU_INLINE__)
|
|
||||||
|
|
||||||
STUBBED("WRITE ME. Argh.");
|
|
||||||
|
|
||||||
#else
|
|
||||||
#error Need inline assembly for your platform.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
// well, make gradient ...
|
// well, make gradient ...
|
||||||
SLONG slR0=0,slG0=0,slB0=0;
|
SLONG slR0=0,slG0=0,slB0=0;
|
||||||
|
@ -1528,9 +1483,8 @@ rowDone:
|
||||||
// apply directional light or ambient to layer
|
// apply directional light or ambient to layer
|
||||||
void CLayerMixer::AddDirectional(void)
|
void CLayerMixer::AddDirectional(void)
|
||||||
{
|
{
|
||||||
#if ASMOPT == 1
|
#if (defined __MSVC_INLINE__)
|
||||||
ULONG ulLight = ByteSwap( lm_colLight);
|
ULONG ulLight = ByteSwap( lm_colLight);
|
||||||
#if (defined __MSVC_INLINE__)
|
|
||||||
__asm {
|
__asm {
|
||||||
// prepare pointers and variables
|
// prepare pointers and variables
|
||||||
mov edi,D [_pulLayer]
|
mov edi,D [_pulLayer]
|
||||||
|
@ -1565,7 +1519,8 @@ rowNext:
|
||||||
emms
|
emms
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
|
ULONG ulLight = ByteSwap( lm_colLight);
|
||||||
ULONG tmp;
|
ULONG tmp;
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
// prepare pointers and variables
|
// prepare pointers and variables
|
||||||
|
@ -1608,10 +1563,6 @@ rowNext:
|
||||||
: FPU_REGS, "mm5", "mm6", "ecx", "edi", "cc", "memory"
|
: FPU_REGS, "mm5", "mm6", "ecx", "edi", "cc", "memory"
|
||||||
);
|
);
|
||||||
|
|
||||||
#else
|
|
||||||
#error Write inline assembly for your platform.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
UBYTE* pubLayer = (UBYTE*)_pulLayer;
|
UBYTE* pubLayer = (UBYTE*)_pulLayer;
|
||||||
// for each pixel in the shadow map
|
// for each pixel in the shadow map
|
||||||
|
@ -1631,9 +1582,8 @@ rowNext:
|
||||||
// apply directional light thru mask to layer
|
// apply directional light thru mask to layer
|
||||||
void CLayerMixer::AddMaskDirectional( UBYTE *pubMask, UBYTE ubMask)
|
void CLayerMixer::AddMaskDirectional( UBYTE *pubMask, UBYTE ubMask)
|
||||||
{
|
{
|
||||||
#if ASMOPT == 1
|
#if (defined __MSVC_INLINE__)
|
||||||
ULONG ulLight = ByteSwap( lm_colLight);
|
ULONG ulLight = ByteSwap( lm_colLight);
|
||||||
#if (defined __MSVC_INLINE__)
|
|
||||||
// prepare some local variables
|
// prepare some local variables
|
||||||
__asm {
|
__asm {
|
||||||
// prepare pointers and variables
|
// prepare pointers and variables
|
||||||
|
@ -1665,7 +1615,8 @@ skipLight:
|
||||||
emms
|
emms
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
|
ULONG ulLight = ByteSwap( lm_colLight);
|
||||||
ULONG tmp;
|
ULONG tmp;
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
// prepare pointers and variables
|
// prepare pointers and variables
|
||||||
|
@ -1706,10 +1657,6 @@ skipLight:
|
||||||
"cc", "memory"
|
"cc", "memory"
|
||||||
);
|
);
|
||||||
|
|
||||||
#else
|
|
||||||
#error Please write inline assembly for your platform.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
UBYTE* pubLayer = (UBYTE*)_pulLayer;
|
UBYTE* pubLayer = (UBYTE*)_pulLayer;
|
||||||
// for each pixel in the shadow map
|
// for each pixel in the shadow map
|
||||||
|
@ -1764,7 +1711,7 @@ void CLayerMixer::AddOneLayerDirectional( CBrushShadowLayer *pbsl, UBYTE *pubMas
|
||||||
|
|
||||||
// get the light source of the layer
|
// get the light source of the layer
|
||||||
lm_plsLight = pbsl->bsl_plsLightSource;
|
lm_plsLight = pbsl->bsl_plsLightSource;
|
||||||
const FLOAT3D &vLight = lm_plsLight->ls_penEntity->GetPlacement().pl_PositionVector;
|
//const FLOAT3D &vLight = lm_plsLight->ls_penEntity->GetPlacement().pl_PositionVector;
|
||||||
AnglesToDirectionVector( lm_plsLight->ls_penEntity->GetPlacement().pl_OrientationAngle,
|
AnglesToDirectionVector( lm_plsLight->ls_penEntity->GetPlacement().pl_OrientationAngle,
|
||||||
lm_vLightDirection);
|
lm_vLightDirection);
|
||||||
// calculate intensity
|
// calculate intensity
|
||||||
|
@ -1823,8 +1770,9 @@ void CLayerMixer::MixOneMipmap(CBrushShadowMap *pbsm, INDEX iMipmap)
|
||||||
if( lm_pbpoPolygon->bpo_ulFlags&BPOF_HASDIRECTIONALAMBIENT) {
|
if( lm_pbpoPolygon->bpo_ulFlags&BPOF_HASDIRECTIONALAMBIENT) {
|
||||||
{FOREACHINLIST( CBrushShadowLayer, bsl_lnInShadowMap, lm_pbsmShadowMap->bsm_lhLayers, itbsl) {
|
{FOREACHINLIST( CBrushShadowLayer, bsl_lnInShadowMap, lm_pbsmShadowMap->bsm_lhLayers, itbsl) {
|
||||||
CBrushShadowLayer &bsl = *itbsl;
|
CBrushShadowLayer &bsl = *itbsl;
|
||||||
|
ASSERT( bsl.bsl_plsLightSource!=NULL);
|
||||||
|
if( bsl.bsl_plsLightSource==NULL) continue; // safety check
|
||||||
CLightSource &ls = *bsl.bsl_plsLightSource;
|
CLightSource &ls = *bsl.bsl_plsLightSource;
|
||||||
ASSERT( &ls!=NULL); if( &ls==NULL) continue; // safety check
|
|
||||||
if( !(ls.ls_ulFlags&LSF_DIRECTIONAL)) continue; // skip non-directional layers
|
if( !(ls.ls_ulFlags&LSF_DIRECTIONAL)) continue; // skip non-directional layers
|
||||||
COLOR col = AdjustColor( ls.GetLightAmbient(), _slShdHueShift, _slShdSaturation);
|
COLOR col = AdjustColor( ls.GetLightAmbient(), _slShdHueShift, _slShdSaturation);
|
||||||
colAmbient = AddColors( colAmbient, col);
|
colAmbient = AddColors( colAmbient, col);
|
||||||
|
@ -1832,7 +1780,33 @@ void CLayerMixer::MixOneMipmap(CBrushShadowMap *pbsm, INDEX iMipmap)
|
||||||
}
|
}
|
||||||
} // set initial color
|
} // set initial color
|
||||||
|
|
||||||
#if (defined USE_PORTABLE_C)
|
#if (defined __MSVC_INLINE__)
|
||||||
|
__asm {
|
||||||
|
cld
|
||||||
|
mov ebx,D [this]
|
||||||
|
mov ecx,D [ebx].lm_pixCanvasSizeU
|
||||||
|
imul ecx,D [ebx].lm_pixCanvasSizeV
|
||||||
|
mov edi,D [ebx].lm_pulShadowMap
|
||||||
|
mov eax,D [colAmbient]
|
||||||
|
bswap eax
|
||||||
|
rep stosd
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
|
ULONG clob1, clob2, clob3;
|
||||||
|
__asm__ __volatile__ (
|
||||||
|
"cld \n\t"
|
||||||
|
"imull %%esi, %%ecx \n\t"
|
||||||
|
"bswapl %%eax \n\t"
|
||||||
|
"rep \n\t"
|
||||||
|
"stosl \n\t"
|
||||||
|
: "=a" (clob1), "=c" (clob2), "=D" (clob3)
|
||||||
|
: "c" (this->lm_pixCanvasSizeU), "S" (this->lm_pixCanvasSizeV),
|
||||||
|
"a" (colAmbient), "D" (this->lm_pulShadowMap)
|
||||||
|
: "cc", "memory"
|
||||||
|
);
|
||||||
|
|
||||||
|
#else
|
||||||
register ULONG count = this->lm_pixCanvasSizeU * this->lm_pixCanvasSizeV;
|
register ULONG count = this->lm_pixCanvasSizeU * this->lm_pixCanvasSizeV;
|
||||||
#if PLATFORM_LITTLEENDIAN
|
#if PLATFORM_LITTLEENDIAN
|
||||||
// Forces C fallback; BYTESWAP itself is a no-op on little endian.
|
// Forces C fallback; BYTESWAP itself is a no-op on little endian.
|
||||||
|
@ -1850,35 +1824,7 @@ void CLayerMixer::MixOneMipmap(CBrushShadowMap *pbsm, INDEX iMipmap)
|
||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif (defined __MSVC_INLINE__)
|
#endif
|
||||||
__asm {
|
|
||||||
cld
|
|
||||||
mov ebx,D [this]
|
|
||||||
mov ecx,D [ebx].lm_pixCanvasSizeU
|
|
||||||
imul ecx,D [ebx].lm_pixCanvasSizeV
|
|
||||||
mov edi,D [ebx].lm_pulShadowMap
|
|
||||||
mov eax,D [colAmbient]
|
|
||||||
bswap eax
|
|
||||||
rep stosd
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
|
||||||
ULONG clob1, clob2, clob3;
|
|
||||||
__asm__ __volatile__ (
|
|
||||||
"cld \n\t"
|
|
||||||
"imull %%esi, %%ecx \n\t"
|
|
||||||
"bswapl %%eax \n\t"
|
|
||||||
"rep \n\t"
|
|
||||||
"stosl \n\t"
|
|
||||||
: "=a" (clob1), "=c" (clob2), "=D" (clob3)
|
|
||||||
: "c" (this->lm_pixCanvasSizeU), "S" (this->lm_pixCanvasSizeV),
|
|
||||||
"a" (colAmbient), "D" (this->lm_pulShadowMap)
|
|
||||||
: "cc", "memory"
|
|
||||||
);
|
|
||||||
|
|
||||||
#else
|
|
||||||
#error Please write inline assembly for your platform.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_pfWorldEditingProfile.StopTimer(CWorldEditingProfile::PTI_AMBIENTFILL);
|
_pfWorldEditingProfile.StopTimer(CWorldEditingProfile::PTI_AMBIENTFILL);
|
||||||
|
|
||||||
|
@ -1898,11 +1844,12 @@ void CLayerMixer::MixOneMipmap(CBrushShadowMap *pbsm, INDEX iMipmap)
|
||||||
{FORDELETELIST( CBrushShadowLayer, bsl_lnInShadowMap, lm_pbsmShadowMap->bsm_lhLayers, itbsl)
|
{FORDELETELIST( CBrushShadowLayer, bsl_lnInShadowMap, lm_pbsmShadowMap->bsm_lhLayers, itbsl)
|
||||||
{
|
{
|
||||||
CBrushShadowLayer &bsl = *itbsl;
|
CBrushShadowLayer &bsl = *itbsl;
|
||||||
|
ASSERT( bsl.bsl_plsLightSource!=NULL);
|
||||||
|
if( bsl.bsl_plsLightSource==NULL) continue; // safety check
|
||||||
CLightSource &ls = *bsl.bsl_plsLightSource;
|
CLightSource &ls = *bsl.bsl_plsLightSource;
|
||||||
ASSERT( &ls!=NULL); if( &ls==NULL) continue; // safety check
|
|
||||||
|
|
||||||
// skip if should not be applied
|
// skip if should not be applied
|
||||||
if( (bDynamicOnly && !(ls.ls_ulFlags&LSF_NONPERSISTENT)) || ls.ls_ulFlags&LSF_DYNAMIC) continue;
|
if( (bDynamicOnly && !(ls.ls_ulFlags&LSF_NONPERSISTENT)) || (ls.ls_ulFlags & LSF_DYNAMIC)) continue;
|
||||||
|
|
||||||
// set corresponding shadowmap flag if this is an animating light
|
// set corresponding shadowmap flag if this is an animating light
|
||||||
if( ls.ls_paoLightAnimation!=NULL) lm_pbsmShadowMap->sm_ulFlags |= SMF_ANIMATINGLIGHTS;
|
if( ls.ls_paoLightAnimation!=NULL) lm_pbsmShadowMap->sm_ulFlags |= SMF_ANIMATINGLIGHTS;
|
||||||
|
@ -1955,9 +1902,7 @@ void CLayerMixer::MixOneMipmap(CBrushShadowMap *pbsm, INDEX iMipmap)
|
||||||
// copy from static shadow map to dynamic layer
|
// copy from static shadow map to dynamic layer
|
||||||
__forceinline void CLayerMixer::CopyShadowLayer(void)
|
__forceinline void CLayerMixer::CopyShadowLayer(void)
|
||||||
{
|
{
|
||||||
#if (defined USE_PORTABLE_C)
|
#if (defined __MSVC_INLINE__)
|
||||||
memcpy(lm_pulShadowMap, lm_pulStaticShadowMap, lm_pixCanvasSizeU*lm_pixCanvasSizeV*4);
|
|
||||||
#elif (defined __MSVC_INLINE__)
|
|
||||||
__asm {
|
__asm {
|
||||||
cld
|
cld
|
||||||
mov ebx,D [this]
|
mov ebx,D [this]
|
||||||
|
@ -1967,7 +1912,7 @@ __forceinline void CLayerMixer::CopyShadowLayer(void)
|
||||||
mov edi,D [ebx].lm_pulShadowMap
|
mov edi,D [ebx].lm_pulShadowMap
|
||||||
rep movsd
|
rep movsd
|
||||||
}
|
}
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
ULONG clob1, clob2, clob3;
|
ULONG clob1, clob2, clob3;
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"cld \n\t"
|
"cld \n\t"
|
||||||
|
@ -1980,21 +1925,16 @@ __forceinline void CLayerMixer::CopyShadowLayer(void)
|
||||||
: "cc", "memory"
|
: "cc", "memory"
|
||||||
);
|
);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error Please write inline assembly for your platform.
|
memcpy(lm_pulShadowMap, lm_pulStaticShadowMap, lm_pixCanvasSizeU*lm_pixCanvasSizeV*4);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// copy from static shadow map to dynamic layer
|
// copy from static shadow map to dynamic layer
|
||||||
__forceinline void CLayerMixer::FillShadowLayer( COLOR col)
|
__forceinline void CLayerMixer::FillShadowLayer( COLOR col)
|
||||||
{
|
{
|
||||||
#if (defined USE_PORTABLE_C)
|
#if (defined __MSVC_INLINE__)
|
||||||
DWORD* dst = (DWORD*)lm_pulShadowMap;
|
|
||||||
int n = lm_pixCanvasSizeU*lm_pixCanvasSizeV;
|
|
||||||
DWORD color = __builtin_bswap32(col);
|
|
||||||
while(n--) {*(dst++)=color;}
|
|
||||||
#elif (defined __MSVC_INLINE__)
|
|
||||||
__asm {
|
__asm {
|
||||||
cld
|
cld
|
||||||
mov ebx,D [this]
|
mov ebx,D [this]
|
||||||
|
@ -2006,7 +1946,7 @@ __forceinline void CLayerMixer::FillShadowLayer( COLOR col)
|
||||||
rep stosd
|
rep stosd
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
ULONG clob1, clob2, clob3;
|
ULONG clob1, clob2, clob3;
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"cld \n\t"
|
"cld \n\t"
|
||||||
|
@ -2020,9 +1960,12 @@ __forceinline void CLayerMixer::FillShadowLayer( COLOR col)
|
||||||
: "cc", "memory"
|
: "cc", "memory"
|
||||||
);
|
);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error Please write inline assembly for your platform.
|
DWORD* dst = (DWORD*)lm_pulShadowMap;
|
||||||
#endif
|
int n = lm_pixCanvasSizeU*lm_pixCanvasSizeV;
|
||||||
|
DWORD color = BYTESWAP32_unsigned(col);
|
||||||
|
while(n--) {*(dst++)=color;}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,20 +24,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#define _PC_64 0x0300
|
#define _PC_64 0x0300
|
||||||
|
|
||||||
// !!! FIXME: I'd like to remove any dependency on the FPU control word from the game, asap. --ryan.
|
// !!! FIXME: I'd like to remove any dependency on the FPU control word from the game, asap. --ryan.
|
||||||
#ifdef USE_PORTABLE_C
|
#if (defined _MSC_VER)
|
||||||
// Fake control87 for USE_PORTABLE_C version
|
|
||||||
inline ULONG _control87(WORD newcw, WORD mask)
|
|
||||||
{
|
|
||||||
static WORD fpw=_PC_64;
|
|
||||||
if (mask != 0)
|
|
||||||
{
|
|
||||||
fpw &= ~mask;
|
|
||||||
fpw |= (newcw & mask);
|
|
||||||
}
|
|
||||||
return(fpw);
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
// _control87 is provided by the compiler
|
||||||
|
|
||||||
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
|
|
||||||
inline ULONG _control87(WORD newcw, WORD mask)
|
inline ULONG _control87(WORD newcw, WORD mask)
|
||||||
{
|
{
|
||||||
|
@ -74,8 +65,20 @@ inline ULONG _control87(WORD newcw, WORD mask)
|
||||||
return(fpw);
|
return(fpw);
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif (!defined _MSC_VER)
|
#else
|
||||||
#error Implement for your platform, or add a stub conditional here.
|
|
||||||
|
// Fake control87 for USE_PORTABLE_C version
|
||||||
|
inline ULONG _control87(WORD newcw, WORD mask)
|
||||||
|
{
|
||||||
|
static WORD fpw=_PC_64;
|
||||||
|
if (mask != 0)
|
||||||
|
{
|
||||||
|
fpw &= ~mask;
|
||||||
|
fpw |= (newcw & mask);
|
||||||
|
}
|
||||||
|
return(fpw);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Get current precision setting of FPU. */
|
/* Get current precision setting of FPU. */
|
||||||
|
|
|
@ -312,12 +312,7 @@ inline FLOAT NormByteToFloat( const ULONG ul)
|
||||||
// fast float to int conversion
|
// fast float to int conversion
|
||||||
inline SLONG FloatToInt( FLOAT f)
|
inline SLONG FloatToInt( FLOAT f)
|
||||||
{
|
{
|
||||||
#if defined(__arm__) || defined(USE_PORTABLE_C)
|
#if (defined __MSVC_INLINE__)
|
||||||
// round to nearest by adding/subtracting 0.5 (depending on f pos/neg) before converting to SLONG
|
|
||||||
float addToRound = copysignf(0.5f, f); // copy f's signbit to 0.5 => if f<0 then addToRound = -0.5, else 0.5
|
|
||||||
return((SLONG) (f + addToRound));
|
|
||||||
|
|
||||||
#elif (defined __MSVC_INLINE__)
|
|
||||||
SLONG slRet;
|
SLONG slRet;
|
||||||
__asm {
|
__asm {
|
||||||
fld D [f]
|
fld D [f]
|
||||||
|
@ -325,7 +320,7 @@ inline SLONG FloatToInt( FLOAT f)
|
||||||
}
|
}
|
||||||
return slRet;
|
return slRet;
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
SLONG slRet;
|
SLONG slRet;
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"flds (%%eax) \n\t"
|
"flds (%%eax) \n\t"
|
||||||
|
@ -336,16 +331,16 @@ inline SLONG FloatToInt( FLOAT f)
|
||||||
);
|
);
|
||||||
return(slRet);
|
return(slRet);
|
||||||
#else
|
#else
|
||||||
#error Fill this in for your platform.
|
// round to nearest by adding/subtracting 0.5 (depending on f pos/neg) before converting to SLONG
|
||||||
|
float addToRound = copysignf(0.5f, f); // copy f's signbit to 0.5 => if f<0 then addToRound = -0.5, else 0.5
|
||||||
|
return((SLONG) (f + addToRound));
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// log base 2 of any float numero
|
// log base 2 of any float numero
|
||||||
inline FLOAT Log2( FLOAT f) {
|
inline FLOAT Log2( FLOAT f) {
|
||||||
#if (defined USE_PORTABLE_C) || defined(__arm__)
|
#if (defined __MSVC_INLINE__)
|
||||||
return log2f(f);
|
|
||||||
|
|
||||||
#elif (defined __MSVC_INLINE__)
|
|
||||||
FLOAT fRet;
|
FLOAT fRet;
|
||||||
_asm {
|
_asm {
|
||||||
fld1
|
fld1
|
||||||
|
@ -355,7 +350,7 @@ inline FLOAT Log2( FLOAT f) {
|
||||||
}
|
}
|
||||||
return fRet;
|
return fRet;
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
FLOAT fRet;
|
FLOAT fRet;
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"fld1 \n\t"
|
"fld1 \n\t"
|
||||||
|
@ -368,7 +363,8 @@ inline FLOAT Log2( FLOAT f) {
|
||||||
);
|
);
|
||||||
return(fRet);
|
return(fRet);
|
||||||
#else
|
#else
|
||||||
#error Fill this in for your platform.
|
return log2f(f);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,8 +372,24 @@ inline FLOAT Log2( FLOAT f) {
|
||||||
// returns accurate values only for integers that are power of 2
|
// returns accurate values only for integers that are power of 2
|
||||||
inline SLONG FastLog2( SLONG x)
|
inline SLONG FastLog2( SLONG x)
|
||||||
{
|
{
|
||||||
#if (defined USE_PORTABLE_C)
|
#if (defined __MSVC_INLINE__)
|
||||||
#ifdef __GNUC__
|
SLONG slRet;
|
||||||
|
__asm {
|
||||||
|
bsr eax,D [x]
|
||||||
|
mov D [slRet],eax
|
||||||
|
}
|
||||||
|
return slRet;
|
||||||
|
|
||||||
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
|
SLONG slRet;
|
||||||
|
__asm__ __volatile__ (
|
||||||
|
"bsrl %%ecx, %%eax \n\t"
|
||||||
|
: "=a" (slRet)
|
||||||
|
: "c" (x)
|
||||||
|
: "memory"
|
||||||
|
);
|
||||||
|
return(slRet);
|
||||||
|
#elif (defined __GNUC__)
|
||||||
if(x == 0) return 0; // __builtin_clz() is undefined for 0
|
if(x == 0) return 0; // __builtin_clz() is undefined for 0
|
||||||
int numLeadingZeros = __builtin_clz(x);
|
int numLeadingZeros = __builtin_clz(x);
|
||||||
return 31 - numLeadingZeros;
|
return 31 - numLeadingZeros;
|
||||||
|
@ -393,38 +405,13 @@ inline SLONG FastLog2( SLONG x)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif (defined __MSVC_INLINE__)
|
|
||||||
SLONG slRet;
|
|
||||||
__asm {
|
|
||||||
bsr eax,D [x]
|
|
||||||
mov D [slRet],eax
|
|
||||||
}
|
|
||||||
return slRet;
|
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
|
||||||
SLONG slRet;
|
|
||||||
__asm__ __volatile__ (
|
|
||||||
"bsrl %%ecx, %%eax \n\t"
|
|
||||||
: "=a" (slRet)
|
|
||||||
: "c" (x)
|
|
||||||
: "memory"
|
|
||||||
);
|
|
||||||
return(slRet);
|
|
||||||
#else
|
|
||||||
#error Fill this in for your platform.
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* DG: function is unused => doesn't matter that portable implementation is not optimal :)
|
/* DG: function is unused => doesn't matter that portable implementation is not optimal :)
|
||||||
// returns log2 of first larger value that is a power of 2
|
// returns log2 of first larger value that is a power of 2
|
||||||
inline SLONG FastMaxLog2( SLONG x)
|
inline SLONG FastMaxLog2( SLONG x)
|
||||||
{
|
{
|
||||||
#if (defined USE_PORTABLE_C)
|
#if (defined __MSVC_INLINE__)
|
||||||
printf("CHECK THIS: %s:%d\n", __FILE__, __LINE__);
|
|
||||||
return((SLONG) log2((double) x));
|
|
||||||
|
|
||||||
#elif (defined __MSVC_INLINE__)
|
|
||||||
SLONG slRet;
|
SLONG slRet;
|
||||||
__asm {
|
__asm {
|
||||||
bsr eax,D [x]
|
bsr eax,D [x]
|
||||||
|
@ -435,7 +422,7 @@ printf("CHECK THIS: %s:%d\n", __FILE__, __LINE__);
|
||||||
}
|
}
|
||||||
return slRet;
|
return slRet;
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
SLONG slRet;
|
SLONG slRet;
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"bsrl %%ecx, %%eax \n\t"
|
"bsrl %%ecx, %%eax \n\t"
|
||||||
|
@ -448,7 +435,9 @@ printf("CHECK THIS: %s:%d\n", __FILE__, __LINE__);
|
||||||
);
|
);
|
||||||
return(slRet);
|
return(slRet);
|
||||||
#else
|
#else
|
||||||
#error Fill this in for your platform.
|
printf("CHECK THIS: %s:%d\n", __FILE__, __LINE__);
|
||||||
|
return((SLONG) log2((double) x));
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -81,7 +81,7 @@ void CObject3D::Project(CSimpleProjection3D_DOUBLE &pr)
|
||||||
BOOL bXInverted = vObjectStretch(1)<0;
|
BOOL bXInverted = vObjectStretch(1)<0;
|
||||||
BOOL bYInverted = vObjectStretch(2)<0;
|
BOOL bYInverted = vObjectStretch(2)<0;
|
||||||
BOOL bZInverted = vObjectStretch(3)<0;
|
BOOL bZInverted = vObjectStretch(3)<0;
|
||||||
BOOL bInverted = bXInverted!=bYInverted!=bZInverted;
|
BOOL bInverted = (bXInverted != bYInverted) != bZInverted;
|
||||||
|
|
||||||
// for all sectors
|
// for all sectors
|
||||||
FOREACHINDYNAMICARRAY(ob_aoscSectors, CObjectSector, itsc) {
|
FOREACHINDYNAMICARRAY(ob_aoscSectors, CObjectSector, itsc) {
|
||||||
|
|
|
@ -90,6 +90,7 @@ static int qsort_CompareVerticesAlongLine(const void *pvVertex0, const void *pvV
|
||||||
CObjectVertex &vx1 = **(CObjectVertex **)pvVertex1;
|
CObjectVertex &vx1 = **(CObjectVertex **)pvVertex1;
|
||||||
return CompareVerticesAlongLine(vx0, vx1);
|
return CompareVerticesAlongLine(vx0, vx1);
|
||||||
}
|
}
|
||||||
|
#if 0 // DG: unused.
|
||||||
/*
|
/*
|
||||||
* Compare two vertices along a line for quick-sort - reversely.
|
* Compare two vertices along a line for quick-sort - reversely.
|
||||||
*/
|
*/
|
||||||
|
@ -99,6 +100,7 @@ static int qsort_CompareVerticesAlongLineReversely(const void *pvVertex0, const
|
||||||
CObjectVertex &vx1 = **(CObjectVertex **)pvVertex1;
|
CObjectVertex &vx1 = **(CObjectVertex **)pvVertex1;
|
||||||
return -CompareVerticesAlongLine(vx0, vx1);
|
return -CompareVerticesAlongLine(vx0, vx1);
|
||||||
}
|
}
|
||||||
|
#endif // 0 (unused)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -254,7 +256,7 @@ void CObjectPolygonEdge::GetVertices(CObjectVertex *&povxStart, CObjectVertex *&
|
||||||
* Default constructor.
|
* Default constructor.
|
||||||
*/
|
*/
|
||||||
CObjectSector::CObjectSector(void) :
|
CObjectSector::CObjectSector(void) :
|
||||||
osc_colAmbient(0), osc_colColor(0), osc_strName("")
|
osc_colColor(0), osc_colAmbient(0), osc_strName("")
|
||||||
{
|
{
|
||||||
osc_ulFlags[0] = 0;
|
osc_ulFlags[0] = 0;
|
||||||
osc_ulFlags[1] = 0;
|
osc_ulFlags[1] = 0;
|
||||||
|
@ -548,6 +550,7 @@ CObjectPolygon *CObjectSector::CreatePolygon(INDEX ctVertices, INDEX aivVertices
|
||||||
void CObjectSector::CheckOptimizationAlgorithm(void)
|
void CObjectSector::CheckOptimizationAlgorithm(void)
|
||||||
{
|
{
|
||||||
// for vertices
|
// for vertices
|
||||||
|
#if 0 // DG: this doesn't really do anything?!
|
||||||
FOREACHINDYNAMICARRAY(osc_aovxVertices, CObjectVertex, itvx1) {
|
FOREACHINDYNAMICARRAY(osc_aovxVertices, CObjectVertex, itvx1) {
|
||||||
FOREACHINDYNAMICARRAY(osc_aovxVertices, CObjectVertex, itvx2) {
|
FOREACHINDYNAMICARRAY(osc_aovxVertices, CObjectVertex, itvx2) {
|
||||||
CObjectVertex &vx1 = itvx1.Current();
|
CObjectVertex &vx1 = itvx1.Current();
|
||||||
|
@ -555,6 +558,7 @@ void CObjectSector::CheckOptimizationAlgorithm(void)
|
||||||
// !!!!why this fails sometimes ?(on spheres) ASSERT( (&vx1 == &vx2) || (CompareVertices(vx1, vx2)!=0) );
|
// !!!!why this fails sometimes ?(on spheres) ASSERT( (&vx1 == &vx2) || (CompareVertices(vx1, vx2)!=0) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // 0
|
||||||
|
|
||||||
// for planes
|
// for planes
|
||||||
FOREACHINDYNAMICARRAY(osc_aoplPlanes, CObjectPlane, itpl1) {
|
FOREACHINDYNAMICARRAY(osc_aoplPlanes, CObjectPlane, itpl1) {
|
||||||
|
@ -600,7 +604,7 @@ void CObjectSector::CheckOptimizationAlgorithm(void)
|
||||||
{FOREACHINDYNAMICARRAY(osc_aopoPolygons, CObjectPolygon, itopo) {
|
{FOREACHINDYNAMICARRAY(osc_aopoPolygons, CObjectPolygon, itopo) {
|
||||||
// for each edge in polygon
|
// for each edge in polygon
|
||||||
{FOREACHINDYNAMICARRAY(itopo->opo_PolygonEdges, CObjectPolygonEdge, itope) {
|
{FOREACHINDYNAMICARRAY(itopo->opo_PolygonEdges, CObjectPolygonEdge, itope) {
|
||||||
CObjectEdge &oedThis = *itope->ope_Edge;
|
//CObjectEdge &oedThis = *itope->ope_Edge;
|
||||||
CObjectVertex *povxStartThis, *povxEndThis;
|
CObjectVertex *povxStartThis, *povxEndThis;
|
||||||
// get start and end vertices
|
// get start and end vertices
|
||||||
itope->GetVertices(povxStartThis, povxEndThis);
|
itope->GetVertices(povxStartThis, povxEndThis);
|
||||||
|
@ -629,7 +633,7 @@ BOOL CObjectSector::ArePolygonsPlanar(void)
|
||||||
{FOREACHINDYNAMICARRAY(osc_aopoPolygons, CObjectPolygon, itopo) {
|
{FOREACHINDYNAMICARRAY(osc_aopoPolygons, CObjectPolygon, itopo) {
|
||||||
// for each edge in polygon
|
// for each edge in polygon
|
||||||
{FOREACHINDYNAMICARRAY(itopo->opo_PolygonEdges, CObjectPolygonEdge, itope) {
|
{FOREACHINDYNAMICARRAY(itopo->opo_PolygonEdges, CObjectPolygonEdge, itope) {
|
||||||
CObjectEdge &oedThis = *itope->ope_Edge;
|
//CObjectEdge &oedThis = *itope->ope_Edge;
|
||||||
CObjectVertex *povxStartThis, *povxEndThis;
|
CObjectVertex *povxStartThis, *povxEndThis;
|
||||||
// get start and end vertices
|
// get start and end vertices
|
||||||
itope->GetVertices(povxStartThis, povxEndThis);
|
itope->GetVertices(povxStartThis, povxEndThis);
|
||||||
|
@ -715,7 +719,7 @@ void CObjectSector::RemapClonedPlanes(void)
|
||||||
/*
|
/*
|
||||||
* Remap different vertices with same coordinates to use only one of each.
|
* Remap different vertices with same coordinates to use only one of each.
|
||||||
*/
|
*/
|
||||||
static BOOL bBug=FALSE;
|
//static BOOL bBug=FALSE;
|
||||||
void CObjectSector::RemapClonedVertices(void)
|
void CObjectSector::RemapClonedVertices(void)
|
||||||
{
|
{
|
||||||
// if there are no vertices in the sector
|
// if there are no vertices in the sector
|
||||||
|
@ -1107,14 +1111,14 @@ void CObjectPolygon::JoinContinuingEdges(CDynamicArray<CObjectEdge> &oedEdges)
|
||||||
// create an empty array for newly created edges
|
// create an empty array for newly created edges
|
||||||
CDynamicArray<CObjectPolygonEdge> aopeNew;
|
CDynamicArray<CObjectPolygonEdge> aopeNew;
|
||||||
// set the counter of edges to current number of edges
|
// set the counter of edges to current number of edges
|
||||||
INDEX ctEdges = opo_PolygonEdges.Count();
|
//INDEX ctEdges = opo_PolygonEdges.Count();
|
||||||
|
|
||||||
// for each edge
|
// for each edge
|
||||||
{FOREACHINDYNAMICARRAY(opo_PolygonEdges, CObjectPolygonEdge, itope) {
|
{FOREACHINDYNAMICARRAY(opo_PolygonEdges, CObjectPolygonEdge, itope) {
|
||||||
CObjectEdge &oedThis = *itope->ope_Edge;
|
CObjectEdge *poedThis = itope->ope_Edge;
|
||||||
|
|
||||||
// if not already marked for removal
|
// if not already marked for removal
|
||||||
if (&oedThis != NULL) {
|
if (poedThis != NULL) {
|
||||||
CObjectVertex *povxStartThis, *povxEndThis;
|
CObjectVertex *povxStartThis, *povxEndThis;
|
||||||
// get start and end vertices
|
// get start and end vertices
|
||||||
itope->GetVertices(povxStartThis, povxEndThis);
|
itope->GetVertices(povxStartThis, povxEndThis);
|
||||||
|
@ -1129,12 +1133,12 @@ void CObjectPolygon::JoinContinuingEdges(CDynamicArray<CObjectEdge> &oedEdges)
|
||||||
|
|
||||||
// for each edge
|
// for each edge
|
||||||
{FOREACHINDYNAMICARRAY(opo_PolygonEdges, CObjectPolygonEdge, itope2) {
|
{FOREACHINDYNAMICARRAY(opo_PolygonEdges, CObjectPolygonEdge, itope2) {
|
||||||
CObjectEdge &oedOther = *itope2->ope_Edge;
|
CObjectEdge *poedOther = itope2->ope_Edge;
|
||||||
|
|
||||||
// if not already marked for removal
|
// if not already marked for removal
|
||||||
if (&oedOther != NULL) {
|
if (poedOther != NULL) {
|
||||||
// if the two edges are collinear
|
// if the two edges are collinear
|
||||||
if ( CompareEdgeLines(*oedThis.colinear2.oed_pedxLine, *oedOther.colinear2.oed_pedxLine)==0) {
|
if ( CompareEdgeLines(*poedThis->colinear2.oed_pedxLine, *poedOther->colinear2.oed_pedxLine)==0) {
|
||||||
CObjectVertex *povxStartOther, *povxEndOther;
|
CObjectVertex *povxStartOther, *povxEndOther;
|
||||||
// get start and end vertices
|
// get start and end vertices
|
||||||
itope2->GetVertices(povxStartOther, povxEndOther);
|
itope2->GetVertices(povxStartOther, povxEndOther);
|
||||||
|
@ -1186,10 +1190,10 @@ void CObjectSector::SplitCollinearEdgesRun(CStaticArray<CEdgeEx *> &apedxSortedE
|
||||||
if (iFirstInRun>iLastInRun) {
|
if (iFirstInRun>iLastInRun) {
|
||||||
return; // this should not happen, but anyway!
|
return; // this should not happen, but anyway!
|
||||||
}
|
}
|
||||||
CEdgeEx &edxLine = *apedxSortedEdgeLines[iFirstInRun]; // representative line of the run
|
|
||||||
|
|
||||||
/* set up array of vertex pointers */
|
/* set up array of vertex pointers */
|
||||||
/*
|
/*
|
||||||
|
CEdgeEx &edxLine = *apedxSortedEdgeLines[iFirstInRun]; // representative line of the run
|
||||||
// for each vertex in sector
|
// for each vertex in sector
|
||||||
INDEX ctVerticesOnLine=0;
|
INDEX ctVerticesOnLine=0;
|
||||||
{FOREACHINDYNAMICARRAY(osc_aovxVertices, CObjectVertex, itovx) {
|
{FOREACHINDYNAMICARRAY(osc_aovxVertices, CObjectVertex, itovx) {
|
||||||
|
|
|
@ -43,7 +43,9 @@ void CIsometricProjection3D::Prepare(void)
|
||||||
BOOL bYInverted = pr_ObjectStretch(2)<0;
|
BOOL bYInverted = pr_ObjectStretch(2)<0;
|
||||||
BOOL bZInverted = pr_ObjectStretch(3)<0;
|
BOOL bZInverted = pr_ObjectStretch(3)<0;
|
||||||
|
|
||||||
pr_bInverted = bXInverted!=bYInverted!=bZInverted;
|
// DG: this is true if either one of X,Y,Z is inverted, or all three
|
||||||
|
// but not if two or none are inverted.
|
||||||
|
pr_bInverted = (bXInverted != bYInverted) != bZInverted;
|
||||||
|
|
||||||
// if the projection is mirrored
|
// if the projection is mirrored
|
||||||
if (pr_bMirror) {
|
if (pr_bMirror) {
|
||||||
|
|
|
@ -43,7 +43,7 @@ void CParallelProjection3D::Prepare(void)
|
||||||
BOOL bYInverted = pr_ObjectStretch(2)<0;
|
BOOL bYInverted = pr_ObjectStretch(2)<0;
|
||||||
BOOL bZInverted = pr_ObjectStretch(3)<0;
|
BOOL bZInverted = pr_ObjectStretch(3)<0;
|
||||||
|
|
||||||
pr_bInverted = bXInverted!=bYInverted!=bZInverted;
|
pr_bInverted = (bXInverted != bYInverted) != bZInverted;
|
||||||
|
|
||||||
// if the projection is mirrored
|
// if the projection is mirrored
|
||||||
if (pr_bMirror) {
|
if (pr_bMirror) {
|
||||||
|
|
|
@ -52,7 +52,7 @@ void CPerspectiveProjection3D::Prepare(void)
|
||||||
BOOL bYInverted = pr_ObjectStretch(2)<0;
|
BOOL bYInverted = pr_ObjectStretch(2)<0;
|
||||||
BOOL bZInverted = pr_ObjectStretch(3)<0;
|
BOOL bZInverted = pr_ObjectStretch(3)<0;
|
||||||
|
|
||||||
pr_bInverted = bXInverted!=bYInverted!=bZInverted;
|
pr_bInverted = (bXInverted != bYInverted) != bZInverted;
|
||||||
|
|
||||||
// if the projection is mirrored
|
// if the projection is mirrored
|
||||||
if (pr_bMirror) {
|
if (pr_bMirror) {
|
||||||
|
|
|
@ -138,7 +138,7 @@ void CMappingDefinition::TransformMappingVectors( const CMappingVectors &mvSrc,
|
||||||
FLOAT vot2 = +sou2*ood2; FLOAT vos2 = -tou2*ood2;
|
FLOAT vot2 = +sou2*ood2; FLOAT vos2 = -tou2*ood2;
|
||||||
|
|
||||||
mvDst.mv_vO = mvSrc.mv_vO
|
mvDst.mv_vO = mvSrc.mv_vO
|
||||||
+ mvDst.mv_vU * (md_fUOffset*uos2 + md_fVOffset*vos2)
|
+ mvDst.mv_vU * (md_fUOffset*uos2 + md_fVOffset*vos2) // FIXME: should vos2 have been uot2 here?
|
||||||
+ mvDst.mv_vV * (md_fUOffset*vos2 + md_fVOffset*vot2);
|
+ mvDst.mv_vV * (md_fUOffset*vos2 + md_fVOffset*vot2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -263,9 +263,9 @@ void CMappingDefinition::ProjectMapping(const FLOATplane3D &plOriginal, const CM
|
||||||
mv.mv_vO = pl.DeprojectPoint (plOriginal, mvOriginal.mv_vO);
|
mv.mv_vO = pl.DeprojectPoint (plOriginal, mvOriginal.mv_vO);
|
||||||
mv.mv_vU = pl.DeprojectDirection(plOriginal, mvOriginal.mv_vU);
|
mv.mv_vU = pl.DeprojectDirection(plOriginal, mvOriginal.mv_vU);
|
||||||
mv.mv_vV = pl.DeprojectDirection(plOriginal, mvOriginal.mv_vV);
|
mv.mv_vV = pl.DeprojectDirection(plOriginal, mvOriginal.mv_vV);
|
||||||
FLOAT3D vOTest = plOriginal.ProjectPoint(mv.mv_vO);
|
//FLOAT3D vOTest = plOriginal.ProjectPoint(mv.mv_vO);
|
||||||
FLOAT3D vUTest = plOriginal.ProjectDirection(mv.mv_vU);
|
//FLOAT3D vUTest = plOriginal.ProjectDirection(mv.mv_vU);
|
||||||
FLOAT3D vVTest = plOriginal.ProjectDirection(mv.mv_vV);
|
//FLOAT3D vVTest = plOriginal.ProjectDirection(mv.mv_vV);
|
||||||
|
|
||||||
// make mapping on this plane
|
// make mapping on this plane
|
||||||
CMappingVectors mvDefault;
|
CMappingVectors mvDefault;
|
||||||
|
|
|
@ -1068,7 +1068,7 @@ void CModelData::IndicesToPtrs()
|
||||||
{
|
{
|
||||||
FOREACHINSTATICARRAY(it1.Current().mp_PolygonVertices, ModelPolygonVertex, it2)
|
FOREACHINSTATICARRAY(it1.Current().mp_PolygonVertices, ModelPolygonVertex, it2)
|
||||||
{
|
{
|
||||||
struct ModelPolygonVertex * pMPV = &it2.Current();
|
//struct ModelPolygonVertex * pMPV = &it2.Current();
|
||||||
// DG: this looks like a 64-bit issue but is most probably ok, as the pointers
|
// DG: this looks like a 64-bit issue but is most probably ok, as the pointers
|
||||||
// should contain indices from PtrToIndices()
|
// should contain indices from PtrToIndices()
|
||||||
j = (INDEX) (size_t) it2.Current().mpv_ptvTransformedVertex;
|
j = (INDEX) (size_t) it2.Current().mpv_ptvTransformedVertex;
|
||||||
|
@ -1397,9 +1397,11 @@ void CModelData::Read_t( CTStream *pFile) // throw char *
|
||||||
if( cidVerticesChunk == CChunkID("AV16"))
|
if( cidVerticesChunk == CChunkID("AV16"))
|
||||||
{
|
{
|
||||||
CChunkID cidDummy = pFile->GetID_t();
|
CChunkID cidDummy = pFile->GetID_t();
|
||||||
|
(void)cidDummy; // shut up about unused variable, compiler.
|
||||||
ULONG ulDummy;
|
ULONG ulDummy;
|
||||||
// skip chunk size
|
// skip chunk size
|
||||||
*pFile >> ulDummy;
|
*pFile >> ulDummy;
|
||||||
|
(void)ulDummy; // shut up about unused variable, compiler.
|
||||||
for( INDEX iVtx=0; iVtx<md_VerticesCt * md_FramesCt; iVtx++)
|
for( INDEX iVtx=0; iVtx<md_VerticesCt * md_FramesCt; iVtx++)
|
||||||
{
|
{
|
||||||
(*pFile)>>md_FrameVertices16[iVtx];
|
(*pFile)>>md_FrameVertices16[iVtx];
|
||||||
|
@ -2859,22 +2861,26 @@ void CModelObject::AutoSetTextures(void)
|
||||||
if( id == CChunkID("WTEX"))
|
if( id == CChunkID("WTEX"))
|
||||||
{
|
{
|
||||||
CChunkID idDummy = strmIni.GetID_t();
|
CChunkID idDummy = strmIni.GetID_t();
|
||||||
|
(void)idDummy; // shut up about unused variable, compiler.
|
||||||
strmIni >> ctDiffuseTextures;
|
strmIni >> ctDiffuseTextures;
|
||||||
strmIni >> fnDiffuse;
|
strmIni >> fnDiffuse;
|
||||||
}
|
}
|
||||||
else if( id == CChunkID("FXTR"))
|
else if( id == CChunkID("FXTR"))
|
||||||
{
|
{
|
||||||
CChunkID idDummy = strmIni.GetID_t();
|
CChunkID idDummy = strmIni.GetID_t();
|
||||||
|
(void)idDummy; // shut up about unused variable, compiler.
|
||||||
strmIni >> fnReflection;
|
strmIni >> fnReflection;
|
||||||
}
|
}
|
||||||
else if( id == CChunkID("FXTS"))
|
else if( id == CChunkID("FXTS"))
|
||||||
{
|
{
|
||||||
CChunkID idDummy = strmIni.GetID_t();
|
CChunkID idDummy = strmIni.GetID_t();
|
||||||
|
(void)idDummy; // shut up about unused variable, compiler.
|
||||||
strmIni >> fnSpecular;
|
strmIni >> fnSpecular;
|
||||||
}
|
}
|
||||||
else if( id == CChunkID("FXTB"))
|
else if( id == CChunkID("FXTB"))
|
||||||
{
|
{
|
||||||
CChunkID idDummy = strmIni.GetID_t();
|
CChunkID idDummy = strmIni.GetID_t();
|
||||||
|
(void)idDummy; // shut up about unused variable, compiler.
|
||||||
strmIni >> fnBump;
|
strmIni >> fnBump;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2914,6 +2920,7 @@ void CModelObject::AutoSetAttachments(void)
|
||||||
if( id == CChunkID("ATTM"))
|
if( id == CChunkID("ATTM"))
|
||||||
{
|
{
|
||||||
CChunkID idDummy = strmIni.GetID_t();
|
CChunkID idDummy = strmIni.GetID_t();
|
||||||
|
(void)idDummy; // shut up about unused variable, compiler.
|
||||||
// try to load attached models
|
// try to load attached models
|
||||||
INDEX ctAttachedModels;
|
INDEX ctAttachedModels;
|
||||||
strmIni >> ctAttachedModels;
|
strmIni >> ctAttachedModels;
|
||||||
|
|
|
@ -240,7 +240,7 @@ BOOL CModelObject::CreateAttachment( CRenderModel &rmMain, CAttachmentModelObjec
|
||||||
_pfModelProfile.StartTimer( CModelProfile::PTI_CREATEATTACHMENT);
|
_pfModelProfile.StartTimer( CModelProfile::PTI_CREATEATTACHMENT);
|
||||||
_pfModelProfile.IncrementTimerAveragingCounter( CModelProfile::PTI_CREATEATTACHMENT);
|
_pfModelProfile.IncrementTimerAveragingCounter( CModelProfile::PTI_CREATEATTACHMENT);
|
||||||
CRenderModel &rmAttached = *amo.amo_prm;
|
CRenderModel &rmAttached = *amo.amo_prm;
|
||||||
rmAttached.rm_ulFlags = rmMain.rm_ulFlags&(RMF_FOG|RMF_HAZE|RMF_WEAPON) | RMF_ATTACHMENT;
|
rmAttached.rm_ulFlags = (rmMain.rm_ulFlags & (RMF_FOG|RMF_HAZE|RMF_WEAPON)) | RMF_ATTACHMENT;
|
||||||
|
|
||||||
// get the position
|
// get the position
|
||||||
rmMain.rm_pmdModelData->md_aampAttachedPosition.Lock();
|
rmMain.rm_pmdModelData->md_aampAttachedPosition.Lock();
|
||||||
|
@ -493,7 +493,7 @@ void CModelObject::SetupModelRendering( CRenderModel &rm)
|
||||||
BOOL bYInverted = rm.rm_vStretch(2) < 0;
|
BOOL bYInverted = rm.rm_vStretch(2) < 0;
|
||||||
BOOL bZInverted = rm.rm_vStretch(3) < 0;
|
BOOL bZInverted = rm.rm_vStretch(3) < 0;
|
||||||
rm.rm_ulFlags &= ~RMF_INVERTED;
|
rm.rm_ulFlags &= ~RMF_INVERTED;
|
||||||
if( bXInverted != bYInverted != bZInverted != _aprProjection->pr_bInverted) rm.rm_ulFlags |= RMF_INVERTED;
|
if( ((bXInverted != bYInverted) != bZInverted) != _aprProjection->pr_bInverted) rm.rm_ulFlags |= RMF_INVERTED;
|
||||||
|
|
||||||
// prepare projections
|
// prepare projections
|
||||||
_pfModelProfile.StartTimer( CModelProfile::PTI_INITPROJECTION);
|
_pfModelProfile.StartTimer( CModelProfile::PTI_INITPROJECTION);
|
||||||
|
|
|
@ -43,7 +43,7 @@ static FLOAT fZoomI, fZoomJ;
|
||||||
static FLOAT fFrontClipDistance, f1oFrontClipDistance;
|
static FLOAT fFrontClipDistance, f1oFrontClipDistance;
|
||||||
static FLOAT fBackClipDistance, f1oBackClipDistance;
|
static FLOAT fBackClipDistance, f1oBackClipDistance;
|
||||||
static FLOAT fDepthBufferFactor;
|
static FLOAT fDepthBufferFactor;
|
||||||
static BOOL bBackFaced, bDoubleSided;
|
//static BOOL bBackFaced, bDoubleSided;
|
||||||
static BOOL bPerspective;
|
static BOOL bPerspective;
|
||||||
static BOOL b16BitCompression;
|
static BOOL b16BitCompression;
|
||||||
static ULONG ulColorMask;
|
static ULONG ulColorMask;
|
||||||
|
|
|
@ -40,14 +40,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#define W word ptr
|
#define W word ptr
|
||||||
#define B byte ptr
|
#define B byte ptr
|
||||||
|
|
||||||
#if (defined __MSVC_INLINE__)
|
|
||||||
#define ASMOPT 1
|
|
||||||
#elif (defined __GNU_INLINE__)
|
|
||||||
#define ASMOPT 0 // !!! FIXME: rcg10112001 Write GCC inline asm versions...
|
|
||||||
#else
|
|
||||||
#define ASMOPT 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
extern BOOL CVA_bModels;
|
extern BOOL CVA_bModels;
|
||||||
extern BOOL GFX_bTruform;
|
extern BOOL GFX_bTruform;
|
||||||
|
@ -483,7 +475,7 @@ static void PrepareModelMipForRendering( CModelData &md, INDEX iMip)
|
||||||
|
|
||||||
// for each surface
|
// for each surface
|
||||||
INDEX iSrfVx = 0;
|
INDEX iSrfVx = 0;
|
||||||
INDEX iSrfEl = 0;
|
//INDEX iSrfEl = 0;
|
||||||
{FOREACHINSTATICARRAY( mmi.mmpi_MappingSurfaces, MappingSurface, itms)
|
{FOREACHINSTATICARRAY( mmi.mmpi_MappingSurfaces, MappingSurface, itms)
|
||||||
{
|
{
|
||||||
MappingSurface &ms = *itms;
|
MappingSurface &ms = *itms;
|
||||||
|
@ -663,7 +655,7 @@ static FLOAT _fHazeAdd;
|
||||||
// check vertex against fog
|
// check vertex against fog
|
||||||
static void GetFogMapInVertex( GFXVertex3 &vtx, GFXTexCoord &tex)
|
static void GetFogMapInVertex( GFXVertex3 &vtx, GFXTexCoord &tex)
|
||||||
{
|
{
|
||||||
#if ASMOPT == 1
|
#if (defined __MSVC_INLINE__)
|
||||||
__asm {
|
__asm {
|
||||||
mov esi,D [vtx]
|
mov esi,D [vtx]
|
||||||
mov edi,D [tex]
|
mov edi,D [tex]
|
||||||
|
@ -708,7 +700,7 @@ static void GetFogMapInVertex( GFXVertex3 &vtx, GFXTexCoord &tex)
|
||||||
// check vertex against haze
|
// check vertex against haze
|
||||||
static void GetHazeMapInVertex( GFXVertex3 &vtx, FLOAT &tx1)
|
static void GetHazeMapInVertex( GFXVertex3 &vtx, FLOAT &tx1)
|
||||||
{
|
{
|
||||||
#if ASMOPT == 1
|
#if (defined __MSVC_INLINE__)
|
||||||
__asm {
|
__asm {
|
||||||
mov esi,D [vtx]
|
mov esi,D [vtx]
|
||||||
mov edi,D [tx1]
|
mov edi,D [tx1]
|
||||||
|
@ -1080,7 +1072,7 @@ static void UnpackFrame( CRenderModel &rm, BOOL bKeepNormals)
|
||||||
const ModelFrameVertex16 *pFrame1 = rm.rm_pFrame16_1;
|
const ModelFrameVertex16 *pFrame1 = rm.rm_pFrame16_1;
|
||||||
if( pFrame0==pFrame1)
|
if( pFrame0==pFrame1)
|
||||||
{
|
{
|
||||||
#if ASMOPT == 1
|
#if (defined __MSVC_INLINE__)
|
||||||
// for each vertex in mip
|
// for each vertex in mip
|
||||||
const SLONG fixLerpRatio = FloatToInt(fLerpRatio*256.0f); // fix 8:8
|
const SLONG fixLerpRatio = FloatToInt(fLerpRatio*256.0f); // fix 8:8
|
||||||
SLONG slTmp1, slTmp2, slTmp3;
|
SLONG slTmp1, slTmp2, slTmp3;
|
||||||
|
@ -1196,7 +1188,7 @@ vtxNext16:
|
||||||
// if lerping
|
// if lerping
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if ASMOPT == 1
|
#if (defined __MSVC_INLINE__)
|
||||||
// for each vertex in mip
|
// for each vertex in mip
|
||||||
const SLONG fixLerpRatio = FloatToInt(fLerpRatio*256.0f); // fix 8:8
|
const SLONG fixLerpRatio = FloatToInt(fLerpRatio*256.0f); // fix 8:8
|
||||||
SLONG slTmp1, slTmp2, slTmp3;
|
SLONG slTmp1, slTmp2, slTmp3;
|
||||||
|
@ -1365,7 +1357,7 @@ vtxNext16L:
|
||||||
// if no lerping
|
// if no lerping
|
||||||
if( pFrame0==pFrame1)
|
if( pFrame0==pFrame1)
|
||||||
{
|
{
|
||||||
#if ASMOPT == 1
|
#if (defined __MSVC_INLINE__)
|
||||||
// for each vertex in mip
|
// for each vertex in mip
|
||||||
const SLONG fixLerpRatio = FloatToInt(fLerpRatio*256.0f); // fix 8:8
|
const SLONG fixLerpRatio = FloatToInt(fLerpRatio*256.0f); // fix 8:8
|
||||||
SLONG slTmp1, slTmp2, slTmp3;
|
SLONG slTmp1, slTmp2, slTmp3;
|
||||||
|
@ -1464,7 +1456,7 @@ vtxNext8:
|
||||||
// if lerping
|
// if lerping
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if ASMOPT == 1
|
#if (defined __MSVC_INLINE__)
|
||||||
const SLONG fixLerpRatio = FloatToInt(fLerpRatio*256.0f); // fix 8:8
|
const SLONG fixLerpRatio = FloatToInt(fLerpRatio*256.0f); // fix 8:8
|
||||||
SLONG slTmp1, slTmp2, slTmp3;
|
SLONG slTmp1, slTmp2, slTmp3;
|
||||||
// re-adjust stretching factors because of fixint lerping (divide by 256)
|
// re-adjust stretching factors because of fixint lerping (divide by 256)
|
||||||
|
@ -1610,7 +1602,7 @@ vtxNext8L:
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate colors from shades
|
// generate colors from shades
|
||||||
#if ASMOPT == 1
|
#if (defined __MSVC_INLINE__)
|
||||||
__asm {
|
__asm {
|
||||||
pxor mm0,mm0
|
pxor mm0,mm0
|
||||||
// construct 64-bit RGBA light
|
// construct 64-bit RGBA light
|
||||||
|
@ -1961,7 +1953,7 @@ void CModelObject::RenderModel_View( CRenderModel &rm)
|
||||||
_pfModelProfile.IncrementTimerAveragingCounter( CModelProfile::PTI_VIEW_INIT_VERTICES, _ctAllSrfVx);
|
_pfModelProfile.IncrementTimerAveragingCounter( CModelProfile::PTI_VIEW_INIT_VERTICES, _ctAllSrfVx);
|
||||||
|
|
||||||
// for each surface in current mip model
|
// for each surface in current mip model
|
||||||
BOOL bEmpty = TRUE;
|
//BOOL bEmpty = TRUE;
|
||||||
{FOREACHINSTATICARRAY( mmi.mmpi_MappingSurfaces, MappingSurface, itms)
|
{FOREACHINSTATICARRAY( mmi.mmpi_MappingSurfaces, MappingSurface, itms)
|
||||||
{
|
{
|
||||||
const MappingSurface &ms = *itms;
|
const MappingSurface &ms = *itms;
|
||||||
|
@ -1969,12 +1961,12 @@ void CModelObject::RenderModel_View( CRenderModel &rm)
|
||||||
ctSrfVx = ms.ms_ctSrfVx;
|
ctSrfVx = ms.ms_ctSrfVx;
|
||||||
// skip to next in case of invisible or empty surface
|
// skip to next in case of invisible or empty surface
|
||||||
if( (ms.ms_ulRenderingFlags&SRF_INVISIBLE) || ctSrfVx==0) break;
|
if( (ms.ms_ulRenderingFlags&SRF_INVISIBLE) || ctSrfVx==0) break;
|
||||||
bEmpty = FALSE;
|
//bEmpty = FALSE;
|
||||||
puwSrfToMip = &mmi.mmpi_auwSrfToMip[iSrfVx0];
|
puwSrfToMip = &mmi.mmpi_auwSrfToMip[iSrfVx0];
|
||||||
pvtxSrfBase = &_avtxSrfBase[iSrfVx0];
|
pvtxSrfBase = &_avtxSrfBase[iSrfVx0];
|
||||||
INDEX iSrfVx;
|
INDEX iSrfVx;
|
||||||
|
|
||||||
#if ASMOPT == 1
|
#if (defined __MSVC_INLINE__)
|
||||||
__asm {
|
__asm {
|
||||||
push ebx
|
push ebx
|
||||||
mov ebx,D [puwSrfToMip]
|
mov ebx,D [puwSrfToMip]
|
||||||
|
@ -2074,7 +2066,7 @@ srfVtxLoop:
|
||||||
const COLOR colD = AdjustColor( ms.ms_colDiffuse, _slTexHueShift, _slTexSaturation);
|
const COLOR colD = AdjustColor( ms.ms_colDiffuse, _slTexHueShift, _slTexSaturation);
|
||||||
colSrfDiff.MultiplyRGBA( colD, colMdlDiff);
|
colSrfDiff.MultiplyRGBA( colD, colMdlDiff);
|
||||||
|
|
||||||
#if ASMOPT == 1
|
#if (defined __MSVC_INLINE__)
|
||||||
// setup texcoord array
|
// setup texcoord array
|
||||||
__asm {
|
__asm {
|
||||||
push ebx
|
push ebx
|
||||||
|
@ -2134,7 +2126,7 @@ vtxEnd:
|
||||||
for( INDEX iSrfVx=0; iSrfVx<ctSrfVx; iSrfVx++) pcolSrfBase[iSrfVx] = colSrfDiffAdj;
|
for( INDEX iSrfVx=0; iSrfVx<ctSrfVx; iSrfVx++) pcolSrfBase[iSrfVx] = colSrfDiffAdj;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#if ASMOPT == 1
|
#if (defined __MSVC_INLINE__)
|
||||||
// setup color array
|
// setup color array
|
||||||
const COLOR colS = colSrfDiff.ul.abgr;
|
const COLOR colS = colSrfDiff.ul.abgr;
|
||||||
__asm {
|
__asm {
|
||||||
|
@ -2294,7 +2286,7 @@ diffColLoop:
|
||||||
// for each vertex in the surface
|
// for each vertex in the surface
|
||||||
for( INDEX iSrfVx=0; iSrfVx<ctSrfVx; iSrfVx++) {
|
for( INDEX iSrfVx=0; iSrfVx<ctSrfVx; iSrfVx++) {
|
||||||
// set detail texcoord and color
|
// set detail texcoord and color
|
||||||
INDEX iMipVx = mmi.mmpi_auwSrfToMip[iSrfVx];
|
//INDEX iMipVx = mmi.mmpi_auwSrfToMip[iSrfVx];
|
||||||
ptexSrfBase[iSrfVx].st.s = pvTexCoord[iSrfVx](1) * fTexCorrU;
|
ptexSrfBase[iSrfVx].st.s = pvTexCoord[iSrfVx](1) * fTexCorrU;
|
||||||
ptexSrfBase[iSrfVx].st.t = pvTexCoord[iSrfVx](2) * fTexCorrV;
|
ptexSrfBase[iSrfVx].st.t = pvTexCoord[iSrfVx](2) * fTexCorrV;
|
||||||
pcolSrfBase[iSrfVx] = colSrfBump;
|
pcolSrfBase[iSrfVx] = colSrfBump;
|
||||||
|
@ -2335,7 +2327,7 @@ diffColLoop:
|
||||||
// cache rotation
|
// cache rotation
|
||||||
const FLOATmatrix3D &m = rm.rm_mObjectRotation;
|
const FLOATmatrix3D &m = rm.rm_mObjectRotation;
|
||||||
|
|
||||||
#if ASMOPT == 1
|
#if (defined __MSVC_INLINE__)
|
||||||
__asm {
|
__asm {
|
||||||
push ebx
|
push ebx
|
||||||
mov ebx,D [m]
|
mov ebx,D [m]
|
||||||
|
@ -2530,7 +2522,7 @@ reflMipLoop:
|
||||||
// cache object view rotation
|
// cache object view rotation
|
||||||
const FLOATmatrix3D &m = rm.rm_mObjectToView;
|
const FLOATmatrix3D &m = rm.rm_mObjectToView;
|
||||||
|
|
||||||
#if ASMOPT == 1
|
#if (defined __MSVC_INLINE__)
|
||||||
__asm {
|
__asm {
|
||||||
push ebx
|
push ebx
|
||||||
mov ebx,D [m]
|
mov ebx,D [m]
|
||||||
|
|
|
@ -98,10 +98,10 @@ void CModelObject::GetModelVertices( CStaticStackArray<FLOAT3D> &avVertices, FLO
|
||||||
_vOffset = vOffset = pmd->md_vCompressedCenter;
|
_vOffset = vOffset = pmd->md_vCompressedCenter;
|
||||||
|
|
||||||
// check if object is inverted (in mirror)
|
// check if object is inverted (in mirror)
|
||||||
BOOL bXInverted = vStretch(1)<0;
|
//BOOL bXInverted = vStretch(1)<0;
|
||||||
BOOL bYInverted = vStretch(2)<0;
|
//BOOL bYInverted = vStretch(2)<0;
|
||||||
BOOL bZInverted = vStretch(3)<0;
|
//BOOL bZInverted = vStretch(3)<0;
|
||||||
BOOL bInverted = bXInverted!=bYInverted!=bZInverted;
|
//BOOL bInverted = bXInverted!=bYInverted!=bZInverted;
|
||||||
|
|
||||||
// if dynamic stretch factor should be applied
|
// if dynamic stretch factor should be applied
|
||||||
if( mo_Stretch != FLOAT3D( 1.0f, 1.0f, 1.0f)) {
|
if( mo_Stretch != FLOAT3D( 1.0f, 1.0f, 1.0f)) {
|
||||||
|
@ -113,7 +113,7 @@ void CModelObject::GetModelVertices( CStaticStackArray<FLOAT3D> &avVertices, FLO
|
||||||
// get current mip model using mip factor
|
// get current mip model using mip factor
|
||||||
INDEX iMipLevel = GetMipModel( fMipFactor);
|
INDEX iMipLevel = GetMipModel( fMipFactor);
|
||||||
// get current vertices mask
|
// get current vertices mask
|
||||||
ULONG ulVtxMask = (1L) << iMipLevel;
|
//ULONG ulVtxMask = (1L) << iMipLevel;
|
||||||
struct ModelMipInfo *pmmiMip = &pmd->md_MipInfos[iMipLevel];
|
struct ModelMipInfo *pmmiMip = &pmd->md_MipInfos[iMipLevel];
|
||||||
|
|
||||||
// allocate space for vertices
|
// allocate space for vertices
|
||||||
|
@ -188,7 +188,7 @@ void CModelObject::GetModelVertices( CStaticStackArray<FLOAT3D> &avVertices, FLO
|
||||||
CAttachmentModelObject *pamo = itamo;
|
CAttachmentModelObject *pamo = itamo;
|
||||||
CModelData *pmd=pamo->amo_moModelObject.GetData();
|
CModelData *pmd=pamo->amo_moModelObject.GetData();
|
||||||
ASSERT(pmd!=NULL);
|
ASSERT(pmd!=NULL);
|
||||||
if(pmd==NULL || pmd->md_Flags&(MF_FACE_FORWARD|MF_HALF_FACE_FORWARD)) continue;
|
if(pmd==NULL || (pmd->md_Flags & (MF_FACE_FORWARD|MF_HALF_FACE_FORWARD))) continue;
|
||||||
FLOATmatrix3D mNew = mRotation;
|
FLOATmatrix3D mNew = mRotation;
|
||||||
FLOAT3D vNew = vPosition;
|
FLOAT3D vNew = vPosition;
|
||||||
// get new rotation and position matrices
|
// get new rotation and position matrices
|
||||||
|
|
|
@ -92,7 +92,7 @@ void CActionBuffer::RemoveOldest(void)
|
||||||
{
|
{
|
||||||
// for each buffered action
|
// for each buffered action
|
||||||
FORDELETELIST(CActionEntry, ae_ln, ab_lhActions, itae) {
|
FORDELETELIST(CActionEntry, ae_ln, ab_lhActions, itae) {
|
||||||
CActionEntry &ae = *itae;
|
//CActionEntry &ae = *itae;
|
||||||
// delete only first one
|
// delete only first one
|
||||||
delete &*itae;
|
delete &*itae;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -395,14 +395,14 @@ void CClientInterface::ExchangeBuffers(void)
|
||||||
// and generate acknowledge messages for incoming reliable packets
|
// and generate acknowledge messages for incoming reliable packets
|
||||||
BOOL CClientInterface::UpdateInputBuffers(void)
|
BOOL CClientInterface::UpdateInputBuffers(void)
|
||||||
{
|
{
|
||||||
BOOL bSomethingDone;
|
//BOOL bSomethingDone;
|
||||||
ULONG pulGenAck[MAX_ACKS_PER_PACKET];
|
ULONG pulGenAck[MAX_ACKS_PER_PACKET];
|
||||||
ULONG ulAckCount=0;
|
ULONG ulAckCount=0;
|
||||||
CTimerValue tvNow;
|
CTimerValue tvNow;
|
||||||
|
|
||||||
// if there are packets in the input buffer, process them
|
// if there are packets in the input buffer, process them
|
||||||
FORDELETELIST(CPacket,pa_lnListNode,ci_pbInputBuffer.pb_lhPacketStorage,ppaPacket) {
|
FORDELETELIST(CPacket,pa_lnListNode,ci_pbInputBuffer.pb_lhPacketStorage,ppaPacket) {
|
||||||
CPacket &paPacket = *ppaPacket;
|
//CPacket &paPacket = *ppaPacket;
|
||||||
|
|
||||||
// if it's an acknowledge packet, remove the acknowledged packets from the wait acknowledge buffer
|
// if it's an acknowledge packet, remove the acknowledged packets from the wait acknowledge buffer
|
||||||
if (ppaPacket->pa_ubReliable & UDP_PACKET_ACKNOWLEDGE) {
|
if (ppaPacket->pa_ubReliable & UDP_PACKET_ACKNOWLEDGE) {
|
||||||
|
@ -438,7 +438,7 @@ BOOL CClientInterface::UpdateInputBuffers(void)
|
||||||
ci_pbInputBuffer.RemovePacket(ppaPacket->pa_ulSequence,FALSE);
|
ci_pbInputBuffer.RemovePacket(ppaPacket->pa_ulSequence,FALSE);
|
||||||
delete ppaPacket;
|
delete ppaPacket;
|
||||||
|
|
||||||
bSomethingDone = TRUE;
|
//bSomethingDone = TRUE;
|
||||||
// if the packet is reliable
|
// if the packet is reliable
|
||||||
} else if (ppaPacket->pa_ubReliable & UDP_PACKET_RELIABLE) {
|
} else if (ppaPacket->pa_ubReliable & UDP_PACKET_RELIABLE) {
|
||||||
|
|
||||||
|
@ -547,12 +547,12 @@ BOOL CClientInterface::UpdateInputBuffers(void)
|
||||||
// packet separately, instead of grouping them together
|
// packet separately, instead of grouping them together
|
||||||
BOOL CClientInterface::UpdateInputBuffersBroadcast(void)
|
BOOL CClientInterface::UpdateInputBuffersBroadcast(void)
|
||||||
{
|
{
|
||||||
BOOL bSomethingDone;
|
//BOOL bSomethingDone;
|
||||||
CTimerValue tvNow;
|
CTimerValue tvNow;
|
||||||
|
|
||||||
// if there are packets in the input buffer, process them
|
// if there are packets in the input buffer, process them
|
||||||
FORDELETELIST(CPacket,pa_lnListNode,ci_pbInputBuffer.pb_lhPacketStorage,ppaPacket) {
|
FORDELETELIST(CPacket,pa_lnListNode,ci_pbInputBuffer.pb_lhPacketStorage,ppaPacket) {
|
||||||
CPacket &paPacket = *ppaPacket;
|
//CPacket &paPacket = *ppaPacket;
|
||||||
|
|
||||||
// if it's an acknowledge packet, remove the acknowledged packets from the wait acknowledge buffer
|
// if it's an acknowledge packet, remove the acknowledged packets from the wait acknowledge buffer
|
||||||
if (ppaPacket->pa_ubReliable & UDP_PACKET_ACKNOWLEDGE) {
|
if (ppaPacket->pa_ubReliable & UDP_PACKET_ACKNOWLEDGE) {
|
||||||
|
@ -585,7 +585,7 @@ BOOL CClientInterface::UpdateInputBuffersBroadcast(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
ci_pbInputBuffer.RemovePacket(ppaPacket->pa_ulSequence,FALSE);
|
ci_pbInputBuffer.RemovePacket(ppaPacket->pa_ulSequence,FALSE);
|
||||||
bSomethingDone = TRUE;
|
//bSomethingDone = TRUE;
|
||||||
delete ppaPacket;
|
delete ppaPacket;
|
||||||
// if the packet is reliable
|
// if the packet is reliable
|
||||||
} else if (ppaPacket->pa_ubReliable & UDP_PACKET_RELIABLE) {
|
} else if (ppaPacket->pa_ubReliable & UDP_PACKET_RELIABLE) {
|
||||||
|
|
|
@ -629,7 +629,7 @@ void CCommunicationInterface::Broadcast_Update_t() {
|
||||||
BOOL bIsAlready;
|
BOOL bIsAlready;
|
||||||
BOOL bFoundEmpty;
|
BOOL bFoundEmpty;
|
||||||
ULONG iClient;
|
ULONG iClient;
|
||||||
UBYTE ubDummy=65;
|
//UBYTE ubDummy=65;
|
||||||
|
|
||||||
|
|
||||||
// while there is a connection request packet in the input buffer
|
// while there is a connection request packet in the input buffer
|
||||||
|
@ -1080,7 +1080,8 @@ void CCommunicationInterface::Client_OpenNet_t(ULONG ulServerAddress)
|
||||||
if (cm_ciLocalClient.ci_pbReliableInputBuffer.pb_ulNumOfPackets > 0) {
|
if (cm_ciLocalClient.ci_pbReliableInputBuffer.pb_ulNumOfPackets > 0) {
|
||||||
ppaReadPacket = cm_ciLocalClient.ci_pbReliableInputBuffer.GetFirstPacket();
|
ppaReadPacket = cm_ciLocalClient.ci_pbReliableInputBuffer.GetFirstPacket();
|
||||||
// and it is a connection confirmation
|
// and it is a connection confirmation
|
||||||
if (ppaReadPacket->pa_ubReliable && UDP_PACKET_CONNECT_RESPONSE) {
|
// DG: replaced && with & as done everywhere else, hope this doesn't rely on being buggy.
|
||||||
|
if (ppaReadPacket->pa_ubReliable & UDP_PACKET_CONNECT_RESPONSE) {
|
||||||
// the client has succedeed to connect, so read the uwID from the packet
|
// the client has succedeed to connect, so read the uwID from the packet
|
||||||
cm_ciLocalClient.ci_adrAddress.adr_ulAddress = ulServerAddress;
|
cm_ciLocalClient.ci_adrAddress.adr_ulAddress = ulServerAddress;
|
||||||
cm_ciLocalClient.ci_adrAddress.adr_uwPort = net_iPort;
|
cm_ciLocalClient.ci_adrAddress.adr_uwPort = net_iPort;
|
||||||
|
|
|
@ -124,7 +124,7 @@ UBYTE *FindFirstEntity(UBYTE *pubBlock, SLONG slSize)
|
||||||
if (*(ULONG*)pub == ENT4) {
|
if (*(ULONG*)pub == ENT4) {
|
||||||
UBYTE *pubTmp = pub;
|
UBYTE *pubTmp = pub;
|
||||||
pubTmp+=sizeof(ULONG);
|
pubTmp+=sizeof(ULONG);
|
||||||
ULONG ulID = *(ULONG*)pubTmp;
|
//ULONG ulID = *(ULONG*)pubTmp;
|
||||||
pubTmp+=sizeof(ULONG);
|
pubTmp+=sizeof(ULONG);
|
||||||
SLONG slSizeChunk = *(SLONG*)pubTmp;
|
SLONG slSizeChunk = *(SLONG*)pubTmp;
|
||||||
pubTmp+=sizeof(ULONG);
|
pubTmp+=sizeof(ULONG);
|
||||||
|
@ -221,17 +221,17 @@ void MakeDiff_t(void)
|
||||||
void UnDiff_t(void)
|
void UnDiff_t(void)
|
||||||
{
|
{
|
||||||
// start at beginning
|
// start at beginning
|
||||||
UBYTE *pubOld = _pubOld;
|
//UBYTE *pubOld = _pubOld;
|
||||||
UBYTE *pubNew = _pubNew;
|
UBYTE *pubNew = _pubNew;
|
||||||
SLONG slSizeOldStream = 0;
|
SLONG slSizeOldStream = 0;
|
||||||
SLONG slSizeOutStream = 0;
|
//SLONG slSizeOutStream = 0;
|
||||||
// get header with size of files
|
// get header with size of files
|
||||||
if (*(SLONG*)pubNew!=DIFF) {
|
if (*(SLONG*)pubNew!=DIFF) {
|
||||||
ThrowF_t(TRANS("Not a DIFF stream!"));
|
ThrowF_t(TRANS("Not a DIFF stream!"));
|
||||||
}
|
}
|
||||||
pubNew+=sizeof(SLONG);
|
pubNew+=sizeof(SLONG);
|
||||||
slSizeOldStream = *(SLONG*)pubNew; pubNew+=sizeof(SLONG);
|
slSizeOldStream = *(SLONG*)pubNew; pubNew+=sizeof(SLONG);
|
||||||
slSizeOutStream = *(SLONG*)pubNew; pubNew+=sizeof(SLONG);
|
/* slSizeOutStream = *(SLONG*)pubNew; */ pubNew+=sizeof(SLONG);
|
||||||
ULONG ulCRC = *(ULONG*)pubNew; pubNew+=sizeof(ULONG);
|
ULONG ulCRC = *(ULONG*)pubNew; pubNew+=sizeof(ULONG);
|
||||||
|
|
||||||
CRC_Start(_ulCRC);
|
CRC_Start(_ulCRC);
|
||||||
|
@ -314,7 +314,7 @@ void Cleanup(void)
|
||||||
void DIFF_Diff_t(CTStream *pstrmOld, CTStream *pstrmNew, CTStream *pstrmDiff)
|
void DIFF_Diff_t(CTStream *pstrmOld, CTStream *pstrmNew, CTStream *pstrmDiff)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
CTimerValue tv0 = _pTimer->GetHighPrecisionTimer();
|
//CTimerValue tv0 = _pTimer->GetHighPrecisionTimer();
|
||||||
|
|
||||||
_slSizeOld = pstrmOld->GetStreamSize()-pstrmOld->GetPos_t();
|
_slSizeOld = pstrmOld->GetStreamSize()-pstrmOld->GetPos_t();
|
||||||
_pubOld = (UBYTE*)AllocMemory(_slSizeOld);
|
_pubOld = (UBYTE*)AllocMemory(_slSizeOld);
|
||||||
|
@ -332,7 +332,7 @@ void DIFF_Diff_t(CTStream *pstrmOld, CTStream *pstrmNew, CTStream *pstrmDiff)
|
||||||
|
|
||||||
MakeDiff_t();
|
MakeDiff_t();
|
||||||
|
|
||||||
CTimerValue tv1 = _pTimer->GetHighPrecisionTimer();
|
//CTimerValue tv1 = _pTimer->GetHighPrecisionTimer();
|
||||||
//CPrintF("diff encoded in %.2gs\n", (tv1-tv0).GetSeconds());
|
//CPrintF("diff encoded in %.2gs\n", (tv1-tv0).GetSeconds());
|
||||||
|
|
||||||
Cleanup();
|
Cleanup();
|
||||||
|
@ -347,7 +347,7 @@ void DIFF_Diff_t(CTStream *pstrmOld, CTStream *pstrmNew, CTStream *pstrmDiff)
|
||||||
void DIFF_Undiff_t(CTStream *pstrmOld, CTStream *pstrmDiff, CTStream *pstrmNew)
|
void DIFF_Undiff_t(CTStream *pstrmOld, CTStream *pstrmDiff, CTStream *pstrmNew)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
CTimerValue tv0 = _pTimer->GetHighPrecisionTimer();
|
//CTimerValue tv0 = _pTimer->GetHighPrecisionTimer();
|
||||||
|
|
||||||
_slSizeOld = pstrmOld->GetStreamSize()-pstrmOld->GetPos_t();
|
_slSizeOld = pstrmOld->GetStreamSize()-pstrmOld->GetPos_t();
|
||||||
_pubOld = (UBYTE*)AllocMemory(_slSizeOld);
|
_pubOld = (UBYTE*)AllocMemory(_slSizeOld);
|
||||||
|
@ -361,7 +361,7 @@ void DIFF_Undiff_t(CTStream *pstrmOld, CTStream *pstrmDiff, CTStream *pstrmNew)
|
||||||
|
|
||||||
UnDiff_t();
|
UnDiff_t();
|
||||||
|
|
||||||
CTimerValue tv1 = _pTimer->GetHighPrecisionTimer();
|
//CTimerValue tv1 = _pTimer->GetHighPrecisionTimer();
|
||||||
//CPrintF("diff decoded in %.2gs\n", (tv1-tv0).GetSeconds());
|
//CPrintF("diff decoded in %.2gs\n", (tv1-tv0).GetSeconds());
|
||||||
|
|
||||||
Cleanup();
|
Cleanup();
|
||||||
|
|
|
@ -655,7 +655,8 @@ extern void FreeUnusedStock(void)
|
||||||
*/
|
*/
|
||||||
void CNetworkTimerHandler::HandleTimer(void)
|
void CNetworkTimerHandler::HandleTimer(void)
|
||||||
{
|
{
|
||||||
if (this==NULL || _bTempNetwork) {
|
ASSERT(this!=NULL);
|
||||||
|
if (_bTempNetwork) {
|
||||||
return; // this can happen during NET_MakeDefaultState_t()!
|
return; // this can happen during NET_MakeDefaultState_t()!
|
||||||
}
|
}
|
||||||
// enable stream handling during timer
|
// enable stream handling during timer
|
||||||
|
@ -676,11 +677,11 @@ void CNetworkTimerHandler::HandleTimer(void)
|
||||||
*/
|
*/
|
||||||
CNetworkLibrary::CNetworkLibrary(void) :
|
CNetworkLibrary::CNetworkLibrary(void) :
|
||||||
ga_IsServer(FALSE), // is not server
|
ga_IsServer(FALSE), // is not server
|
||||||
|
ga_srvServer(*new CServer),
|
||||||
|
ga_sesSessionState(*new CSessionState),
|
||||||
ga_bDemoRec(FALSE), // not recording demo
|
ga_bDemoRec(FALSE), // not recording demo
|
||||||
ga_bDemoPlay(FALSE), // not playing demo
|
ga_bDemoPlay(FALSE), // not playing demo
|
||||||
ga_bDemoPlayFinished(FALSE), // demo not finished
|
ga_bDemoPlayFinished(FALSE) // demo not finished
|
||||||
ga_srvServer(*new CServer),
|
|
||||||
ga_sesSessionState(*new CSessionState)
|
|
||||||
{
|
{
|
||||||
ga_aplsPlayers.New(NET_MAXLOCALPLAYERS);
|
ga_aplsPlayers.New(NET_MAXLOCALPLAYERS);
|
||||||
|
|
||||||
|
@ -902,7 +903,8 @@ void CNetworkLibrary::Init(const CTString &strGameID)
|
||||||
*/
|
*/
|
||||||
void CNetworkLibrary::AddTimerHandler(void)
|
void CNetworkLibrary::AddTimerHandler(void)
|
||||||
{
|
{
|
||||||
if (this==NULL || _bTempNetwork) {
|
ASSERT(this!=NULL);
|
||||||
|
if (_bTempNetwork) {
|
||||||
return; // this can happen during NET_MakeDefaultState_t()!
|
return; // this can happen during NET_MakeDefaultState_t()!
|
||||||
}
|
}
|
||||||
_pTimer->AddHandler(&ga_thTimerHandler);
|
_pTimer->AddHandler(&ga_thTimerHandler);
|
||||||
|
@ -912,7 +914,8 @@ void CNetworkLibrary::AddTimerHandler(void)
|
||||||
*/
|
*/
|
||||||
void CNetworkLibrary::RemoveTimerHandler(void)
|
void CNetworkLibrary::RemoveTimerHandler(void)
|
||||||
{
|
{
|
||||||
if (this==NULL || _bTempNetwork) {
|
ASSERT(this!=NULL);
|
||||||
|
if (_bTempNetwork) {
|
||||||
return; // this can happen during NET_MakeDefaultState_t()!
|
return; // this can happen during NET_MakeDefaultState_t()!
|
||||||
}
|
}
|
||||||
_pTimer->RemHandler(&ga_thTimerHandler);
|
_pTimer->RemHandler(&ga_thTimerHandler);
|
||||||
|
@ -1390,7 +1393,8 @@ void CNetworkLibrary::TogglePause(void)
|
||||||
// test if game is paused
|
// test if game is paused
|
||||||
BOOL CNetworkLibrary::IsPaused(void)
|
BOOL CNetworkLibrary::IsPaused(void)
|
||||||
{
|
{
|
||||||
if (this==NULL || _bTempNetwork) {
|
ASSERT(this!=NULL);
|
||||||
|
if (_bTempNetwork) {
|
||||||
return TRUE; // this can happen during NET_MakeDefaultState_t()!
|
return TRUE; // this can happen during NET_MakeDefaultState_t()!
|
||||||
}
|
}
|
||||||
return ga_sesSessionState.ses_bPause;
|
return ga_sesSessionState.ses_bPause;
|
||||||
|
@ -1427,7 +1431,8 @@ void CNetworkLibrary::SetLocalPause(BOOL bPause)
|
||||||
|
|
||||||
BOOL CNetworkLibrary::GetLocalPause(void)
|
BOOL CNetworkLibrary::GetLocalPause(void)
|
||||||
{
|
{
|
||||||
if (this==NULL || _bTempNetwork) {
|
ASSERT(this!=NULL);
|
||||||
|
if (_bTempNetwork) {
|
||||||
return TRUE; // this can happen during NET_MakeDefaultState_t()!
|
return TRUE; // this can happen during NET_MakeDefaultState_t()!
|
||||||
}
|
}
|
||||||
return ga_bLocalPause;
|
return ga_bLocalPause;
|
||||||
|
@ -2033,7 +2038,8 @@ void CNetworkLibrary::SendActionsToServer(void)
|
||||||
*/
|
*/
|
||||||
void CNetworkLibrary::TimerLoop(void)
|
void CNetworkLibrary::TimerLoop(void)
|
||||||
{
|
{
|
||||||
if (this==NULL || _bTempNetwork) {
|
ASSERT(this!=NULL);
|
||||||
|
if (_bTempNetwork) {
|
||||||
return; // this can happen during NET_MakeDefaultState_t()!
|
return; // this can happen during NET_MakeDefaultState_t()!
|
||||||
}
|
}
|
||||||
_pfNetworkProfile.StartTimer(CNetworkProfile::PTI_TIMERLOOP);
|
_pfNetworkProfile.StartTimer(CNetworkProfile::PTI_TIMERLOOP);
|
||||||
|
|
|
@ -459,8 +459,8 @@ void CServer::SendGameStreamBlocks(INDEX iClient)
|
||||||
nmGameStreamBlocks.PackDefault(nmPackedBlocksNew);
|
nmGameStreamBlocks.PackDefault(nmPackedBlocksNew);
|
||||||
// if some blocks written already and the batch is too large
|
// if some blocks written already and the batch is too large
|
||||||
if (iBlocksOk>0) {
|
if (iBlocksOk>0) {
|
||||||
if (iStep>0 && nmPackedBlocksNew.nm_slSize>=ctMaxBytes ||
|
if ((iStep>0 && nmPackedBlocksNew.nm_slSize>=ctMaxBytes) ||
|
||||||
iStep<0 && nmPackedBlocksNew.nm_slSize>=ctMinBytes ) {
|
(iStep<0 && nmPackedBlocksNew.nm_slSize>=ctMinBytes) ) {
|
||||||
// stop
|
// stop
|
||||||
// CPrintF("toomuch ");
|
// CPrintF("toomuch ");
|
||||||
break;
|
break;
|
||||||
|
@ -728,7 +728,7 @@ void CServer::ServerLoop(void)
|
||||||
// handle all incoming messages
|
// handle all incoming messages
|
||||||
HandleAll();
|
HandleAll();
|
||||||
|
|
||||||
INDEX iSpeed = 1;
|
//INDEX iSpeed = 1;
|
||||||
extern INDEX ser_bWaitFirstPlayer;
|
extern INDEX ser_bWaitFirstPlayer;
|
||||||
// if the local session is keeping up with time and not paused
|
// if the local session is keeping up with time and not paused
|
||||||
BOOL bPaused = srv_bPause || _pNetwork->ga_bLocalPause || _pNetwork->IsWaitingForPlayers() ||
|
BOOL bPaused = srv_bPause || _pNetwork->ga_bLocalPause || _pNetwork->IsWaitingForPlayers() ||
|
||||||
|
@ -1094,8 +1094,8 @@ void CServer::SendSessionStateData(INDEX iClient)
|
||||||
void CServer::HandleAll()
|
void CServer::HandleAll()
|
||||||
{
|
{
|
||||||
// clear last accepted client info
|
// clear last accepted client info
|
||||||
INDEX iClient = -1;
|
/* INDEX iClient = -1;
|
||||||
/* if (_cmiComm.GetLastAccepted(iClient)) {
|
if (_cmiComm.GetLastAccepted(iClient)) {
|
||||||
CPrintF(TRANSV("Server: Accepted session connection by '%s'\n"),
|
CPrintF(TRANSV("Server: Accepted session connection by '%s'\n"),
|
||||||
(const char *) _cmiComm.Server_GetClientName(iClient));
|
(const char *) _cmiComm.Server_GetClientName(iClient));
|
||||||
}
|
}
|
||||||
|
|
|
@ -695,7 +695,7 @@ void CSessionState::HandleMovers(void)
|
||||||
void CSessionState::HandleTimers(TIME tmCurrentTick)
|
void CSessionState::HandleTimers(TIME tmCurrentTick)
|
||||||
{
|
{
|
||||||
#define TIME_EPSILON 0.0001f
|
#define TIME_EPSILON 0.0001f
|
||||||
IFDEBUG(TIME tmLast = 0.0f);
|
//IFDEBUG(TIME tmLast = 0.0f);
|
||||||
|
|
||||||
_pfPhysicsProfile.StartTimer(CPhysicsProfile::PTI_HANDLETIMERS);
|
_pfPhysicsProfile.StartTimer(CPhysicsProfile::PTI_HANDLETIMERS);
|
||||||
// repeat
|
// repeat
|
||||||
|
@ -729,7 +729,7 @@ void CSessionState::HandleTimers(TIME tmCurrentTick)
|
||||||
// check that timers are propertly handled
|
// check that timers are propertly handled
|
||||||
ASSERT(penTimer->en_timeTimer>tmCurrentTick-_pTimer->TickQuantum-TIME_EPSILON);
|
ASSERT(penTimer->en_timeTimer>tmCurrentTick-_pTimer->TickQuantum-TIME_EPSILON);
|
||||||
//ASSERT(penTimer->en_timeTimer>=tmLast);
|
//ASSERT(penTimer->en_timeTimer>=tmLast);
|
||||||
IFDEBUG(tmLast=penTimer->en_timeTimer);
|
//IFDEBUG(tmLast=penTimer->en_timeTimer);
|
||||||
|
|
||||||
// remove the timer from the list
|
// remove the timer from the list
|
||||||
penTimer->en_timeTimer = THINKTIME_NEVER;
|
penTimer->en_timeTimer = THINKTIME_NEVER;
|
||||||
|
|
|
@ -118,7 +118,7 @@ void CRenderer::PreClipPlanes(void)
|
||||||
const FLOAT fx = wpl.wpl_plRelative(1);
|
const FLOAT fx = wpl.wpl_plRelative(1);
|
||||||
const FLOAT fy = wpl.wpl_plRelative(2);
|
const FLOAT fy = wpl.wpl_plRelative(2);
|
||||||
const FLOAT fz = wpl.wpl_plRelative(3);
|
const FLOAT fz = wpl.wpl_plRelative(3);
|
||||||
const FLOAT fd = wpl.wpl_plRelative.Distance();
|
//const FLOAT fd = wpl.wpl_plRelative.Distance();
|
||||||
wpl.wpl_plView(1) = fx*m(1, 1)+fy*m(1, 2)+fz*m(1, 3);
|
wpl.wpl_plView(1) = fx*m(1, 1)+fy*m(1, 2)+fz*m(1, 3);
|
||||||
wpl.wpl_plView(2) = fx*m(2, 1)+fy*m(2, 2)+fz*m(2, 3);
|
wpl.wpl_plView(2) = fx*m(2, 1)+fy*m(2, 2)+fz*m(2, 3);
|
||||||
wpl.wpl_plView(3) = fx*m(3, 1)+fy*m(3, 2)+fz*m(3, 3);
|
wpl.wpl_plView(3) = fx*m(3, 1)+fy*m(3, 2)+fz*m(3, 3);
|
||||||
|
@ -179,8 +179,8 @@ void CRenderer::PreClipPlanes(void)
|
||||||
void CRenderer::PostClipVertices(void)
|
void CRenderer::PostClipVertices(void)
|
||||||
{
|
{
|
||||||
_pfRenderProfile.StartTimer(CRenderProfile::PTI_PROJECTVERTICES);
|
_pfRenderProfile.StartTimer(CRenderProfile::PTI_PROJECTVERTICES);
|
||||||
const FLOATmatrix3D &m = re_pbrCurrent->br_prProjection->pr_RotationMatrix;
|
//const FLOATmatrix3D &m = re_pbrCurrent->br_prProjection->pr_RotationMatrix;
|
||||||
const FLOAT3D &v = re_pbrCurrent->br_prProjection->pr_TranslationVector;
|
//const FLOAT3D &v = re_pbrCurrent->br_prProjection->pr_TranslationVector;
|
||||||
|
|
||||||
// if the projection is perspective
|
// if the projection is perspective
|
||||||
if (re_pbrCurrent->br_prProjection.IsPerspective()) {
|
if (re_pbrCurrent->br_prProjection.IsPerspective()) {
|
||||||
|
@ -449,8 +449,8 @@ inline void CRenderer::MakeScreenEdge(
|
||||||
sed.sed_xI = (FIX16_16) (fI0 + ((FLOAT)sed.sed_pixTopJ-fJ0) * fDIoDJ );
|
sed.sed_xI = (FIX16_16) (fI0 + ((FLOAT)sed.sed_pixTopJ-fJ0) * fDIoDJ );
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT( sed.sed_xI > FIX16_16(-1.0f)
|
ASSERT( (sed.sed_xI > FIX16_16(-1.0f)
|
||||||
&& sed.sed_xI < FIX16_16(re_fbbClipBox.Max()(1) + SENTINELEDGE_EPSILON)
|
&& sed.sed_xI < FIX16_16(re_fbbClipBox.Max()(1) + SENTINELEDGE_EPSILON))
|
||||||
|| (sed.sed_pixTopJ >= sed.sed_pixBottomJ));
|
|| (sed.sed_pixTopJ >= sed.sed_pixBottomJ));
|
||||||
|
|
||||||
// return the screen edge
|
// return the screen edge
|
||||||
|
@ -749,7 +749,7 @@ CScreenPolygon *CRenderer::MakeScreenPolygon(CBrushPolygon &bpo)
|
||||||
sppo.spo_aubTextureFlags[0] = STXF_BLEND_ALPHA;
|
sppo.spo_aubTextureFlags[0] = STXF_BLEND_ALPHA;
|
||||||
}
|
}
|
||||||
// get its mapping gradients from shadowmap and stretch
|
// get its mapping gradients from shadowmap and stretch
|
||||||
CWorkingPlane &wpl = *bpo.bpo_pbplPlane->bpl_pwplWorking;
|
//CWorkingPlane &wpl = *bpo.bpo_pbplPlane->bpl_pwplWorking;
|
||||||
sppo.spo_amvMapping[0] = sppo.spo_amvMapping[3];
|
sppo.spo_amvMapping[0] = sppo.spo_amvMapping[3];
|
||||||
FLOAT fStretch = bpo.bpo_boxBoundingBox.Size().Length()/1000;
|
FLOAT fStretch = bpo.bpo_boxBoundingBox.Size().Length()/1000;
|
||||||
sppo.spo_amvMapping[0].mv_vU *= fStretch;
|
sppo.spo_amvMapping[0].mv_vU *= fStretch;
|
||||||
|
@ -779,23 +779,23 @@ CScreenPolygon *CRenderer::MakeScreenPolygon(CBrushPolygon &bpo)
|
||||||
void CRenderer::AddPolygonToScene( CScreenPolygon *pspo)
|
void CRenderer::AddPolygonToScene( CScreenPolygon *pspo)
|
||||||
{
|
{
|
||||||
// if the polygon is not falid or occluder and not selected
|
// if the polygon is not falid or occluder and not selected
|
||||||
CBrushPolygon &bpo = *pspo->spo_pbpoBrushPolygon;
|
CBrushPolygon *pbpo = pspo->spo_pbpoBrushPolygon;
|
||||||
if( &bpo==NULL || ((bpo.bpo_ulFlags&BPOF_OCCLUDER) && (!(bpo.bpo_ulFlags&BPOF_SELECTED) ||
|
if(pbpo==NULL || ((pbpo->bpo_ulFlags&BPOF_OCCLUDER) && (!(pbpo->bpo_ulFlags&BPOF_SELECTED) ||
|
||||||
_wrpWorldRenderPrefs.GetSelectionType()!=CWorldRenderPrefs::ST_POLYGONS))) {
|
_wrpWorldRenderPrefs.GetSelectionType()!=CWorldRenderPrefs::ST_POLYGONS))) {
|
||||||
// do not add it to rendering
|
// do not add it to rendering
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CBrushSector &bsc = *bpo.bpo_pbscSector;
|
CBrushSector &bsc = *pbpo->bpo_pbscSector;
|
||||||
ScenePolygon &sppo = pspo->spo_spoScenePolygon;
|
ScenePolygon &sppo = pspo->spo_spoScenePolygon;
|
||||||
const CViewVertex *pvvx0 = &re_avvxViewVertices[bsc.bsc_ivvx0];
|
const CViewVertex *pvvx0 = &re_avvxViewVertices[bsc.bsc_ivvx0];
|
||||||
const INDEX ctVtx = bpo.bpo_apbvxTriangleVertices.Count();
|
const INDEX ctVtx = pbpo->bpo_apbvxTriangleVertices.Count();
|
||||||
sppo.spo_iVtx0 = _avtxScene.Count();
|
sppo.spo_iVtx0 = _avtxScene.Count();
|
||||||
GFXVertex3 *pvtx = _avtxScene.Push(ctVtx);
|
GFXVertex3 *pvtx = _avtxScene.Push(ctVtx);
|
||||||
|
|
||||||
// find vertex with nearest Z distance while copying vertices
|
// find vertex with nearest Z distance while copying vertices
|
||||||
FLOAT fNearestZ = 123456789.0f;
|
FLOAT fNearestZ = 123456789.0f;
|
||||||
for( INDEX i=0; i<ctVtx; i++) {
|
for( INDEX i=0; i<ctVtx; i++) {
|
||||||
CBrushVertex *pbvx = bpo.bpo_apbvxTriangleVertices[i];
|
CBrushVertex *pbvx = pbpo->bpo_apbvxTriangleVertices[i];
|
||||||
const INDEX iVtx = bsc.bsc_abvxVertices.Index(pbvx);
|
const INDEX iVtx = bsc.bsc_abvxVertices.Index(pbvx);
|
||||||
const FLOAT3D &v = pvvx0[iVtx].vvx_vView;
|
const FLOAT3D &v = pvvx0[iVtx].vvx_vView;
|
||||||
if( -v(3)<fNearestZ) fNearestZ = -v(3); // inverted because of negative sign
|
if( -v(3)<fNearestZ) fNearestZ = -v(3); // inverted because of negative sign
|
||||||
|
@ -809,8 +809,8 @@ void CRenderer::AddPolygonToScene( CScreenPolygon *pspo)
|
||||||
|
|
||||||
// all done
|
// all done
|
||||||
sppo.spo_ctVtx = ctVtx;
|
sppo.spo_ctVtx = ctVtx;
|
||||||
sppo.spo_ctElements = bpo.bpo_aiTriangleElements.Count();
|
sppo.spo_ctElements = pbpo->bpo_aiTriangleElements.Count();
|
||||||
sppo.spo_piElements = sppo.spo_ctElements ? &bpo.bpo_aiTriangleElements[0] : NULL;
|
sppo.spo_piElements = sppo.spo_ctElements ? &pbpo->bpo_aiTriangleElements[0] : NULL;
|
||||||
_sfStats.IncrementCounter(CStatForm::SCI_SCENE_TRIANGLES, sppo.spo_ctElements/3);
|
_sfStats.IncrementCounter(CStatForm::SCI_SCENE_TRIANGLES, sppo.spo_ctElements/3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -870,7 +870,7 @@ void CRenderer::AddSpansToScene(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FLOAT fpixLastScanJOffseted = re_pixCurrentScanJ-1 +OFFSET_DN;
|
//FLOAT fpixLastScanJOffseted = re_pixCurrentScanJ-1 +OFFSET_DN;
|
||||||
// first, little safety check - quit if zero spans in line!
|
// first, little safety check - quit if zero spans in line!
|
||||||
INDEX ctSpans = re_aspSpans.Count();
|
INDEX ctSpans = re_aspSpans.Count();
|
||||||
if( ctSpans==0) {
|
if( ctSpans==0) {
|
||||||
|
|
9
Sources/Engine/Rendering/RendASER.cpp
Normal file → Executable file
9
Sources/Engine/Rendering/RendASER.cpp
Normal file → Executable file
|
@ -34,7 +34,6 @@ void CRenderer::AddAddListToActiveList(INDEX iScanLine)
|
||||||
// allocate space in destination for sum of source and add
|
// allocate space in destination for sum of source and add
|
||||||
INDEX ctActiveEdges = re_aaceActiveEdges.Count();
|
INDEX ctActiveEdges = re_aaceActiveEdges.Count();
|
||||||
re_aaceActiveEdgesTmp.Push(ctAddEdges+ctActiveEdges);
|
re_aaceActiveEdgesTmp.Push(ctAddEdges+ctActiveEdges);
|
||||||
|
|
||||||
// check that the add list is sorted right
|
// check that the add list is sorted right
|
||||||
#if ASER_EXTREME_CHECKING
|
#if ASER_EXTREME_CHECKING
|
||||||
{
|
{
|
||||||
|
@ -66,18 +65,18 @@ void CRenderer::AddAddListToActiveList(INDEX iScanLine)
|
||||||
// start at begining of add list, source active list and destination active list
|
// start at begining of add list, source active list and destination active list
|
||||||
LISTITER(CAddEdge, ade_lnInAdd) itadeAdd(lhAdd);
|
LISTITER(CAddEdge, ade_lnInAdd) itadeAdd(lhAdd);
|
||||||
CActiveEdge *paceSrc = &re_aaceActiveEdges[0];
|
CActiveEdge *paceSrc = &re_aaceActiveEdges[0];
|
||||||
|
CActiveEdge *paceEnd = &re_aaceActiveEdges[re_aaceActiveEdges.Count()-1];
|
||||||
CActiveEdge *paceDst = &re_aaceActiveEdgesTmp[0];
|
CActiveEdge *paceDst = &re_aaceActiveEdgesTmp[0];
|
||||||
|
|
||||||
IFDEBUG(INDEX ctNewActive=0);
|
IFDEBUG(INDEX ctNewActive=0);
|
||||||
IFDEBUG(INDEX ctOldActive1=0);
|
IFDEBUG(INDEX ctOldActive1=0);
|
||||||
IFDEBUG(INDEX ctOldActive2=0);
|
IFDEBUG(INDEX ctOldActive2=0);
|
||||||
|
|
||||||
// for each edge in add list
|
// for each edge in add list
|
||||||
while(!itadeAdd.IsPastEnd()) {
|
while(!itadeAdd.IsPastEnd()) {
|
||||||
CAddEdge &ade = *itadeAdd;
|
CAddEdge &ade = *itadeAdd;
|
||||||
|
|
||||||
// while the edge in active list is left of the edge in add list
|
// while the edge in active list is left of the edge in add list
|
||||||
while (paceSrc->ace_xI.slHolder < itadeAdd->ade_xI.slHolder) {
|
while ((paceSrc->ace_xI.slHolder < ade.ade_xI.slHolder) && (paceSrc!=paceEnd)) {
|
||||||
// copy the active edge
|
// copy the active edge
|
||||||
ASSERT(paceSrc<=&re_aaceActiveEdges[ctActiveEdges-1]);
|
ASSERT(paceSrc<=&re_aaceActiveEdges[ctActiveEdges-1]);
|
||||||
*paceDst++=*paceSrc++;
|
*paceDst++=*paceSrc++;
|
||||||
|
@ -763,7 +762,7 @@ CScreenPolygon *CRenderer::ScanOneLine(void)
|
||||||
}
|
}
|
||||||
// remove all left-over polygons from stack
|
// remove all left-over polygons from stack
|
||||||
do {
|
do {
|
||||||
BOOL bWasTop = RemPolygonFromSurfaceStack(*pspoTop);
|
/* BOOL bWasTop = */ RemPolygonFromSurfaceStack(*pspoTop);
|
||||||
pspoTop = LIST_HEAD(re_lhSurfaceStack, CScreenPolygon, spo_lnInStack);
|
pspoTop = LIST_HEAD(re_lhSurfaceStack, CScreenPolygon, spo_lnInStack);
|
||||||
} while (&re_spoFarSentinel != pspoTop);
|
} while (&re_spoFarSentinel != pspoTop);
|
||||||
// mark start of background span at right border
|
// mark start of background span at right border
|
||||||
|
@ -810,7 +809,7 @@ void CRenderer::ScanEdges(void)
|
||||||
CopyActiveCoordinates();
|
CopyActiveCoordinates();
|
||||||
|
|
||||||
// if scan-line is not coherent with the last one
|
// if scan-line is not coherent with the last one
|
||||||
} else/**/ {
|
} else*/ {
|
||||||
|
|
||||||
// scan list of active edges into spans
|
// scan list of active edges into spans
|
||||||
pspoPortal = ScanOneLine();
|
pspoPortal = ScanOneLine();
|
||||||
|
|
|
@ -105,10 +105,7 @@ static SLONG slTmp;
|
||||||
|
|
||||||
static inline PIX PIXCoord(FLOAT f) // (f+0.9999f) or (ceil(f))
|
static inline PIX PIXCoord(FLOAT f) // (f+0.9999f) or (ceil(f))
|
||||||
{
|
{
|
||||||
#if (defined USE_PORTABLE_C)
|
#if (defined __MSVC_INLINE__)
|
||||||
return((PIX) (f+0.9999f));
|
|
||||||
|
|
||||||
#elif (defined __MSVC_INLINE__)
|
|
||||||
PIX pixRet;
|
PIX pixRet;
|
||||||
__asm {
|
__asm {
|
||||||
fld dword ptr [f]
|
fld dword ptr [f]
|
||||||
|
@ -123,7 +120,7 @@ static inline PIX PIXCoord(FLOAT f) // (f+0.9999f) or (ceil(f))
|
||||||
}
|
}
|
||||||
return pixRet;
|
return pixRet;
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
PIX pixRet;
|
PIX pixRet;
|
||||||
SLONG clobber;
|
SLONG clobber;
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
|
@ -142,7 +139,8 @@ static inline PIX PIXCoord(FLOAT f) // (f+0.9999f) or (ceil(f))
|
||||||
return pixRet;
|
return pixRet;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error Please write inline ASM for your platform.
|
return((PIX) (f+0.9999f));
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -512,20 +512,20 @@ void CRenderer::RenderWireFrameTerrains(void)
|
||||||
papr = &re_prProjection;
|
papr = &re_prProjection;
|
||||||
|
|
||||||
BOOL bShowEdges = _wrpWorldRenderPrefs.wrp_ftEdges != CWorldRenderPrefs::FT_NONE;
|
BOOL bShowEdges = _wrpWorldRenderPrefs.wrp_ftEdges != CWorldRenderPrefs::FT_NONE;
|
||||||
BOOL bShowVertices = _wrpWorldRenderPrefs.wrp_ftVertices != CWorldRenderPrefs::FT_NONE;
|
//BOOL bShowVertices = _wrpWorldRenderPrefs.wrp_ftVertices != CWorldRenderPrefs::FT_NONE;
|
||||||
// BOOL bForceRegenerate = _wrpWorldRenderPrefs.wrp_ftPolygons
|
// BOOL bForceRegenerate = _wrpWorldRenderPrefs.wrp_ftPolygons
|
||||||
|
|
||||||
COLOR colEdges = _wrpWorldRenderPrefs.wrp_colEdges;
|
COLOR colEdges = _wrpWorldRenderPrefs.wrp_colEdges;
|
||||||
COLOR colVertices = 0xFF0000FF;
|
//COLOR colVertices = 0xFF0000FF;
|
||||||
// for all active terrains
|
// for all active terrains
|
||||||
{FORDELETELIST(CTerrain, tr_lnInActiveTerrains, re_lhActiveTerrains, ittr) {
|
{FORDELETELIST(CTerrain, tr_lnInActiveTerrains, re_lhActiveTerrains, ittr) {
|
||||||
// render terrain
|
// render terrain
|
||||||
if(bShowEdges) {
|
if(bShowEdges) {
|
||||||
ittr->RenderWireFrame(*papr, re_pdpDrawPort,colEdges);
|
ittr->RenderWireFrame(*papr, re_pdpDrawPort,colEdges);
|
||||||
}
|
}
|
||||||
if(bShowVertices) {
|
/*if(bShowVertices) {
|
||||||
//ittr->RenderVertices(*papr, re_pdpDrawPort,colVertices);
|
//ittr->RenderVertices(*papr, re_pdpDrawPort,colVertices);
|
||||||
}
|
}*/
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
// draw the prepared things to screen
|
// draw the prepared things to screen
|
||||||
|
@ -564,7 +564,7 @@ void CRenderer::DrawToScreen(void)
|
||||||
&&_wrpWorldRenderPrefs.wrp_ftPolygons != CWorldRenderPrefs::FT_NONE) {
|
&&_wrpWorldRenderPrefs.wrp_ftPolygons != CWorldRenderPrefs::FT_NONE) {
|
||||||
// render translucent portals
|
// render translucent portals
|
||||||
_pfRenderProfile.StartTimer(CRenderProfile::PTI_RENDERSCENE);
|
_pfRenderProfile.StartTimer(CRenderProfile::PTI_RENDERSCENE);
|
||||||
CPerspectiveProjection3D *pprPerspective = (CPerspectiveProjection3D*)(CProjection3D*)(re_prBackgroundProjection);
|
//CPerspectiveProjection3D *pprPerspective = (CPerspectiveProjection3D*)(CProjection3D*)(re_prBackgroundProjection);
|
||||||
RenderScene( re_pdpDrawPort, SortTranslucentPolygons(re_pspoFirstBackgroundTranslucent),
|
RenderScene( re_pdpDrawPort, SortTranslucentPolygons(re_pspoFirstBackgroundTranslucent),
|
||||||
re_prBackgroundProjection, re_colSelection, TRUE);
|
re_prBackgroundProjection, re_colSelection, TRUE);
|
||||||
_pfRenderProfile.StopTimer(CRenderProfile::PTI_RENDERSCENE);
|
_pfRenderProfile.StopTimer(CRenderProfile::PTI_RENDERSCENE);
|
||||||
|
@ -583,7 +583,7 @@ void CRenderer::DrawToScreen(void)
|
||||||
// render the spans to screen
|
// render the spans to screen
|
||||||
re_prProjection->Prepare();
|
re_prProjection->Prepare();
|
||||||
_pfRenderProfile.StartTimer(CRenderProfile::PTI_RENDERSCENE);
|
_pfRenderProfile.StartTimer(CRenderProfile::PTI_RENDERSCENE);
|
||||||
CPerspectiveProjection3D *pprPerspective = (CPerspectiveProjection3D*)(CProjection3D*)re_prProjection;
|
//CPerspectiveProjection3D *pprPerspective = (CPerspectiveProjection3D*)(CProjection3D*)re_prProjection;
|
||||||
RenderScene( re_pdpDrawPort, re_pspoFirst, re_prProjection, re_colSelection, FALSE);
|
RenderScene( re_pdpDrawPort, re_pspoFirst, re_prProjection, re_colSelection, FALSE);
|
||||||
_pfRenderProfile.StopTimer(CRenderProfile::PTI_RENDERSCENE);
|
_pfRenderProfile.StopTimer(CRenderProfile::PTI_RENDERSCENE);
|
||||||
}
|
}
|
||||||
|
@ -659,7 +659,7 @@ void CRenderer::FillMirrorDepth(CMirror &mi)
|
||||||
// for each polygon
|
// for each polygon
|
||||||
FOREACHINDYNAMICCONTAINER(mi.mi_cspoPolygons, CScreenPolygon, itspo) {
|
FOREACHINDYNAMICCONTAINER(mi.mi_cspoPolygons, CScreenPolygon, itspo) {
|
||||||
CScreenPolygon &spo = *itspo;
|
CScreenPolygon &spo = *itspo;
|
||||||
CBrushPolygon &bpo = *spo.spo_pbpoBrushPolygon;
|
//CBrushPolygon &bpo = *spo.spo_pbpoBrushPolygon;
|
||||||
// create a new screen polygon
|
// create a new screen polygon
|
||||||
CScreenPolygon &spoNew = re_aspoScreenPolygons.Push();
|
CScreenPolygon &spoNew = re_aspoScreenPolygons.Push();
|
||||||
ScenePolygon &sppoNew = spoNew.spo_spoScenePolygon;
|
ScenePolygon &sppoNew = spoNew.spo_spoScenePolygon;
|
||||||
|
@ -870,9 +870,9 @@ void CRenderer::Render(void)
|
||||||
// or not rendering second layer in world editor
|
// or not rendering second layer in world editor
|
||||||
// and not in wireframe mode
|
// and not in wireframe mode
|
||||||
if( re_iIndex>0
|
if( re_iIndex>0
|
||||||
|| !re_bRenderingShadows
|
|| (!re_bRenderingShadows
|
||||||
&& !re_pdpDrawPort->IsOverlappedRendering()
|
&& !re_pdpDrawPort->IsOverlappedRendering()
|
||||||
&& _wrpWorldRenderPrefs.wrp_ftPolygons != CWorldRenderPrefs::FT_NONE) {
|
&& _wrpWorldRenderPrefs.wrp_ftPolygons != CWorldRenderPrefs::FT_NONE)) {
|
||||||
re_pdpDrawPort->FillZBuffer(ZBUF_BACK);
|
re_pdpDrawPort->FillZBuffer(ZBUF_BACK);
|
||||||
}
|
}
|
||||||
// draw the prepared things to screen and finish
|
// draw the prepared things to screen and finish
|
||||||
|
|
|
@ -762,7 +762,7 @@ void CRenderer::AddZoningSectorsAroundBox(const FLOATaabbox3D &boxNear)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// if it is not zoning brush
|
// if it is not zoning brush
|
||||||
if (iten->en_RenderType!=CEntity::RT_BRUSH && iten->en_RenderType!=CEntity::RT_FIELDBRUSH
|
if ((iten->en_RenderType!=CEntity::RT_BRUSH && iten->en_RenderType!=CEntity::RT_FIELDBRUSH)
|
||||||
||!(iten->en_ulFlags&ENF_ZONING)) {
|
||!(iten->en_ulFlags&ENF_ZONING)) {
|
||||||
// skip it
|
// skip it
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -20,8 +20,8 @@ void CRenderer::DrawBrushPolygonVerticesAndEdges(CBrushPolygon &bpo)
|
||||||
CBrushSector &bsc = *bpo.bpo_pbscSector;
|
CBrushSector &bsc = *bpo.bpo_pbscSector;
|
||||||
CBrushMip *pbm = bsc.bsc_pbmBrushMip;
|
CBrushMip *pbm = bsc.bsc_pbmBrushMip;
|
||||||
CBrush3D &br = *pbm->bm_pbrBrush;
|
CBrush3D &br = *pbm->bm_pbrBrush;
|
||||||
INDEX iMinVx = bsc.bsc_ivvx0;
|
//INDEX iMinVx = bsc.bsc_ivvx0;
|
||||||
INDEX iMaxVx = bsc.bsc_ivvx0+bsc.bsc_awvxVertices.Count();
|
//INDEX iMaxVx = bsc.bsc_ivvx0+bsc.bsc_awvxVertices.Count();
|
||||||
|
|
||||||
// set line type and color for edges and vertices
|
// set line type and color for edges and vertices
|
||||||
ULONG ulEdgesLineType = EdgeLineType(wplPolygonPlane.wpl_bVisible);
|
ULONG ulEdgesLineType = EdgeLineType(wplPolygonPlane.wpl_bVisible);
|
||||||
|
@ -154,8 +154,8 @@ void CRenderer::DrawBrushPolygonVerticesAndEdges(CBrushPolygon &bpo)
|
||||||
*/
|
*/
|
||||||
void CRenderer::DrawBrushSectorVerticesAndEdges(CBrushSector &bscSector)
|
void CRenderer::DrawBrushSectorVerticesAndEdges(CBrushSector &bscSector)
|
||||||
{
|
{
|
||||||
CBrushMip *pbm = bscSector.bsc_pbmBrushMip;
|
//CBrushMip *pbm = bscSector.bsc_pbmBrushMip;
|
||||||
CBrush3D &br = *pbm->bm_pbrBrush;
|
//CBrush3D &br = *pbm->bm_pbrBrush;
|
||||||
|
|
||||||
// clear all vertex drawn flags
|
// clear all vertex drawn flags
|
||||||
FOREACHINSTATICARRAY(bscSector.bsc_abvxVertices, CBrushVertex, itbvx) {
|
FOREACHINSTATICARRAY(bscSector.bsc_abvxVertices, CBrushVertex, itbvx) {
|
||||||
|
@ -275,7 +275,7 @@ void CRenderer::PrepareBrush(CEntity *penBrush)
|
||||||
// for static brushes
|
// for static brushes
|
||||||
CProjection3D &pr = *brBrush.br_prProjection;
|
CProjection3D &pr = *brBrush.br_prProjection;
|
||||||
const FLOATmatrix3D &mRot = penBrush->en_mRotation;
|
const FLOATmatrix3D &mRot = penBrush->en_mRotation;
|
||||||
const FLOAT3D &vRot = penBrush->en_plPlacement.pl_PositionVector;
|
//const FLOAT3D &vRot = penBrush->en_plPlacement.pl_PositionVector;
|
||||||
// fixup projection to use placement of this brush
|
// fixup projection to use placement of this brush
|
||||||
pr.pr_mDirectionRotation = pr.pr_ViewerRotationMatrix*mRot;
|
pr.pr_mDirectionRotation = pr.pr_ViewerRotationMatrix*mRot;
|
||||||
pr.pr_RotationMatrix = pr.pr_mDirectionRotation;
|
pr.pr_RotationMatrix = pr.pr_mDirectionRotation;
|
||||||
|
|
|
@ -789,7 +789,7 @@ void CMesh::Read_t(CTStream *istrFile)
|
||||||
// read float count
|
// read float count
|
||||||
(*istrFile)>>ctfl;
|
(*istrFile)>>ctfl;
|
||||||
|
|
||||||
CShader *pshMeshShader = NULL;
|
//CShader *pshMeshShader = NULL;
|
||||||
ShaderParams *pshpShaderParams = NULL;
|
ShaderParams *pshpShaderParams = NULL;
|
||||||
CShader shDummyShader; // dummy shader if shader is not found
|
CShader shDummyShader; // dummy shader if shader is not found
|
||||||
ShaderParams shpDummyShaderParams;// dummy shader params if shader is not found
|
ShaderParams shpDummyShaderParams;// dummy shader params if shader is not found
|
||||||
|
@ -799,12 +799,12 @@ void CMesh::Read_t(CTStream *istrFile)
|
||||||
// try to load shader
|
// try to load shader
|
||||||
try{
|
try{
|
||||||
msrf.msrf_pShader = _pShaderStock->Obtain_t(strShaderName);
|
msrf.msrf_pShader = _pShaderStock->Obtain_t(strShaderName);
|
||||||
pshMeshShader = msrf.msrf_pShader;
|
//pshMeshShader = msrf.msrf_pShader;
|
||||||
pshpShaderParams = &msrf.msrf_ShadingParams;
|
pshpShaderParams = &msrf.msrf_ShadingParams;
|
||||||
} catch(char *strErr) {
|
} catch(char *strErr) {
|
||||||
CPrintF("%s\n",strErr);
|
CPrintF("%s\n",strErr);
|
||||||
msrf.msrf_pShader = NULL;
|
msrf.msrf_pShader = NULL;
|
||||||
pshMeshShader = &shDummyShader;
|
//pshMeshShader = &shDummyShader;
|
||||||
pshpShaderParams = &shpDummyShaderParams;
|
pshpShaderParams = &shpDummyShaderParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -263,6 +263,7 @@ static void GetHazeMapInVertex( GFXVertex4 &vtx, FLOAT &tx1)
|
||||||
tx1 = (fD+_fHazeAdd) * _haze_fMul;
|
tx1 = (fD+_fHazeAdd) * _haze_fMul;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0 // DG: unused
|
||||||
// check model's bounding box against fog
|
// check model's bounding box against fog
|
||||||
static BOOL IsModelInFog( FLOAT3D &vMin, FLOAT3D &vMax)
|
static BOOL IsModelInFog( FLOAT3D &vMin, FLOAT3D &vMax)
|
||||||
{
|
{
|
||||||
|
@ -294,6 +295,7 @@ static BOOL IsModelInHaze( FLOAT3D &vMin, FLOAT3D &vMax)
|
||||||
vtx.x=vMax(1); vtx.y=vMax(2); vtx.z=vMax(3); GetHazeMapInVertex(vtx,fS); if(InHaze(fS)) return TRUE;
|
vtx.x=vMax(1); vtx.y=vMax(2); vtx.z=vMax(3); GetHazeMapInVertex(vtx,fS); if(InHaze(fS)) return TRUE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
#endif // 0 (unused)
|
||||||
|
|
||||||
BOOL PrepareHaze(void)
|
BOOL PrepareHaze(void)
|
||||||
{
|
{
|
||||||
|
@ -312,7 +314,7 @@ BOOL PrepareHaze(void)
|
||||||
// _fFogAddZ = _vViewer % (rm.rm_vObjectPosition - _aprProjection->pr_vViewerPosition); // BUG in compiler !!!!
|
// _fFogAddZ = _vViewer % (rm.rm_vObjectPosition - _aprProjection->pr_vViewerPosition); // BUG in compiler !!!!
|
||||||
_fFogAddZ = -_mObjToView[11];
|
_fFogAddZ = -_mObjToView[11];
|
||||||
// get fog offset
|
// get fog offset
|
||||||
_fFogAddH = _fog_fAddH;/*(
|
_fFogAddH = _fog_fAddH; // (
|
||||||
_vHDirView(1)*_mObjToView[3] +
|
_vHDirView(1)*_mObjToView[3] +
|
||||||
_vHDirView(2)*_mObjToView[7] +
|
_vHDirView(2)*_mObjToView[7] +
|
||||||
_vHDirView(3)*_mObjToView[11]) + _fog_fp.fp_fH3;
|
_vHDirView(3)*_mObjToView[11]) + _fog_fp.fp_fH3;
|
||||||
|
@ -2087,7 +2089,7 @@ static void RenderMesh(RenMesh &rmsh,RenModel &rm)
|
||||||
|
|
||||||
// clamp surface texture count to max number of textrues in mesh
|
// clamp surface texture count to max number of textrues in mesh
|
||||||
INDEX cttx = pShaderParams->sp_aiTextureIDs.Count();
|
INDEX cttx = pShaderParams->sp_aiTextureIDs.Count();
|
||||||
INDEX cttxMax = rmsh.rmsh_pMeshInst->mi_tiTextures.Count();
|
//INDEX cttxMax = rmsh.rmsh_pMeshInst->mi_tiTextures.Count();
|
||||||
// cttx = ClampUp(cttx,cttxMax);
|
// cttx = ClampUp(cttx,cttxMax);
|
||||||
|
|
||||||
_patoTextures.PopAll();
|
_patoTextures.PopAll();
|
||||||
|
@ -2250,7 +2252,7 @@ static void PrepareMeshForRendering(RenMesh &rmsh, INDEX iSkeletonlod)
|
||||||
} else {
|
} else {
|
||||||
// blend absolute (1-f)*cur + f*dst
|
// blend absolute (1-f)*cur + f*dst
|
||||||
INDEX vtx = rm.rmp_pmmmMorphMap->mmp_aMorphMap[ivx].mwm_iVxIndex;
|
INDEX vtx = rm.rmp_pmmmMorphMap->mmp_aMorphMap[ivx].mwm_iVxIndex;
|
||||||
MeshVertex &mvSrc = mlod.mlod_aVertices[vtx];
|
//MeshVertex &mvSrc = mlod.mlod_aVertices[vtx];
|
||||||
MeshVertexMorph &mvmDst = rm.rmp_pmmmMorphMap->mmp_aMorphMap[ivx];
|
MeshVertexMorph &mvmDst = rm.rmp_pmmmMorphMap->mmp_aMorphMap[ivx];
|
||||||
// blend vertices
|
// blend vertices
|
||||||
_aMorphedVtxs[vtx].x = (1.0f-rm.rmp_fFactor) * _aMorphedVtxs[vtx].x + rm.rmp_fFactor*mvmDst.mwm_x;
|
_aMorphedVtxs[vtx].x = (1.0f-rm.rmp_fFactor) * _aMorphedVtxs[vtx].x + rm.rmp_fFactor*mvmDst.mwm_x;
|
||||||
|
|
|
@ -252,16 +252,14 @@ SLONG CSoundData::GetUsedMemory(void)
|
||||||
// Add one reference
|
// Add one reference
|
||||||
void CSoundData::AddReference(void)
|
void CSoundData::AddReference(void)
|
||||||
{
|
{
|
||||||
if (this!=NULL) {
|
ASSERT(this!=NULL);
|
||||||
MarkUsed();
|
MarkUsed();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Remove one reference
|
// Remove one reference
|
||||||
void CSoundData::RemReference(void)
|
void CSoundData::RemReference(void)
|
||||||
{
|
{
|
||||||
if (this!=NULL) {
|
ASSERT(this!=NULL);
|
||||||
_pSoundStock->Release(this);
|
_pSoundStock->Release(this);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,18 +103,19 @@ static HINSTANCE _hInstDS = NULL;
|
||||||
static CTString snd_strDeviceName;
|
static CTString snd_strDeviceName;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static INDEX _iWriteOffset = 0;
|
|
||||||
static INDEX _iWriteOffset2 = 0;
|
|
||||||
static BOOL _bMuted = FALSE;
|
static BOOL _bMuted = FALSE;
|
||||||
static INDEX _iLastEnvType = 1234;
|
static INDEX _iLastEnvType = 1234;
|
||||||
static FLOAT _fLastEnvSize = 1234;
|
static FLOAT _fLastEnvSize = 1234;
|
||||||
static FLOAT _fLastPanning = 1234;
|
|
||||||
|
|
||||||
|
#ifdef PLATFORM_WIN32
|
||||||
|
static FLOAT _fLastPanning = 1234;
|
||||||
|
static INDEX _iWriteOffset = 0;
|
||||||
|
static INDEX _iWriteOffset2 = 0;
|
||||||
|
|
||||||
// TEMP! - for writing mixer buffer to file
|
// TEMP! - for writing mixer buffer to file
|
||||||
static FILE *_filMixerBuffer;
|
static FILE *_filMixerBuffer;
|
||||||
static BOOL _bOpened = FALSE;
|
static BOOL _bOpened = FALSE;
|
||||||
|
#endif
|
||||||
|
|
||||||
#define WAVEOUTBLOCKSIZE 1024
|
#define WAVEOUTBLOCKSIZE 1024
|
||||||
#define MINPAN (1.0f)
|
#define MINPAN (1.0f)
|
||||||
|
@ -1232,6 +1233,7 @@ BOOL CSoundLibrary::SetEnvironment( INDEX iEnvNo, FLOAT fEnvSize/*=0*/)
|
||||||
// mute all sounds (erase playing buffer(s) and supress mixer)
|
// mute all sounds (erase playing buffer(s) and supress mixer)
|
||||||
void CSoundLibrary::Mute(void)
|
void CSoundLibrary::Mute(void)
|
||||||
{
|
{
|
||||||
|
ASSERT(this!=NULL);
|
||||||
// stop all IFeel effects
|
// stop all IFeel effects
|
||||||
IFeel_StopEffect(NULL);
|
IFeel_StopEffect(NULL);
|
||||||
|
|
||||||
|
@ -1243,7 +1245,7 @@ void CSoundLibrary::Mute(void)
|
||||||
|
|
||||||
#ifdef PLATFORM_WIN32
|
#ifdef PLATFORM_WIN32
|
||||||
// erase direct sound buffer (waveout will shut-up by itself), but skip if there's no more sound library
|
// erase direct sound buffer (waveout will shut-up by itself), but skip if there's no more sound library
|
||||||
if( this==NULL || !sl_bUsingDirectSound) return;
|
if(!sl_bUsingDirectSound) return;
|
||||||
|
|
||||||
// synchronize access to sounds
|
// synchronize access to sounds
|
||||||
CTSingleLock slSounds(&sl_csSound, TRUE);
|
CTSingleLock slSounds(&sl_csSound, TRUE);
|
||||||
|
@ -1467,10 +1469,10 @@ void CSoundTimerHandler::HandleTimer(void)
|
||||||
|
|
||||||
// copying of mixer buffer to sound buffer(s)
|
// copying of mixer buffer to sound buffer(s)
|
||||||
|
|
||||||
|
#ifdef PLATFORM_WIN32
|
||||||
static LPVOID _lpData, _lpData2;
|
static LPVOID _lpData, _lpData2;
|
||||||
static DWORD _dwSize, _dwSize2;
|
static DWORD _dwSize, _dwSize2;
|
||||||
|
|
||||||
#ifdef PLATFORM_WIN32
|
|
||||||
static void CopyMixerBuffer_dsound( CSoundLibrary &sl, SLONG slMixedSize)
|
static void CopyMixerBuffer_dsound( CSoundLibrary &sl, SLONG slMixedSize)
|
||||||
{
|
{
|
||||||
LPVOID lpData;
|
LPVOID lpData;
|
||||||
|
@ -1660,7 +1662,7 @@ void CSoundLibrary::MixSounds(void)
|
||||||
_pfSoundProfile.IncrementCounter(CSoundProfile::PCI_MIXINGS, 1);
|
_pfSoundProfile.IncrementCounter(CSoundProfile::PCI_MIXINGS, 1);
|
||||||
ResetMixer( sl_pslMixerBuffer, slDataToMix);
|
ResetMixer( sl_pslMixerBuffer, slDataToMix);
|
||||||
|
|
||||||
BOOL bGamePaused = _pNetwork->IsPaused() || _pNetwork->IsServer() && _pNetwork->GetLocalPause();
|
BOOL bGamePaused = _pNetwork->IsPaused() || (_pNetwork->IsServer() && _pNetwork->GetLocalPause());
|
||||||
|
|
||||||
// for each sound
|
// for each sound
|
||||||
FOREACHINLIST( CSoundData, sd_Node, sl_ClhAwareList, itCsdSoundData) {
|
FOREACHINLIST( CSoundData, sd_Node, sl_ClhAwareList, itCsdSoundData) {
|
||||||
|
|
|
@ -43,17 +43,15 @@ static CSoundData *psd;
|
||||||
|
|
||||||
// nasm on MacOS X is getting wrong addresses of external globals, so I have
|
// nasm on MacOS X is getting wrong addresses of external globals, so I have
|
||||||
// to define them in the .asm file...lame.
|
// to define them in the .asm file...lame.
|
||||||
#ifdef __GNU_INLINE__
|
#if (defined __GNU_INLINE_X86_32__) && (defined USE_I386_NASM_ASM)
|
||||||
#ifdef USE_PORTABLE_C
|
|
||||||
#define INASM
|
|
||||||
#else
|
|
||||||
#define INASM extern
|
#define INASM extern
|
||||||
#endif
|
#elif (defined __MSVC_INLINE__)
|
||||||
#else
|
|
||||||
#define INASM static
|
#define INASM static
|
||||||
static __int64 mmInvFactor = 0x00007FFF00007FFF;
|
static __int64 mmInvFactor = 0x00007FFF00007FFF;
|
||||||
static FLOAT f65536 = 65536.0f;
|
static FLOAT f65536 = 65536.0f;
|
||||||
static FLOAT f4G = 4294967296.0f;
|
static FLOAT f4G = 4294967296.0f;
|
||||||
|
#else
|
||||||
|
#define INASM static
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
INASM SLONG slMixerBufferSize; // size in samples per channel of the destination buffers
|
INASM SLONG slMixerBufferSize; // size in samples per channel of the destination buffers
|
||||||
|
@ -81,11 +79,7 @@ void ResetMixer( const SLONG *pslBuffer, const SLONG slBufferSize)
|
||||||
slMixerBufferSampleRate = _pSound->sl_SwfeFormat.nSamplesPerSec;
|
slMixerBufferSampleRate = _pSound->sl_SwfeFormat.nSamplesPerSec;
|
||||||
|
|
||||||
// wipe destination mixer buffer
|
// wipe destination mixer buffer
|
||||||
// (Mac OS X uses this path because Apple's memset() is customized for each CPU they support and way faster than this inline asm. --ryan.)
|
#if (defined __MSVC_INLINE__)
|
||||||
#if ((defined USE_PORTABLE_C) || (PLATFORM_MACOSX))
|
|
||||||
memset(pvMixerBuffer, 0, slMixerBufferSize * 8);
|
|
||||||
|
|
||||||
#elif (defined __MSVC_INLINE__)
|
|
||||||
__asm {
|
__asm {
|
||||||
cld
|
cld
|
||||||
xor eax,eax
|
xor eax,eax
|
||||||
|
@ -94,19 +88,8 @@ void ResetMixer( const SLONG *pslBuffer, const SLONG slBufferSize)
|
||||||
shl ecx,1 // *2 because of 32-bit src format
|
shl ecx,1 // *2 because of 32-bit src format
|
||||||
rep stosd
|
rep stosd
|
||||||
}
|
}
|
||||||
#elif (defined __GNU_INLINE__)
|
|
||||||
// !!! FIXME : rcg12172001 Is this REALLY any faster than memset()?
|
|
||||||
ULONG clob1, clob2;
|
|
||||||
__asm__ __volatile__ (
|
|
||||||
"cld \n\t"
|
|
||||||
"rep \n\t"
|
|
||||||
"stosl \n\t"
|
|
||||||
: "=D" (clob1), "=c" (clob2)
|
|
||||||
: "a" (0), "D" (pvMixerBuffer), "c" (slMixerBufferSize*2)
|
|
||||||
: "cc", "memory"
|
|
||||||
);
|
|
||||||
#else
|
#else
|
||||||
#error please write inline asm for your platform.
|
memset(pvMixerBuffer, 0, slMixerBufferSize * 8);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,10 +101,7 @@ void CopyMixerBuffer_stereo( const SLONG slSrcOffset, void *pDstBuffer, const SL
|
||||||
ASSERT( slBytes%4==0);
|
ASSERT( slBytes%4==0);
|
||||||
if( slBytes<4) return;
|
if( slBytes<4) return;
|
||||||
|
|
||||||
#if ((defined USE_PORTABLE_C) || (PLATFORM_MACOSX))
|
#if (defined __MSVC_INLINE__)
|
||||||
// (Mac OS X uses this path because Apple's memset() is customized for each CPU they support and way faster than this inline asm. --ryan.)
|
|
||||||
memcpy(pDstBuffer, ((const char *)pvMixerBuffer) + slSrcOffset, slBytes);
|
|
||||||
#elif (defined __MSVC_INLINE__)
|
|
||||||
__asm {
|
__asm {
|
||||||
cld
|
cld
|
||||||
mov esi,D [slSrcOffset]
|
mov esi,D [slSrcOffset]
|
||||||
|
@ -131,21 +111,8 @@ void CopyMixerBuffer_stereo( const SLONG slSrcOffset, void *pDstBuffer, const SL
|
||||||
shr ecx,2 // bytes to samples per channel
|
shr ecx,2 // bytes to samples per channel
|
||||||
rep movsd
|
rep movsd
|
||||||
}
|
}
|
||||||
#elif (defined __GNU_INLINE__)
|
|
||||||
// !!! FIXME : rcg12172001 Is this REALLY any faster than memcpy()?
|
|
||||||
ULONG clob1, clob2, clob3;
|
|
||||||
__asm__ __volatile__ (
|
|
||||||
"cld \n\t"
|
|
||||||
"rep \n\t"
|
|
||||||
"movsl \n\t"
|
|
||||||
: "=S" (clob1), "=D" (clob2), "=c" (clob3)
|
|
||||||
: "S" (((char *)pvMixerBuffer) + slSrcOffset),
|
|
||||||
"D" (pDstBuffer),
|
|
||||||
"c" (slBytes >> 2)
|
|
||||||
: "cc", "memory"
|
|
||||||
);
|
|
||||||
#else
|
#else
|
||||||
#error please write inline asm for your platform.
|
memcpy(pDstBuffer, ((const char *)pvMixerBuffer) + slSrcOffset, slBytes);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,18 +124,7 @@ void CopyMixerBuffer_mono( const SLONG slSrcOffset, void *pDstBuffer, const SLON
|
||||||
ASSERT( slBytes%2==0);
|
ASSERT( slBytes%2==0);
|
||||||
if( slBytes<4) return;
|
if( slBytes<4) return;
|
||||||
|
|
||||||
#if (defined USE_PORTABLE_C)
|
#if (defined __MSVC_INLINE__)
|
||||||
// (This is untested, currently. --ryan.)
|
|
||||||
WORD *dest = (WORD *) pDstBuffer;
|
|
||||||
WORD *src = (WORD *) ( ((char *) pvMixerBuffer) + slSrcOffset );
|
|
||||||
SLONG max = slBytes / 4;
|
|
||||||
for (SLONG i = 0; i < max; i++) {
|
|
||||||
*dest = *src;
|
|
||||||
dest++; // move 16 bits.
|
|
||||||
src+=2; // move 32 bits.
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif (defined __MSVC_INLINE__)
|
|
||||||
__asm {
|
__asm {
|
||||||
mov esi,D [slSrcOffset]
|
mov esi,D [slSrcOffset]
|
||||||
add esi,D [pvMixerBuffer]
|
add esi,D [pvMixerBuffer]
|
||||||
|
@ -184,7 +140,7 @@ copyLoop:
|
||||||
jnz copyLoop
|
jnz copyLoop
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"movl %[pvMixerBuffer], %%esi \n\t"
|
"movl %[pvMixerBuffer], %%esi \n\t"
|
||||||
"movl %[pDstBuffer], %%edi \n\t"
|
"movl %[pDstBuffer], %%edi \n\t"
|
||||||
|
@ -204,7 +160,15 @@ copyLoop:
|
||||||
);
|
);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error please write inline asm for your platform.
|
// (This is untested, currently. --ryan.)
|
||||||
|
WORD *dest = (WORD *) pDstBuffer;
|
||||||
|
WORD *src = (WORD *) ( ((char *) pvMixerBuffer) + slSrcOffset );
|
||||||
|
SLONG max = slBytes / 4;
|
||||||
|
for (SLONG i = 0; i < max; i++) {
|
||||||
|
*dest = *src;
|
||||||
|
dest++; // move 16 bits.
|
||||||
|
src+=2; // move 32 bits.
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,24 +179,7 @@ static void ConvertMixerBuffer( const SLONG slBytes)
|
||||||
ASSERT( slBytes%4==0);
|
ASSERT( slBytes%4==0);
|
||||||
if( slBytes<4) return;
|
if( slBytes<4) return;
|
||||||
|
|
||||||
#if (defined USE_PORTABLE_C)
|
#if (defined __MSVC_INLINE__)
|
||||||
//STUBBED("ConvertMixerBuffer");
|
|
||||||
SWORD *dest = (SWORD *) pvMixerBuffer;
|
|
||||||
SLONG *src = (SLONG *) pvMixerBuffer;
|
|
||||||
SLONG max = slBytes / 2;
|
|
||||||
int tmp;
|
|
||||||
for (SLONG i = 0; i < max; i++) {
|
|
||||||
tmp = *src;
|
|
||||||
if (tmp>32767) tmp=32767;
|
|
||||||
if (tmp<-32767) tmp=-32767;
|
|
||||||
*dest=tmp;
|
|
||||||
dest++; // move 16 bits.
|
|
||||||
src++; // move 32 bits.
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#elif (defined __MSVC_INLINE__)
|
|
||||||
__asm {
|
__asm {
|
||||||
cld
|
cld
|
||||||
mov esi,D [pvMixerBuffer]
|
mov esi,D [pvMixerBuffer]
|
||||||
|
@ -250,7 +197,7 @@ copyLoop:
|
||||||
emms
|
emms
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__)
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"movl %[pvMixerBuffer], %%esi \n\t"
|
"movl %[pvMixerBuffer], %%esi \n\t"
|
||||||
"movl %[pvMixerBuffer], %%edi \n\t"
|
"movl %[pvMixerBuffer], %%edi \n\t"
|
||||||
|
@ -271,7 +218,20 @@ copyLoop:
|
||||||
);
|
);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error please write inline asm for your platform.
|
|
||||||
|
SWORD *dest = (SWORD *) pvMixerBuffer;
|
||||||
|
SLONG *src = (SLONG *) pvMixerBuffer;
|
||||||
|
SLONG max = slBytes / 2;
|
||||||
|
int tmp;
|
||||||
|
for (SLONG i = 0; i < max; i++) {
|
||||||
|
tmp = *src;
|
||||||
|
if (tmp>32767) tmp=32767;
|
||||||
|
if (tmp<-32767) tmp=-32767;
|
||||||
|
*dest=tmp;
|
||||||
|
dest++; // move 16 bits.
|
||||||
|
src++; // move 32 bits.
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,7 +283,7 @@ void NormalizeMixerBuffer( const FLOAT fNormStrength, const SLONG slBytes, FLOAT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef __GNU_INLINE__
|
#if (defined __GNU_INLINE_X86_32__) && (defined USE_I386_NASM_ASM)
|
||||||
// These are implemented in an external NASM file.
|
// These are implemented in an external NASM file.
|
||||||
extern "C" {
|
extern "C" {
|
||||||
void MixStereo_asm(CSoundObject *pso);
|
void MixStereo_asm(CSoundObject *pso);
|
||||||
|
@ -337,85 +297,7 @@ inline void MixMono( CSoundObject *pso)
|
||||||
{
|
{
|
||||||
_pfSoundProfile.StartTimer(CSoundProfile::PTI_RAWMIXER);
|
_pfSoundProfile.StartTimer(CSoundProfile::PTI_RAWMIXER);
|
||||||
|
|
||||||
#if (defined USE_PORTABLE_C)
|
#if (defined __MSVC_INLINE__)
|
||||||
// initialize some local vars
|
|
||||||
SLONG slLeftSample, slRightSample, slNextSample;
|
|
||||||
SLONG *pslDstBuffer = (SLONG*)pvMixerBuffer;
|
|
||||||
fixLeftOfs = (__int64)(fLeftOfs * 65536.0);
|
|
||||||
fixRightOfs = (__int64)(fRightOfs * 65536.0);
|
|
||||||
__int64 fixLeftStep = (__int64)(fLeftStep * 65536.0);
|
|
||||||
__int64 fixRightStep = (__int64)(fRightStep * 65536.0);
|
|
||||||
__int64 fixSoundBufferSize = ((__int64)slSoundBufferSize)<<16;
|
|
||||||
mmSurroundFactor = (__int64)(SWORD)mmSurroundFactor;
|
|
||||||
|
|
||||||
SLONG slLeftVolume_ = slLeftVolume >> 16;
|
|
||||||
SLONG slRightVolume_ = slRightVolume >> 16;
|
|
||||||
|
|
||||||
// loop thru source buffer
|
|
||||||
INDEX iCt = slMixerBufferSize;
|
|
||||||
FOREVER
|
|
||||||
{
|
|
||||||
// if left channel source sample came to end of sample buffer
|
|
||||||
if( fixLeftOfs >= fixSoundBufferSize) {
|
|
||||||
fixLeftOfs -= fixSoundBufferSize;
|
|
||||||
// if has no loop, end it
|
|
||||||
bEndOfSound = bNotLoop;
|
|
||||||
}
|
|
||||||
// if right channel source sample came to end of sample buffer
|
|
||||||
if( fixRightOfs >= fixSoundBufferSize) {
|
|
||||||
fixRightOfs -= fixSoundBufferSize;
|
|
||||||
// if has no loop, end it
|
|
||||||
bEndOfSound = bNotLoop;
|
|
||||||
}
|
|
||||||
// end of buffer?
|
|
||||||
if( iCt<=0 || bEndOfSound) break;
|
|
||||||
|
|
||||||
// fetch one lineary interpolated sample on left channel
|
|
||||||
slLeftSample = pswSrcBuffer[(fixLeftOfs>>16)+0];
|
|
||||||
slNextSample = pswSrcBuffer[(fixLeftOfs>>16)+1];
|
|
||||||
slLeftSample = (slLeftSample*(65535-(fixLeftOfs&65535)) + slNextSample*(fixLeftOfs&65535)) >>16;
|
|
||||||
// fetch one lineary interpolated sample on right channel
|
|
||||||
slRightSample = pswSrcBuffer[(fixRightOfs>>16)+0];
|
|
||||||
slNextSample = pswSrcBuffer[(fixRightOfs>>16)+1];
|
|
||||||
slRightSample = (slRightSample*(65535-(fixRightOfs&65535)) + slNextSample*(fixRightOfs&65535)) >>16;
|
|
||||||
|
|
||||||
// filter samples
|
|
||||||
slLastLeftSample += ((slLeftSample -slLastLeftSample) *slLeftFilter) >>15;
|
|
||||||
slLastRightSample += ((slRightSample-slLastRightSample)*slRightFilter)>>15;
|
|
||||||
|
|
||||||
// apply stereo volume to current sample
|
|
||||||
slLeftSample = (slLastLeftSample * slLeftVolume_) >>15;
|
|
||||||
slRightSample = (slLastRightSample * slRightVolume_)>>15;
|
|
||||||
|
|
||||||
slLeftSample ^= (SLONG)((mmSurroundFactor>> 0)&0xFFFFFFFF);
|
|
||||||
slRightSample ^= (SLONG)((mmSurroundFactor>>32)&0xFFFFFFFF);
|
|
||||||
|
|
||||||
// mix in current sample
|
|
||||||
slLeftSample += pslDstBuffer[0];
|
|
||||||
slRightSample += pslDstBuffer[1];
|
|
||||||
// upper clamp
|
|
||||||
if( slLeftSample > MAX_SWORD) slLeftSample = MAX_SWORD;
|
|
||||||
if( slRightSample > MAX_SWORD) slRightSample = MAX_SWORD;
|
|
||||||
// lower clamp
|
|
||||||
if( slLeftSample < MIN_SWORD) slLeftSample = MIN_SWORD;
|
|
||||||
if( slRightSample < MIN_SWORD) slRightSample = MIN_SWORD;
|
|
||||||
|
|
||||||
// store samples (both channels)
|
|
||||||
pslDstBuffer[0] = slLeftSample;
|
|
||||||
pslDstBuffer[1] = slRightSample;
|
|
||||||
|
|
||||||
// modify volume `
|
|
||||||
slLeftVolume += (SWORD)((mmVolumeGain>> 0)&0xFFFF);
|
|
||||||
slRightVolume += (SWORD)((mmVolumeGain>>16)&0xFFFF);
|
|
||||||
|
|
||||||
// advance to next sample
|
|
||||||
fixLeftOfs += fixLeftStep;
|
|
||||||
fixRightOfs += fixRightStep;
|
|
||||||
pslDstBuffer += 2;
|
|
||||||
iCt--;
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif (defined __MSVC_INLINE__)
|
|
||||||
__asm {
|
__asm {
|
||||||
// convert from floats to fixints 32:16
|
// convert from floats to fixints 32:16
|
||||||
fld D [fLeftOfs]
|
fld D [fLeftOfs]
|
||||||
|
@ -548,24 +430,11 @@ loopEnd:
|
||||||
emms
|
emms
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__) && (defined USE_I386_NASM_ASM)
|
||||||
// This is implemented in an external NASM file.
|
// This is implemented in an external NASM file.
|
||||||
MixMono_asm(pso);
|
MixMono_asm(pso);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error please write inline asm for your platform.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_pfSoundProfile.StopTimer(CSoundProfile::PTI_RAWMIXER);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// mixes one stereo 16-bit signed sound to destination buffer
|
|
||||||
inline void MixStereo( CSoundObject *pso)
|
|
||||||
{
|
|
||||||
_pfSoundProfile.StartTimer(CSoundProfile::PTI_RAWMIXER);
|
|
||||||
|
|
||||||
#if (defined USE_PORTABLE_C)
|
|
||||||
// initialize some local vars
|
// initialize some local vars
|
||||||
SLONG slLeftSample, slRightSample, slNextSample;
|
SLONG slLeftSample, slRightSample, slNextSample;
|
||||||
SLONG *pslDstBuffer = (SLONG*)pvMixerBuffer;
|
SLONG *pslDstBuffer = (SLONG*)pvMixerBuffer;
|
||||||
|
@ -599,12 +468,12 @@ inline void MixStereo( CSoundObject *pso)
|
||||||
if( iCt<=0 || bEndOfSound) break;
|
if( iCt<=0 || bEndOfSound) break;
|
||||||
|
|
||||||
// fetch one lineary interpolated sample on left channel
|
// fetch one lineary interpolated sample on left channel
|
||||||
slLeftSample = pswSrcBuffer[(fixLeftOfs>>15)+0];
|
slLeftSample = pswSrcBuffer[(fixLeftOfs>>16)+0];
|
||||||
slNextSample = pswSrcBuffer[(fixLeftOfs>>15)+2];
|
slNextSample = pswSrcBuffer[(fixLeftOfs>>16)+1];
|
||||||
slLeftSample = (slLeftSample*(65535-(fixLeftOfs&65535)) + slNextSample*(fixLeftOfs&65535)) >>16;
|
slLeftSample = (slLeftSample*(65535-(fixLeftOfs&65535)) + slNextSample*(fixLeftOfs&65535)) >>16;
|
||||||
// fetch one lineary interpolated sample on right channel
|
// fetch one lineary interpolated sample on right channel
|
||||||
slRightSample = pswSrcBuffer[(fixRightOfs>>15)+0];
|
slRightSample = pswSrcBuffer[(fixRightOfs>>16)+0];
|
||||||
slNextSample = pswSrcBuffer[(fixRightOfs>>15)+2];
|
slNextSample = pswSrcBuffer[(fixRightOfs>>16)+1];
|
||||||
slRightSample = (slRightSample*(65535-(fixRightOfs&65535)) + slNextSample*(fixRightOfs&65535)) >>16;
|
slRightSample = (slRightSample*(65535-(fixRightOfs&65535)) + slNextSample*(fixRightOfs&65535)) >>16;
|
||||||
|
|
||||||
// filter samples
|
// filter samples
|
||||||
|
@ -643,7 +512,18 @@ inline void MixStereo( CSoundObject *pso)
|
||||||
iCt--;
|
iCt--;
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif (defined __MSVC_INLINE__)
|
#endif
|
||||||
|
|
||||||
|
_pfSoundProfile.StopTimer(CSoundProfile::PTI_RAWMIXER);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// mixes one stereo 16-bit signed sound to destination buffer
|
||||||
|
inline void MixStereo( CSoundObject *pso)
|
||||||
|
{
|
||||||
|
_pfSoundProfile.StartTimer(CSoundProfile::PTI_RAWMIXER);
|
||||||
|
|
||||||
|
#if (defined __MSVC_INLINE__)
|
||||||
__asm {
|
__asm {
|
||||||
// convert from floats to fixints 32:16
|
// convert from floats to fixints 32:16
|
||||||
fld D [fLeftOfs]
|
fld D [fLeftOfs]
|
||||||
|
@ -778,12 +658,88 @@ loopEnd:
|
||||||
emms
|
emms
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif (defined __GNU_INLINE__)
|
#elif (defined __GNU_INLINE_X86_32__) && (defined USE_I386_NASM_ASM)
|
||||||
// This is implemented in an external NASM file.
|
// This is implemented in an external NASM file.
|
||||||
MixStereo_asm(pso);
|
MixStereo_asm(pso);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error please write inline asm for your platform.
|
// initialize some local vars
|
||||||
|
SLONG slLeftSample, slRightSample, slNextSample;
|
||||||
|
SLONG *pslDstBuffer = (SLONG*)pvMixerBuffer;
|
||||||
|
fixLeftOfs = (__int64)(fLeftOfs * 65536.0);
|
||||||
|
fixRightOfs = (__int64)(fRightOfs * 65536.0);
|
||||||
|
__int64 fixLeftStep = (__int64)(fLeftStep * 65536.0);
|
||||||
|
__int64 fixRightStep = (__int64)(fRightStep * 65536.0);
|
||||||
|
__int64 fixSoundBufferSize = ((__int64)slSoundBufferSize)<<16;
|
||||||
|
mmSurroundFactor = (__int64)(SWORD)mmSurroundFactor;
|
||||||
|
|
||||||
|
SLONG slLeftVolume_ = slLeftVolume >> 16;
|
||||||
|
SLONG slRightVolume_ = slRightVolume >> 16;
|
||||||
|
|
||||||
|
// loop thru source buffer
|
||||||
|
INDEX iCt = slMixerBufferSize;
|
||||||
|
FOREVER
|
||||||
|
{
|
||||||
|
// if left channel source sample came to end of sample buffer
|
||||||
|
if( fixLeftOfs >= fixSoundBufferSize) {
|
||||||
|
fixLeftOfs -= fixSoundBufferSize;
|
||||||
|
// if has no loop, end it
|
||||||
|
bEndOfSound = bNotLoop;
|
||||||
|
}
|
||||||
|
// if right channel source sample came to end of sample buffer
|
||||||
|
if( fixRightOfs >= fixSoundBufferSize) {
|
||||||
|
fixRightOfs -= fixSoundBufferSize;
|
||||||
|
// if has no loop, end it
|
||||||
|
bEndOfSound = bNotLoop;
|
||||||
|
}
|
||||||
|
// end of buffer?
|
||||||
|
if( iCt<=0 || bEndOfSound) break;
|
||||||
|
|
||||||
|
// fetch one lineary interpolated sample on left channel
|
||||||
|
slLeftSample = pswSrcBuffer[(fixLeftOfs>>15)+0];
|
||||||
|
slNextSample = pswSrcBuffer[(fixLeftOfs>>15)+2];
|
||||||
|
slLeftSample = (slLeftSample*(65535-(fixLeftOfs&65535)) + slNextSample*(fixLeftOfs&65535)) >>16;
|
||||||
|
// fetch one lineary interpolated sample on right channel
|
||||||
|
slRightSample = pswSrcBuffer[(fixRightOfs>>15)+0];
|
||||||
|
slNextSample = pswSrcBuffer[(fixRightOfs>>15)+2];
|
||||||
|
slRightSample = (slRightSample*(65535-(fixRightOfs&65535)) + slNextSample*(fixRightOfs&65535)) >>16;
|
||||||
|
|
||||||
|
// filter samples
|
||||||
|
slLastLeftSample += ((slLeftSample -slLastLeftSample) *slLeftFilter) >>15;
|
||||||
|
slLastRightSample += ((slRightSample-slLastRightSample)*slRightFilter)>>15;
|
||||||
|
|
||||||
|
// apply stereo volume to current sample
|
||||||
|
slLeftSample = (slLastLeftSample * slLeftVolume_) >>15;
|
||||||
|
slRightSample = (slLastRightSample * slRightVolume_)>>15;
|
||||||
|
|
||||||
|
slLeftSample ^= (SLONG)((mmSurroundFactor>> 0)&0xFFFFFFFF);
|
||||||
|
slRightSample ^= (SLONG)((mmSurroundFactor>>32)&0xFFFFFFFF);
|
||||||
|
|
||||||
|
// mix in current sample
|
||||||
|
slLeftSample += pslDstBuffer[0];
|
||||||
|
slRightSample += pslDstBuffer[1];
|
||||||
|
// upper clamp
|
||||||
|
if( slLeftSample > MAX_SWORD) slLeftSample = MAX_SWORD;
|
||||||
|
if( slRightSample > MAX_SWORD) slRightSample = MAX_SWORD;
|
||||||
|
// lower clamp
|
||||||
|
if( slLeftSample < MIN_SWORD) slLeftSample = MIN_SWORD;
|
||||||
|
if( slRightSample < MIN_SWORD) slRightSample = MIN_SWORD;
|
||||||
|
|
||||||
|
// store samples (both channels)
|
||||||
|
pslDstBuffer[0] = slLeftSample;
|
||||||
|
pslDstBuffer[1] = slRightSample;
|
||||||
|
|
||||||
|
// modify volume `
|
||||||
|
slLeftVolume += (SWORD)((mmVolumeGain>> 0)&0xFFFF);
|
||||||
|
slRightVolume += (SWORD)((mmVolumeGain>>16)&0xFFFF);
|
||||||
|
|
||||||
|
// advance to next sample
|
||||||
|
fixLeftOfs += fixLeftStep;
|
||||||
|
fixRightOfs += fixRightStep;
|
||||||
|
pslDstBuffer += 2;
|
||||||
|
iCt--;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_pfSoundProfile.StopTimer(CSoundProfile::PTI_RAWMIXER);
|
_pfSoundProfile.StopTimer(CSoundProfile::PTI_RAWMIXER);
|
||||||
|
|
|
@ -51,6 +51,7 @@ extern BOOL _bPredictionActive;
|
||||||
extern FLOAT snd_fSoundVolume;
|
extern FLOAT snd_fSoundVolume;
|
||||||
extern FLOAT snd_fMusicVolume;
|
extern FLOAT snd_fMusicVolume;
|
||||||
|
|
||||||
|
#if 0 // DG: unused.
|
||||||
static CTString GetPred(CEntity*pen)
|
static CTString GetPred(CEntity*pen)
|
||||||
{
|
{
|
||||||
CTString str1;
|
CTString str1;
|
||||||
|
@ -67,6 +68,7 @@ static CTString GetPred(CEntity*pen)
|
||||||
str.PrintF("%08x-%s", pen, (const char *) str1);
|
str.PrintF("%08x-%s", pen, (const char *) str1);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
#endif // 0 (unused)
|
||||||
/* ====================================================
|
/* ====================================================
|
||||||
*
|
*
|
||||||
* Class global methods
|
* Class global methods
|
||||||
|
@ -238,9 +240,9 @@ void CSoundObject::Play_internal( CSoundData *pCsdLink, SLONG slFlags)
|
||||||
Stop_internal();
|
Stop_internal();
|
||||||
|
|
||||||
// mark new data as referenced once more
|
// mark new data as referenced once more
|
||||||
pCsdLink->AddReference();
|
if(pCsdLink != NULL) pCsdLink->AddReference();
|
||||||
// mark old data as referenced once less
|
// mark old data as referenced once less
|
||||||
so_pCsdLink->RemReference();
|
if(so_pCsdLink != NULL) so_pCsdLink->RemReference();
|
||||||
|
|
||||||
// store init SoundData
|
// store init SoundData
|
||||||
so_pCsdLink = pCsdLink;
|
so_pCsdLink = pCsdLink;
|
||||||
|
|
|
@ -186,6 +186,8 @@ void BSPVertexContainer<Type, iDimensions>::Sort(void)
|
||||||
template<class Type, int iDimensions>
|
template<class Type, int iDimensions>
|
||||||
void BSPVertexContainer<Type, iDimensions>::ElliminatePairedVertices(void)
|
void BSPVertexContainer<Type, iDimensions>::ElliminatePairedVertices(void)
|
||||||
{
|
{
|
||||||
|
// FIXME: DG: am I missing something or is this function not actually changing anything?
|
||||||
|
|
||||||
// if there are no vertices, or the container is not line
|
// if there are no vertices, or the container is not line
|
||||||
if (bvc_aVertices.Count()==0 || IsPlannar()) {
|
if (bvc_aVertices.Count()==0 || IsPlannar()) {
|
||||||
// do not attempt to sort
|
// do not attempt to sort
|
||||||
|
@ -416,9 +418,9 @@ template<class Type, int iDimensions>
|
||||||
BSPNode<Type, iDimensions>::BSPNode(const Plane<Type, iDimensions> &plSplitPlane, size_t ulPlaneTag,
|
BSPNode<Type, iDimensions>::BSPNode(const Plane<Type, iDimensions> &plSplitPlane, size_t ulPlaneTag,
|
||||||
BSPNode<Type, iDimensions> &bnFront, BSPNode<Type, iDimensions> &bnBack)
|
BSPNode<Type, iDimensions> &bnFront, BSPNode<Type, iDimensions> &bnBack)
|
||||||
: Plane<Type, iDimensions>(plSplitPlane)
|
: Plane<Type, iDimensions>(plSplitPlane)
|
||||||
|
, bn_bnlLocation(BNL_BRANCH)
|
||||||
, bn_pbnFront(&bnFront)
|
, bn_pbnFront(&bnFront)
|
||||||
, bn_pbnBack(&bnBack)
|
, bn_pbnBack(&bnBack)
|
||||||
, bn_bnlLocation(BNL_BRANCH)
|
|
||||||
, bn_ulPlaneTag(ulPlaneTag)
|
, bn_ulPlaneTag(ulPlaneTag)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -956,7 +958,6 @@ template<class Type, int iDimensions>
|
||||||
BSPNode<Type, iDimensions> *BSPTree<Type, iDimensions>::CreateSubTree(CDynamicArray<BSPPolygon<Type, iDimensions> > &abpoPolygons)
|
BSPNode<Type, iDimensions> *BSPTree<Type, iDimensions>::CreateSubTree(CDynamicArray<BSPPolygon<Type, iDimensions> > &abpoPolygons)
|
||||||
{
|
{
|
||||||
// local declarations, to fix macro expansion in FOREACHINDYNAMICARRAY
|
// local declarations, to fix macro expansion in FOREACHINDYNAMICARRAY
|
||||||
typedef BSPEdge<Type, iDimensions> edge_t;
|
|
||||||
typedef BSPPolygon<Type, iDimensions> polygon_t;
|
typedef BSPPolygon<Type, iDimensions> polygon_t;
|
||||||
ASSERT(abpoPolygons.Count()>=1);
|
ASSERT(abpoPolygons.Count()>=1);
|
||||||
|
|
||||||
|
@ -1042,8 +1043,6 @@ BSPNode<Type, iDimensions> *BSPTree<Type, iDimensions>::CreateSubTree(CDynamicAr
|
||||||
template<class Type, int iDimensions>
|
template<class Type, int iDimensions>
|
||||||
void BSPTree<Type, iDimensions>::Create(CDynamicArray<BSPPolygon<Type, iDimensions> > &abpoPolygons)
|
void BSPTree<Type, iDimensions>::Create(CDynamicArray<BSPPolygon<Type, iDimensions> > &abpoPolygons)
|
||||||
{
|
{
|
||||||
typedef BSPPolygon<Type, iDimensions> polygon_t; // local declaration, to fix macro expansion in FOREACHINDYNAMICARRAY
|
|
||||||
|
|
||||||
// free eventual existing tree
|
// free eventual existing tree
|
||||||
Destroy();
|
Destroy();
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,7 @@ SLONG CStock_TYPE::CalculateUsedMemory(void)
|
||||||
void CStock_TYPE::DumpMemoryUsage_t(CTStream &strm) // throw char *
|
void CStock_TYPE::DumpMemoryUsage_t(CTStream &strm) // throw char *
|
||||||
{
|
{
|
||||||
CTString strLine;
|
CTString strLine;
|
||||||
SLONG slUsedTotal = 0;
|
//SLONG slUsedTotal = 0;
|
||||||
{FOREACHINDYNAMICCONTAINER(st_ctObjects, TYPE, itt) {
|
{FOREACHINDYNAMICCONTAINER(st_ctObjects, TYPE, itt) {
|
||||||
SLONG slUsedByObject = itt->GetUsedMemory();
|
SLONG slUsedByObject = itt->GetUsedMemory();
|
||||||
if (slUsedByObject<0) {
|
if (slUsedByObject<0) {
|
||||||
|
|
|
@ -202,13 +202,14 @@ void CTerrain::CreateEmptyTerrain_t(PIX pixWidth,PIX pixHeight)
|
||||||
void CTerrain::ImportHeightMap_t(CTFileName fnHeightMap, BOOL bUse16b/*=TRUE*/)
|
void CTerrain::ImportHeightMap_t(CTFileName fnHeightMap, BOOL bUse16b/*=TRUE*/)
|
||||||
{
|
{
|
||||||
_ptrTerrain = this;
|
_ptrTerrain = this;
|
||||||
BOOL bResizeTerrain = FALSE;
|
//BOOL bResizeTerrain = FALSE;
|
||||||
|
|
||||||
// Load targa file
|
// Load targa file
|
||||||
CImageInfo iiHeightMap;
|
CImageInfo iiHeightMap;
|
||||||
iiHeightMap.LoadAnyGfxFormat_t(fnHeightMap);
|
iiHeightMap.LoadAnyGfxFormat_t(fnHeightMap);
|
||||||
|
|
||||||
// if new width and height are same
|
// if new width and height are same
|
||||||
|
/* unused
|
||||||
if(tr_pixHeightMapWidth==iiHeightMap.ii_Width && tr_pixHeightMapHeight==iiHeightMap.ii_Height) {
|
if(tr_pixHeightMapWidth==iiHeightMap.ii_Width && tr_pixHeightMapHeight==iiHeightMap.ii_Height) {
|
||||||
// Clear terrain data without removing layers
|
// Clear terrain data without removing layers
|
||||||
bResizeTerrain = FALSE;
|
bResizeTerrain = FALSE;
|
||||||
|
@ -217,6 +218,7 @@ void CTerrain::ImportHeightMap_t(CTFileName fnHeightMap, BOOL bUse16b/*=TRUE*/)
|
||||||
bResizeTerrain = TRUE;
|
bResizeTerrain = TRUE;
|
||||||
}
|
}
|
||||||
bResizeTerrain = TRUE;
|
bResizeTerrain = TRUE;
|
||||||
|
*/
|
||||||
|
|
||||||
FLOAT fLogWidht = Log2(iiHeightMap.ii_Width-1);
|
FLOAT fLogWidht = Log2(iiHeightMap.ii_Width-1);
|
||||||
FLOAT fLogHeight = Log2(iiHeightMap.ii_Height-1);
|
FLOAT fLogHeight = Log2(iiHeightMap.ii_Height-1);
|
||||||
|
@ -359,15 +361,15 @@ static void CropMap(INDEX iNewWidth, INDEX iNewHeight, INDEX iOldWidth, INDEX iO
|
||||||
template <class Type>
|
template <class Type>
|
||||||
static void StretchMap(INDEX iNewWidth, INDEX iNewHeight, INDEX iOldWidth, INDEX iOldHeight, Type *pNewData, Type *pOldData)
|
static void StretchMap(INDEX iNewWidth, INDEX iNewHeight, INDEX iOldWidth, INDEX iOldHeight, Type *pNewData, Type *pOldData)
|
||||||
{
|
{
|
||||||
int a=0;
|
//int a=0;
|
||||||
CropMap(iNewWidth,iNewHeight,iOldWidth,iOldHeight,pNewData,pOldData);
|
CropMap(iNewWidth,iNewHeight,iOldWidth,iOldHeight,pNewData,pOldData);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
static void ShrinkMap(INDEX iNewWidth, INDEX iNewHeight, INDEX iOldWidth, INDEX iOldHeight, Type *pNewData, Type *pOldData)
|
static void ShrinkMap(INDEX iNewWidth, INDEX iNewHeight, INDEX iOldWidth, INDEX iOldHeight, Type *pNewData, Type *pOldData)
|
||||||
{
|
{
|
||||||
FLOAT fWidth = iNewWidth;
|
//FLOAT fWidth = iNewWidth;
|
||||||
FLOAT fHeight = iNewHeight;
|
//FLOAT fHeight = iNewHeight;
|
||||||
FLOAT fDiffX = (FLOAT)iNewWidth / iOldWidth;
|
FLOAT fDiffX = (FLOAT)iNewWidth / iOldWidth;
|
||||||
FLOAT fDiffY = (FLOAT)iNewHeight / iOldHeight;
|
FLOAT fDiffY = (FLOAT)iNewHeight / iOldHeight;
|
||||||
|
|
||||||
|
@ -800,7 +802,7 @@ void CTerrain::AddAllTilesToRegenQueue()
|
||||||
// for each terrain tile
|
// for each terrain tile
|
||||||
for(INDEX itt=0;itt<tr_ctTiles;itt++) {
|
for(INDEX itt=0;itt<tr_ctTiles;itt++) {
|
||||||
// Add tile to reqen queue
|
// Add tile to reqen queue
|
||||||
CTerrainTile &tt = tr_attTiles[itt];
|
//CTerrainTile &tt = tr_attTiles[itt];
|
||||||
AddTileToRegenQueue(itt);
|
AddTileToRegenQueue(itt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -842,6 +844,7 @@ __forceinline void CopyPixel(COLOR *pubSrc,COLOR *pubDst,FLOAT fMaskStrength)
|
||||||
pcolSrc->ub.a = 255;
|
pcolSrc->ub.a = 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0 // DG: unused.
|
||||||
static INDEX _ctSavedTopMaps=0;
|
static INDEX _ctSavedTopMaps=0;
|
||||||
static void SaveAsTga(CTextureData *ptdTex)
|
static void SaveAsTga(CTextureData *ptdTex)
|
||||||
{
|
{
|
||||||
|
@ -879,6 +882,7 @@ static void SaveAsTga(CTextureData *ptdTex)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#endif // 0
|
||||||
|
|
||||||
static void AddTileLayerToTopMap(CTerrain *ptrTerrain, INDEX iTileIndex, INDEX iLayer)
|
static void AddTileLayerToTopMap(CTerrain *ptrTerrain, INDEX iTileIndex, INDEX iLayer)
|
||||||
{
|
{
|
||||||
|
@ -1004,7 +1008,7 @@ void CTerrain::UpdateTopMap(INDEX iTileIndex, Rect *prcDest/*=NULL*/)
|
||||||
INDEX iFirstInMask = 0;
|
INDEX iFirstInMask = 0;
|
||||||
INDEX iMaskWidth = tr_pixHeightMapWidth;
|
INDEX iMaskWidth = tr_pixHeightMapWidth;
|
||||||
INDEX iTiling = 1;
|
INDEX iTiling = 1;
|
||||||
INDEX iSrcMipWidth = 1;
|
//INDEX iSrcMipWidth = 1;
|
||||||
|
|
||||||
|
|
||||||
// destionation texture (must have set allocated memory)
|
// destionation texture (must have set allocated memory)
|
||||||
|
@ -1587,7 +1591,7 @@ void CTerrain::BuildQuadTree(void)
|
||||||
INDEX ctQuadLevels = tr_aqtlQuadTreeLevels.Count();
|
INDEX ctQuadLevels = tr_aqtlQuadTreeLevels.Count();
|
||||||
// for each quadtree level after first
|
// for each quadtree level after first
|
||||||
for(INDEX iql=1;iql<ctQuadLevels;iql++) {
|
for(INDEX iql=1;iql<ctQuadLevels;iql++) {
|
||||||
QuadTreeLevel &qtl = tr_aqtlQuadTreeLevels[iql];
|
//QuadTreeLevel &qtl = tr_aqtlQuadTreeLevels[iql];
|
||||||
QuadTreeLevel &qtlPrev = tr_aqtlQuadTreeLevels[iql-1];
|
QuadTreeLevel &qtlPrev = tr_aqtlQuadTreeLevels[iql-1];
|
||||||
// for each quadtree node row
|
// for each quadtree node row
|
||||||
for(INDEX ir=0;ir<qtlPrev.qtl_ctNodesRow;ir+=2) {
|
for(INDEX ir=0;ir<qtlPrev.qtl_ctNodesRow;ir+=2) {
|
||||||
|
@ -1737,7 +1741,7 @@ static void ShowTerrainInfo(CAnyProjection3D &apr, CDrawPort *pdp, CTerrain *ptr
|
||||||
strInfo +=strTemp;
|
strInfo +=strTemp;
|
||||||
|
|
||||||
// Show memory usage
|
// Show memory usage
|
||||||
SLONG slUsedMemory=0;
|
//SLONG slUsedMemory=0;
|
||||||
// Height map usage
|
// Height map usage
|
||||||
SLONG slHeightMap = ptrTerrain->tr_pixHeightMapWidth*ptrTerrain->tr_pixHeightMapHeight*sizeof(UWORD);
|
SLONG slHeightMap = ptrTerrain->tr_pixHeightMapWidth*ptrTerrain->tr_pixHeightMapHeight*sizeof(UWORD);
|
||||||
// Edge map usage
|
// Edge map usage
|
||||||
|
|
|
@ -44,7 +44,7 @@ void CTerrainArchive::Read_t( CTStream *istrFile) // throw char *
|
||||||
// if there are some terrains
|
// if there are some terrains
|
||||||
if (ctTerrains!=0) {
|
if (ctTerrains!=0) {
|
||||||
// create that much terrains
|
// create that much terrains
|
||||||
CTerrain *atrBrushes = ta_atrTerrains.New(ctTerrains);
|
/* CTerrain *atrBrushes = */ ta_atrTerrains.New(ctTerrains);
|
||||||
// for each of the new terrains
|
// for each of the new terrains
|
||||||
for (INDEX iTerrain=0; iTerrain<ctTerrains; iTerrain++) {
|
for (INDEX iTerrain=0; iTerrain<ctTerrains; iTerrain++) {
|
||||||
// read it from stream
|
// read it from stream
|
||||||
|
|
|
@ -39,7 +39,7 @@ static FLOATaabbox3D CalculateAABBoxFromRect(CTerrain *ptrTerrain, Rect rcExtrac
|
||||||
ASSERT(ptrTerrain->tr_penEntity!=NULL);
|
ASSERT(ptrTerrain->tr_penEntity!=NULL);
|
||||||
|
|
||||||
// Get entity that holds this terrain
|
// Get entity that holds this terrain
|
||||||
CEntity *penEntity = ptrTerrain->tr_penEntity;
|
//CEntity *penEntity = ptrTerrain->tr_penEntity;
|
||||||
|
|
||||||
FLOATaabbox3D bboxExtract;
|
FLOATaabbox3D bboxExtract;
|
||||||
FLOATaabbox3D bboxAllTerrain;
|
FLOATaabbox3D bboxAllTerrain;
|
||||||
|
@ -60,7 +60,7 @@ static INDEX GetFirstTileInMidLod(CTerrain *ptrTerrain, Rect &rcExtract)
|
||||||
// for each terrain tile
|
// for each terrain tile
|
||||||
for(INDEX itt=0;itt<ptrTerrain->tr_ctTiles;itt++) {
|
for(INDEX itt=0;itt<ptrTerrain->tr_ctTiles;itt++) {
|
||||||
QuadTreeNode &qtn = ptrTerrain->tr_aqtnQuadTreeNodes[itt];
|
QuadTreeNode &qtn = ptrTerrain->tr_aqtnQuadTreeNodes[itt];
|
||||||
CTerrainTile &tt = ptrTerrain->tr_attTiles[itt];
|
//CTerrainTile &tt = ptrTerrain->tr_attTiles[itt];
|
||||||
// if it is coliding with given box
|
// if it is coliding with given box
|
||||||
if(qtn.qtn_aabbox.HasContactWith(bboxExtract)) {
|
if(qtn.qtn_aabbox.HasContactWith(bboxExtract)) {
|
||||||
// calculate its real distance factor
|
// calculate its real distance factor
|
||||||
|
@ -367,8 +367,8 @@ void SetBufferForEditing(CTerrain *ptrTerrain, UWORD *puwEditedBuffer, Rect &rcE
|
||||||
PIX pixTop = rcExtract.rc_iTop;
|
PIX pixTop = rcExtract.rc_iTop;
|
||||||
PIX pixBottom = rcExtract.rc_iBottom;
|
PIX pixBottom = rcExtract.rc_iBottom;
|
||||||
|
|
||||||
PIX pixWidht = pixRight-pixLeft;
|
//PIX pixWidht = pixRight-pixLeft;
|
||||||
PIX pixHeight = pixBottom-pixTop;
|
//PIX pixHeight = pixBottom-pixTop;
|
||||||
PIX pixMaxWidth = ptrTerrain->tr_pixHeightMapWidth;
|
PIX pixMaxWidth = ptrTerrain->tr_pixHeightMapWidth;
|
||||||
PIX pixMaxHeight = ptrTerrain->tr_pixHeightMapHeight;
|
PIX pixMaxHeight = ptrTerrain->tr_pixHeightMapHeight;
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,7 @@ FLOATaabbox3D _bboxDrawTwo;
|
||||||
#define LEFT 1
|
#define LEFT 1
|
||||||
#define MIDDLE 2
|
#define MIDDLE 2
|
||||||
|
|
||||||
|
#if 0 // DG: unused.
|
||||||
// Test AABBox agains ray
|
// Test AABBox agains ray
|
||||||
static BOOL HitBoundingBox(FLOAT3D &vOrigin, FLOAT3D &vDir, FLOAT3D &vHit, FLOATaabbox3D &bbox)
|
static BOOL HitBoundingBox(FLOAT3D &vOrigin, FLOAT3D &vDir, FLOAT3D &vHit, FLOATaabbox3D &bbox)
|
||||||
{
|
{
|
||||||
|
@ -123,7 +124,6 @@ static BOOL HitBoundingBox(FLOAT3D &vOrigin, FLOAT3D &vDir, FLOAT3D &vHit, FLOAT
|
||||||
return (TRUE); /* ray hits box */
|
return (TRUE); /* ray hits box */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Test AABBox agains ray
|
// Test AABBox agains ray
|
||||||
static BOOL RayHitsAABBox(FLOAT3D &vOrigin, FLOAT3D &vDir, FLOAT3D &vHit, FLOATaabbox3D &bbox)
|
static BOOL RayHitsAABBox(FLOAT3D &vOrigin, FLOAT3D &vDir, FLOAT3D &vHit, FLOATaabbox3D &bbox)
|
||||||
{
|
{
|
||||||
|
@ -201,11 +201,12 @@ static BOOL RayHitsAABBox(FLOAT3D &vOrigin, FLOAT3D &vDir, FLOAT3D &vHit, FLOATa
|
||||||
vHit = FLOAT3D(coord[0],coord[1],coord[2]);
|
vHit = FLOAT3D(coord[0],coord[1],coord[2]);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
#endif // 0 (unused)
|
||||||
|
|
||||||
// Get exact hit location in tile
|
// Get exact hit location in tile
|
||||||
FLOAT GetExactHitLocation(INDEX iTileIndex, FLOAT3D &vOrigin, FLOAT3D &vTarget, FLOAT3D &vHitLocation)
|
FLOAT GetExactHitLocation(INDEX iTileIndex, FLOAT3D &vOrigin, FLOAT3D &vTarget, FLOAT3D &vHitLocation)
|
||||||
{
|
{
|
||||||
CTerrainTile &tt = _ptrTerrain->tr_attTiles[iTileIndex];
|
//CTerrainTile &tt = _ptrTerrain->tr_attTiles[iTileIndex];
|
||||||
QuadTreeNode &qtn = _ptrTerrain->tr_aqtnQuadTreeNodes[iTileIndex];
|
QuadTreeNode &qtn = _ptrTerrain->tr_aqtnQuadTreeNodes[iTileIndex];
|
||||||
|
|
||||||
GFXVertex *pavVertices;
|
GFXVertex *pavVertices;
|
||||||
|
@ -341,7 +342,7 @@ Rect ExtractPolygonsInBox(CTerrain *ptrTerrain, const FLOATaabbox3D &bboxExtract
|
||||||
|
|
||||||
INDEX iFirst = iStartX + iStartY * ptrTerrain->tr_pixHeightMapWidth;
|
INDEX iFirst = iStartX + iStartY * ptrTerrain->tr_pixHeightMapWidth;
|
||||||
INDEX iPitchX = ptrTerrain->tr_pixHeightMapWidth - iWidth;
|
INDEX iPitchX = ptrTerrain->tr_pixHeightMapWidth - iWidth;
|
||||||
INDEX iPitchY = ptrTerrain->tr_pixHeightMapHeight - iHeight;
|
//INDEX iPitchY = ptrTerrain->tr_pixHeightMapHeight - iHeight;
|
||||||
|
|
||||||
// get first pixel in height map
|
// get first pixel in height map
|
||||||
UWORD *puwHeight = &ptrTerrain->tr_auwHeightMap[iFirst];
|
UWORD *puwHeight = &ptrTerrain->tr_auwHeightMap[iFirst];
|
||||||
|
@ -385,7 +386,7 @@ Rect ExtractPolygonsInBox(CTerrain *ptrTerrain, const FLOATaabbox3D &bboxExtract
|
||||||
}
|
}
|
||||||
|
|
||||||
INDEX ivx=0;
|
INDEX ivx=0;
|
||||||
INDEX ind=0;
|
//INDEX ind=0;
|
||||||
INDEX iFacing=iFirst;
|
INDEX iFacing=iFirst;
|
||||||
|
|
||||||
GFXVertex *pavExtVtx = &_avExtVertices[0];
|
GFXVertex *pavExtVtx = &_avExtVertices[0];
|
||||||
|
@ -493,7 +494,7 @@ void ExtractVerticesInRect(CTerrain *ptrTerrain, Rect &rc, GFXVertex4 **pavVtx,
|
||||||
|
|
||||||
INDEX *pauiIndices = &_aiExtIndices[0];
|
INDEX *pauiIndices = &_aiExtIndices[0];
|
||||||
INDEX ivx=0;
|
INDEX ivx=0;
|
||||||
INDEX ind=0;
|
//INDEX ind=0;
|
||||||
INDEX iFacing=iFirstHeight;
|
INDEX iFacing=iFirstHeight;
|
||||||
// for each row
|
// for each row
|
||||||
for(iy=0;iy<iHeight-1;iy++) {
|
for(iy=0;iy<iHeight-1;iy++) {
|
||||||
|
@ -903,7 +904,7 @@ static FLOATaabbox3D AbsoluteToRelative(const CTerrain *ptrTerrain, const FLOATa
|
||||||
return bboxRelative;
|
return bboxRelative;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ULONG ulTemp = 0xFFFFFFFF;
|
//static ULONG ulTemp = 0xFFFFFFFF;
|
||||||
|
|
||||||
void UpdateTerrainShadowMap(CTerrain *ptrTerrain, FLOATaabbox3D *pboxUpdate/*=NULL*/, BOOL bAbsoluteSpace/*=FALSE*/)
|
void UpdateTerrainShadowMap(CTerrain *ptrTerrain, FLOATaabbox3D *pboxUpdate/*=NULL*/, BOOL bAbsoluteSpace/*=FALSE*/)
|
||||||
{
|
{
|
||||||
|
@ -952,8 +953,8 @@ void UpdateTerrainShadowMap(CTerrain *ptrTerrain, FLOATaabbox3D *pboxUpdate/*=NU
|
||||||
// Get pointer to world that holds this terrain
|
// Get pointer to world that holds this terrain
|
||||||
CWorld *pwldWorld = penEntity->en_pwoWorld;
|
CWorld *pwldWorld = penEntity->en_pwoWorld;
|
||||||
|
|
||||||
PIX pixWidth = ptrTerrain->GetShadowMapWidth();
|
//PIX pixWidth = ptrTerrain->GetShadowMapWidth();
|
||||||
PIX pixHeight = ptrTerrain->GetShadowMapHeight();
|
//PIX pixHeight = ptrTerrain->GetShadowMapHeight();
|
||||||
|
|
||||||
CTextureData &tdShadowMap = ptrTerrain->tr_tdShadowMap;
|
CTextureData &tdShadowMap = ptrTerrain->tr_tdShadowMap;
|
||||||
ASSERT(tdShadowMap.td_pulFrames!=NULL);
|
ASSERT(tdShadowMap.td_pulFrames!=NULL);
|
||||||
|
|
|
@ -269,7 +269,7 @@ void PrepareSmothVertices(INDEX itt)
|
||||||
GFXVertex *pvBorderSrc = pavSrc;
|
GFXVertex *pvBorderSrc = pavSrc;
|
||||||
|
|
||||||
for(INDEX ivx=tt.tt_ctNonBorderVertices;ivx<ctVertices;ivx++) {
|
for(INDEX ivx=tt.tt_ctNonBorderVertices;ivx<ctVertices;ivx++) {
|
||||||
//*pavDst++ = *pavSrc++;
|
// *pavDst++ = *pavSrc++;
|
||||||
pvBorderDst[0] = pvBorderSrc[0];
|
pvBorderDst[0] = pvBorderSrc[0];
|
||||||
pvBorderDst++;
|
pvBorderDst++;
|
||||||
pvBorderSrc++;
|
pvBorderSrc++;
|
||||||
|
@ -601,7 +601,7 @@ void PrepareSmothVertices(INDEX itt)
|
||||||
void PrepareSmothVerticesOnTileLayer(INDEX iTerrainTile, INDEX iTileLayer)
|
void PrepareSmothVerticesOnTileLayer(INDEX iTerrainTile, INDEX iTileLayer)
|
||||||
{
|
{
|
||||||
CTerrainTile &tt = _ptrTerrain->tr_attTiles[iTerrainTile];
|
CTerrainTile &tt = _ptrTerrain->tr_attTiles[iTerrainTile];
|
||||||
CTerrainLayer &tl = _ptrTerrain->tr_atlLayers[iTileLayer];
|
//CTerrainLayer &tl = _ptrTerrain->tr_atlLayers[iTileLayer];
|
||||||
TileLayer &ttl = tt.GetTileLayers()[iTileLayer];
|
TileLayer &ttl = tt.GetTileLayers()[iTileLayer];
|
||||||
|
|
||||||
ASSERT(tt.tt_iLod==0);
|
ASSERT(tt.tt_iLod==0);
|
||||||
|
@ -1231,7 +1231,7 @@ void RenderTerrain(void)
|
||||||
RenderBatchedTiles();
|
RenderBatchedTiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
CEntity *pen = _ptrTerrain->tr_penEntity;
|
//CEntity *pen = _ptrTerrain->tr_penEntity;
|
||||||
|
|
||||||
extern void ShowRayPath(CDrawPort *pdp);
|
extern void ShowRayPath(CDrawPort *pdp);
|
||||||
ShowRayPath(_pdp);
|
ShowRayPath(_pdp);
|
||||||
|
|
|
@ -441,8 +441,8 @@ void CTerrainTile::ReGenerate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
INDEX ctVtxBefore = GetVertices().Count();
|
//INDEX ctVtxBefore = GetVertices().Count();
|
||||||
INDEX ctTrisBefore = GetIndices().Count()/3;
|
//INDEX ctTrisBefore = GetIndices().Count()/3;
|
||||||
|
|
||||||
// tt_ctNormalVertices = GetVertexCount();
|
// tt_ctNormalVertices = GetVertexCount();
|
||||||
// Generate borders for tile
|
// Generate borders for tile
|
||||||
|
@ -535,7 +535,7 @@ INDEX CTerrainTile::CalculateLOD(void)
|
||||||
INDEX ini = tt_aiNeighbours[in];
|
INDEX ini = tt_aiNeighbours[in];
|
||||||
// if neighbour is valid
|
// if neighbour is valid
|
||||||
if(ini>=0) {
|
if(ini>=0) {
|
||||||
CTerrainTile &ttNeigbour = _ptrTerrain->tr_attTiles[ini];
|
//CTerrainTile &ttNeigbour = _ptrTerrain->tr_attTiles[ini];
|
||||||
// if neighbour is in higher lod
|
// if neighbour is in higher lod
|
||||||
if(TRUE) { /*ttNeigbour.tt_iLod > tt.tt_iNewLod*/
|
if(TRUE) { /*ttNeigbour.tt_iLod > tt.tt_iNewLod*/
|
||||||
// add neighbour to regen queue
|
// add neighbour to regen queue
|
||||||
|
|
|
@ -51,6 +51,7 @@ extern BOOL _bPortalSectorLinksPreLoaded;
|
||||||
extern BOOL _bEntitySectorLinksPreLoaded;
|
extern BOOL _bEntitySectorLinksPreLoaded;
|
||||||
extern INDEX _ctPredictorEntities;
|
extern INDEX _ctPredictorEntities;
|
||||||
|
|
||||||
|
#if 0 // DG: unused.
|
||||||
// calculate ray placement from origin and target positions (obsolete?)
|
// calculate ray placement from origin and target positions (obsolete?)
|
||||||
static inline CPlacement3D CalculateRayPlacement(
|
static inline CPlacement3D CalculateRayPlacement(
|
||||||
const FLOAT3D &vOrigin, const FLOAT3D &vTarget)
|
const FLOAT3D &vOrigin, const FLOAT3D &vTarget)
|
||||||
|
@ -65,6 +66,7 @@ static inline CPlacement3D CalculateRayPlacement(
|
||||||
DirectionVectorToAngles(vDirection, plRay.pl_OrientationAngle);
|
DirectionVectorToAngles(vDirection, plRay.pl_OrientationAngle);
|
||||||
return plRay;
|
return plRay;
|
||||||
}
|
}
|
||||||
|
#endif // 0
|
||||||
|
|
||||||
/* Constructor. */
|
/* Constructor. */
|
||||||
CTextureTransformation::CTextureTransformation(void)
|
CTextureTransformation::CTextureTransformation(void)
|
||||||
|
@ -84,12 +86,12 @@ CTextureBlending::CTextureBlending(void)
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*/
|
*/
|
||||||
CWorld::CWorld(void)
|
CWorld::CWorld(void)
|
||||||
: wo_colBackground(C_lGRAY) // clear background color
|
: wo_pecWorldBaseClass(NULL) // worldbase class must be obtained before using the world
|
||||||
, wo_pecWorldBaseClass(NULL) // worldbase class must be obtained before using the world
|
|
||||||
, wo_bPortalLinksUpToDate(FALSE) // portal-sector links must be updated
|
|
||||||
, wo_baBrushes(*new CBrushArchive)
|
, wo_baBrushes(*new CBrushArchive)
|
||||||
, wo_taTerrains(*new CTerrainArchive)
|
, wo_taTerrains(*new CTerrainArchive)
|
||||||
|
, wo_colBackground(C_lGRAY) // clear background color
|
||||||
, wo_ulSpawnFlags(0)
|
, wo_ulSpawnFlags(0)
|
||||||
|
, wo_bPortalLinksUpToDate(FALSE) // portal-sector links must be updated
|
||||||
{
|
{
|
||||||
wo_baBrushes.ba_pwoWorld = this;
|
wo_baBrushes.ba_pwoWorld = this;
|
||||||
wo_taTerrains.ta_pwoWorld = this;
|
wo_taTerrains.ta_pwoWorld = this;
|
||||||
|
@ -544,7 +546,7 @@ void CWorld::FindShadowLayers(
|
||||||
CLightSource *pls = iten->GetLightSource();
|
CLightSource *pls = iten->GetLightSource();
|
||||||
if (pls!=NULL) {
|
if (pls!=NULL) {
|
||||||
FLOATaabbox3D boxLight(iten->en_plPlacement.pl_PositionVector, pls->ls_rFallOff);
|
FLOATaabbox3D boxLight(iten->en_plPlacement.pl_PositionVector, pls->ls_rFallOff);
|
||||||
if ( bDirectional && (pls->ls_ulFlags &LSF_DIRECTIONAL)
|
if ( (bDirectional && (pls->ls_ulFlags & LSF_DIRECTIONAL))
|
||||||
||boxLight.HasContactWith(boxNear)) {
|
||boxLight.HasContactWith(boxNear)) {
|
||||||
// find layers for that light source
|
// find layers for that light source
|
||||||
pls->FindShadowLayers(bSelectedOnly);
|
pls->FindShadowLayers(bSelectedOnly);
|
||||||
|
@ -934,10 +936,11 @@ void CWorld::TriangularizeForVertices( CBrushVertexSelection &selVertex)
|
||||||
// add this entity to prediction
|
// add this entity to prediction
|
||||||
void CEntity::AddToPrediction(void)
|
void CEntity::AddToPrediction(void)
|
||||||
{
|
{
|
||||||
// this function may be called even for NULLs - so ignore it
|
// this function may be called even for NULLs - TODO: fix those cases
|
||||||
if (this==NULL) {
|
// (The compiler is free to assume that "this" is never NULL and optimize
|
||||||
return;
|
// based on that assumption. For example, an "if (this==NULL) {...}" could
|
||||||
}
|
// be optimized away completely.)
|
||||||
|
ASSERT(this!=NULL);
|
||||||
// if already added
|
// if already added
|
||||||
if (en_ulFlags&ENF_WILLBEPREDICTED) {
|
if (en_ulFlags&ENF_WILLBEPREDICTED) {
|
||||||
// do nothing
|
// do nothing
|
||||||
|
@ -968,8 +971,8 @@ void CWorld::MarkForPrediction(void)
|
||||||
// find whether it is local
|
// find whether it is local
|
||||||
BOOL bLocal = _pNetwork->IsPlayerLocal(pen);
|
BOOL bLocal = _pNetwork->IsPlayerLocal(pen);
|
||||||
// if allowed for prediction
|
// if allowed for prediction
|
||||||
if ( bLocal && cli_bPredictLocalPlayers
|
if ( (bLocal && cli_bPredictLocalPlayers)
|
||||||
|| !bLocal && cli_bPredictRemotePlayers) {
|
|| (!bLocal && cli_bPredictRemotePlayers)) {
|
||||||
// add it
|
// add it
|
||||||
pen->AddToPrediction();
|
pen->AddToPrediction();
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,15 +172,15 @@ void CWorld::DoCSGOperation(
|
||||||
AssureFPT_53();
|
AssureFPT_53();
|
||||||
|
|
||||||
// get relevant brush mips in each brush
|
// get relevant brush mips in each brush
|
||||||
CBrushMip &bmThis = *GetBrushMip(enThis);
|
CBrushMip *pbmThis = GetBrushMip(enThis);
|
||||||
CBrushMip &bmOther = *GetBrushMip(enOther);
|
CBrushMip *pbmOther = GetBrushMip(enOther);
|
||||||
if (&bmThis==NULL || &bmOther==NULL) {
|
if (pbmThis==NULL || pbmOther==NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get open sector of the other brush to object
|
// get open sector of the other brush to object
|
||||||
CBrushSectorSelectionForCSG selbscOtherOpen;
|
CBrushSectorSelectionForCSG selbscOtherOpen;
|
||||||
bmOther.SelectOpenSector(selbscOtherOpen);
|
pbmOther->SelectOpenSector(selbscOtherOpen);
|
||||||
CObject3D obOtherOpen;
|
CObject3D obOtherOpen;
|
||||||
DOUBLEaabbox3D boxOtherOpen;
|
DOUBLEaabbox3D boxOtherOpen;
|
||||||
woOther.CopySourceBrushSectorsToObject(enOther, selbscOtherOpen, plOther,
|
woOther.CopySourceBrushSectorsToObject(enOther, selbscOtherOpen, plOther,
|
||||||
|
@ -193,7 +193,7 @@ void CWorld::DoCSGOperation(
|
||||||
obOtherOpen.TurnPortalsToWalls();
|
obOtherOpen.TurnPortalsToWalls();
|
||||||
|
|
||||||
// if there are any sectors in this brush
|
// if there are any sectors in this brush
|
||||||
if (bmThis.bm_abscSectors.Count()>0) {
|
if (pbmThis->bm_abscSectors.Count()>0) {
|
||||||
// move affected part of this brush to an object3d object
|
// move affected part of this brush to an object3d object
|
||||||
CObject3D obThis;
|
CObject3D obThis;
|
||||||
MoveTargetBrushPartToObject(enThis, boxOtherOpen, obThis);
|
MoveTargetBrushPartToObject(enThis, boxOtherOpen, obThis);
|
||||||
|
@ -213,7 +213,7 @@ void CWorld::DoCSGOperation(
|
||||||
|
|
||||||
// get closed sectors of the other brush to object
|
// get closed sectors of the other brush to object
|
||||||
CBrushSectorSelectionForCSG selbscOtherClosed;
|
CBrushSectorSelectionForCSG selbscOtherClosed;
|
||||||
bmOther.SelectClosedSectors(selbscOtherClosed);
|
pbmOther->SelectClosedSectors(selbscOtherClosed);
|
||||||
CObject3D obOtherClosed;
|
CObject3D obOtherClosed;
|
||||||
DOUBLEaabbox3D boxOtherClosed;
|
DOUBLEaabbox3D boxOtherClosed;
|
||||||
woOther.CopySourceBrushSectorsToObject(enOther, selbscOtherClosed, plOther,
|
woOther.CopySourceBrushSectorsToObject(enOther, selbscOtherClosed, plOther,
|
||||||
|
@ -224,7 +224,7 @@ void CWorld::DoCSGOperation(
|
||||||
CObject3D obResult;
|
CObject3D obResult;
|
||||||
|
|
||||||
// if there are any sectors in this brush
|
// if there are any sectors in this brush
|
||||||
if (bmThis.bm_abscSectors.Count()>0) {
|
if (pbmThis->bm_abscSectors.Count()>0) {
|
||||||
// move affected part of this brush to an object3d object
|
// move affected part of this brush to an object3d object
|
||||||
CObject3D obThis;
|
CObject3D obThis;
|
||||||
MoveTargetBrushPartToObject(enThis, boxOtherClosed, obThis);
|
MoveTargetBrushPartToObject(enThis, boxOtherClosed, obThis);
|
||||||
|
@ -304,16 +304,16 @@ void CWorld::CSGRemove(CEntity &enThis, CWorld &woOther, CEntity &enOther,
|
||||||
AssureFPT_53();
|
AssureFPT_53();
|
||||||
|
|
||||||
// get relevant brush mip in other brush
|
// get relevant brush mip in other brush
|
||||||
CBrushMip &bmOther = *GetBrushMip(enOther);
|
CBrushMip *pbmOther = GetBrushMip(enOther);
|
||||||
if (&bmOther==NULL) {
|
if (pbmOther==NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if other brush has more than one sector
|
// if other brush has more than one sector
|
||||||
if (bmOther.bm_abscSectors.Count()>1) {
|
if (pbmOther->bm_abscSectors.Count()>1) {
|
||||||
// join all sectors of the other brush together
|
// join all sectors of the other brush together
|
||||||
CBrushSectorSelection selbscOtherAll;
|
CBrushSectorSelection selbscOtherAll;
|
||||||
bmOther.SelectAllSectors(selbscOtherAll);
|
pbmOther->SelectAllSectors(selbscOtherAll);
|
||||||
woOther.JoinSectors(selbscOtherAll);
|
woOther.JoinSectors(selbscOtherAll);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,15 +380,15 @@ void CWorld::SplitSectors(CEntity &enThis, CBrushSectorSelection &selbscSectorsT
|
||||||
AssureFPT_53();
|
AssureFPT_53();
|
||||||
|
|
||||||
// get relevant brush mip in this brush
|
// get relevant brush mip in this brush
|
||||||
CBrushMip &bmThis = *GetBrushMip(enThis);
|
CBrushMip *pbmThis = GetBrushMip(enThis);
|
||||||
if (&bmThis==NULL) {
|
if (pbmThis==NULL) {
|
||||||
_pfWorldEditingProfile.StopTimer(CWorldEditingProfile::PTI_CSGTOTAL);
|
_pfWorldEditingProfile.StopTimer(CWorldEditingProfile::PTI_CSGTOTAL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get relevant brush mip in other brush
|
// get relevant brush mip in other brush
|
||||||
CBrushMip &bmOther = *GetBrushMip(enOther);
|
CBrushMip *pbmOther = GetBrushMip(enOther);
|
||||||
if (&bmOther==NULL) {
|
if (pbmOther==NULL) {
|
||||||
_pfWorldEditingProfile.StopTimer(CWorldEditingProfile::PTI_CSGTOTAL);
|
_pfWorldEditingProfile.StopTimer(CWorldEditingProfile::PTI_CSGTOTAL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -396,10 +396,10 @@ void CWorld::SplitSectors(CEntity &enThis, CBrushSectorSelection &selbscSectorsT
|
||||||
/* Assure that the other brush has only one sector. */
|
/* Assure that the other brush has only one sector. */
|
||||||
|
|
||||||
// if other brush has more than one sector
|
// if other brush has more than one sector
|
||||||
if (bmOther.bm_abscSectors.Count()>1) {
|
if (pbmOther->bm_abscSectors.Count()>1) {
|
||||||
// join all sectors of the other brush together
|
// join all sectors of the other brush together
|
||||||
CBrushSectorSelection selbscOtherAll;
|
CBrushSectorSelection selbscOtherAll;
|
||||||
bmOther.SelectAllSectors(selbscOtherAll);
|
pbmOther->SelectAllSectors(selbscOtherAll);
|
||||||
woOther.JoinSectors(selbscOtherAll);
|
woOther.JoinSectors(selbscOtherAll);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,7 +407,7 @@ void CWorld::SplitSectors(CEntity &enThis, CBrushSectorSelection &selbscSectorsT
|
||||||
|
|
||||||
// get the sector of the other brush to object
|
// get the sector of the other brush to object
|
||||||
CBrushSectorSelectionForCSG selbscOther;
|
CBrushSectorSelectionForCSG selbscOther;
|
||||||
bmOther.SelectAllSectors(selbscOther);
|
pbmOther->SelectAllSectors(selbscOther);
|
||||||
CObject3D obOther;
|
CObject3D obOther;
|
||||||
DOUBLEaabbox3D boxOther;
|
DOUBLEaabbox3D boxOther;
|
||||||
woOther.CopySourceBrushSectorsToObject(enOther, selbscOther, plOther,
|
woOther.CopySourceBrushSectorsToObject(enOther, selbscOther, plOther,
|
||||||
|
@ -416,7 +416,7 @@ void CWorld::SplitSectors(CEntity &enThis, CBrushSectorSelection &selbscSectorsT
|
||||||
// if the selection is empty
|
// if the selection is empty
|
||||||
if (selbscSectorsToSplit.Count()==0) {
|
if (selbscSectorsToSplit.Count()==0) {
|
||||||
// select all sectors near the splitting tool
|
// select all sectors near the splitting tool
|
||||||
bmThis.SelectSectorsInRange(selbscSectorsToSplit, DOUBLEtoFLOAT(boxOther));
|
pbmThis->SelectSectorsInRange(selbscSectorsToSplit, DOUBLEtoFLOAT(boxOther));
|
||||||
}
|
}
|
||||||
// for all sectors in the selection
|
// for all sectors in the selection
|
||||||
FOREACHINDYNAMICCONTAINER(selbscSectorsToSplit, CBrushSector, itbsc) {
|
FOREACHINDYNAMICCONTAINER(selbscSectorsToSplit, CBrushSector, itbsc) {
|
||||||
|
@ -426,7 +426,7 @@ void CWorld::SplitSectors(CEntity &enThis, CBrushSectorSelection &selbscSectorsT
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the bounding boxes of this brush
|
// update the bounding boxes of this brush
|
||||||
bmThis.bm_pbrBrush->CalculateBoundingBoxes();
|
pbmThis->bm_pbrBrush->CalculateBoundingBoxes();
|
||||||
// find possible shadow layers near affected area
|
// find possible shadow layers near affected area
|
||||||
FindShadowLayers(DOUBLEtoFLOAT(boxOther));
|
FindShadowLayers(DOUBLEtoFLOAT(boxOther));
|
||||||
|
|
||||||
|
@ -574,8 +574,8 @@ void CWorld::SplitPolygons(CEntity &enThis, CBrushPolygonSelection &selbpoPolygo
|
||||||
_pfWorldEditingProfile.IncrementAveragingCounter();
|
_pfWorldEditingProfile.IncrementAveragingCounter();
|
||||||
|
|
||||||
// get relevant brush mip in other brush
|
// get relevant brush mip in other brush
|
||||||
CBrushMip &bmOther = *GetBrushMip(enOther);
|
CBrushMip *pbmOther = GetBrushMip(enOther);
|
||||||
if (&bmOther==NULL) {
|
if (pbmOther==NULL) {
|
||||||
_pfWorldEditingProfile.StopTimer(CWorldEditingProfile::PTI_CSGTOTAL);
|
_pfWorldEditingProfile.StopTimer(CWorldEditingProfile::PTI_CSGTOTAL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -596,7 +596,7 @@ void CWorld::SplitPolygons(CEntity &enThis, CBrushPolygonSelection &selbpoPolygo
|
||||||
|
|
||||||
// get the sector of the other brush to object
|
// get the sector of the other brush to object
|
||||||
CBrushSectorSelectionForCSG selbscOther;
|
CBrushSectorSelectionForCSG selbscOther;
|
||||||
bmOther.SelectAllSectors(selbscOther);
|
pbmOther->SelectAllSectors(selbscOther);
|
||||||
CObject3D obOther;
|
CObject3D obOther;
|
||||||
DOUBLEaabbox3D boxOther;
|
DOUBLEaabbox3D boxOther;
|
||||||
woOther.CopySourceBrushSectorsToObject(enOther, selbscOther, plOther,
|
woOther.CopySourceBrushSectorsToObject(enOther, selbscOther, plOther,
|
||||||
|
@ -1004,13 +1004,18 @@ void CWorld::DeleteSectors(CBrushSectorSelection &selbscSectorsToDelete, BOOL bC
|
||||||
|
|
||||||
void CheckOnePolygon(CBrushSector &bsc, CBrushPolygon &bpo)
|
void CheckOnePolygon(CBrushSector &bsc, CBrushPolygon &bpo)
|
||||||
{
|
{
|
||||||
|
// NOTE: This function has no side effects, but I think "Check" means
|
||||||
|
// "try to access stuff and make sure it doesn't segfault", so keep it
|
||||||
|
// like it is even if the compiler complains about unused values?
|
||||||
CBrushPlane *pbplPlane=bpo.bpo_pbplPlane;
|
CBrushPlane *pbplPlane=bpo.bpo_pbplPlane;
|
||||||
|
(void)pbplPlane; // shut up, compiler - I know this is unused, but I think it's intended like that.
|
||||||
INDEX ctEdges=bpo.bpo_abpePolygonEdges.Count();
|
INDEX ctEdges=bpo.bpo_abpePolygonEdges.Count();
|
||||||
INDEX ctVertices=bpo.bpo_apbvxTriangleVertices.Count();
|
INDEX ctVertices=bpo.bpo_apbvxTriangleVertices.Count();
|
||||||
for(INDEX iEdge=0;iEdge<ctEdges;iEdge++)
|
for(INDEX iEdge=0;iEdge<ctEdges;iEdge++)
|
||||||
{
|
{
|
||||||
CBrushPolygonEdge &edg=bpo.bpo_abpePolygonEdges[iEdge];
|
CBrushPolygonEdge &edg=bpo.bpo_abpePolygonEdges[iEdge];
|
||||||
CBrushEdge &be=*edg.bpe_pbedEdge;
|
CBrushEdge &be=*edg.bpe_pbedEdge;
|
||||||
|
(void)be; // shut up, compiler
|
||||||
CBrushVertex *pbvx0, *pbvx1;
|
CBrushVertex *pbvx0, *pbvx1;
|
||||||
edg.GetVertices(pbvx0, pbvx1);
|
edg.GetVertices(pbvx0, pbvx1);
|
||||||
}
|
}
|
||||||
|
@ -1022,11 +1027,13 @@ void CheckOnePolygon(CBrushSector &bsc, CBrushPolygon &bpo)
|
||||||
DOUBLE3D vdRel=vtx.bvx_vdPreciseRelative;
|
DOUBLE3D vdRel=vtx.bvx_vdPreciseRelative;
|
||||||
DOUBLE3D *pvdPreciseAbsolute=vtx.bvx_pvdPreciseAbsolute;
|
DOUBLE3D *pvdPreciseAbsolute=vtx.bvx_pvdPreciseAbsolute;
|
||||||
CBrushSector &bsc=*vtx.bvx_pbscSector;
|
CBrushSector &bsc=*vtx.bvx_pbscSector;
|
||||||
|
(void)vAbs; (void)vRel; (void)vdRel; (void)pvdPreciseAbsolute; (void)bsc; // shut up, compiler
|
||||||
}
|
}
|
||||||
for(INDEX ite=0;ite<bpo.bpo_aiTriangleElements.Count();ite++)
|
for(INDEX ite=0;ite<bpo.bpo_aiTriangleElements.Count();ite++)
|
||||||
{
|
{
|
||||||
INDEX iTriangleVtx=bpo.bpo_aiTriangleElements[ite];
|
INDEX iTriangleVtx=bpo.bpo_aiTriangleElements[ite];
|
||||||
CBrushSector &bsc=*bpo.bpo_pbscSector;
|
CBrushSector &bsc=*bpo.bpo_pbscSector;
|
||||||
|
(void)iTriangleVtx; (void)bsc; // ...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -384,7 +384,7 @@ void CWorld::ReadState_veryold_t( CTStream *istr) // throw char *
|
||||||
// read entity class index and entity placement
|
// read entity class index and entity placement
|
||||||
(*istr)>>iEntityClass>>plPlacement;
|
(*istr)>>iEntityClass>>plPlacement;
|
||||||
// create an entity of that class
|
// create an entity of that class
|
||||||
CEntity *penNew = CreateEntity_t(plPlacement, cecClasses[iEntityClass]);
|
/* CEntity *penNew = */ CreateEntity_t(plPlacement, cecClasses[iEntityClass]);
|
||||||
}}
|
}}
|
||||||
|
|
||||||
// for each entity
|
// for each entity
|
||||||
|
@ -498,7 +498,7 @@ void CWorld::ReadState_old_t( CTStream *istr) // throw char *
|
||||||
// read entity class index and entity placement
|
// read entity class index and entity placement
|
||||||
(*istr)>>iEntityClass>>plPlacement;
|
(*istr)>>iEntityClass>>plPlacement;
|
||||||
// create an entity of that class
|
// create an entity of that class
|
||||||
CEntity *penNew = CreateEntity_t(plPlacement, cecClasses[iEntityClass]);
|
/* CEntity *penNew = */ CreateEntity_t(plPlacement, cecClasses[iEntityClass]);
|
||||||
}}
|
}}
|
||||||
|
|
||||||
// for each entity
|
// for each entity
|
||||||
|
|
|
@ -344,7 +344,7 @@ functions:
|
||||||
GetNormalComponent( vDistance/fDistance, vHitNormal, ese.vDirection);
|
GetNormalComponent( vDistance/fDistance, vHitNormal, ese.vDirection);
|
||||||
FLOAT fLength = ese.vDirection.Length();
|
FLOAT fLength = ese.vDirection.Length();
|
||||||
fLength = Clamp( fLength*3, 1.0f, 3.0f);
|
fLength = Clamp( fLength*3, 1.0f, 3.0f);
|
||||||
fDistance = Clamp( log10(fDistance), 0.5, 2.0);
|
fDistance = Clamp( log10f(fDistance), 0.5f, 2.0f);
|
||||||
ese.vStretch = FLOAT3D( fDistance, fLength*fDistance, 1.0f);
|
ese.vStretch = FLOAT3D( fDistance, fLength*fDistance, 1.0f);
|
||||||
SpawnEffect(vHitPoint, ese);
|
SpawnEffect(vHitPoint, ese);
|
||||||
}
|
}
|
||||||
|
@ -417,4 +417,4 @@ procedures:
|
||||||
m_iBullet = 0;
|
m_iBullet = 0;
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -234,6 +234,7 @@ static int qsort_CompareDeaths( const void *ppPEN0, const void *ppPEN1) {
|
||||||
else return 0;
|
else return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0 // DG: unused
|
||||||
static int qsort_CompareLatencies( const void *ppPEN0, const void *ppPEN1) {
|
static int qsort_CompareLatencies( const void *ppPEN0, const void *ppPEN1) {
|
||||||
CPlayer &en0 = **(CPlayer**)ppPEN0;
|
CPlayer &en0 = **(CPlayer**)ppPEN0;
|
||||||
CPlayer &en1 = **(CPlayer**)ppPEN1;
|
CPlayer &en1 = **(CPlayer**)ppPEN1;
|
||||||
|
@ -243,6 +244,7 @@ static int qsort_CompareLatencies( const void *ppPEN0, const void *ppPEN1) {
|
||||||
else if( sl0>sl1) return -1;
|
else if( sl0>sl1) return -1;
|
||||||
else return 0;
|
else return 0;
|
||||||
}
|
}
|
||||||
|
#endif // 0 (unused)
|
||||||
|
|
||||||
// prepare color transitions
|
// prepare color transitions
|
||||||
static void PrepareColorTransitions( COLOR colFine, COLOR colHigh, COLOR colMedium, COLOR colLow,
|
static void PrepareColorTransitions( COLOR colFine, COLOR colHigh, COLOR colMedium, COLOR colLow,
|
||||||
|
@ -690,7 +692,7 @@ extern void DrawHUD( const CPlayer *penPlayerCurrent, CDrawPort *pdpCurrent, BOO
|
||||||
_fCustomScaling = ClampDn( _fCustomScaling*0.8f, 0.5f);
|
_fCustomScaling = ClampDn( _fCustomScaling*0.8f, 0.5f);
|
||||||
const FLOAT fOneUnitS = fOneUnit *0.8f;
|
const FLOAT fOneUnitS = fOneUnit *0.8f;
|
||||||
const FLOAT fAdvUnitS = fAdvUnit *0.8f;
|
const FLOAT fAdvUnitS = fAdvUnit *0.8f;
|
||||||
const FLOAT fNextUnitS = fNextUnit *0.8f;
|
//const FLOAT fNextUnitS = fNextUnit *0.8f;
|
||||||
const FLOAT fHalfUnitS = fHalfUnit *0.8f;
|
const FLOAT fHalfUnitS = fHalfUnit *0.8f;
|
||||||
|
|
||||||
// prepare postition and ammo quantities
|
// prepare postition and ammo quantities
|
||||||
|
@ -868,7 +870,7 @@ extern void DrawHUD( const CPlayer *penPlayerCurrent, CDrawPort *pdpCurrent, BOO
|
||||||
if( iHealth>25) colHealth = _colHUD;
|
if( iHealth>25) colHealth = _colHUD;
|
||||||
if( iArmor >25) colArmor = _colHUD;
|
if( iArmor >25) colArmor = _colHUD;
|
||||||
// eventually print it out
|
// eventually print it out
|
||||||
if( hud_iShowPlayers==1 || hud_iShowPlayers==-1 && !bSinglePlay) {
|
if( hud_iShowPlayers==1 || (hud_iShowPlayers==-1 && !bSinglePlay)) {
|
||||||
// printout location and info aren't the same for deathmatch and coop play
|
// printout location and info aren't the same for deathmatch and coop play
|
||||||
const FLOAT fCharWidth = (PIX)((_pfdDisplayFont->GetWidth()-2) *fTextScale);
|
const FLOAT fCharWidth = (PIX)((_pfdDisplayFont->GetWidth()-2) *fTextScale);
|
||||||
if( bCooperative) {
|
if( bCooperative) {
|
||||||
|
|
|
@ -276,7 +276,7 @@ void Particles_RomboidTrail(CEntity *pen)
|
||||||
for(INDEX iPos = 0; iPos<plp->lp_ctUsed; iPos++)
|
for(INDEX iPos = 0; iPos<plp->lp_ctUsed; iPos++)
|
||||||
{
|
{
|
||||||
FLOAT3D vPos = plp->GetPosition(iPos);
|
FLOAT3D vPos = plp->GetPosition(iPos);
|
||||||
FLOAT fRand = rand()/FLOAT(RAND_MAX);
|
//FLOAT fRand = rand()/FLOAT(RAND_MAX);
|
||||||
FLOAT fAngle = fSeconds*256+iPos*2.0f*PI/ROMBOID_TRAIL_POSITIONS;
|
FLOAT fAngle = fSeconds*256+iPos*2.0f*PI/ROMBOID_TRAIL_POSITIONS;
|
||||||
FLOAT fSin = FLOAT(sin(fAngle));
|
FLOAT fSin = FLOAT(sin(fAngle));
|
||||||
vPos(2) += fSin*iPos/ROMBOID_TRAIL_POSITIONS;
|
vPos(2) += fSin*iPos/ROMBOID_TRAIL_POSITIONS;
|
||||||
|
@ -437,7 +437,7 @@ void Particles_WhiteLineTrail(CEntity *pen)
|
||||||
vPos(1) += fSin*iPos*1.0f/WHITE_LINE_TRAIL_POSITIONS;
|
vPos(1) += fSin*iPos*1.0f/WHITE_LINE_TRAIL_POSITIONS;
|
||||||
vPos(2) += fCos*iPos*1.0f/WHITE_LINE_TRAIL_POSITIONS;
|
vPos(2) += fCos*iPos*1.0f/WHITE_LINE_TRAIL_POSITIONS;
|
||||||
|
|
||||||
UBYTE ub = 255-iPos*256/WHITE_LINE_TRAIL_POSITIONS;
|
//UBYTE ub = 255-iPos*256/WHITE_LINE_TRAIL_POSITIONS;
|
||||||
FLOAT fLerpFactor = FLOAT(iPos)/WHITE_LINE_TRAIL_POSITIONS;
|
FLOAT fLerpFactor = FLOAT(iPos)/WHITE_LINE_TRAIL_POSITIONS;
|
||||||
COLOR colColor = LerpColor( C_YELLOW, C_dRED, fLerpFactor);
|
COLOR colColor = LerpColor( C_YELLOW, C_dRED, fLerpFactor);
|
||||||
Particle_RenderLine( vPos, vOldPos, 0.05f, colColor);
|
Particle_RenderLine( vPos, vOldPos, 0.05f, colColor);
|
||||||
|
@ -533,7 +533,7 @@ void Particles_CannonBall_Prepare(CEntity *pen)
|
||||||
void Particles_CannonBall(CEntity *pen, FLOAT fSpeedRatio)
|
void Particles_CannonBall(CEntity *pen, FLOAT fSpeedRatio)
|
||||||
{
|
{
|
||||||
CLastPositions *plp = pen->GetLastPositions(CANNON_TRAIL_POSITIONS);
|
CLastPositions *plp = pen->GetLastPositions(CANNON_TRAIL_POSITIONS);
|
||||||
FLOAT fSeconds = _pTimer->GetLerpedCurrentTick();
|
// FLOAT fSeconds = _pTimer->GetLerpedCurrentTick();
|
||||||
|
|
||||||
Particle_PrepareTexture(&_toCannonBall, PBT_BLEND);
|
Particle_PrepareTexture(&_toCannonBall, PBT_BLEND);
|
||||||
Particle_SetTexturePart( 512, 512, 0, 0);
|
Particle_SetTexturePart( 512, 512, 0, 0);
|
||||||
|
@ -718,9 +718,9 @@ void Particles_BeastProjectileTrail( CEntity *pen, FLOAT fSize, FLOAT fHeight, I
|
||||||
fT *= 1/BEAST_PROJECTILE_TOTAL_TIME;
|
fT *= 1/BEAST_PROJECTILE_TOTAL_TIME;
|
||||||
// get fraction part
|
// get fraction part
|
||||||
fT = fT-int(fT);
|
fT = fT-int(fT);
|
||||||
FLOAT fFade;
|
//FLOAT fFade;
|
||||||
if (fT>(1.0f-BEAST_PROJECTILE_FADE_OUT)) fFade=(1-fT)*(1/BEAST_PROJECTILE_FADE_OUT);
|
//if (fT>(1.0f-BEAST_PROJECTILE_FADE_OUT)) fFade=(1-fT)*(1/BEAST_PROJECTILE_FADE_OUT);
|
||||||
else fFade=1.0f;
|
//else fFade=1.0f;
|
||||||
|
|
||||||
#define GET_POS( time) vCenter + \
|
#define GET_POS( time) vCenter + \
|
||||||
vX*(afStarsPositions[iStar][0]*time*fSize*1.5) +\
|
vX*(afStarsPositions[iStar][0]*time*fSize*1.5) +\
|
||||||
|
@ -816,7 +816,7 @@ void Particles_RocketTrail_Prepare(CEntity *pen)
|
||||||
void Particles_RocketTrail(CEntity *pen, FLOAT fStretch)
|
void Particles_RocketTrail(CEntity *pen, FLOAT fStretch)
|
||||||
{
|
{
|
||||||
CLastPositions *plp = pen->GetLastPositions(ROCKET_TRAIL_POSITIONS);
|
CLastPositions *plp = pen->GetLastPositions(ROCKET_TRAIL_POSITIONS);
|
||||||
FLOAT fSeconds = _pTimer->GetLerpedCurrentTick();
|
//FLOAT fSeconds = _pTimer->GetLerpedCurrentTick();
|
||||||
|
|
||||||
Particle_PrepareTexture(&_toRocketTrail, PBT_ADD);
|
Particle_PrepareTexture(&_toRocketTrail, PBT_ADD);
|
||||||
Particle_SetTexturePart( 512, 512, 0, 0);
|
Particle_SetTexturePart( 512, 512, 0, 0);
|
||||||
|
@ -835,7 +835,7 @@ void Particles_RocketTrail(CEntity *pen, FLOAT fStretch)
|
||||||
}
|
}
|
||||||
for (INDEX iInter=0; iInter<ROCKET_TRAIL_INTERPOSITIONS; iInter++)
|
for (INDEX iInter=0; iInter<ROCKET_TRAIL_INTERPOSITIONS; iInter++)
|
||||||
{
|
{
|
||||||
FLOAT fRand = rand()/FLOAT(RAND_MAX);
|
//FLOAT fRand = rand()/FLOAT(RAND_MAX);
|
||||||
FLOAT fAngle = 0.0f;
|
FLOAT fAngle = 0.0f;
|
||||||
FLOAT3D vPos = Lerp(*pvPos1, *pvPos2, iInter*1.0f/ROCKET_TRAIL_INTERPOSITIONS);
|
FLOAT3D vPos = Lerp(*pvPos1, *pvPos2, iInter*1.0f/ROCKET_TRAIL_INTERPOSITIONS);
|
||||||
FLOAT fSize = iParticle*0.5f/iParticlesLiving*fStretch+0.25f;
|
FLOAT fSize = iParticle*0.5f/iParticlesLiving*fStretch+0.25f;
|
||||||
|
@ -888,9 +888,9 @@ void Particles_BloodTrail(CEntity *pen)
|
||||||
{
|
{
|
||||||
Particle_SetTexturePart( 256, 256, iPos%8, 0);
|
Particle_SetTexturePart( 256, 256, iPos%8, 0);
|
||||||
FLOAT3D vPos = plp->GetPosition(iPos);
|
FLOAT3D vPos = plp->GetPosition(iPos);
|
||||||
FLOAT fRand = rand()/FLOAT(RAND_MAX);
|
//FLOAT fRand = rand()/FLOAT(RAND_MAX);
|
||||||
FLOAT fAngle = iPos*2.0f*PI/BLOOD01_TRAIL_POSITIONS;
|
FLOAT fAngle = iPos*2.0f*PI/BLOOD01_TRAIL_POSITIONS;
|
||||||
FLOAT fSin = FLOAT(sin(fAngle));
|
//FLOAT fSin = FLOAT(sin(fAngle));
|
||||||
FLOAT fT = iPos*_pTimer->TickQuantum;
|
FLOAT fT = iPos*_pTimer->TickQuantum;
|
||||||
vPos += vGDir*fGA*fT*fT/8.0f;
|
vPos += vGDir*fGA*fT*fT/8.0f;
|
||||||
FLOAT fSize = 0.2f-iPos*0.15f/BLOOD01_TRAIL_POSITIONS;
|
FLOAT fSize = 0.2f-iPos*0.15f/BLOOD01_TRAIL_POSITIONS;
|
||||||
|
@ -1709,7 +1709,7 @@ void Particles_Rain(CEntity *pen, FLOAT fGridSize, INDEX ctGrids, FLOAT fFactor,
|
||||||
pixRainMapH = ptdRainMap->GetPixHeight();
|
pixRainMapH = ptdRainMap->GetPixHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
INDEX ctDiscarded=0;
|
//INDEX ctDiscarded=0;
|
||||||
for( INDEX iZ=0; iZ<ctGrids; iZ++)
|
for( INDEX iZ=0; iZ<ctGrids; iZ++)
|
||||||
{
|
{
|
||||||
INDEX iRndZ = (ULONG(vPos(3)+iZ)) % CT_MAX_PARTICLES_TABLE;
|
INDEX iRndZ = (ULONG(vPos(3)+iZ)) % CT_MAX_PARTICLES_TABLE;
|
||||||
|
@ -1803,7 +1803,7 @@ void Particles_Snow( CEntity *pen, FLOAT fGridSize, INDEX ctGrids)
|
||||||
UBYTE ubR = 128+afStarsPositions[(INDEX)fT0*CT_MAX_PARTICLES_TABLE][2]*64;
|
UBYTE ubR = 128+afStarsPositions[(INDEX)fT0*CT_MAX_PARTICLES_TABLE][2]*64;
|
||||||
COLOR colDrop = RGBToColor(ubR, ubR, ubR)|CT_OPAQUE;
|
COLOR colDrop = RGBToColor(ubR, ubR, ubR)|CT_OPAQUE;
|
||||||
FLOAT3D vRender = FLOAT3D( fX, fY, fZ);
|
FLOAT3D vRender = FLOAT3D( fX, fY, fZ);
|
||||||
FLOAT fSize = 1.75f+afStarsPositions[(INDEX)fT0*CT_MAX_PARTICLES_TABLE][1];
|
//FLOAT fSize = 1.75f+afStarsPositions[(INDEX)fT0*CT_MAX_PARTICLES_TABLE][1];
|
||||||
Particle_RenderSquare( vRender, 0.1f, 0, colDrop);
|
Particle_RenderSquare( vRender, 0.1f, 0, colDrop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2113,9 +2113,9 @@ void Particles_BulletSpray(CEntity *pen, FLOAT3D vGDir, enum EffectParticlesType
|
||||||
fSpeedStart = 1.75f;
|
fSpeedStart = 1.75f;
|
||||||
fConeMultiplier = 0.125f;
|
fConeMultiplier = 0.125f;
|
||||||
|
|
||||||
FLOAT fFadeStart = BULLET_SPRAY_WATER_FADEOUT_START;
|
//FLOAT fFadeStart = BULLET_SPRAY_WATER_FADEOUT_START;
|
||||||
FLOAT fLifeTotal = BULLET_SPRAY_WATER_TOTAL_TIME;
|
//FLOAT fLifeTotal = BULLET_SPRAY_WATER_TOTAL_TIME;
|
||||||
FLOAT fFadeLen = fLifeTotal-fFadeStart;
|
//FLOAT fFadeLen = fLifeTotal-fFadeStart;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2321,7 +2321,7 @@ void Particles_EmptyShells( CEntity *pen, ShellLaunchData *asldData)
|
||||||
{
|
{
|
||||||
// render smoke
|
// render smoke
|
||||||
INDEX iRnd = (INDEX(tmLaunch*1234))%CT_MAX_PARTICLES_TABLE;
|
INDEX iRnd = (INDEX(tmLaunch*1234))%CT_MAX_PARTICLES_TABLE;
|
||||||
FLOAT fTRatio = fT/fLife;
|
//FLOAT fTRatio = fT/fLife;
|
||||||
INDEX iColumn = 4+INDEX( iShell)%4;
|
INDEX iColumn = 4+INDEX( iShell)%4;
|
||||||
Particle_SetTexturePart( 256, 256, iColumn, 2);
|
Particle_SetTexturePart( 256, 256, iColumn, 2);
|
||||||
|
|
||||||
|
@ -2342,7 +2342,7 @@ void Particles_EmptyShells( CEntity *pen, ShellLaunchData *asldData)
|
||||||
{
|
{
|
||||||
// render smoke
|
// render smoke
|
||||||
INDEX iRnd = (INDEX(tmLaunch*1234))%CT_MAX_PARTICLES_TABLE;
|
INDEX iRnd = (INDEX(tmLaunch*1234))%CT_MAX_PARTICLES_TABLE;
|
||||||
FLOAT fTRatio = fT/fLife;
|
//FLOAT fTRatio = fT/fLife;
|
||||||
INDEX iColumn = 4+INDEX( iShell)%4;
|
INDEX iColumn = 4+INDEX( iShell)%4;
|
||||||
Particle_SetTexturePart( 256, 256, iColumn, 2);
|
Particle_SetTexturePart( 256, 256, iColumn, 2);
|
||||||
|
|
||||||
|
@ -2369,7 +2369,7 @@ void Particles_EmptyShells( CEntity *pen, ShellLaunchData *asldData)
|
||||||
FLOAT3D vUp( m(1,2), m(2,2), m(3,2));
|
FLOAT3D vUp( m(1,2), m(2,2), m(3,2));
|
||||||
|
|
||||||
INDEX iRnd = (INDEX(tmLaunch*1234))%CT_MAX_PARTICLES_TABLE;
|
INDEX iRnd = (INDEX(tmLaunch*1234))%CT_MAX_PARTICLES_TABLE;
|
||||||
FLOAT fTRatio = fT/fLife;
|
//FLOAT fTRatio = fT/fLife;
|
||||||
INDEX iColumn = 4+INDEX( iShell)%4;
|
INDEX iColumn = 4+INDEX( iShell)%4;
|
||||||
Particle_SetTexturePart( 256, 256, iColumn, 2);
|
Particle_SetTexturePart( 256, 256, iColumn, 2);
|
||||||
|
|
||||||
|
@ -2495,7 +2495,7 @@ void Particles_Appearing(CEntity *pen, TIME tmStart)
|
||||||
if( (fTime<APPEAR_IN_START) || (fTime>APPEAR_OUT_END)) {
|
if( (fTime<APPEAR_IN_START) || (fTime>APPEAR_OUT_END)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FLOAT fPowerTime = pow(fTime-SPIRIT_SPIRAL_START, 2.5f);
|
//FLOAT fPowerTime = pow(fTime-SPIRIT_SPIRAL_START, 2.5f);
|
||||||
|
|
||||||
// fill array with absolute vertices of entity's model and its attached models
|
// fill array with absolute vertices of entity's model and its attached models
|
||||||
pen->GetModelVerticesAbsolute(avVertices, 0.05f, fMipFactor);
|
pen->GetModelVerticesAbsolute(avVertices, 0.05f, fMipFactor);
|
||||||
|
@ -2505,7 +2505,7 @@ void Particles_Appearing(CEntity *pen, TIME tmStart)
|
||||||
FLOAT3D vX( m(1,1), m(2,1), m(3,1));
|
FLOAT3D vX( m(1,1), m(2,1), m(3,1));
|
||||||
FLOAT3D vY( m(1,2), m(2,2), m(3,2));
|
FLOAT3D vY( m(1,2), m(2,2), m(3,2));
|
||||||
FLOAT3D vZ( m(1,3), m(2,3), m(3,3));
|
FLOAT3D vZ( m(1,3), m(2,3), m(3,3));
|
||||||
FLOAT3D vCenter = pen->GetLerpedPlacement().pl_PositionVector;
|
//FLOAT3D vCenter = pen->GetLerpedPlacement().pl_PositionVector;
|
||||||
|
|
||||||
SetupParticleTexture( PT_STAR07);
|
SetupParticleTexture( PT_STAR07);
|
||||||
|
|
||||||
|
@ -2524,12 +2524,12 @@ void Particles_Appearing(CEntity *pen, TIME tmStart)
|
||||||
COLOR col = RGBToColor(ubColor,ubColor,ubColor)|CT_OPAQUE;
|
COLOR col = RGBToColor(ubColor,ubColor,ubColor)|CT_OPAQUE;
|
||||||
|
|
||||||
INDEX ctVtx = avVertices.Count();
|
INDEX ctVtx = avVertices.Count();
|
||||||
FLOAT fSpeedFactor = 1.0f/ctVtx;
|
//FLOAT fSpeedFactor = 1.0f/ctVtx;
|
||||||
|
|
||||||
// get corp size
|
// get corp size
|
||||||
FLOATaabbox3D box;
|
FLOATaabbox3D box;
|
||||||
pen->en_pmoModelObject->GetCurrentFrameBBox(box);
|
pen->en_pmoModelObject->GetCurrentFrameBBox(box);
|
||||||
FLOAT fHeightStretch = box.Size()(2);
|
//FLOAT fHeightStretch = box.Size()(2);
|
||||||
|
|
||||||
FLOAT fStep = ClampDn( fMipFactor, 1.0f);
|
FLOAT fStep = ClampDn( fMipFactor, 1.0f);
|
||||||
for( FLOAT fVtx=0.0f; fVtx<ctVtx; fVtx+=fStep)
|
for( FLOAT fVtx=0.0f; fVtx<ctVtx; fVtx+=fStep)
|
||||||
|
@ -2733,7 +2733,7 @@ void Particles_BloodSpray(enum SprayParticlesType sptType, CEntity *penSpray, FL
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UBYTE ubRndH = UBYTE( 32+afStarsPositions[ int(iSpray+tmStarted*10)%CT_MAX_PARTICLES_TABLE][0]*16);
|
UBYTE ubRndH = UBYTE( 32+afStarsPositions[ int(iSpray+tmStarted*10)%CT_MAX_PARTICLES_TABLE][0]*16);
|
||||||
UBYTE ubRndS = UBYTE( 127+(afStarsPositions[ int(iSpray+tmStarted*10)%CT_MAX_PARTICLES_TABLE][1]+0.5)*128);
|
//UBYTE ubRndS = UBYTE( 127+(afStarsPositions[ int(iSpray+tmStarted*10)%CT_MAX_PARTICLES_TABLE][1]+0.5)*128);
|
||||||
UBYTE ubRndV = UBYTE( 159+(afStarsPositions[ int(iSpray+tmStarted*10)%CT_MAX_PARTICLES_TABLE][2])*192);
|
UBYTE ubRndV = UBYTE( 159+(afStarsPositions[ int(iSpray+tmStarted*10)%CT_MAX_PARTICLES_TABLE][2])*192);
|
||||||
col = HSVToColor(ubRndH, 0, ubRndV)|ubAlpha;
|
col = HSVToColor(ubRndH, 0, ubRndV)|ubAlpha;
|
||||||
fSize/=2.0f;
|
fSize/=2.0f;
|
||||||
|
|
|
@ -35,8 +35,9 @@ CPathNode::~CPathNode(void)
|
||||||
// get name of this node
|
// get name of this node
|
||||||
const CTString &CPathNode::GetName(void)
|
const CTString &CPathNode::GetName(void)
|
||||||
{
|
{
|
||||||
|
ASSERT(this!=NULL);
|
||||||
static CTString strNone="<none>";
|
static CTString strNone="<none>";
|
||||||
if (this==NULL || pn_pnmMarker==NULL) {
|
if (pn_pnmMarker==NULL) {
|
||||||
return strNone;
|
return strNone;
|
||||||
} else {
|
} else {
|
||||||
return pn_pnmMarker->GetName();
|
return pn_pnmMarker->GetName();
|
||||||
|
@ -46,7 +47,8 @@ const CTString &CPathNode::GetName(void)
|
||||||
// get link with given index or null if no more (for iteration along the graph)
|
// get link with given index or null if no more (for iteration along the graph)
|
||||||
CPathNode *CPathNode::GetLink(INDEX i)
|
CPathNode *CPathNode::GetLink(INDEX i)
|
||||||
{
|
{
|
||||||
if (this==NULL || pn_pnmMarker==NULL) {
|
ASSERT(this!=NULL);
|
||||||
|
if (pn_pnmMarker==NULL) {
|
||||||
ASSERT(FALSE);
|
ASSERT(FALSE);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ functions:
|
||||||
{
|
{
|
||||||
// cannot be damaged immediately after spawning
|
// cannot be damaged immediately after spawning
|
||||||
if ((_pTimer->CurrentTick()-m_tmStarted<1.0f)
|
if ((_pTimer->CurrentTick()-m_tmStarted<1.0f)
|
||||||
||(dmtType==DMT_CANNONBALL_EXPLOSION) && (_pTimer->CurrentTick()-m_tmStarted<5.0f)) {
|
||((dmtType==DMT_CANNONBALL_EXPLOSION) && (_pTimer->CurrentTick()-m_tmStarted<5.0f))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CMovableModelEntity::ReceiveDamage(penInflictor, dmtType, fDamageAmmount, vHitPoint, vDirection);
|
CMovableModelEntity::ReceiveDamage(penInflictor, dmtType, fDamageAmmount, vHitPoint, vDirection);
|
||||||
|
|
|
@ -444,8 +444,8 @@ procedures:
|
||||||
|
|
||||||
Hit(EVoid) : CEnemyBase::Hit {
|
Hit(EVoid) : CEnemyBase::Hit {
|
||||||
// burn enemy
|
// burn enemy
|
||||||
if (m_EdtType == DT_SERGEANT && CalcDist(m_penEnemy) <= 6.0f ||
|
if ((m_EdtType == DT_SERGEANT && CalcDist(m_penEnemy) <= 6.0f) ||
|
||||||
m_EdtType == DT_MONSTER && CalcDist(m_penEnemy) <= 20.0f) {
|
(m_EdtType == DT_MONSTER && CalcDist(m_penEnemy) <= 20.0f)) {
|
||||||
jump BurnEnemy();
|
jump BurnEnemy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@ functions:
|
||||||
|
|
||||||
void AdjustMipFactor(FLOAT &fMipFactor)
|
void AdjustMipFactor(FLOAT &fMipFactor)
|
||||||
{
|
{
|
||||||
if (m_eetType==ET_DISAPPEAR_MODEL || m_eetType==ET_DISAPPEAR_MODEL_NOW && m_penModel!=NULL)
|
if (m_eetType==ET_DISAPPEAR_MODEL || (m_eetType==ET_DISAPPEAR_MODEL_NOW && m_penModel!=NULL))
|
||||||
{
|
{
|
||||||
CModelObject *pmo = m_penModel->GetModelObject();
|
CModelObject *pmo = m_penModel->GetModelObject();
|
||||||
TIME tmDelta = _pTimer->GetLerpedCurrentTick()-m_tmStarted;
|
TIME tmDelta = _pTimer->GetLerpedCurrentTick()-m_tmStarted;
|
||||||
|
@ -131,7 +131,7 @@ functions:
|
||||||
COLOR col = C_WHITE|ubAlpha;
|
COLOR col = C_WHITE|ubAlpha;
|
||||||
pmo->mo_colBlendColor = col;
|
pmo->mo_colBlendColor = col;
|
||||||
}
|
}
|
||||||
if (m_eetType==ET_APPEAR_MODEL || m_eetType==ET_APPEAR_MODEL_NOW && m_penModel!=NULL)
|
if (m_eetType==ET_APPEAR_MODEL || (m_eetType==ET_APPEAR_MODEL_NOW && m_penModel!=NULL))
|
||||||
{
|
{
|
||||||
CModelObject *pmo = m_penModel->GetModelObject();
|
CModelObject *pmo = m_penModel->GetModelObject();
|
||||||
TIME tmDelta = _pTimer->GetLerpedCurrentTick()-m_tmStarted;
|
TIME tmDelta = _pTimer->GetLerpedCurrentTick()-m_tmStarted;
|
||||||
|
@ -434,7 +434,7 @@ procedures:
|
||||||
// setup light source
|
// setup light source
|
||||||
if (m_bLightSource) { SetupLightSource(); }
|
if (m_bLightSource) { SetupLightSource(); }
|
||||||
|
|
||||||
while(_pTimer->CurrentTick()<m_tmStarted+m_tmLifeTime && m_bAlive || m_bWaitTrigger)
|
while((_pTimer->CurrentTick()<m_tmStarted+m_tmLifeTime && m_bAlive) || m_bWaitTrigger)
|
||||||
{
|
{
|
||||||
wait( 0.25f)
|
wait( 0.25f)
|
||||||
{
|
{
|
||||||
|
|
|
@ -425,6 +425,7 @@ functions:
|
||||||
default: iAnim = ELEMENTALLAVA_ANIM_WOUND03; break;
|
default: iAnim = ELEMENTALLAVA_ANIM_WOUND03; break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
iAnim = 0; // DG: should at least have deterministic value
|
||||||
/* switch (IRnd()%3) {
|
/* switch (IRnd()%3) {
|
||||||
case 0: iAnim = STONEMAN_ANIM_WOUND01; break;
|
case 0: iAnim = STONEMAN_ANIM_WOUND01; break;
|
||||||
case 1: iAnim = STONEMAN_ANIM_WOUND02; break;
|
case 1: iAnim = STONEMAN_ANIM_WOUND02; break;
|
||||||
|
@ -494,6 +495,7 @@ functions:
|
||||||
if (m_EetType == ELT_LAVA) {
|
if (m_EetType == ELT_LAVA) {
|
||||||
iAnim = ELEMENTALLAVA_ANIM_DEATH03;
|
iAnim = ELEMENTALLAVA_ANIM_DEATH03;
|
||||||
} else {
|
} else {
|
||||||
|
iAnim = 0; // DG: should at least have deterministic value
|
||||||
// iAnim = STONEMAN_ANIM_DEATH03;
|
// iAnim = STONEMAN_ANIM_DEATH03;
|
||||||
}
|
}
|
||||||
StartModelAnim(iAnim, 0);
|
StartModelAnim(iAnim, 0);
|
||||||
|
@ -821,20 +823,23 @@ functions:
|
||||||
GetBoundingBox(box);
|
GetBoundingBox(box);
|
||||||
FLOAT fEntitySize = box.Size().MaxNorm()/2;
|
FLOAT fEntitySize = box.Size().MaxNorm()/2;
|
||||||
|
|
||||||
|
/*
|
||||||
INDEX iCount = 1;
|
INDEX iCount = 1;
|
||||||
switch (m_EecChar) {
|
switch (m_EecChar) {
|
||||||
case ELC_SMALL: iCount = 3; break;
|
case ELC_SMALL: iCount = 3; break;
|
||||||
case ELC_BIG: iCount = 5; break;
|
case ELC_BIG: iCount = 5; break;
|
||||||
case ELC_LARGE: iCount = 7; break;
|
case ELC_LARGE: iCount = 7; break;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
FLOAT3D vNormalizedDamage = m_vDamage-m_vDamage*(m_fBlowUpAmount/m_vDamage.Length());
|
FLOAT3D vNormalizedDamage = m_vDamage-m_vDamage*(m_fBlowUpAmount/m_vDamage.Length());
|
||||||
vNormalizedDamage /= Sqrt(vNormalizedDamage.Length());
|
vNormalizedDamage /= Sqrt(vNormalizedDamage.Length());
|
||||||
vNormalizedDamage *= 1.75f;
|
vNormalizedDamage *= 1.75f;
|
||||||
|
|
||||||
|
/*
|
||||||
FLOAT3D vBodySpeed = en_vCurrentTranslationAbsolute-en_vGravityDir*(en_vGravityDir%en_vCurrentTranslationAbsolute);
|
FLOAT3D vBodySpeed = en_vCurrentTranslationAbsolute-en_vGravityDir*(en_vGravityDir%en_vCurrentTranslationAbsolute);
|
||||||
|
|
||||||
// spawn debris
|
// spawn debris
|
||||||
/*
|
|
||||||
switch (m_EetType) {
|
switch (m_EetType) {
|
||||||
case ELT_ICE: {
|
case ELT_ICE: {
|
||||||
Debris_Begin(EIBT_ICE, DPT_NONE, BET_NONE, fEntitySize, vNormalizedDamage, vBodySpeed, 1.0f, 0.0f);
|
Debris_Begin(EIBT_ICE, DPT_NONE, BET_NONE, fEntitySize, vNormalizedDamage, vBodySpeed, 1.0f, 0.0f);
|
||||||
|
@ -1213,6 +1218,7 @@ procedures:
|
||||||
if (m_EetType == ELT_LAVA) {
|
if (m_EetType == ELT_LAVA) {
|
||||||
iAnim = ELEMENTALLAVA_ANIM_MELTUP;
|
iAnim = ELEMENTALLAVA_ANIM_MELTUP;
|
||||||
} else {
|
} else {
|
||||||
|
iAnim = 0; // DG: should at least have deterministic value
|
||||||
// iAnim = STONEMAN_ANIM_MORPHPLANEUP;
|
// iAnim = STONEMAN_ANIM_MORPHPLANEUP;
|
||||||
}
|
}
|
||||||
StartModelAnim(iAnim, 0);
|
StartModelAnim(iAnim, 0);
|
||||||
|
@ -1318,7 +1324,7 @@ procedures:
|
||||||
autocall FallOnFloor() EReturn;
|
autocall FallOnFloor() EReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_EecChar==ELC_LARGE || m_EecChar==ELC_BIG && m_EetType==ELT_LAVA)
|
if ((m_EecChar==ELC_LARGE || m_EecChar==ELC_BIG) && m_EetType==ELT_LAVA)
|
||||||
{
|
{
|
||||||
PlaySound(m_soBackground, SOUND_LAVA_LAVABURN, SOF_3D|SOF_LOOP);
|
PlaySound(m_soBackground, SOUND_LAVA_LAVABURN, SOF_3D|SOF_LOOP);
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,7 @@ functions:
|
||||||
// render one lightning toward enemy
|
// render one lightning toward enemy
|
||||||
FLOAT3D vSource = GetPlacement().pl_PositionVector;
|
FLOAT3D vSource = GetPlacement().pl_PositionVector;
|
||||||
FLOAT3D vTarget = m_penEnemy->GetPlacement().pl_PositionVector;
|
FLOAT3D vTarget = m_penEnemy->GetPlacement().pl_PositionVector;
|
||||||
FLOAT3D vDirection = (vTarget-vSource).Normalize();
|
//FLOAT3D vDirection = (vTarget-vSource).Normalize();
|
||||||
Particles_Ghostbuster(vSource, vTarget, 32, 1.0f);
|
Particles_Ghostbuster(vSource, vTarget, 32, 1.0f);
|
||||||
|
|
||||||
// random lightnings arround
|
// random lightnings arround
|
||||||
|
@ -268,7 +268,7 @@ procedures:
|
||||||
// declare yourself as a model
|
// declare yourself as a model
|
||||||
InitAsModel();
|
InitAsModel();
|
||||||
// fish must not go upstairs, or it will get out of water
|
// fish must not go upstairs, or it will get out of water
|
||||||
SetPhysicsFlags((EPF_MODEL_WALKING|EPF_HASGILLS)&~EPF_ONBLOCK_CLIMBORSLIDE|EPF_ONBLOCK_SLIDE);
|
SetPhysicsFlags(((EPF_MODEL_WALKING|EPF_HASGILLS)&~EPF_ONBLOCK_CLIMBORSLIDE)|EPF_ONBLOCK_SLIDE);
|
||||||
SetCollisionFlags(ECF_MODEL);
|
SetCollisionFlags(ECF_MODEL);
|
||||||
SetFlags(GetFlags()|ENF_ALIVE);
|
SetFlags(GetFlags()|ENF_ALIVE);
|
||||||
SetHealth(30.0f);
|
SetHealth(30.0f);
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user