summaryrefslogtreecommitdiffstats
path: root/src/rw/RwHelper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/rw/RwHelper.cpp')
-rw-r--r--src/rw/RwHelper.cpp52
1 files changed, 48 insertions, 4 deletions
diff --git a/src/rw/RwHelper.cpp b/src/rw/RwHelper.cpp
index 191fc7ab..f568532a 100644
--- a/src/rw/RwHelper.cpp
+++ b/src/rw/RwHelper.cpp
@@ -11,7 +11,11 @@
RtCharset *debugCharset;
#endif
-bool gPS2alphaTest = 1;
+#ifdef PS2_ALPHA_TEST
+bool gPS2alphaTest = true;
+#else
+bool gPS2alphaTest = false;
+#endif
#ifndef FINAL
static bool charsetOpen;
@@ -202,7 +206,7 @@ isSkinnedCb(RpAtomic *atomic, void *data)
RpAtomic **pAtomic = (RpAtomic**)data;
if(*pAtomic)
return nil; // already found one
- if(RpSkinGeometryGetSkin(atomic->geometry))
+ if(RpSkinGeometryGetSkin(RpAtomicGetGeometry(atomic)))
*pAtomic = atomic; // we could just return nil here directly...
return atomic;
}
@@ -319,14 +323,20 @@ HAnimAnimationCreateForHierarchy(RpHAnimHierarchy *hier)
RpHAnimAnimation *anim = RpHAnimAnimationCreate(rpHANIMSTDKEYFRAMETYPEID, numNodes, 0, 0.0f);
if(anim == nil)
return nil;
- RpHAnimStdKeyFrame *frame = (RpHAnimStdKeyFrame*)HANIMFRAMES(anim);
+ RpHAnimStdKeyFrame *frame;
for(i = 0; i < numNodes; i++){
+ frame = (RpHAnimStdKeyFrame*)HANIMFRAME(anim, i); // games uses struct size here, not safe
frame->q.real = 1.0f;
frame->q.imag.x = frame->q.imag.y = frame->q.imag.z = 0.0f;
frame->t.x = frame->t.y = frame->t.z = 0.0f;
+#ifdef FIX_BUGS
+ // times are subtracted and divided giving NaNs
+ // so they can't both be 0
+ frame->time = i/hier->numNodes;
+#else
frame->time = 0.0f;
+#endif
frame->prevFrame = nil;
- frame++;
}
return anim;
}
@@ -605,3 +615,37 @@ CameraCreate(RwInt32 width, RwInt32 height, RwBool zBuffer)
WRAPPER void _TexturePoolsInitialise() { EAXJMP(0x598B10); }
WRAPPER void _TexturePoolsShutdown() { EAXJMP(0x598B30); }
#endif
+
+#if defined(FIX_BUGS) && defined(GTA_PC)
+RwUInt32 saved_alphafunc, saved_alpharef;
+
+void
+SetAlphaTest(RwUInt32 alpharef)
+{
+#ifdef LIBRW
+ saved_alphafunc = rw::GetRenderState(rw::ALPHATESTFUNC);
+ saved_alpharef = rw::GetRenderState(rw::ALPHATESTREF);
+
+ rw::SetRenderState(rw::ALPHATESTFUNC, rw::ALPHAGREATEREQUAL);
+ rw::SetRenderState(rw::ALPHATESTREF, 0);
+#else
+ RwD3D8GetRenderState(D3DRS_ALPHAFUNC, &saved_alphafunc);
+ RwD3D8GetRenderState(D3DRS_ALPHAREF, &saved_alpharef);
+
+ RwD3D8SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL);
+ RwD3D8SetRenderState(D3DRS_ALPHAREF, alpharef);
+#endif
+}
+
+void
+RestoreAlphaTest()
+{
+#ifdef LIBRW
+ rw::SetRenderState(rw::ALPHATESTFUNC, saved_alphafunc);
+ rw::SetRenderState(rw::ALPHATESTREF, saved_alpharef);
+#else
+ RwD3D8SetRenderState(D3DRS_ALPHAFUNC, saved_alphafunc);
+ RwD3D8SetRenderState(D3DRS_ALPHAREF, saved_alpharef);
+#endif
+}
+#endif \ No newline at end of file