Compare commits

...

13 Commits

Author SHA1 Message Date
Josh Pearson
282b639a4c Fog Parameters Updated
Hook timecycle to get fog start value.  This is then converted into a density value (based on known range) to produce a nicer fog cutoff value using EXP fog instead of linear table mode.
2025-01-29 15:58:40 -07:00
Stefanos Kornilios Mitsis Poiitidis
69f9bbcf7b Merge branch 'skmp/fix-audio-sample-calculations' into 'main'
audio: Do sample <-> milisecond in 64 bit precision, as intermediate steps might overflow int32

See merge request skmp/dca3-game!19
2025-01-26 14:43:07 +00:00
Stefanos Kornilios Mitsis Poiitidis
40f212e131 audio: Do sample <-> milisecond in 64 bit precision, as intermediate steps might overflow int32 2025-01-26 15:36:43 +01:00
Stefanos Kornilios Mitsis Poiitidis
43c0e99ebf Merge branch 'skmp/fix-dam-flamethrower' into 'main'
Fix Dynamic Acoustic Modelling: off & Flamethrower SFX

See merge request skmp/dca3-game!18
2025-01-26 13:55:55 +00:00
Stefanos Kornilios Mitsis Poiitidis
42647ddc6b Fix Dynamic Acoustic Modelling: off & Flamethrower SFX 2025-01-26 14:44:29 +01:00
Stefanos Kornilios Mitsis Poiitidis
b3ccf1f900 Merge branch 'ph3nom/fix-throwing-controls' into 'main'
Fix Throwing Grenade and Moltov Coctail Controls

See merge request skmp/dca3-game!17
2025-01-25 10:50:26 +00:00
Josh Pearson
baf7612fcf Fix Throwing Grenade and Moltov Coctail Controls 2025-01-24 17:08:55 -07:00
Stefanos Kornilios Mitsis Poiitidis
33b9dd1c8a Merge branch 'skmp/protect-from-zero-delta-times' into 'main'
CAnimBlendNode::GetCurrentTranslation: Protect against zero delta times

See merge request skmp/dca3-game!15
2025-01-16 06:13:03 +00:00
Stefanos Kornilios Mitsis Poiitidis
5786eeecb8 Merge branch 'falco/fuck_da_fences' into 'main'
Fixed the goddamn fences.

See merge request skmp/dca3-game!14
2025-01-16 06:11:54 +00:00
Stefanos Kornilios Mitsis Poiitidis
20864fdac6 Merge branch '49-game-crash-when-entering-parking-garage-on-staunton-island' into 'main'
Resolve "Parking garage crash fix"

See merge request skmp/dca3-game!16
2025-01-16 06:09:08 +00:00
mark wallace
1587d707a8 Parking garage bug fix. 2025-01-16 04:11:34 +00:00
Stefanos Kornilios Mitsis Poiitidis
911b93bd0f CAnimBlendNode::GetCurrentTranslation: Protect against zero delta times 2025-01-14 23:18:24 +02:00
Falco Girgis
e86fb27a48 Fixed the goddamn fences.
Colliding with and/or brushing against the metal chain-linked fences in
the game caused severe performance degredation as the SH4 struggled to
keep up with the physics.

The PSVita REGTA3 port also struggled, somehow, with its bazillion times
faster CPU. The PS2 version has no fences. The Xbox version implemented
an interesting compromise, where fences could be collided with and
knocked over, but individual links did not interact with one-another,
only with the car.

So that's what I've essentially done here. Intersection testing is still
happening between all of the previous CPhysical entities in question
(player vs fences vs fences); however, the contact resolution for fence vs
fence collisions is now being essentially canceled.

Apparently that's all that was needed, as you can now mow down long-ass
fences with no performance impact and a response that looks like what
the Xbox does.
2025-01-12 00:29:42 -06:00
9 changed files with 51 additions and 15 deletions

View File

@@ -140,7 +140,7 @@ CAnimBlendNode::GetCurrentTranslation(CVector &trans, float weight)
float blend = association->GetBlendAmount(weight);
if(blend > 0.0f){
auto kfAdt = sequence->GetDeltaTime(frameA);
float t = (kfAdt - remainingTime)/kfAdt;
float t = kfAdt == 0.0f ? 0.0f : (kfAdt - remainingTime)/kfAdt;
if(sequence->type & CAnimBlendSequence::KF_TRANS){
auto kfAt = sequence->GetTranslation(frameA);
auto kfBt = sequence->GetTranslation(frameB);

View File

@@ -3789,6 +3789,10 @@ cAudioManager::ProcessPedOneShots(cPedParams &params)
if (iSound > 60)
iSound = 21;
}
// In some cases the left and right channels have different loop points
// This looks like a data file issue where the left and right channels have different loop points
// This is a hot fix to always have the correct loop point for each channel individually
SET_LOOP_OFFSETS(m_sQueueSample.m_nSampleIndex)
AddSampleToRequestedQueue();
}
}

View File

@@ -1132,7 +1132,8 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream)
debugf("StartStreamedFile(%d, %d, %d)\n", nFile, nPos, nStream);
uint32_t seek_aligned = 0;
if (nPos) {
uint32 seek_bytes = nPos * streams[nStream].rate / (streams[nStream].stereo ? 1000: 2000);
uint64_t seek_bytes = (uint64_t)nPos * streams[nStream].rate / (streams[nStream].stereo ? 1000: 2000);
assert(seek_bytes <= INT32_MAX);
seek_aligned = seek_bytes & ~(streams[nStream].stereo ? (STREAM_STAGING_READ_SIZE_STEREO-1) : (STREAM_STAGING_READ_SIZE_MONO-1));
}
PreloadStreamedFile(nFile, nStream, seek_aligned);
@@ -1164,7 +1165,9 @@ cSampleManager::GetStreamedFilePosition(uint8 nStream)
ASSERT( nStream < MAX_STREAMS );
int32 rv = 0;
return streams[nStream].played_samples * 1000 / streams[nStream].rate;
int64_t rv64 = (int64_t)streams[nStream].played_samples * 1000 / streams[nStream].rate;
assert(rv64 <= INT32_MAX);
rv = (int32)rv64;
// if(streams[nStream].fd >= 0) {
// rv = fs_tell(streams[nStream].fd);
// }
@@ -1207,7 +1210,10 @@ cSampleManager::GetStreamedFileLength(uint8 nFile)
WavHeader hdr;
assert(fs_read(fd, &hdr, sizeof(hdr)) == sizeof(hdr));
rv = hdr.dataSize * 2000 / hdr.numOfChan / hdr.samplesPerSec;
uint64_t rv64 = (uint64_t)hdr.dataSize * 2000 / hdr.numOfChan / hdr.samplesPerSec;
assert(rv64 <= INT32_MAX);
rv = (int32)rv64;
fs_close(fd);

View File

@@ -1721,8 +1721,8 @@ int8 CRunningScript::ProcessCommands900To999(int32 command)
return 0;
int attempts;
int model = -1;
int index = CGeneral::GetRandomNumberInRange(0, 50);
for (attempts = 0; attempts < 50; attempts++) {
int index = CGeneral::GetRandomNumberInRange(0, MAXVEHICLESLOADED);
for (attempts = 0; attempts < MAXVEHICLESLOADED; attempts++) {
if (model != -1)
break;
model = CStreaming::ms_vehiclesLoaded[index];

View File

@@ -2785,22 +2785,22 @@ bool CPad::WeaponJustDown(void)
case 0: //Xbox Mode
if (CPad::GetPad(0)->IsDualAnalog)
{
if (NewState.RightTrigger > 128)
if (NewState.RightTrigger > 128 && !(OldState.RightTrigger > 128))
return true;
}
else
{
if (NewState.RightTrigger > 128)
if (NewState.RightTrigger > 128 && !(OldState.RightTrigger > 128))
return true;
}
case 1: //PS2 Mode
if (CPad::GetPad(0)->IsDualAnalog)
{
return NewState.B;
return NewState.B && !OldState.B;
}
else
{
return NewState.B;
return NewState.B && !OldState.B;
}
}

View File

@@ -83,6 +83,11 @@ CEntity::~CEntity(void)
ResolveReferences();
}
bool
CEntity::IsFence(void) {
return IsObject() && ::IsFence(static_cast<CObject *>(this)->GetModelIndex());
}
void
CEntity::SetModelIndex(uint32 id)
{

View File

@@ -131,6 +131,7 @@ public:
bool IsPed(void) { return m_type == ENTITY_TYPE_PED; }
bool IsObject(void) { return m_type == ENTITY_TYPE_OBJECT; }
bool IsDummy(void) { return m_type == ENTITY_TYPE_DUMMY; }
bool IsFence(void);
RpAtomic *GetAtomic(void) {
assert(RwObjectGetType(m_rwObject) == rpATOMIC);

View File

@@ -59,7 +59,7 @@ CPhysical::CPhysical(void)
bInfiniteMass = false;
bIsInWater = false;
bHitByTrain = false;
bSkipLineCol = false;
bSkipLineCol = IsFence();
m_fDistanceTravelled = 0.0f;
m_treadable[PATH_CAR] = nil;
@@ -1461,6 +1461,10 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
skipCollision = false;
altcollision = false;
if(A->IsFence() && B->IsFence()) {
skipCollision = true;
A->bSkipLineCol = true;
}
if(B->IsBuilding())
skipCollision = false;
else if(IsStreetLight(A->GetModelIndex()) &&
@@ -1922,12 +1926,12 @@ CPhysical::ProcessCollision(void)
n = NUMSTEPS(0.09f);
step = savedTimeStep / n;
}
}else if(responsecase == COLLRESPONSE_SMALLBOX || responsecase == COLLRESPONSE_FENCEPART){
}else if(responsecase == COLLRESPONSE_SMALLBOX){
if(distSq >= sq(0.15f)){
n = NUMSTEPS(0.15f);
step = savedTimeStep / n;
}
}else{
}else if(responsecase != COLLRESPONSE_FENCEPART){
if(distSq >= sq(0.3f)){
n = NUMSTEPS(0.3f);
step = savedTimeStep / n;

View File

@@ -174,6 +174,7 @@ static pvr_dr_state_t drState;
#include <kos/dbglog.h>
#if !defined(DC_TEXCONV) && !defined(DC_SIM)
#include "Timecycle.h"
#include <kos.h>
#define VIDEO_MODE_WIDTH vid_mode->width
@@ -305,6 +306,7 @@ void rw_mat_load_4x4(rw::Matrix* mtx) {
#define mat_identity(a)
#define pvr_fog_table_color(a,r,g,b)
#define pvr_fog_table_linear(s,e)
#define pvr_fog_table_exp(d)
#endif
#define mat_trans_single3_nomod(x_, y_, z_, x2, y2, z2) do { \
@@ -1098,6 +1100,7 @@ static bool doAlphaTest;
static uint8_t fogFuncPvr = PVR_FOG_DISABLE;
static uint32_t fogColor = 0;
static float fogStart = 0.0f;
static uint32 cullModePvr;
static inline unsigned pvrCullMode(uint32_t cullMode) {
@@ -1198,8 +1201,9 @@ setRenderState(int32 state, void *pvalue)
fogFuncPvr = value ? PVR_FOG_TABLE : PVR_FOG_DISABLE;
break;
case FOGCOLOR:
#if !defined(DC_TEXCONV)
// Set fog color when state changes
if(fogColor != value) {
if(fogColor != value || fogStart != CTimeCycle::GetFogStart()) {
fogColor = value;
RGBA c;
c.red = value;
@@ -1207,9 +1211,21 @@ setRenderState(int32 state, void *pvalue)
c.blue = value>>16;
c.alpha = value>>24;
pvr_fog_table_color(c.alpha / 255.0f, c.red / 255.0f, c.green / 255.0f, c.blue / 255.0f);
pvr_fog_table_linear(50.0f, 450.0f);
fogStart = CTimeCycle::GetFogStart();
//pvr_fog_table_linear(fogStart + 200.0f, fogStart + 450.0f);
// Fog ranges between -200 (Most Fog) and +100 (least fog) (these are loaded from TIMECYC.DAT)
// This formula will transform these values into a density between 0 and 0.02f
const float MAX_DENSITY = 0.02f;
const float FOG_RANGE = 300.0f;
const float FOG_OFFSET = 200.0f;
float density = ((FOG_RANGE - (fogStart + FOG_OFFSET)) / FOG_RANGE) * MAX_DENSITY;
pvr_fog_table_exp(density);
}
#endif
break;
// case CULLMODE:
// if(rwStateCache.cullmode != value){
// rwStateCache.cullmode = value;