1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-11-05 06:35:54 +00:00

Merge remote-tracking branch 'origin/master' into miami

# Conflicts:
#	src/control/RoadBlocks.cpp
#	src/core/Collision.h
#	src/core/Pad.cpp
#	src/core/SurfaceTable.h
#	src/core/main.cpp
#	src/core/re3.cpp
#	src/peds/Population.cpp
#	src/render/Fluff.cpp
#	src/render/Shadows.cpp
#	src/render/Shadows.h
#	src/render/Sprite2d.cpp
#	src/weapons/BulletInfo.cpp
This commit is contained in:
Sergeanur 2020-08-07 12:34:41 +03:00
commit 7d8ffa9ebd
34 changed files with 3423 additions and 306 deletions

BIN
mpg123.32/dist/libmpg123-0.dll vendored Normal file

Binary file not shown.

Binary file not shown.

159
mpg123.32/include/fmt123.h Normal file
View file

@ -0,0 +1,159 @@
/*
libmpg123: MPEG Audio Decoder library
separate header just for audio format definitions not tied to
library code
copyright 1995-2020 by the mpg123 project
free software under the terms of the LGPL 2.1
see COPYING and AUTHORS files in distribution or http://mpg123.org
*/
#ifndef MPG123_ENC_H
#define MPG123_ENC_H
/** \file fmt123.h Audio format definitions. */
/** \defgroup mpg123_enc mpg123 PCM sample encodings
* These are definitions for audio formats used by libmpg123 and
* libout123.
*
* @{
*/
/** An enum over all sample types possibly known to mpg123.
* The values are designed as bit flags to allow bitmasking for encoding
* families.
* This is also why the enum is not used as type for actual encoding variables,
* plain integers (at least 16 bit, 15 bit being used) cover the possible
* combinations of these flags.
*
* Note that (your build of) libmpg123 does not necessarily support all these.
* Usually, you can expect the 8bit encodings and signed 16 bit.
* Also 32bit float will be usual beginning with mpg123-1.7.0 .
* What you should bear in mind is that (SSE, etc) optimized routines may be
* absent for some formats. We do have SSE for 16, 32 bit and float, though.
* 24 bit integer is done via postprocessing of 32 bit output -- just cutting
* the last byte, no rounding, even. If you want better, do it yourself.
*
* All formats are in native byte order. If you need different endinaness, you
* can simply postprocess the output buffers (libmpg123 wouldn't do anything
* else). The macro MPG123_SAMPLESIZE() can be helpful there.
*/
enum mpg123_enc_enum
{
/* 0000 0000 0000 1111 Some 8 bit integer encoding. */
MPG123_ENC_8 = 0x00f
/* 0000 0000 0100 0000 Some 16 bit integer encoding. */
, MPG123_ENC_16 = 0x040
/* 0100 0000 0000 0000 Some 24 bit integer encoding. */
, MPG123_ENC_24 = 0x4000
/* 0000 0001 0000 0000 Some 32 bit integer encoding. */
, MPG123_ENC_32 = 0x100
/* 0000 0000 1000 0000 Some signed integer encoding. */
, MPG123_ENC_SIGNED = 0x080
/* 0000 1110 0000 0000 Some float encoding. */
, MPG123_ENC_FLOAT = 0xe00
/* 0000 0000 1101 0000 signed 16 bit */
, MPG123_ENC_SIGNED_16 = (MPG123_ENC_16|MPG123_ENC_SIGNED|0x10)
/* 0000 0000 0110 0000 unsigned 16 bit */
, MPG123_ENC_UNSIGNED_16 = (MPG123_ENC_16|0x20)
/* 0000 0000 0000 0001 unsigned 8 bit */
, MPG123_ENC_UNSIGNED_8 = 0x01
/* 0000 0000 1000 0010 signed 8 bit */
, MPG123_ENC_SIGNED_8 = (MPG123_ENC_SIGNED|0x02)
/* 0000 0000 0000 0100 ulaw 8 bit */
, MPG123_ENC_ULAW_8 = 0x04
/* 0000 0000 0000 1000 alaw 8 bit */
, MPG123_ENC_ALAW_8 = 0x08
/* 0001 0001 1000 0000 signed 32 bit */
, MPG123_ENC_SIGNED_32 = MPG123_ENC_32|MPG123_ENC_SIGNED|0x1000
/* 0010 0001 0000 0000 unsigned 32 bit */
, MPG123_ENC_UNSIGNED_32 = MPG123_ENC_32|0x2000
/* 0101 0000 1000 0000 signed 24 bit */
, MPG123_ENC_SIGNED_24 = MPG123_ENC_24|MPG123_ENC_SIGNED|0x1000
/* 0110 0000 0000 0000 unsigned 24 bit */
, MPG123_ENC_UNSIGNED_24 = MPG123_ENC_24|0x2000
/* 0000 0010 0000 0000 32bit float */
, MPG123_ENC_FLOAT_32 = 0x200
/* 0000 0100 0000 0000 64bit float */
, MPG123_ENC_FLOAT_64 = 0x400
/* Any possibly known encoding from the list above. */
, MPG123_ENC_ANY = ( MPG123_ENC_SIGNED_16 | MPG123_ENC_UNSIGNED_16
| MPG123_ENC_UNSIGNED_8 | MPG123_ENC_SIGNED_8
| MPG123_ENC_ULAW_8 | MPG123_ENC_ALAW_8
| MPG123_ENC_SIGNED_32 | MPG123_ENC_UNSIGNED_32
| MPG123_ENC_SIGNED_24 | MPG123_ENC_UNSIGNED_24
| MPG123_ENC_FLOAT_32 | MPG123_ENC_FLOAT_64 )
};
/** Get size of one PCM sample with given encoding.
* This is included both in libmpg123 and libout123. Both offer
* an API function to provide the macro results from library
* compile-time, not that of you application. This most likely
* does not matter as I do not expect any fresh PCM sample
* encoding to appear. But who knows? Perhaps the encoding type
* will be abused for funny things in future, not even plain PCM.
* And, by the way: Thomas really likes the ?: operator.
* \param enc the encoding (mpg123_enc_enum value)
* \return size of one sample in bytes
*/
#define MPG123_SAMPLESIZE(enc) ( \
(enc) < 1 \
? 0 \
: ( (enc) & MPG123_ENC_8 \
? 1 \
: ( (enc) & MPG123_ENC_16 \
? 2 \
: ( (enc) & MPG123_ENC_24 \
? 3 \
: ( ( (enc) & MPG123_ENC_32 \
|| (enc) == MPG123_ENC_FLOAT_32 ) \
? 4 \
: ( (enc) == MPG123_ENC_FLOAT_64 \
? 8 \
: 0 \
) ) ) ) ) )
/** Representation of zero in differing encodings.
* This exists to define proper silence in various encodings without
* having to link to libsyn123 to do actual conversions at runtime.
* You have to handle big/little endian order yourself, though.
* This takes the shortcut that any signed encoding has a zero with
* all-zero bits. Unsigned linear encodings just have the highest bit set
* (2^(n-1) for n bits), while the nonlinear 8-bit ones are special.
* \param enc the encoding (mpg123_enc_enum value)
* \param siz bytes per sample (return value of MPG123_SAMPLESIZE(enc))
* \param off byte (octet) offset counted from LSB
* \return unsigned byte value for the designated octet
*/
#define MPG123_ZEROSAMPLE(enc, siz, off) ( \
(enc) == MPG123_ENC_ULAW_8 \
? (off == 0 ? 0xff : 0x00) \
: ( (enc) == MPG123_ENC_ALAW_8 \
? (off == 0 ? 0xd5 : 0x00) \
: ( (((enc) & (MPG123_ENC_SIGNED|MPG123_ENC_FLOAT)) || (siz) != ((off)+1)) \
? 0x00 \
: 0x80 \
) ) )
/** Structure defining an audio format.
* Providing the members as individual function arguments to define a certain
* output format is easy enough. This struct makes is more comfortable to deal
* with a list of formats.
* Negative values for the members might be used to communicate use of default
* values.
*/
struct mpg123_fmt
{
long rate; /**< sampling rate in Hz */
int channels; /**< channel count */
/** encoding code, can be single value or bitwise or of members of
* mpg123_enc_enum */
int encoding;
};
/* @} */
#endif

File diff suppressed because it is too large Load diff

Binary file not shown.

Binary file not shown.

View file

@ -8,13 +8,8 @@
#include <opusfile.h>
#else
#ifdef _WIN32
// TODO: This is due to version difference of 32-bit libmpg123 and 64-bit libmpg123, fix it
#ifndef _WIN64
typedef long ssize_t;
#endif
#pragma comment( lib, "libsndfile-1.lib" )
#pragma comment( lib, "libmpg123.lib" )
#pragma comment( lib, "libmpg123-0.lib" )
#else
#include "crossplatform.h"
#endif

View file

@ -111,6 +111,10 @@ CRoadBlocks::GenerateRoadBlocks(void)
{
CMatrix tmp1, tmp2;
static int16 unk;
#ifdef SQUEEZE_PERFORMANCE
if (FindPlayerPed()->m_pWanted->m_RoadblockDensity == 0)
return;
#endif
uint32 frame = CTimer::GetFrameCounter() & 0xF;
int16 nRoadblockNode = (int16)(NUMROADBLOCKS * frame) / 16;
const int16 maxRoadBlocks = (int16)(NUMROADBLOCKS * (frame + 1)) / 16;

View file

@ -53,6 +53,10 @@ CAccidentManager::ReportAccident(CPed *ped)
void
CAccidentManager::Update()
{
#ifdef SQUEEZE_PERFORMANCE
// Handled after injury registered.
return;
#endif
int32 e;
if (CEventList::GetEvent(EVENT_INJURED_PED, &e)) {
CPed *ped = CPools::GetPed(gaEvent[e].entityRef);

View file

@ -1,5 +1,4 @@
#pragma once
#include "common.h"
#include "config.h"
class CPed;

File diff suppressed because it is too large Load diff

View file

@ -2,9 +2,12 @@
#include "templates.h"
#include "Game.h" // for eLevelName
#ifdef VU_COLLISION
#include "VuVector.h"
#endif
// If you spawn many tanks at once, you will see that collisions of two entity exceeds 32.
#ifdef FIX_BUGS
#if defined(FIX_BUGS) && !defined(SQUEEZE_PERFORMANCE)
#define MAX_COLLISION_POINTS 64
#else
#define MAX_COLLISION_POINTS 32
@ -16,6 +19,28 @@ struct CompressedVector
int16 x, y, z;
CVector Get(void) const { return CVector(x, y, z)/128.0f; };
void Set(float x, float y, float z) { this->x = x*128.0f; this->y = y*128.0f; this->z = z*128.0f; };
#ifdef GTA_PS2
void Unpack(uint128 &qword) const {
__asm__ volatile (
"lh $8, 0(%1)\n"
"lh $9, 2(%1)\n"
"lh $10, 4(%1)\n"
"pextlw $10, $8\n"
"pextlw $2, $9, $10\n"
"sq $2, %0\n"
: "=m" (qword)
: "r" (this)
: "$8", "$9", "$10", "$2"
);
}
#else
void Unpack(int32 *qword) const {
qword[0] = x;
qword[1] = y;
qword[2] = z;
qword[3] = 0; // junk
}
#endif
#else
float x, y, z;
CVector Get(void) const { return CVector(x, y, z); };
@ -25,6 +50,7 @@ struct CompressedVector
struct CSphere
{
// NB: this has to be compatible with a CVuVector
CVector center;
float radius;
void Set(float radius, const CVector &center) { this->center = center; this->radius = radius; }
@ -59,6 +85,7 @@ struct CColBox : public CBox
struct CColLine
{
// NB: this has to be compatible with two CVuVectors
CVector p0;
int pad0;
CVector p1;
@ -81,6 +108,39 @@ struct CColTriangle
struct CColTrianglePlane
{
#ifdef VU_COLLISION
CompressedVector normal;
int16 dist;
void Set(const CVector &va, const CVector &vb, const CVector &vc);
void Set(const CompressedVector *v, CColTriangle &tri) { Set(v[tri.a].Get(), v[tri.b].Get(), v[tri.c].Get()); }
void GetNormal(CVector &n) const { n.x = normal.x/4096.0f; n.y = normal.y/4096.0f; n.z = normal.z/4096.0f; }
float CalcPoint(const CVector &v) const { CVector n; GetNormal(n); return DotProduct(n, v) - dist/128.0f; };
#ifdef GTA_PS2
void Unpack(uint128 &qword) const {
__asm__ volatile (
"lh $8, 0(%1)\n"
"lh $9, 2(%1)\n"
"lh $10, 4(%1)\n"
"lh $11, 6(%1)\n"
"pextlw $10, $8\n"
"pextlw $11, $9\n"
"pextlw $2, $11, $10\n"
"sq $2, %0\n"
: "=m" (qword)
: "r" (this)
: "$8", "$9", "$10", "$11", "$2"
);
}
#else
void Unpack(int32 *qword) const {
qword[0] = normal.x;
qword[1] = normal.y;
qword[2] = normal.z;
qword[3] = dist;
}
#endif
#else
CVector normal;
float dist;
uint8 dir;
@ -92,6 +152,7 @@ struct CColTrianglePlane
float GetNormalY() const { return normal.y; }
float GetNormalZ() const { return normal.z; }
float CalcPoint(const CVector &v) const { return DotProduct(normal, v) - dist; };
#endif
};
struct CColPoint
@ -112,7 +173,11 @@ struct CColPoint
struct CStoredCollPoly
{
#ifdef VU_COLLISION
CVuVector verts[3];
#else
CVector verts[3];
#endif
bool valid;
};

View file

@ -8,6 +8,7 @@
#include "Messages.h"
#include "Text.h"
#include "main.h"
#include "Accident.h"
int32 CEventList::ms_nFirstFreeSlotIndex;
CEvent gaEvent[NUMEVENTS];
@ -63,6 +64,13 @@ CEventList::RegisterEvent(eEventType type, eEventEntity entityType, CEntity *ent
int ref;
bool copsDontCare;
#ifdef SQUEEZE_PERFORMANCE
if (type == EVENT_INJURED_PED) {
gAccidentManager.ReportAccident((CPed*)ent);
return;
}
#endif
copsDontCare = false;
switch(entityType){
case EVENT_ENTITY_PED:

View file

@ -109,6 +109,7 @@ int gameTxdSlot;
bool DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha);
void DoRWStuffEndOfFrame(void);
#ifdef PS2_MENU
void MessageScreen(char *msg)
{
//TODO: stretch_screen
@ -142,6 +143,7 @@ void MessageScreen(char *msg)
DoRWStuffEndOfFrame();
}
#endif
bool
CGame::InitialiseOnceBeforeRW(void)

View file

@ -1933,6 +1933,11 @@ CWorld::Process(void)
} else {
for(CPtrNode *node = ms_listMovingEntityPtrs.first; node; node = node->next) {
CEntity *movingEnt = (CEntity *)node->item;
#ifdef SQUEEZE_PERFORMANCE
if (movingEnt->bRemoveFromWorld) {
RemoveEntityInsteadOfProcessingIt(movingEnt);
} else
#endif
if(movingEnt->m_rwObject && RwObjectGetType(movingEnt->m_rwObject) == rpCLUMP &&
RpAnimBlendClumpGetFirstAssociation(movingEnt->GetClump())) {
// TODO(MIAMI): doRender argument

View file

@ -7,6 +7,7 @@
#include "Clock.h"
#include "Text.h"
#include "World.h"
#include "Timer.h"
eLevelName CTheZones::m_CurrLevel;
int16 CTheZones::FindIndex;
@ -127,6 +128,10 @@ CTheZones::Init(void)
void
CTheZones::Update(void)
{
#ifdef SQUEEZE_PERFORMANCE
if (CTimer::GetFrameCounter() % 5 != 0)
return;
#endif
CVector pos;
pos = FindPlayerCoors();
m_CurrLevel = GetLevelFromPosition(&pos);

View file

@ -89,6 +89,16 @@ typedef uint16_t wchar;
#include <rpskin.h>
#endif
#ifdef __GNUC__
#define TYPEALIGN(n) __attribute__ ((aligned (n)))
#else
#ifdef _MSC_VER
#define TYPEALIGN(n) __declspec(align(n))
#else
#define TYPEALIGN(n) // unknown compiler...ignore
#endif
#endif
#define ALIGNPTR(p) (void*)((((uintptr)(void*)p) + sizeof(void*)-1) & ~(sizeof(void*)-1))
// PDP-10 like byte functions

View file

@ -167,7 +167,7 @@ enum Config {
#if defined GTA_PS2
# define GTA_PS2_STUFF
# define RANDOMSPLASH
# define COMPRESSED_COL_VECTORS
# define VU_COLLISION
#elif defined GTA_PC
# define GTA3_1_1_PATCH
//# define GTA3_STEAM_PATCH
@ -180,6 +180,10 @@ enum Config {
#elif defined GTA_XBOX
#endif
#ifdef VU_COLLISION
#define COMPRESSED_COL_VECTORS // current need compressed vectors in this code
#endif
#ifdef MASTER
// only in master builds
#else
@ -298,3 +302,12 @@ enum Config {
#define AUDIO_CACHE // cache sound lengths to speed up the cold boot
#endif
//#define PS2_AUDIO // changes audio paths for cutscenes and radio to PS2 paths, needs vbdec to support VB with MSS
//#define SQUEEZE_PERFORMANCE
#ifdef SQUEEZE_PERFORMANCE
#undef PS2_ALPHA_TEST
#undef NO_ISLAND_LOADING
#define PC_PARTICLE
#define VC_PED_PORTS // To not process collisions always. But should be tested if that's really beneficial
#endif

View file

@ -489,9 +489,7 @@ DebugMenuPopulate(void)
DebugMenuAddVarBool8("Render", "Draw hud", &CHud::m_Wants_To_Draw_Hud, nil);
DebugMenuAddVarBool8("Render", "Backface Culling", &gBackfaceCulling, nil);
#ifdef LIBRW
DebugMenuAddVarBool8("Render", "PS2 Alpha test Emu", &gPS2alphaTest, nil);
#endif
DebugMenuAddVarBool8("Render", "Frame limiter", &FrontEndMenuManager.m_PrefsFrameLimiter, nil);
DebugMenuAddVarBool8("Render", "VSynch", &FrontEndMenuManager.m_PrefsVsync, nil);
DebugMenuAddVar("Render", "Max FPS", &RsGlobal.maxFPS, nil, 1, 1, 1000, nil);

21
src/core/vu0Collision.dsm Normal file
View file

@ -0,0 +1,21 @@
.align 4
.global Vu0CollisionDmaTag
Vu0CollisionDmaTag:
DMAcnt *
MPG 0, *
.vu
.include "vu0Collision_1.s"
.EndMPG
.EndDmaData
DMAend
.global Vu0Collision2DmaTag
Vu0Collision2DmaTag:
DMAcnt *
MPG 0, *
.vu
.include "vu0Collision_2.s"
.EndMPG
.EndDmaData
DMAend
.end

610
src/core/vu0Collision_1.s Normal file
View file

@ -0,0 +1,610 @@
QuitAndFail:
NOP[E] IADDIU VI01, VI00, 0
NOP NOP
QuitAndSucceed:
NOP[E] IADDIU VI01, VI00, 1
NOP NOP
; 20 -- unused
; VF12, VF13 xyz: sphere centers
; VF14, VF15 x: sphere radii
; out:
; VI01: set when collision
; VF01: supposed to be intersection point?
; VF02: normal (pointing towards s1, not normalized)
.globl Vu0SphereToSphereCollision
Vu0SphereToSphereCollision:
SUB.xyz VF02, VF13, VF12 NOP ; dist of centers
ADD.x VF04, VF14, VF15 NOP ; s = sum of radii
MUL.xyzw VF03, VF02, VF02 NOP ;
MUL.x VF04, VF04, VF04 DIV Q, VF14x, VF04x ; square s
NOP NOP ;
NOP NOP ;
MULAx.w ACC, VF00, VF03 NOP ;
MADDAy.w ACC, VF00, VF03 NOP ;
MADDz.w VF03, VF00, VF03 NOP ; d = DistSq of centers
NOP NOP ;
MULAw.xyz ACC, VF12, VF00 NOP ;
MADDq.xyz VF01, VF02, Q NOP ; intersection, but wrong
CLIPw.xyz VF04, VF03 NOP ; compare s and d
SUB.xyz VF02, VF00, VF02 NOP ; compute normal
NOP NOP ;
NOP NOP ;
NOP FCAND VI01, 0x3 ; 0x2 cannot be set here
NOP[E] NOP ;
NOP NOP ;
; B8 -- unused
; VF12:
; VF13: radius
; VF14:
; VF15: box dimensions (?)
.globl Vu0SphereToAABBCollision
Vu0SphereToAABBCollision:
SUB.xyz VF03, VF12, VF14 LOI 0.5
MULi.xyz VF15, VF15, I NOP
MUL.x VF13, VF13, VF13 NOP
SUB.xyz VF04, VF03, VF15 NOP
ADD.xyz VF05, VF03, VF15 MR32.xyzw VF16, VF15
CLIPw.xyz VF03, VF16 MR32.xyzw VF17, VF16
MUL.xyz VF04, VF04, VF04 NOP
MUL.xyz VF05, VF05, VF05 NOP
CLIPw.xyz VF03, VF17 MR32.xyzw VF16, VF17
NOP FCAND VI01, 0x1
MINI.xyz VF04, VF04, VF05 MFIR.x VF09, VI01
NOP NOP
CLIPw.xyz VF03, VF16 FCAND VI01, 0x4
NOP MFIR.y VF09, VI01
NOP NOP
MULAx.w ACC, VF00, VF00 NOP
ADD.xyz VF01, VF00, VF03 FCAND VI01, 0x10
NOP MFIR.z VF09, VI01
NOP LOI 2
NOP FCAND VI01, 0x30
SUBAw.xyz ACC, VF00, VF00 IADD VI04, VI00, VI01
ITOF0.xyz VF09, VF09 FCAND VI01, 0x300
NOP IADD VI03, VI00, VI01
NOP FCAND VI01, 0x3000
NOP IADD VI02, VI00, VI01
MADDi.xyzw VF09, VF09, I NOP
NOP IBEQ VI04, VI00, IgnoreZValue
NOP NOP
MADDAz.w ACC, VF00, VF04 NOP
MUL.z VF01, VF09, VF15 NOP
IgnoreZValue:
NOP IBEQ VI03, VI00, IgnoreYValue
NOP NOP
MADDAy.w ACC, VF00, VF04 NOP
MUL.y VF01, VF09, VF15 NOP
IgnoreYValue:
NOP IBEQ VI02, VI00, IgnoreXValue
NOP NOP
MADDAx.w ACC, VF00, VF04 NOP
MUL.x VF01, VF09, VF15 NOP
IgnoreXValue:
MADDx.w VF06, VF00, VF00 NOP
SUB.xyz VF02, VF03, VF01 NOP
ADD.xyz VF01, VF01, VF14 NOP
MULx.w VF01, VF00, VF00 NOP
CLIPw.xyz VF13, VF06 NOP
NOP NOP
NOP NOP
NOP NOP
NOP FCAND VI01, 0x1
QuitMicrocode:
NOP[E] NOP
NOP NOP
; 240
.globl Vu0LineToSphereCollision
Vu0LineToSphereCollision:
SUB.xyzw VF01, VF13, VF12 NOP
SUB.xyzw VF02, VF14, VF12 NOP
MUL.xyz VF03, VF01, VF02 NOP
MUL.xyz VF04, VF01, VF01 NOP
MUL.x VF15, VF15, VF15 NOP
MUL.xyz VF02, VF02, VF02 NOP
MULAx.w ACC, VF00, VF03 NOP
MADDAy.w ACC, VF00, VF03 NOP
MADDz.w VF03, VF00, VF03 NOP
MULAx.w ACC, VF00, VF04 NOP
MADDAy.w ACC, VF00, VF04 NOP
MADDz.w VF01, VF00, VF04 NOP
MULAx.w ACC, VF00, VF02 NOP
MADDAy.w ACC, VF00, VF02 NOP
MADDz.w VF02, VF00, VF02 NOP
MULA.w ACC, VF03, VF03 NOP
MADDAx.w ACC, VF01, VF15 NOP
MSUB.w VF05, VF01, VF02 NOP
NOP NOP
NOP NOP
NOP IADDIU VI02, VI00, 0x10
NOP FMAND VI01, VI02
NOP IBNE VI01, VI00, QuitAndFail
NOP NOP
CLIPw.xyz VF15, VF02 SQRT Q, VF05w
NOP NOP
NOP NOP
NOP NOP
NOP FCAND VI01, 0x1
NOP IBNE VI00, VI01, LineStartInsideSphere
NOP NOP
SUBq.w VF05, VF03, Q NOP
SUB.w VF05, VF05, VF01 DIV Q, VF05w, VF01w
NOP FMAND VI01, VI02
NOP IBNE VI01, VI00, QuitAndFail
NOP NOP
NOP FMAND VI01, VI02
NOP IBEQ VI01, VI00, QuitAndFail
NOP NOP
ADDA.xyz ACC, VF12, VF00 NOP
MADDq.xyz VF01, VF01, Q NOP
MULx.w VF01, VF00, VF00 NOP
SUB.xyz VF02, VF01, VF14 NOP
NOP[E] NOP
NOP NOP
LineStartInsideSphere:
NOP MOVE.xyzw VF01, VF12
NOP[E] IADDIU VI01, VI00, 0x1
NOP NOP
; 3C0
.globl Vu0LineToAABBCollision
Vu0LineToAABBCollision:
SUB.xyzw VF08, VF13, VF12 LOI 0.5
MULi.xyz VF15, VF15, I IADDIU VI08, VI00, 0x0
SUB.xyzw VF12, VF12, VF14 NOP
SUB.xyzw VF13, VF13, VF14 NOP
NOP DIV Q, VF00w, VF08x
NOP MR32.xyzw VF03, VF15
SUB.xyz VF06, VF15, VF12 NOP
ADD.xyz VF07, VF15, VF12 NOP
NOP NOP
CLIPw.xyz VF12, VF03 MR32.xyzw VF04, VF03
NOP NOP
ADDq.x VF09, VF00, Q DIV Q, VF00w, VF08y
NOP NOP
CLIPw.xyz VF12, VF04 MR32.xyzw VF05, VF04
SUB.xyz VF07, VF00, VF07 IADDIU VI06, VI00, 0xCC
NOP IADDIU VI07, VI00, 0x30
NOP NOP
CLIPw.xyz VF12, VF05 FCGET VI02
NOP IAND VI02, VI02, VI06
ADDq.y VF09, VF00, Q DIV Q, VF00w, VF08z
SUB.xyz VF10, VF00, VF10 NOP
CLIPw.xyz VF13, VF03 FCGET VI03
CLIPw.xyz VF13, VF04 IAND VI03, VI03, VI07
CLIPw.xyz VF13, VF05 FCAND VI01, 0x3330
NOP IBEQ VI01, VI00, StartPointInsideAABB
NOP NOP
ADDq.z VF09, VF00, Q FCGET VI04
NOP FCGET VI05
NOP IAND VI04, VI04, VI06
NOP IAND VI05, VI05, VI07
MULx.xyz VF17, VF08, VF09 NOP
MULy.xyz VF18, VF08, VF09 IADDIU VI07, VI00, 0x80
MULz.xyz VF19, VF08, VF09 IAND VI06, VI02, VI07
MUL.w VF10, VF00, VF00 IAND VI07, VI04, VI07
NOP NOP
NOP IBEQ VI06, VI07, CheckMaxXSide
NOP NOP
MULAx.xyz ACC, VF17, VF07 NOP
MADDw.xyz VF16, VF12, VF00 NOP
MUL.x VF10, VF07, VF09 NOP
CLIPw.xyz VF16, VF04 NOP
CLIPw.xyz VF16, VF05 NOP
NOP NOP
NOP NOP
NOP NOP
NOP FCAND VI01, 0x330
NOP IBNE VI01, VI00, CheckMaxXSide
NOP NOP
MULx.w VF10, VF00, VF10 IADDIU VI08, VI00, 0x1
ADD.yz VF02, VF00, VF00 MOVE.xyzw VF01, VF16
SUBw.x VF02, VF00, VF00 NOP
CheckMaxXSide:
MULAx.xyz ACC, VF17, VF06 IADDIU VI07, VI00, 0x40
MADDw.xyz VF16, VF12, VF00 IAND VI06, VI02, VI07
MUL.x VF10, VF06, VF09 IAND VI07, VI04, VI07
NOP NOP
NOP IBEQ VI06, VI07, CheckMinYSide
NOP NOP
CLIPw.xyz VF16, VF04 NOP
CLIPw.xyz VF16, VF05 NOP
CLIPw.xyz VF10, VF10 NOP
NOP NOP
NOP NOP
NOP NOP
NOP FCAND VI01, 0xCC03
NOP IBNE VI01, VI00, CheckMinYSide
NOP NOP
MULx.w VF10, VF00, VF10 IADDIU VI08, VI00, 0x1
ADD.yz VF02, VF00, VF00 MOVE.xyzw VF01, VF16
ADDw.x VF02, VF00, VF00 NOP
CheckMinYSide:
MULAy.xyz ACC, VF18, VF07 IADDIU VI07, VI00, 0x8
MADDw.xyz VF16, VF12, VF00 IAND VI06, VI02, VI07
MUL.y VF10, VF07, VF09 IAND VI07, VI04, VI07
NOP NOP
NOP IBEQ VI06, VI07, CheckMaxYSide
NOP NOP
CLIPw.xyz VF16, VF03 NOP
CLIPw.xyz VF16, VF05 NOP
CLIPw.xyz VF10, VF10 NOP
NOP NOP
NOP NOP
NOP NOP
NOP FCAND VI01, 0x3C0C
NOP IBNE VI01, VI00, CheckMaxYSide
NOP NOP
MULy.w VF10, VF00, VF10 IADDIU VI08, VI00, 0x1
ADD.xz VF02, VF00, VF00 MOVE.xyzw VF01, VF16
SUBw.y VF02, VF00, VF00 NOP
CheckMaxYSide:
MULAy.xyz ACC, VF18, VF06 IADDIU VI07, VI00, 0x4
MADDw.xyz VF16, VF12, VF00 IAND VI06, VI02, VI07
MUL.y VF10, VF06, VF09 IAND VI07, VI04, VI07
NOP NOP
NOP IBEQ VI06, VI07, CheckMinZSide
NOP NOP
CLIPw.xyz VF16, VF03 NOP
CLIPw.xyz VF16, VF05 NOP
CLIPw.xyz VF10, VF10 NOP
NOP NOP
NOP NOP
NOP NOP
NOP FCAND VI01, 0x3C0C
NOP IBNE VI01, VI00, CheckMinZSide
NOP NOP
MULy.w VF10, VF00, VF10 IADDIU VI08, VI00, 0x1
ADD.xz VF02, VF00, VF00 MOVE.xyzw VF01, VF16
ADDw.y VF02, VF00, VF00 NOP
CheckMinZSide:
MULAz.xyz ACC, VF19, VF07 IADDIU VI07, VI00, 0x20
MADDw.xyz VF16, VF12, VF00 IAND VI06, VI03, VI07
MUL.z VF10, VF07, VF09 IAND VI07, VI05, VI07
NOP NOP
NOP IBEQ VI06, VI07, CheckMaxZSide
NOP NOP
CLIPw.xyz VF16, VF03 NOP
CLIPw.xyz VF16, VF04 NOP
CLIPw.xyz VF10, VF10 NOP
NOP NOP
NOP NOP
NOP NOP
NOP FCAND VI01, 0x3330
NOP IBNE VI01, VI00, CheckMaxZSide
NOP NOP
MULz.w VF10, VF00, VF10 IADDIU VI08, VI00, 0x1
ADD.xy VF02, VF00, VF00 MOVE.xyzw VF01, VF16
SUBw.z VF02, VF00, VF00 NOP
CheckMaxZSide:
MULAz.xyz ACC, VF19, VF06 IADDIU VI07, VI00, 0x10
MADDw.xyz VF16, VF12, VF00 IAND VI06, VI03, VI07
MUL.z VF10, VF06, VF09 IAND VI07, VI05, VI07
NOP NOP
NOP IBEQ VI06, VI07, DoneAllChecks
NOP NOP
CLIPw.xyz VF16, VF03 NOP
CLIPw.xyz VF16, VF04 NOP
CLIPw.xyz VF10, VF10 NOP
NOP NOP
NOP NOP
NOP NOP
NOP FCAND VI01, 0x3330
NOP IBNE VI01, VI00, DoneAllChecks
NOP NOP
MULz.w VF10, VF00, VF10 IADDIU VI08, VI00, 0x1
ADD.xy VF02, VF00, VF00 MOVE.xyzw VF01, VF16
ADDw.z VF02, VF00, VF00 NOP
DoneAllChecks:
ADD.xyz VF01, VF01, VF14 IADD VI01, VI00, VI08
NOP[E] NOP
NOP NOP
StartPointInsideAABB:
ADD.xyz VF01, VF12, VF14 WAITQ
NOP IADDIU VI01, VI00, 0x1
NOP[E] NOP
NOP NOP
; 860
.globl Vu0LineToTriangleCollisionCompressedStart
Vu0LineToTriangleCollisionCompressedStart:
ITOF0.xyzw VF17, VF17 LOI 0.000244140625 ; 1.0/4096.0
ITOF0.xyzw VF14, VF14 NOP
ITOF0.xyzw VF15, VF15 NOP
ITOF0.xyzw VF16, VF16 NOP
MULi.xyz VF17, VF17, I LOI 0.0078125 ; 1.0/128.0
MULi.w VF17, VF17, I NOP
MULi.xyzw VF14, VF14, I NOP
MULi.xyzw VF15, VF15, I NOP
MULi.xyzw VF16, VF16, I NOP
; fall through
; 8A8
; VF12: point0
; VF13: point1
; VF14-16: verts
; VF17: plane
; out:
; VF01: intersection point
; VF02: triangle normal
; VF03 x: intersection parameter
.globl Vu0LineToTriangleCollisionStart
Vu0LineToTriangleCollisionStart:
MUL.xyz VF10, VF17, VF12 LOI 0.5
MUL.xyz VF11, VF17, VF13 NOP
SUB.xyz VF02, VF13, VF12 NOP ; line dist
ADD.xyz VF17, VF17, VF00 NOP
MULi.w VF03, VF00, I NOP
MULAx.w ACC, VF00, VF10 NOP
MADDAy.w ACC, VF00, VF10 IADDIU VI06, VI00, 0xE0
MADDz.w VF10, VF00, VF10 FMAND VI05, VI06 ; -- normal sign flags, unused
MULAx.w ACC, VF00, VF11 NOP
MADDAy.w ACC, VF00, VF11 NOP
MADDz.w VF11, VF00, VF11 NOP
SUB.w VF09, VF17, VF10 NOP ; plane-pos 0
CLIPw.xyz VF17, VF03 NOP ; compare normal against 0.5 to figure out which in which dimension to compare
NOP IADDIU VI02, VI00, 0x10 ; Sw flag
SUBA.w ACC, VF17, VF11 NOP ; plane-pos 1
SUB.w VF08, VF11, VF10 FMAND VI01, VI02
NOP NOP
NOP NOP
NOP FMAND VI02, VI02
NOP IBEQ VI01, VI02, QuitAndFail ; if on same side, no collision
NOP NOP
NOP DIV Q, VF09w, VF08w ; parameter of intersection
NOP FCAND VI01, 0x3 ; check x direction
NOP IADDIU VI02, VI01, 0x7F
NOP IADDIU VI06, VI00, 0x80
NOP IAND VI02, VI02, VI06 ; Sx flag
NOP FCAND VI01, 0xC ; check y direction
NOP IADDIU VI03, VI01, 0x3F
MULAw.xyz ACC, VF12, VF00 IADDIU VI06, VI00, 0x40
MADDq.xyz VF01, VF02, Q IAND VI03, VI03, VI06 ; point of intersection -- Sy flag
MULx.w VF01, VF00, VF00 FCAND VI01, 0x30 ; -- check z direction
ADDq.x VF03, VF00, Q IADDIU VI04, VI01, 0x1F ; output parameter
SUB.xyz VF05, VF15, VF14 IADDIU VI06, VI00, 0x20 ; edge vectors
SUB.xyz VF08, VF01, VF14 IAND VI04, VI04, VI06 ; edge vectors -- Sz flag
SUB.xyz VF06, VF16, VF15 IADD VI06, VI02, VI03 ; edge vectors
SUB.xyz VF09, VF01, VF15 IADD VI06, VI06, VI04 ; edge vectors -- combine flags
SUB.xyz VF07, VF14, VF16 NOP ; edge vectors
SUB.xyz VF10, VF01, VF16 NOP ; edge vectors
OPMULA.xyz ACC, VF08, VF05 NOP
OPMSUB.xyz VF18, VF05, VF08 NOP ; cross1
OPMULA.xyz ACC, VF09, VF06 NOP
OPMSUB.xyz VF19, VF06, VF09 NOP ; cross2
OPMULA.xyz ACC, VF10, VF07 NOP
OPMSUB.xyz VF20, VF07, VF10 FMAND VI02, VI06 ; cross3
NOP NOP
NOP FMAND VI03, VI06
NOP NOP
NOP FMAND VI04, VI06
NOP NOP
NOP IBNE VI03, VI02, QuitAndFail ; point has to lie on the same side of all edges (i.e. inside)
NOP NOP
NOP IBNE VI04, VI02, QuitAndFail
NOP NOP
MULw.xyz VF02, VF17, VF00 IADDIU VI01, VI00, 0x1 ; success
NOP[E] NOP
NOP NOP
; A68
; VF12: center
; VF14: line origin
; VF15: line vector to other point
; out: VF16 xyz: nearest point on line; w: distance to that point
DistanceBetweenSphereAndLine:
SUB.xyz VF20, VF12, VF14 NOP
MUL.xyz VF21, VF15, VF15 NOP
ADDA.xyz ACC, VF14, VF15 NOP
MSUBw.xyz VF25, VF12, VF00 NOP ; VF25 = VF12 - (VF14+VF15)
MUL.xyz VF22, VF20, VF20 NOP
MUL.xyz VF23, VF20, VF15 NOP
MULAx.w ACC, VF00, VF21 NOP
MADDAy.w ACC, VF00, VF21 NOP
MADDz.w VF21, VF00, VF21 NOP ; MagSq VF15 (line length)
MULAx.w ACC, VF00, VF23 NOP
MADDAy.w ACC, VF00, VF23 NOP
MADDz.w VF23, VF00, VF23 NOP ; dot(VF12-VF14, VF15)
MULAx.w ACC, VF00, VF22 NOP
MADDAy.w ACC, VF00, VF22 NOP
MADDz.w VF22, VF00, VF22 IADDIU VI08, VI00, 0x10 ; MagSq VF12-VF14 -- Sw bit
MUL.xyz VF25, VF25, VF25 FMAND VI08, VI08
NOP DIV Q, VF23w, VF21w
NOP IBNE VI00, VI08, NegativeRatio
NOP NOP
ADDA.xyz ACC, VF00, VF14 NOP
MADDq.xyz VF16, VF15, Q WAITQ ; nearest point on infinte line
ADDq.x VF24, VF00, Q NOP ; ratio
NOP NOP
NOP NOP
SUB.xyz VF26, VF16, VF12 NOP
CLIPw.xyz VF24, VF00 NOP ; compare ratio to 1.0
NOP NOP
NOP NOP
MUL.xyz VF26, VF26, VF26 NOP
NOP FCAND VI01, 0x1
NOP IBNE VI00, VI01, RatioGreaterThanOne
NOP NOP
MULAx.w ACC, VF00, VF26 NOP
MADDAy.w ACC, VF00, VF26 NOP
MADDz.w VF16, VF00, VF26 NOP ; distance
NOP JR VI15
NOP NOP
NegativeRatio:
ADD.xyz VF16, VF00, VF14 NOP ; return line origin
MUL.w VF16, VF00, VF22 NOP ; and DistSq to it
NOP JR VI15
NOP NOP
RatioGreaterThanOne:
MULAx.w ACC, VF00, VF25 NOP
MADDAy.w ACC, VF00, VF25 NOP
MADDz.w VF16, VF00, VF25 NOP
ADD.xyz VF16, VF14, VF15 NOP ; return toerh line point
NOP JR VI15
NOP NOP
; BE0
.globl Vu0SphereToTriangleCollisionCompressedStart
Vu0SphereToTriangleCollisionCompressedStart:
ITOF0.xyzw VF17, VF17 LOI 0.000244140625 ; 1.0/4096.0
ITOF0.xyzw VF14, VF14 NOP
ITOF0.xyzw VF15, VF15 NOP
ITOF0.xyzw VF16, VF16 NOP
MULi.xyz VF17, VF17, I LOI 0.0078125 ; 1.0/128.0
MULi.w VF17, VF17, I NOP
MULi.xyzw VF14, VF14, I NOP
MULi.xyzw VF15, VF15, I NOP
MULi.xyzw VF16, VF16, I NOP
; fall through
; C28
; VF12: sphere
; VF14-16: verts
; VF17: plane
; out:
; VF01: intersection point
; VF02: triangle normal
; VF03 x: intersection parameter
.globl Vu0SphereToTriangleCollisionStart
Vu0SphereToTriangleCollisionStart:
MUL.xyz VF02, VF12, VF17 LOI 0.1
ADD.xyz VF17, VF17, VF00 NOP
ADDw.x VF13, VF00, VF12 NOP
NOP NOP
MULAx.w ACC, VF00, VF02 IADDIU VI06, VI00, 0xE0
MADDAy.w ACC, VF00, VF02 FMAND VI05, VI06 ; normal sign flags
MADDAz.w ACC, VF00, VF02 NOP
MSUB.w VF02, VF00, VF17 NOP ; center plane pos
MULi.w VF03, VF00, I MOVE.xyzw VF04, VF03
NOP NOP
NOP NOP
CLIPw.xyz VF13, VF02 NOP ; compare dist and radius
CLIPw.xyz VF17, VF03 NOP
MULAw.xyz ACC, VF12, VF00 IADDIU VI07, VI00, 0x0 ; -- clear test case
MSUBw.xyz VF01, VF17, VF02 NOP
MULx.w VF01, VF00, VF00 FCAND VI01, 0x3 ; projected center on plane
ABS.w VF02, VF02 IBEQ VI00, VI01, QuitAndFail ; no intersection
NOP NOP
NOP FCAND VI01, 0x3 ; -- check x direction
SUB.xyz VF02, VF12, VF01 IADDIU VI02, VI01, 0x7F
NOP IADDIU VI06, VI00, 0x80
SUB.xyz VF05, VF15, VF14 IAND VI02, VI02, VI06
SUB.xyz VF08, VF01, VF14 FCAND VI01, 0xC ; -- check y direction
SUB.xyz VF06, VF16, VF15 IADDIU VI03, VI01, 0x3F
SUB.xyz VF09, VF01, VF15 IADDIU VI06, VI00, 0x40
SUB.xyz VF07, VF14, VF16 IAND VI03, VI03, VI06
SUB.xyz VF10, VF01, VF16 FCAND VI01, 0x30 ; -- check z direction
MUL.xyz VF03, VF02, VF02 IADDIU VI04, VI01, 0x1F
OPMULA.xyz ACC, VF08, VF05 IADDIU VI06, VI00, 0x20
OPMSUB.xyz VF18, VF05, VF08 IAND VI04, VI04, VI06
OPMULA.xyz ACC, VF09, VF06 NOP
OPMSUB.xyz VF19, VF06, VF09 IADD VI06, VI02, VI03
OPMULA.xyz ACC, VF10, VF07 IADD VI06, VI06, VI04 ; -- combine flags
OPMSUB.xyz VF20, VF07, VF10 FMAND VI02, VI06 ; -- cross 1 flags
MULAx.w ACC, VF00, VF03 IAND VI05, VI05, VI06
MADDAy.w ACC, VF00, VF03 FMAND VI03, VI06 ; -- cross 2 flags
MADDz.w VF03, VF00, VF03 IADDIU VI08, VI00, 0x3
NOP FMAND VI04, VI06 ; -- cross 3 flags
NOP NOP
NOP IBNE VI02, VI05, CheckSide2
NOP RSQRT Q, VF00w, VF03w
ADD.xyz VF04, VF00, VF16 IADDIU VI07, VI07, 0x1 ; inside side 1
CheckSide2:
NOP IBNE VI03, VI05, CheckSide3
NOP NOP
ADD.xyz VF04, VF00, VF14 IADDIU VI07, VI07, 0x1 ; inside side 2
CheckSide3:
NOP IBNE VI04, VI05, FinishCheckingSides
NOP NOP
ADD.xyz VF04, VF00, VF15 IADDIU VI07, VI07, 0x1 ; inside side 3
NOP NOP
NOP IBEQ VI07, VI08, TotallyInsideTriangle
NOP NOP
FinishCheckingSides:
MUL.x VF13, VF13, VF13 IADDIU VI08, VI00, 0x2
MULq.xyz VF02, VF02, Q WAITQ
NOP IBNE VI07, VI08, IntersectionOutsideTwoSides
NOP NOP
NOP IBEQ VI02, VI05, CheckDistanceSide2
NOP NOP
NOP MOVE.xyzw VF15, VF05
NOP BAL VI15, DistanceBetweenSphereAndLine
NOP NOP
NOP B ProcessLineResult
NOP NOP
CheckDistanceSide2:
NOP IBEQ VI03, VI05, CheckDistanceSide3
NOP NOP
NOP MOVE.xyzw VF14, VF15
NOP MOVE.xyzw VF15, VF06
NOP BAL VI15, DistanceBetweenSphereAndLine
NOP NOP
NOP B ProcessLineResult
NOP NOP
CheckDistanceSide3:
NOP MOVE.xyzw VF14, VF16
NOP MOVE.xyzw VF15, VF07
NOP BAL VI15, DistanceBetweenSphereAndLine
NOP NOP
NOP B ProcessLineResult
NOP NOP
IntersectionOutsideTwoSides:
SUB.xyz VF05, VF04, VF12 NOP
ADD.xyz VF01, VF00, VF04 NOP ; col point
SUB.xyz VF02, VF12, VF04 NOP
NOP NOP
MUL.xyz VF05, VF05, VF05 NOP
NOP NOP
NOP NOP
NOP NOP
MULAx.w ACC, VF00, VF05 NOP
MADDAy.w ACC, VF00, VF05 NOP
MADDz.w VF05, VF00, VF05 NOP ; distSq to vertex
NOP NOP
NOP NOP
NOP NOP
CLIPw.xyz VF13, VF05 SQRT Q, VF05w ; compare radiusSq and distSq
NOP NOP
NOP NOP
NOP NOP
NOP FCAND VI01, 0x1
ADDq.x VF03, VF00, Q WAITQ ; dist to vertex
NOP IBEQ VI00, VI01, QuitAndFail ; too far
NOP NOP
NOP NOP
NOP DIV Q, VF00w, VF03x
MULq.xyz VF02, VF02, Q WAITQ ; col normal
NOP[E] NOP
NOP NOP
TotallyInsideTriangle:
ADDw.x VF03, VF00, VF02 WAITQ
MULq.xyz VF02, VF02, Q NOP
NOP[E] IADDIU VI01, VI00, 0x1
NOP NOP
ProcessLineResult:
CLIPw.xyz VF13, VF16 SQRT Q, VF16w
ADD.xyz VF01, VF00, VF16 NOP
SUB.xyz VF02, VF12, VF16 NOP
NOP NOP
NOP FCAND VI01, 0x1
ADDq.x VF03, VF00, Q WAITQ
NOP IBEQ VI00, VI01, QuitAndFail
NOP NOP
NOP NOP
NOP DIV Q, VF00w, VF03x
MULq.xyz VF02, VF02, Q WAITQ
NOP[E] NOP
NOP NOP
EndOfMicrocode:

191
src/core/vu0Collision_2.s Normal file
View file

@ -0,0 +1,191 @@
QuitAndFail2:
NOP[E] IADDIU VI01, VI00, 0x0
NOP NOP
QuitAndSucceed2:
NOP[E] IADDIU VI01, VI00, 0x1
NOP NOP
; 20
GetBBVertices:
MULw.xy VF02, VF01, VF00 NOP
MUL.z VF02, VF01, VF11 NOP
MULw.xz VF03, VF01, VF00 NOP
MUL.y VF03, VF01, VF11 NOP
MULw.x VF04, VF01, VF00 NOP
MUL.yz VF04, VF01, VF11 NOP
NOP JR VI15
NOP NOP
; 60
Vu0OBBToOBBCollision:
SUBw.xyz VF11, VF00, VF00 LOI 0.5
MULi.xyz VF12, VF12, I NOP
MULi.xyz VF13, VF13, I NOP
NOP NOP
NOP NOP
NOP MOVE.xyz VF01, VF12
NOP BAL VI15, GetBBVertices
NOP NOP
MULAx.xyz ACC, VF14, VF01 NOP
MADDAy.xyz ACC, VF15, VF01 NOP
MADDz.xyz VF01, VF16, VF01 NOP
MULAx.xyz ACC, VF14, VF02 NOP
MADDAy.xyz ACC, VF15, VF02 NOP
MADDz.xyz VF02, VF16, VF02 NOP
MULAx.xyz ACC, VF14, VF03 NOP
MADDAy.xyz ACC, VF15, VF03 NOP
MADDz.xyz VF03, VF16, VF03 NOP
MULAx.xyz ACC, VF14, VF04 NOP
MADDAy.xyz ACC, VF15, VF04 NOP
MADDz.xyz VF04, VF16, VF04 NOP
ABS.xyz VF05, VF01 NOP
ABS.xyz VF06, VF02 NOP
ABS.xyz VF07, VF03 NOP
ABS.xyz VF08, VF04 NOP
NOP NOP
MAX.xyz VF05, VF05, VF06 NOP
NOP NOP
MAX.xyz VF07, VF07, VF08 NOP
NOP NOP
NOP NOP
NOP NOP
MAX.xyz VF05, VF05, VF07 NOP
NOP NOP
NOP NOP
NOP NOP
ADD.xyz VF09, VF05, VF13 NOP
NOP NOP
NOP NOP
NOP NOP
MULx.w VF05, VF00, VF09 NOP
MULy.w VF06, VF00, VF09 NOP
MULz.w VF07, VF00, VF09 NOP
CLIPw.xyz VF17, VF05 NOP
CLIPw.xyz VF17, VF06 NOP
CLIPw.xyz VF17, VF07 MOVE.xyz VF01, VF13
NOP NOP
NOP NOP
NOP NOP
NOP FCAND VI01, 0x3330
NOP IBNE VI01, VI00, QuitAndFail2
NOP NOP
NOP BAL VI15, GetBBVertices
NOP NOP
MULAx.xyz ACC, VF18, VF01 NOP
MADDAy.xyz ACC, VF19, VF01 NOP
MADDz.xyz VF01, VF20, VF01 NOP
MULAx.xyz ACC, VF18, VF02 NOP
MADDAy.xyz ACC, VF19, VF02 NOP
MADDz.xyz VF02, VF20, VF02 NOP
MULAx.xyz ACC, VF18, VF03 NOP
MADDAy.xyz ACC, VF19, VF03 NOP
MADDz.xyz VF03, VF20, VF03 NOP
MULAx.xyz ACC, VF18, VF04 NOP
MADDAy.xyz ACC, VF19, VF04 NOP
MADDz.xyz VF04, VF20, VF04 NOP
ABS.xyz VF05, VF01 NOP
ABS.xyz VF06, VF02 NOP
ABS.xyz VF07, VF03 NOP
ABS.xyz VF08, VF04 NOP
NOP NOP
MAX.xyz VF05, VF05, VF06 NOP
NOP NOP
MAX.xyz VF07, VF07, VF08 NOP
NOP NOP
NOP NOP
NOP NOP
MAX.xyz VF05, VF05, VF07 NOP
NOP NOP
NOP NOP
NOP NOP
ADD.xyz VF09, VF05, VF12 NOP
NOP NOP
NOP NOP
NOP NOP
MULx.w VF05, VF00, VF09 NOP
MULy.w VF06, VF00, VF09 NOP
MULz.w VF07, VF00, VF09 NOP
CLIPw.xyz VF21, VF05 NOP
CLIPw.xyz VF21, VF06 NOP
CLIPw.xyz VF21, VF07 NOP
NOP NOP
NOP NOP
NOP NOP
NOP FCAND VI01, 0x3330
NOP IBNE VI01, VI00, QuitAndFail2
NOP NOP
SUB.xyz VF06, VF02, VF01 NOP
SUB.xyz VF07, VF03, VF01 NOP
ADD.xyz VF08, VF04, VF01 NOP
ADD.x VF09, VF00, VF12 NOP
ADD.yz VF09, VF00, VF00 NOP
ADD.y VF10, VF00, VF12 NOP
ADD.xz VF10, VF00, VF00 NOP
ADD.z VF11, VF00, VF12 IADDI VI04, VI00, 0x0
ADD.xy VF11, VF00, VF00 IADD VI02, VI00, VI00
OPMULA.xyz ACC, VF06, VF09 NOP
OPMSUB.xyz VF01, VF09, VF06 NOP
OPMULA.xyz ACC, VF06, VF10 NOP
OPMSUB.xyz VF02, VF10, VF06 NOP
OPMULA.xyz ACC, VF06, VF11 NOP
OPMSUB.xyz VF03, VF11, VF06 SQI.xyzw VF01, (VI02++)
OPMULA.xyz ACC, VF07, VF09 NOP
OPMSUB.xyz VF01, VF09, VF07 SQI.xyzw VF02, (VI02++)
OPMULA.xyz ACC, VF07, VF10 NOP
OPMSUB.xyz VF02, VF10, VF07 SQI.xyzw VF03, (VI02++)
OPMULA.xyz ACC, VF07, VF11 NOP
OPMSUB.xyz VF03, VF11, VF07 SQI.xyzw VF01, (VI02++)
OPMULA.xyz ACC, VF08, VF09 NOP
OPMSUB.xyz VF01, VF09, VF08 SQI.xyzw VF02, (VI02++)
OPMULA.xyz ACC, VF08, VF10 NOP
OPMSUB.xyz VF02, VF10, VF08 SQI.xyzw VF03, (VI02++)
OPMULA.xyz ACC, VF08, VF11 LOI 0.5
OPMSUB.xyz VF01, VF11, VF08 SQI.xyzw VF01, (VI02++)
MULi.xyz VF06, VF06, I NOP
MULi.xyz VF07, VF07, I SQI.xyzw VF02, (VI02++)
MULi.xyz VF08, VF08, I NOP
MUL.xyz VF02, VF21, VF01 NOP
MUL.xyz VF03, VF12, VF01 NOP
MUL.xyz VF09, VF06, VF01 NOP
MUL.xyz VF10, VF07, VF01 NOP
MUL.xyz VF11, VF08, VF01 NOP
ABS.xyz VF03, VF03 NOP
ADDy.x VF05, VF09, VF09 NOP
ADDx.y VF05, VF10, VF10 NOP
ADDx.z VF05, VF11, VF11 NOP
NOP NOP
EdgePairLoop:
ADDz.x VF05, VF05, VF09 NOP
ADDz.y VF05, VF05, VF10 NOP
ADDy.z VF05, VF05, VF11 NOP
MULAx.w ACC, VF00, VF02 IADD VI03, VI02, VI00
MADDAy.w ACC, VF00, VF02 LQD.xyzw VF01, (--VI02)
MADDz.w VF02, VF00, VF02 NOP
ABS.xyz VF05, VF05 NOP
MULAx.w ACC, VF00, VF03 NOP
MADDAy.w ACC, VF00, VF03 NOP
MADDAz.w ACC, VF00, VF03 NOP
MADDAx.w ACC, VF00, VF05 NOP
MADDAy.w ACC, VF00, VF05 NOP
MADDz.w VF03, VF00, VF05 NOP
ADDw.x VF04, VF00, VF02 NOP
MUL.xyz VF02, VF21, VF01 NOP
MUL.xyz VF03, VF12, VF01 NOP
MUL.xyz VF09, VF06, VF01 NOP
CLIPw.xyz VF04, VF03 NOP
MUL.xyz VF10, VF07, VF01 NOP
MUL.xyz VF11, VF08, VF01 NOP
ABS.xyz VF03, VF03 NOP
ADDy.x VF05, VF09, VF09 FCAND VI01, 0x3
ADDx.y VF05, VF10, VF10 IBNE VI01, VI00, QuitAndFail2
ADDx.z VF05, VF11, VF11 NOP
NOP IBNE VI03, VI00, EdgePairLoop
NOP NOP
NOP[E] IADDIU VI01, VI00, 0x1
NOP NOP
EndOfMicrocode2:

View file

@ -90,6 +90,7 @@ public:
m_matrix.pos.z += rhs.m_matrix.pos.z;
return *this;
}
CMatrix& operator*=(CMatrix const &rhs);
const CVector &GetPosition(void) const { return *(CVector*)&m_matrix.pos; }
CVector& GetPosition(void) { return *(CVector*)&m_matrix.pos; }

41
src/math/VuVector.h Normal file
View file

@ -0,0 +1,41 @@
#pragma once
class TYPEALIGN(16) CVuVector : public CVector
{
public:
float w;
CVuVector(void) {}
CVuVector(float x, float y, float z) : CVector(x, y, z) {}
CVuVector(float x, float y, float z, float w) : CVector(x, y, z), w(w) {}
CVuVector(const CVector &v) : CVector(v.x, v.y, v.z) {}
#ifdef RWCORE_H
CVuVector(const RwV3d &v) : CVector(v.x, v.y, v.z) {}
operator RwV3d (void) const {
RwV3d vecRw = { this->x, this->y, this->z };
return vecRw;
}
operator RwV3d *(void) {
return (RwV3d*)this;
}
#endif
/*
void Normalise(void) {
float sq = MagnitudeSqr();
// TODO: VU0 code
if(sq > 0.0f){
float invsqrt = RecipSqrt(sq);
x *= invsqrt;
y *= invsqrt;
z *= invsqrt;
}else
x = 1.0f;
}
*/
};
void TransformPoint(CVuVector &out, const CMatrix &mat, const CVuVector &in);
void TransformPoint(CVuVector &out, const CMatrix &mat, const RwV3d &in);
void TransformPoints(CVuVector *out, int n, const CMatrix &mat, const RwV3d *in, int stride);
void TransformPoints(CVuVector *out, int n, const CMatrix &mat, const CVuVector *in);

View file

@ -1,9 +1,124 @@
#include "common.h"
#include "Quaternion.h"
#include "VuVector.h"
// TODO: move more stuff into here
void TransformPoint(CVuVector &out, const CMatrix &mat, const CVuVector &in)
{
#ifdef GTA_PS2
__asm__ __volatile__("\n\
lqc2 vf01,0x0(%2)\n\
lqc2 vf02,0x0(%1)\n\
lqc2 vf03,0x10(%1)\n\
lqc2 vf04,0x20(%1)\n\
lqc2 vf05,0x30(%1)\n\
vmulax.xyz ACC, vf02,vf01\n\
vmadday.xyz ACC, vf03,vf01\n\
vmaddaz.xyz ACC, vf04,vf01\n\
vmaddw.xyz vf06,vf05,vf00\n\
sqc2 vf06,0x0(%0)\n\
": : "r" (&out) , "r" (&mat) ,"r" (&in): "memory");
#else
out = mat * in;
#endif
}
void TransformPoint(CVuVector &out, const CMatrix &mat, const RwV3d &in)
{
#ifdef GTA_PS2
__asm__ __volatile__("\n\
ldr $8,0x0(%2)\n\
ldl $8,0x7(%2)\n\
lw $9,0x8(%2)\n\
pcpyld $10,$9,$8\n\
qmtc2 $10,vf01\n\
lqc2 vf02,0x0(%1)\n\
lqc2 vf03,0x10(%1)\n\
lqc2 vf04,0x20(%1)\n\
lqc2 vf05,0x30(%1)\n\
vmulax.xyz ACC, vf02,vf01\n\
vmadday.xyz ACC, vf03,vf01\n\
vmaddaz.xyz ACC, vf04,vf01\n\
vmaddw.xyz vf06,vf05,vf00\n\
sqc2 vf06,0x0(%0)\n\
": : "r" (&out) , "r" (&mat) ,"r" (&in): "memory");
#else
out = mat * in;
#endif
}
void TransformPoints(CVuVector *out, int n, const CMatrix &mat, const RwV3d *in, int stride)
{
#ifdef GTA_PS3
__asm__ __volatile__("\n\
paddub $3,%4,$0\n\
lqc2 vf02,0x0(%2)\n\
lqc2 vf03,0x10(%2)\n\
lqc2 vf04,0x20(%2)\n\
lqc2 vf05,0x30(%2)\n\
ldr $8,0x0(%3)\n\
ldl $8,0x7(%3)\n\
lw $9,0x8(%3)\n\
pcpyld $10,$9,$8\n\
qmtc2 $10,vf01\n\
1: vmulax.xyz ACC, vf02,vf01\n\
vmadday.xyz ACC, vf03,vf01\n\
vmaddaz.xyz ACC, vf04,vf01\n\
vmaddw.xyz vf06,vf05,vf00\n\
add %3,%3,$3\n\
ldr $8,0x0(%3)\n\
ldl $8,0x7(%3)\n\
lw $9,0x8(%3)\n\
pcpyld $10,$9,$8\n\
qmtc2 $10,vf01\n\
addi %1,%1,-1\n\
addiu %0,%0,0x10\n\
sqc2 vf06,-0x10(%0)\n\
bnez %1,1b\n\
": : "r" (out) , "r" (n), "r" (&mat), "r" (in), "r" (stride): "memory");
#else
while(n--){
*out = mat * *in;
in = (RwV3d*)((uint8*)in + stride);
out++;
}
#endif
}
void TransformPoints(CVuVector *out, int n, const CMatrix &mat, const CVuVector *in)
{
#ifdef GTA_PS2
__asm__ __volatile__("\n\
lqc2 vf02,0x0(%2)\n\
lqc2 vf03,0x10(%2)\n\
lqc2 vf04,0x20(%2)\n\
lqc2 vf05,0x30(%2)\n\
lqc2 vf01,0x0(%3)\n\
nop\n\
1: vmulax.xyz ACC, vf02,vf01\n\
vmadday.xyz ACC, vf03,vf01\n\
vmaddaz.xyz ACC, vf04,vf01\n\
vmaddw.xyz vf06,vf05,vf00\n\
lqc2 vf01,0x10(%3)\n\
addiu %3,%3,0x10\n\
addi %1,%1,-1\n\
addiu %0,%0,0x10\n\
sqc2 vf06,-0x10(%0)\n\
bnez %1,1b\n\
": : "r" (out) , "r" (n), "r" (&mat) ,"r" (in): "memory");
#else
while(n--){
*out = mat * *in;
in++;
out++;
}
#endif
}
void
CMatrix::SetRotate(float xAngle, float yAngle, float zAngle)
{
@ -74,6 +189,7 @@ CMatrix::Reorthogonalise(void)
CMatrix&
Invert(const CMatrix &src, CMatrix &dst)
{
// TODO: VU0 code
// GTA handles this as a raw 4x4 orthonormal matrix
// and trashes the RW flags, let's not do that
// actual copy of librw code:
@ -104,6 +220,7 @@ Invert(const CMatrix &src, CMatrix &dst)
CVector
operator*(const CMatrix &mat, const CVector &vec)
{
// TODO: VU0 code
return CVector(
mat.m_matrix.right.x * vec.x + mat.m_matrix.up.x * vec.y + mat.m_matrix.at.x * vec.z + mat.m_matrix.pos.x,
mat.m_matrix.right.y * vec.x + mat.m_matrix.up.y * vec.y + mat.m_matrix.at.y * vec.z + mat.m_matrix.pos.y,
@ -113,6 +230,7 @@ operator*(const CMatrix &mat, const CVector &vec)
CMatrix
operator*(const CMatrix &m1, const CMatrix &m2)
{
// TODO: VU0 code
CMatrix out;
RwMatrix *dst = &out.m_matrix;
const RwMatrix *src1 = &m1.m_matrix;
@ -132,9 +250,18 @@ operator*(const CMatrix &m1, const CMatrix &m2)
return out;
}
CMatrix&
CMatrix::operator*=(CMatrix const &rhs)
{
// TODO: VU0 code
*this = *this * rhs;
return *this;
}
const CVector
Multiply3x3(const CMatrix &mat, const CVector &vec)
{
// TODO: VU0 code
return CVector(
mat.m_matrix.right.x * vec.x + mat.m_matrix.up.x * vec.y + mat.m_matrix.at.x * vec.z,
mat.m_matrix.right.y * vec.x + mat.m_matrix.up.y * vec.y + mat.m_matrix.at.y * vec.z,
@ -166,6 +293,7 @@ CQuaternion::Slerp(const CQuaternion &q1, const CQuaternion &q2, float theta, fl
w1 = Sin((1.0f - t) * theta) * invSin;
w2 = Sin(t * theta) * invSin;
}
// TODO: VU0 code
*this = w1*q1 + w2*q2;
}
}

View file

@ -1004,7 +1004,11 @@ CPopulation::ManagePopulation(void)
}
int pedPoolSize = CPools::GetPedPool()->GetSize();
#ifndef SQUEEZE_PERFORMANCE
for (int poolIndex = pedPoolSize-1; poolIndex >= 0; poolIndex--) {
#else
for (int poolIndex = (pedPoolSize * (frameMod32 + 1) / 32) - 1; poolIndex >= pedPoolSize * frameMod32 / 32; poolIndex--) {
#endif
CPed *ped = CPools::GetPedPool()->GetSlot(poolIndex);
if (ped && !ped->IsPlayer() && ped->CanBeDeleted() && !ped->bInVehicle) {

View file

@ -74,8 +74,12 @@ CRenderer::PreRender(void)
for(i = 0; i < ms_nNoOfVisibleEntities; i++)
ms_aVisibleEntityPtrs[i]->PreRender();
for(i = 0; i < ms_nNoOfInVisibleEntities; i++)
for (i = 0; i < ms_nNoOfInVisibleEntities; i++) {
#ifdef SQUEEZE_PERFORMANCE
if (ms_aInVisibleEntityPtrs[i]->IsVehicle() && ((CVehicle*)ms_aInVisibleEntityPtrs[i])->IsHeli())
#endif
ms_aInVisibleEntityPtrs[i]->PreRender();
}
for(node = CVisibilityPlugins::m_alphaEntityList.head.next;
node != &CVisibilityPlugins::m_alphaEntityList.tail;

View file

@ -4,7 +4,11 @@ class CVehicle;
enum {
// NB: not all values are allowed, check the code
#ifdef SQUEEZE_PERFORMANCE
NUM_RUBBISH_SHEETS = 32
#else
NUM_RUBBISH_SHEETS = 64
#endif
};
class COneSheet

View file

@ -1585,7 +1585,9 @@ CShadows::CastShadowEntityXY(CEntity *pEntity, float fStartX, float fStartY, fl
CColTrianglePlane *pColTriPlanes = pCol->trianglePlanes;
ASSERT(pColTriPlanes != nil);
if ( Abs(pColTriPlanes[i].normal.z) > 0.1f )
CVector normal;
pColTriPlanes[i].GetNormal(normal);
if ( Abs(normal.z) > 0.1f )
{
CColTriangle *pColTri = pCol->triangles;
ASSERT(pColTri != nil);

View file

@ -24,6 +24,10 @@
#include "World.h"
#include "SurfaceTable.h"
#ifdef SQUEEZE_PERFORMANCE
uint32 bulletInfoInUse;
#endif
#define BULLET_LIFETIME (1000)
#define NUM_PED_BLOOD_PARTICLES (8)
#define BLOOD_PARTICLE_OFFSET (CVector(0.0f, 0.0f, 0.0f))
@ -47,6 +51,9 @@ void CBulletInfo::Initialise(void)
gaBulletInfo[i].m_pSource = nil;
}
debug("CBulletInfo ready\n");
#ifdef SQUEEZE_PERFORMANCE
bulletInfoInUse = 0;
#endif
}
void CBulletInfo::Shutdown(void)
@ -71,11 +78,19 @@ bool CBulletInfo::AddBullet(CEntity* pSource, eWeaponType type, CVector vecPosit
gaBulletInfo[i].m_vecSpeed = vecSpeed;
gaBulletInfo[i].m_fTimer = CTimer::GetTimeInMilliseconds() + BULLET_LIFETIME;
gaBulletInfo[i].m_bInUse = true;
#ifdef SQUEEZE_PERFORMANCE
bulletInfoInUse++;
#endif
return true;
}
void CBulletInfo::Update(void)
{
#ifdef SQUEEZE_PERFORMANCE
if (bulletInfoInUse == 0)
return;
#endif
bPlayerSniperBullet = false;
for (int i = 0; i < NUM_BULLETS; i++) {
CBulletInfo* pBullet = &gaBulletInfo[i];
@ -83,8 +98,12 @@ void CBulletInfo::Update(void)
pBullet->m_pSource = nil;
if (!pBullet->m_bInUse)
continue;
if (CTimer::GetTimeInMilliseconds() > pBullet->m_fTimer)
if (CTimer::GetTimeInMilliseconds() > pBullet->m_fTimer) {
pBullet->m_bInUse = false;
#ifdef SQUEEZE_PERFORMANCE
bulletInfoInUse--;
#endif
}
CVector vecOldPos = pBullet->m_vecPosition;
CVector vecNewPos = pBullet->m_vecPosition + pBullet->m_vecSpeed * CTimer::GetTimeStep() * 0.5f;
CWorld::bIncludeCarTyres = true;
@ -108,6 +127,9 @@ void CBulletInfo::Update(void)
pPed->InflictDamage(pBullet->m_pSource, pBullet->m_eWeaponType, pBullet->m_nDamage, (ePedPieceTypes)point.pieceB, pPed->GetLocalDirection(pPed->GetPosition() - point.point));
CEventList::RegisterEvent(pPed->m_nPedType == PEDTYPE_COP ? EVENT_SHOOT_COP : EVENT_SHOOT_PED, EVENT_ENTITY_PED, pPed, (CPed*)pBullet->m_pSource, 1000);
pBullet->m_bInUse = false;
#ifdef SQUEEZE_PERFORMANCE
bulletInfoInUse--;
#endif
vecNewPos = point.point;
}
if (CGame::nastyGame) {
@ -130,6 +152,9 @@ void CBulletInfo::Update(void)
}
}
pBullet->m_bInUse = false;
#ifdef SQUEEZE_PERFORMANCE
bulletInfoInUse--;
#endif
vecNewPos = point.point;
}
}
@ -144,6 +169,9 @@ void CBulletInfo::Update(void)
}
#ifdef FIX_BUGS
pBullet->m_bInUse = false;
#ifdef SQUEEZE_PERFORMANCE
bulletInfoInUse--;
#endif
vecNewPos = point.point;
#endif
}
@ -163,6 +191,9 @@ void CBulletInfo::Update(void)
}
#ifdef FIX_BUGS
pBullet->m_bInUse = false;
#ifdef SQUEEZE_PERFORMANCE
bulletInfoInUse--;
#endif
vecNewPos = point.point;
#endif
}
@ -213,8 +244,12 @@ void CBulletInfo::Update(void)
}
pBullet->m_vecPosition = vecNewPos;
if (pBullet->m_vecPosition.x < -MAP_BORDER || pBullet->m_vecPosition.x > MAP_BORDER ||
pBullet->m_vecPosition.y < -MAP_BORDER || pBullet->m_vecPosition.y > MAP_BORDER)
pBullet->m_vecPosition.y < -MAP_BORDER || pBullet->m_vecPosition.y > MAP_BORDER) {
pBullet->m_bInUse = false;
#ifdef SQUEEZE_PERFORMANCE
bulletInfoInUse--;
#endif
}
}
}

View file

@ -13,6 +13,10 @@
#include "Weapon.h"
#include "World.h"
#ifdef SQUEEZE_PERFORMANCE
uint32 projectileInUse;
#endif
CProjectileInfo gaProjectileInfo[NUM_PROJECTILES];
CProjectile *CProjectileInfo::ms_apProjectile[NUM_PROJECTILES];
@ -30,6 +34,10 @@ CProjectileInfo::Initialise()
}
debug("CProjectileInfo ready\n");
#ifdef SQUEEZE_PERFORMANCE
projectileInUse = 0;
#endif
}
void
@ -163,6 +171,10 @@ CProjectileInfo::AddProjectile(CEntity *entity, eWeaponType weapon, CVector pos,
ms_apProjectile[i]->m_fElasticity = elasticity;
ms_apProjectile[i]->m_nSpecialCollisionResponseCases = SpecialCollisionResponseCase;
#ifdef SQUEEZE_PERFORMANCE
projectileInUse++;
#endif
gaProjectileInfo[i].m_bInUse = true;
CWorld::Add(ms_apProjectile[i]);
@ -178,6 +190,9 @@ void
CProjectileInfo::RemoveProjectile(CProjectileInfo *info, CProjectile *projectile)
{
RemoveNotAdd(info->m_pSource, info->m_eWeaponType, projectile->GetPosition());
#ifdef SQUEEZE_PERFORMANCE
projectileInUse--;
#endif
info->m_bInUse = false;
CWorld::Remove(projectile);
@ -205,6 +220,11 @@ CProjectileInfo::RemoveNotAdd(CEntity *entity, eWeaponType weaponType, CVector p
void
CProjectileInfo::Update()
{
#ifdef SQUEEZE_PERFORMANCE
if (projectileInUse == 0)
return;
#endif
for (int i = 0; i < ARRAY_SIZE(gaProjectileInfo); i++) {
if (!gaProjectileInfo[i].m_bInUse) continue;
@ -213,6 +233,10 @@ CProjectileInfo::Update()
gaProjectileInfo[i].m_pSource = nil;
if (ms_apProjectile[i] == nil) {
#ifdef SQUEEZE_PERFORMANCE
projectileInUse--;
#endif
gaProjectileInfo[i].m_bInUse = false;
continue;
}
@ -276,6 +300,10 @@ CProjectileInfo::IsProjectileInRange(float x1, float x2, float y1, float y2, flo
if (pos.x >= x1 && pos.x <= x2 && pos.y >= y1 && pos.y <= y2 && pos.z >= z1 && pos.z <= z2) {
result = true;
if (remove) {
#ifdef SQUEEZE_PERFORMANCE
projectileInUse--;
#endif
gaProjectileInfo[i].m_bInUse = false;
CWorld::Remove(ms_apProjectile[i]);
delete ms_apProjectile[i];
@ -304,8 +332,17 @@ CProjectileInfo::RemoveDetonatorProjectiles()
void
CProjectileInfo::RemoveAllProjectiles()
{
#ifdef SQUEEZE_PERFORMANCE
if (projectileInUse == 0)
return;
#endif
for (int i = 0; i < ARRAY_SIZE(ms_apProjectile); i++) {
if (gaProjectileInfo[i].m_bInUse) {
#ifdef SQUEEZE_PERFORMANCE
projectileInUse--;
#endif
gaProjectileInfo[i].m_bInUse = false;
CWorld::Remove(ms_apProjectile[i]);
delete ms_apProjectile[i];
@ -316,12 +353,21 @@ CProjectileInfo::RemoveAllProjectiles()
bool
CProjectileInfo::RemoveIfThisIsAProjectile(CObject *object)
{
#ifdef SQUEEZE_PERFORMANCE
if (projectileInUse == 0)
return false;
#endif
int i = 0;
while (ms_apProjectile[i++] != object) {
if (i >= ARRAY_SIZE(ms_apProjectile))
return false;
}
#ifdef SQUEEZE_PERFORMANCE
projectileInUse--;
#endif
gaProjectileInfo[i].m_bInUse = false;
CWorld::Remove(ms_apProjectile[i]);
delete ms_apProjectile[i];

View file

@ -13,6 +13,9 @@
CShotInfo gaShotInfo[NUMSHOTINFOS];
float CShotInfo::ms_afRandTable[20];
#ifdef SQUEEZE_PERFORMANCE
uint32 shotInfoInUse;
#endif
/*
Used for flamethrower. I don't know why it's name is CShotInfo.
@ -41,6 +44,9 @@ CShotInfo::Initialise()
nextVal += 0.005f;
}
debug("CShotInfo ready\n");
#ifdef SQUEEZE_PERFORMANCE
shotInfoInUse = 0;
#endif
}
bool
@ -54,6 +60,10 @@ CShotInfo::AddShot(CEntity *sourceEntity, eWeaponType weapon, CVector startPos,
if (slot == ARRAY_SIZE(gaShotInfo))
return false;
#ifdef SQUEEZE_PERFORMANCE
shotInfoInUse++;
#endif
gaShotInfo[slot].m_inUse = true;
gaShotInfo[slot].m_weapon = weapon;
gaShotInfo[slot].m_startPos = startPos;
@ -87,6 +97,10 @@ CShotInfo::Shutdown()
void
CShotInfo::Update()
{
#ifdef SQUEEZE_PERFORMANCE
if (shotInfoInUse == 0)
return;
#endif
for (int slot = 0; slot < ARRAY_SIZE(gaShotInfo); slot++) {
CShotInfo &shot = gaShotInfo[slot];
if (shot.m_sourceEntity && shot.m_sourceEntity->IsPed() && !((CPed*)shot.m_sourceEntity)->IsPointerValid())
@ -96,8 +110,12 @@ CShotInfo::Update()
continue;
CWeaponInfo *weaponInfo = CWeaponInfo::GetWeaponInfo(shot.m_weapon);
if (CTimer::GetTimeInMilliseconds() > shot.m_timeout)
if (CTimer::GetTimeInMilliseconds() > shot.m_timeout) {
#ifdef SQUEEZE_PERFORMANCE
shotInfoInUse--;
#endif
shot.m_inUse = false;
}
if (weaponInfo->m_bSlowsDown)
shot.m_areaAffected *= pow(0.96, CTimer::GetTimeStep()); // FRAMERATE