Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
VReaperV committed Jan 6, 2025
1 parent b929736 commit 5ae3f4d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
19 changes: 18 additions & 1 deletion src/engine/client/cg_msgdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,35 @@ namespace Util {
}
};

template<> struct SerializeTraits<std::vector<BoneMod>&> {
static void Write( Writer& stream, const std::vector<BoneMod>& boneMods ) {
stream.WriteSize( boneMods.size() );
// stream.Write<float>( skel.scale );
// size_t length = sizeof( refBone_t ) * skel.numBones;
stream.WriteData( boneMods.data(), boneMods.size() );
}
static std::vector<BoneMod>& Read( Reader& stream ) {
std::vector<BoneMod> boneMods;
boneMods.reserve( stream.ReadSize<BoneMod>() );
size_t length = sizeof( refBone_t ) * boneMods.size();
stream.ReadData( boneMods.data(), length );
return boneMods;

Check failure

Code scanning / CodeQL

Returning stack-allocated memory Critical

May return stack-allocated memory from
boneMods
.
}
};

// Use that bone optimization for refEntity_t
template<> struct SerializeTraits<refEntity_t> {
static void Write(Writer& stream, const refEntity_t& ent)
{
stream.WriteData(&ent, offsetof(refEntity_t, boneMods));
// stream.WriteData( ent.boneMods.data(), ent.boneMods.size() * sizeof( BoneMod ) );
stream.Write<std::vector<BoneMod>&>( ent.boneMods );
// stream.Write<refSkeleton_t>(ent.skeleton);
}
static refEntity_t Read(Reader& stream)
{
refEntity_t ent;
stream.ReadData(&ent, offsetof(refEntity_t, boneMods));
ent.boneMods = stream.Read<std::vector<BoneMod>&>();
// ent.skeleton = stream.Read<refSkeleton_t>();
return ent;
}
Expand Down
13 changes: 11 additions & 2 deletions src/engine/renderer/tr_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2108,10 +2108,16 @@ void R_AddEntitySurfaces()
if ( ent->e.scale == 0 ) {
ent->e.scale = 1;
}
if ( ent->e.animationHandle == 0 ) {
ent->e.animationHandle = ent->e.animationHandle2;
} else if ( ent->e.animationHandle2 == 0 ) {
ent->e.animationHandle2 = ent->e.animationHandle;
}

RE_BuildSkeleton( &ent->e.skeleton, ent->e.animationHandle, ent->e.startFrame, ent->e.endFrame,
ent->e.lerp, ent->e.clearOrigin );
ent->e.skeleton.scale = ent->e.scale;
if ( ent->e.blendLerp > 0.0 || true ) {
if ( ent->e.blendLerp > 0.0 ) {
refSkeleton_t skel;
RE_BuildSkeleton( &skel, ent->e.animationHandle2, ent->e.startFrame2, ent->e.endFrame2,
ent->e.lerp2, ent->e.clearOrigin2 );
Expand All @@ -2132,11 +2138,14 @@ void R_AddEntitySurfaces()
}
if ( ent->e.animationHandle == 0 ) {
ent->e.animationHandle = ent->e.animationHandle2;
} else if ( ent->e.animationHandle2 == 0 ) {
ent->e.animationHandle2 = ent->e.animationHandle;
}

ent->e.skeleton.scale = ent->e.scale;
RE_BuildSkeleton( &ent->e.skeleton, ent->e.animationHandle, ent->e.startFrame, ent->e.endFrame,
ent->e.lerp, ent->e.clearOrigin );
if ( ent->e.blendLerp > 0.0 || true ) {
if ( ent->e.blendLerp > 0.0 ) {
refSkeleton_t skel;
RE_BuildSkeleton( &skel, ent->e.animationHandle2, ent->e.startFrame2, ent->e.endFrame2,
ent->e.lerp2, ent->e.clearOrigin2 );
Expand Down

0 comments on commit 5ae3f4d

Please sign in to comment.