SomaZ / OpenJK

Community effort to maintain and improve Jedi Academy + Jedi Outcast released by Raven Software
GNU General Public License v2.0
11 stars 4 forks source link

Error when hit 3PO in torso by saber #54

Closed AntiAnti closed 1 week ago

AntiAnti commented 10 months ago

It happens, because 3PO model has no "Motion" bone. Should use function similar to SP-vanilla renderer.

rend2-unified-wip/code/rd-rend2/G2_API.cpp

qboolean G2API_SetNewOrigin(CGhoul2Info* ghlInfo, const int boltIndex)
{
    if (G2_SetupModelPointers(ghlInfo))
    {
        /*
        if (boltIndex < 0)
        {
            char modelName[MAX_QPATH];
            if (ghlInfo->currentModel && ghlInfo->currentModel->name[0])
            {
                strcpy(modelName, ghlInfo->currentModel->name);
            }
            else
            {
                strcpy(modelName, "[Unknown - unexpected]");
            }

            Com_Error(ERR_DROP, "Bad boltindex (%i) trying to SetNewOrigin (naughty naughty!)\nModel %s\n", boltIndex, modelName);
        }
        */

        // log instead of warning message on screen, like in SP-vanilla renderer
        G2ERROR(boltIndex >= 0 && boltIndex < (int)ghlInfo->mBltlist.size(), "invalid boltIndex");

        // check for valid boltIndex before applying new origin
        if (boltIndex >= 0 && boltIndex < (int)ghlInfo->mBltlist.size())
        {
            ghlInfo->mNewOrigin = boltIndex;
            ghlInfo->mFlags |= GHOUL2_NEWORIGIN;
        }
        return qtrue;
    }
    return qfalse;
}