Allow ragdoll joints to default to disabled, fix off-by-one bug (which can cause ode problems).

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5519 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2019-08-19 16:09:47 +00:00
parent 87fdee2282
commit 2f6cd29511
2 changed files with 9 additions and 3 deletions

View File

@ -117,7 +117,7 @@ static void skel_copy_toabs(skelobject_t *skelobjdst, skelobject_t *skelobjsrc,
galiasbone_t *boneinfo = Mod_GetBoneInfo(skelobjsrc->model, &maxbones);
if (!boneinfo)
return;
endbone = min(endbone, maxbones-1);
endbone = min(endbone, maxbones);
if (skelobjsrc->type == SKEL_ABSOLUTE)
{
if (skelobjsrc != skelobjdst)
@ -334,6 +334,7 @@ static dollcreatectx_t *rag_createdoll(model_t *mod, const char *fname, int numb
ctx->defbody.orient = false;
memset(&ctx->defjoint, 0, sizeof(ctx->defjoint));
ctx->defjoint.startenabled = true;
ctx->defjoint.axis[1] = 1;
ctx->defjoint.axis2[2] = 1;
ctx->defjoint.ERP = 0.2; //use ODE defaults
@ -418,9 +419,9 @@ static qboolean rag_dollline(dollcreatectx_t *ctx, int linenum)
if (!ctx->errors++)
{
if (ctx->joint->body2 == ctx->joint->body1)
Con_Printf("^[Joint \"%s\" joints body \"%s\" to itself\\edit\\%s:%i^]\n", ctx->joint->name, name, d->name, linenum);
Con_Printf("^[Joint \"%s\" joins body \"%s\" to itself\\edit\\%s:%i^]\n", ctx->joint->name, name, d->name, linenum);
else
Con_Printf("^[Joint \"%s\" joints invalid body \"%s\"\\edit\\%s:%i^]\n", ctx->joint->name, name, d->name, linenum);
Con_Printf("^[Joint \"%s\" joins invalid body \"%s\"\\edit\\%s:%i^]\n", ctx->joint->name, name, d->name, linenum);
}
return true;
}
@ -527,6 +528,8 @@ static qboolean rag_dollline(dollcreatectx_t *ctx, int linenum)
}
else if (ctx->joint && argc == 2 && !stricmp(cmd, "draw"))
ctx->joint->draw = atoi(val);
else if (ctx->joint && argc == 2 && !stricmp(cmd, "enabled"))
ctx->joint->startenabled = atoi(val)?true:false;
else if (ctx->joint && argc == 2 && !stricmp(cmd, "ERP"))
ctx->joint->ERP = atof(val);
else if (ctx->joint && argc == 2 && !stricmp(cmd, "ERP2"))
@ -1293,6 +1296,8 @@ static qboolean rag_instanciate(skelobject_t *sko, doll_t *doll, float *emat, we
VectorNormalize2(j->axis2, aaa2[2]);
sko->world->rbe->RagCreateJoint(sko->world, &sko->joint[i], j, body1, body2, aaa2);
sko->world->rbe->RagEnableJoint(&sko->joint[i], j->startenabled);
}
//now the joints have all their various properties, move the bones to their real positions.

View File

@ -480,6 +480,7 @@ typedef struct
char name[32];
// unsigned int disablebits;
qboolean draw:1;
qboolean startenabled:1;
//ode info
int type;