few fixes

This commit is contained in:
aap 2020-04-25 00:40:14 +02:00
parent 5bb4e99926
commit ac19de45b8
11 changed files with 71 additions and 37 deletions

2
librw

@ -1 +1 @@
Subproject commit 374f951d7cee353914059d8ddf9c5aff7d764984
Subproject commit c4ffa3622ae02f56168a1e93b978987981f3b68d

View File

@ -1,6 +1,7 @@
#include "common.h"
#include "General.h"
#include "RwHelper.h"
#include "ModelInfo.h"
#include "ModelIndices.h"
#include "FileMgr.h"
@ -754,6 +755,11 @@ CAnimManager::LoadAnimFiles(void)
group->CreateAssociations(def->blockName, clump, def->animNames, def->numAnims);
for(j = 0; j < group->numAssociations; j++)
group->GetAnimation(j)->flags |= def->animDescs[j].flags;
#ifdef PED_SKIN
// forgot on xbox/android
if(IsClumpSkinned(clump))
RpClumpForAllAtomics(clump, AtomicRemoveAnimFromSkinCB, nil);
#endif
RpClumpDestroy(clump);
}
}

View File

@ -754,7 +754,8 @@ CStreaming::RequestSpecialModel(int32 modelId, const char *modelName, int32 flag
}else
RemoveModel(modelId);
ms_pExtraObjectsDir->FindItem(modelName, pos, size);
bool found = ms_pExtraObjectsDir->FindItem(modelName, pos, size);
assert(found);
mi->ClearTexDictionary();
if(CTxdStore::FindTxdSlot(modelName) == -1)
mi->SetTexDictionary("generic");

View File

@ -91,7 +91,6 @@ void GameInit(void);
void SystemInit(void);
void TheGame(void);
void DebugMenuInit(void) {}
void DebugMenuPopulate(void);
@ -344,6 +343,8 @@ static void
Terminate3D(void)
{
CGame::ShutdownRenderWare();
DebugMenuShutdown();
RsRwTerminate();
@ -794,6 +795,7 @@ RenderDebugShit(void)
CRenderer::RenderCollisionLines();
ThePaths.DisplayPathData();
CDebug::DrawLines();
DefinedState();
#endif
}

View File

@ -285,28 +285,6 @@ CEntity::CreateRwObject(void)
}
}
#ifdef PED_SKIN
RpAtomic*
AtomicRemoveAnimFromSkinCB(RpAtomic *atomic, void *data)
{
if(RpSkinGeometryGetSkin(RpAtomicGetGeometry(atomic))){
RpHAnimHierarchy *hier = RpSkinAtomicGetHAnimHierarchy(atomic);
#ifdef LIBRW
if(hier && hier->interpolator->currentAnim){
RpHAnimAnimationDestroy(hier->interpolator->currentAnim);
hier->interpolator->currentAnim = nil;
}
#else
if(hier && hier->pCurrentAnim){
RpHAnimAnimationDestroy(hier->pCurrentAnim);
hier->pCurrentAnim = nil;
}
#endif
}
return atomic;
}
#endif
void
CEntity::DeleteRwObject(void)
{

View File

@ -95,6 +95,18 @@ createMenuFont(void)
RtCharsetGetDesc(fontStyles[MENUFONT_NORMAL], &fontDesc);
}
void
destroyMenuFont(void)
{
RtCharsetDestroy(fontStyles[MENUFONT_NORMAL]);
fontStyles[MENUFONT_NORMAL] = nil;
RtCharsetDestroy(fontStyles[MENUFONT_SEL_ACTIVE]);
fontStyles[MENUFONT_SEL_ACTIVE] = nil;
RtCharsetDestroy(fontStyles[MENUFONT_SEL_INACTIVE]);
fontStyles[MENUFONT_SEL_INACTIVE] = nil;
RtCharsetDestroy(fontStyles[MENUFONT_MOUSE]);
fontStyles[MENUFONT_MOUSE] = nil;
}
@ -755,7 +767,7 @@ static uint8 arrowPx[] = {
};
void
initDebug(void)
DebugMenuInit(void)
{
createMenuFont();
@ -779,6 +791,22 @@ initDebug(void)
arrow = RwRasterSetFromImage(arrow, img);
assert(arrow);
RwImageDestroy(img);
menuInitialized = true;
}
void
DebugMenuShutdown(void)
{
if(menuInitialized){
destroyMenuFont();
RwRasterDestroy(cursor);
cursor = nil;
RwRasterDestroy(arrow);
arrow = nil;
// TODO: the menus ...
}
menuInitialized = false;
}
void
@ -971,10 +999,8 @@ DebugMenuProcess(void)
pad->DisablePlayerControls = 1;
// TODO: this could happen earlier
if(!menuInitialized){
initDebug();
menuInitialized = 1;
}
if(!menuInitialized)
DebugMenuInit();
updateMouse();
}

View File

@ -31,6 +31,8 @@ MenuEntry *DebugMenuAddCmd(const char *path, const char *name, TriggerFunc trigg
void DebugMenuEntrySetWrap(MenuEntry *e, bool wrap);
void DebugMenuEntrySetStrings(MenuEntry *e, const char **strings);
void DebugMenuEntrySetAddress(MenuEntry *e, void *addr);
void DebugMenuInit(void);
void DebugMenuShutdown(void);
void DebugMenuProcess(void);
void DebugMenuRender(void);

View File

@ -241,7 +241,7 @@ RwRaster *RwRasterSetFromImage(RwRaster *raster, RwImage *image) { return raster
RwTexture *RwTextureCreate(RwRaster * raster) { return Texture::create(raster); }
RwBool RwTextureDestroy(RwTexture * texture) { texture->destroy(); return true; }
RwTexture *RwTextureAddRef(RwTexture *texture) { texture->refCount++; return texture; }
RwTexture *RwTextureAddRef(RwTexture *texture) { texture->addRef(); return texture; }
// TODO
RwBool RwTextureSetMipmapping(RwBool enable) { return true; }
RwBool RwTextureGetMipmapping(void);
@ -410,11 +410,11 @@ RwBool RwIm3DRenderLine(RwInt32 vert1, RwInt32 vert2) {
RwImVertexIndex indices[2];
indices[0] = vert1;
indices[1] = vert2;
im3d::RenderIndexed((PrimitiveType)PRIMTYPELINELIST, indices, 2);
im3d::RenderIndexedPrimitive((PrimitiveType)PRIMTYPELINELIST, indices, 2);
return true;
}
RwBool RwIm3DRenderTriangle(RwInt32 vert1, RwInt32 vert2, RwInt32 vert3);
RwBool RwIm3DRenderIndexedPrimitive(RwPrimitiveType primType, RwImVertexIndex *indices, RwInt32 numIndices) { im3d::RenderIndexed((PrimitiveType)primType, indices, numIndices); return true; }
RwBool RwIm3DRenderIndexedPrimitive(RwPrimitiveType primType, RwImVertexIndex *indices, RwInt32 numIndices) { im3d::RenderIndexedPrimitive((PrimitiveType)primType, indices, numIndices); return true; }
RwBool RwIm3DRenderPrimitive(RwPrimitiveType primType);

View File

@ -312,6 +312,26 @@ HAnimAnimationCreateForHierarchy(RpHAnimHierarchy *hier)
return anim;
}
RpAtomic*
AtomicRemoveAnimFromSkinCB(RpAtomic *atomic, void *data)
{
if(RpSkinGeometryGetSkin(RpAtomicGetGeometry(atomic))){
RpHAnimHierarchy *hier = RpSkinAtomicGetHAnimHierarchy(atomic);
#ifdef LIBRW
if(hier && hier->interpolator->currentAnim){
RpHAnimAnimationDestroy(hier->interpolator->currentAnim);
hier->interpolator->currentAnim = nil;
}
#else
if(hier && hier->pCurrentAnim){
RpHAnimAnimationDestroy(hier->pCurrentAnim);
hier->pCurrentAnim = nil;
}
#endif
}
return atomic;
}
void
RenderSkeleton(RpHAnimHierarchy *hier)
{

View File

@ -21,6 +21,8 @@ RpHAnimHierarchy *GetAnimHierarchyFromClump(RpClump *clump); // get from frame
RwFrame *GetHierarchyFromChildNodesCB(RwFrame *frame, void *data);
void SkinGetBonePositionsToTable(RpClump *clump, RwV3d *boneTable);
RpHAnimAnimation *HAnimAnimationCreateForHierarchy(RpHAnimHierarchy *hier);
RpAtomic *AtomicRemoveAnimFromSkinCB(RpAtomic *atomic, void *data);
void RenderSkeleton(RpHAnimHierarchy *hier);
#endif
RwTexDictionary *RwTexDictionaryGtaStreamRead(RwStream *stream);

View File

@ -66,10 +66,7 @@ RwTexDictionaryGtaStreamRead(RwStream *stream)
if(!RwStreamFindChunk(stream, rwID_STRUCT, &size, &version))
return nil;
assert(size == 4);
int foo = RwStreamRead(stream, &numTextures, size);
if(foo != size)
// if(RwStreamRead(stream, &numTextures, size) != size)
if(RwStreamRead(stream, &numTextures, size) != size)
return nil;
texDict = RwTexDictionaryCreate();