From: divverent Date: Mon, 18 Oct 2010 07:29:59 +0000 (+0000) Subject: experimental: do not auto allocate a skeletonobject when a CSQC model just uses frame... X-Git-Tag: xonotic-v0.1.0preview~56^2~67 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=56712b26644459a90ad48b8a796abdf1b0176dee;p=xonotic%2Fdarkplaces.git experimental: do not auto allocate a skeletonobject when a CSQC model just uses frame based animation (NOTE: this MAY even cause crashes, please test, I just can't find any case where that object is really required); this moves blending of frame based animations back into Mod_Skeletal_AnimateVertices again (if this commit causes worse performance, a different course of action may be reverting it, and making sure a skeletonobject is ALWAYS created, even for SVQC managed legacy entities) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10550 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/prvm_cmds.c b/prvm_cmds.c index 391f9e27..30b790f1 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -187,9 +187,14 @@ void VM_UpdateEdictSkeleton(prvm_edict_t *ed, const dp_model_t *edmodel, const f VM_RemoveEdictSkeleton(ed); ed->priv.server->skeleton.model = edmodel; } - if (!ed->priv.server->skeleton.relativetransforms && ed->priv.server->skeleton.model && ed->priv.server->skeleton.model->num_bones) - ed->priv.server->skeleton.relativetransforms = (matrix4x4_t *)Mem_Alloc(prog->progs_mempool, ed->priv.server->skeleton.model->num_bones * sizeof(matrix4x4_t)); - if (ed->priv.server->skeleton.relativetransforms) + if (!ed->priv.server->skeleton.model || !ed->priv.server->skeleton.model->num_bones) + { + if(ed->priv.server->skeleton.relativetransforms) + Mem_Free(ed->priv.server->skeleton.relativetransforms); + ed->priv.server->skeleton.relativetransforms = NULL; + return; + } + { int skeletonindex = -1; skeleton_t *skeleton; @@ -198,30 +203,15 @@ void VM_UpdateEdictSkeleton(prvm_edict_t *ed, const dp_model_t *edmodel, const f if (skeletonindex >= 0 && skeletonindex < MAX_EDICTS && (skeleton = prog->skeletons[skeletonindex]) && skeleton->model->num_bones == ed->priv.server->skeleton.model->num_bones) { // custom skeleton controlled by the game (FTE_CSQC_SKELETONOBJECTS) + if (!ed->priv.server->skeleton.relativetransforms) + ed->priv.server->skeleton.relativetransforms = (matrix4x4_t *)Mem_Alloc(prog->progs_mempool, ed->priv.server->skeleton.model->num_bones * sizeof(matrix4x4_t)); memcpy(ed->priv.server->skeleton.relativetransforms, skeleton->relativetransforms, ed->priv.server->skeleton.model->num_bones * sizeof(matrix4x4_t)); } else { - // generated skeleton from frame animation - int blendindex; - int bonenum; - int numbones = ed->priv.server->skeleton.model->num_bones; - const short *framebones6s; - float lerp; - float scale = ed->priv.server->skeleton.model->num_posescale; - matrix4x4_t *relativetransforms = ed->priv.server->skeleton.relativetransforms; - matrix4x4_t matrix; - memset(relativetransforms, 0, numbones * sizeof(matrix4x4_t)); - for (blendindex = 0;blendindex < MAX_FRAMEBLENDS && frameblend[blendindex].lerp > 0;blendindex++) - { - lerp = frameblend[blendindex].lerp; - framebones6s = ed->priv.server->skeleton.model->data_poses6s + 6 * frameblend[blendindex].subframe * numbones; - for (bonenum = 0;bonenum < numbones;bonenum++) - { - Matrix4x4_FromBonePose6s(&matrix, scale, framebones6s + 6 * bonenum); - Matrix4x4_Accumulate(&ed->priv.server->skeleton.relativetransforms[bonenum], &matrix, lerp); - } - } + if(ed->priv.server->skeleton.relativetransforms) + Mem_Free(ed->priv.server->skeleton.relativetransforms); + ed->priv.server->skeleton.relativetransforms = NULL; } } }