aboutsummaryrefslogtreecommitdiff
path: root/mp/src/public/studio.h
diff options
context:
space:
mode:
Diffstat (limited to 'mp/src/public/studio.h')
-rw-r--r--mp/src/public/studio.h85
1 files changed, 60 insertions, 25 deletions
diff --git a/mp/src/public/studio.h b/mp/src/public/studio.h
index bcc38d5d..bc70313b 100644
--- a/mp/src/public/studio.h
+++ b/mp/src/public/studio.h
@@ -26,7 +26,7 @@
#include "datamap.h"
#include "generichash.h"
#include "localflexcontroller.h"
-
+#include "utlsymbol.h"
#define STUDIO_ENABLE_PERF_COUNTERS
@@ -755,6 +755,14 @@ struct mstudioautolayer_t
float end; // end of all influence
};
+struct mstudioactivitymodifier_t
+{
+ DECLARE_BYTESWAP_DATADESC();
+
+ int sznameindex;
+ inline char *pszName() { return (sznameindex) ? (char *)(((byte *)this) + sznameindex ) : NULL; }
+};
+
// sequence descriptions
struct mstudioseqdesc_t
{
@@ -851,7 +859,11 @@ struct mstudioseqdesc_t
int cycleposeindex; // index of pose parameter to use as cycle index
- int unused[7]; // remove/add as appropriate (grow back to 8 ints on version change!)
+ int activitymodifierindex;
+ int numactivitymodifiers;
+ inline mstudioactivitymodifier_t *pActivityModifier( int i ) const { Assert( i >= 0 && i < numactivitymodifiers); return activitymodifierindex != 0 ? (mstudioactivitymodifier_t *)(((byte *)this) + activitymodifierindex) + i : NULL; };
+
+ int unused[5]; // remove/add as appropriate (grow back to 8 ints on version change!)
mstudioseqdesc_t(){}
private:
@@ -1947,75 +1959,75 @@ struct vertexFileFixup_t
};
// This flag is set if no hitbox information was specified
-#define STUDIOHDR_FLAGS_AUTOGENERATED_HITBOX ( 1 << 0 )
+#define STUDIOHDR_FLAGS_AUTOGENERATED_HITBOX 0x00000001
// NOTE: This flag is set at loadtime, not mdl build time so that we don't have to rebuild
// models when we change materials.
-#define STUDIOHDR_FLAGS_USES_ENV_CUBEMAP ( 1 << 1 )
+#define STUDIOHDR_FLAGS_USES_ENV_CUBEMAP 0x00000002
// Use this when there are translucent parts to the model but we're not going to sort it
-#define STUDIOHDR_FLAGS_FORCE_OPAQUE ( 1 << 2 )
+#define STUDIOHDR_FLAGS_FORCE_OPAQUE 0x00000004
// Use this when we want to render the opaque parts during the opaque pass
// and the translucent parts during the translucent pass
-#define STUDIOHDR_FLAGS_TRANSLUCENT_TWOPASS ( 1 << 3 )
+#define STUDIOHDR_FLAGS_TRANSLUCENT_TWOPASS 0x00000008
// This is set any time the .qc files has $staticprop in it
// Means there's no bones and no transforms
-#define STUDIOHDR_FLAGS_STATIC_PROP ( 1 << 4 )
+#define STUDIOHDR_FLAGS_STATIC_PROP 0x00000010
// NOTE: This flag is set at loadtime, not mdl build time so that we don't have to rebuild
// models when we change materials.
-#define STUDIOHDR_FLAGS_USES_FB_TEXTURE ( 1 << 5 )
+#define STUDIOHDR_FLAGS_USES_FB_TEXTURE 0x00000020
// This flag is set by studiomdl.exe if a separate "$shadowlod" entry was present
// for the .mdl (the shadow lod is the last entry in the lod list if present)
-#define STUDIOHDR_FLAGS_HASSHADOWLOD ( 1 << 6 )
+#define STUDIOHDR_FLAGS_HASSHADOWLOD 0x00000040
// NOTE: This flag is set at loadtime, not mdl build time so that we don't have to rebuild
// models when we change materials.
-#define STUDIOHDR_FLAGS_USES_BUMPMAPPING ( 1 << 7 )
+#define STUDIOHDR_FLAGS_USES_BUMPMAPPING 0x00000080
// NOTE: This flag is set when we should use the actual materials on the shadow LOD
// instead of overriding them with the default one (necessary for translucent shadows)
-#define STUDIOHDR_FLAGS_USE_SHADOWLOD_MATERIALS ( 1 << 8 )
+#define STUDIOHDR_FLAGS_USE_SHADOWLOD_MATERIALS 0x00000100
// NOTE: This flag is set when we should use the actual materials on the shadow LOD
// instead of overriding them with the default one (necessary for translucent shadows)
-#define STUDIOHDR_FLAGS_OBSOLETE ( 1 << 9 )
+#define STUDIOHDR_FLAGS_OBSOLETE 0x00000200
-#define STUDIOHDR_FLAGS_UNUSED ( 1 << 10 )
+#define STUDIOHDR_FLAGS_UNUSED 0x00000400
// NOTE: This flag is set at mdl build time
-#define STUDIOHDR_FLAGS_NO_FORCED_FADE ( 1 << 11 )
+#define STUDIOHDR_FLAGS_NO_FORCED_FADE 0x00000800
// NOTE: The npc will lengthen the viseme check to always include two phonemes
-#define STUDIOHDR_FLAGS_FORCE_PHONEME_CROSSFADE ( 1 << 12 )
+#define STUDIOHDR_FLAGS_FORCE_PHONEME_CROSSFADE 0x00001000
// This flag is set when the .qc has $constantdirectionallight in it
// If set, we use constantdirectionallightdot to calculate light intensity
// rather than the normal directional dot product
// only valid if STUDIOHDR_FLAGS_STATIC_PROP is also set
-#define STUDIOHDR_FLAGS_CONSTANT_DIRECTIONAL_LIGHT_DOT ( 1 << 13 )
+#define STUDIOHDR_FLAGS_CONSTANT_DIRECTIONAL_LIGHT_DOT 0x00002000
// Flag to mark delta flexes as already converted from disk format to memory format
-#define STUDIOHDR_FLAGS_FLEXES_CONVERTED ( 1 << 14 )
+#define STUDIOHDR_FLAGS_FLEXES_CONVERTED 0x00004000
// Indicates the studiomdl was built in preview mode
-#define STUDIOHDR_FLAGS_BUILT_IN_PREVIEW_MODE ( 1 << 15 )
+#define STUDIOHDR_FLAGS_BUILT_IN_PREVIEW_MODE 0x00008000
// Ambient boost (runtime flag)
-#define STUDIOHDR_FLAGS_AMBIENT_BOOST ( 1 << 16 )
+#define STUDIOHDR_FLAGS_AMBIENT_BOOST 0x00010000
// Don't cast shadows from this model (useful on first-person models)
-#define STUDIOHDR_FLAGS_DO_NOT_CAST_SHADOWS ( 1 << 17 )
+#define STUDIOHDR_FLAGS_DO_NOT_CAST_SHADOWS 0x00020000
// alpha textures should cast shadows in vrad on this model (ONLY prop_static!)
-#define STUDIOHDR_FLAGS_CAST_TEXTURE_SHADOWS ( 1 << 18 )
+#define STUDIOHDR_FLAGS_CAST_TEXTURE_SHADOWS 0x00040000
// flagged on load to indicate no animation events on this model
-#define STUDIOHDR_FLAGS_VERT_ANIM_FIXED_POINT_SCALE ( 1 << 21 )
+#define STUDIOHDR_FLAGS_VERT_ANIM_FIXED_POINT_SCALE 0x00200000
// NOTE! Next time we up the .mdl file format, remove studiohdr2_t
// and insert all fields in this structure into studiohdr_t.
@@ -2493,6 +2505,7 @@ private:
CUtlVector< int > m_boneParent;
public:
+
// This class maps an activity to sequences allowed for that activity, accelerating the resolution
// of SelectWeightedSequence(), especially on PowerPC. Iterating through every sequence
// attached to a model turned out to be a very destructive cache access pattern on 360.
@@ -2508,8 +2521,10 @@ public:
// A tuple of a sequence and its corresponding weight. Lists of these correspond to activities.
struct SequenceTuple
{
- short seqnum;
- short weight; // the absolute value of the weight from the sequence header
+ short seqnum;
+ short weight; // the absolute value of the weight from the sequence header
+ CUtlSymbol *pActivityModifiers; // list of activity modifier symbols
+ int iNumActivityModifiers;
};
// The type of the hash's stored data, a composite of both key and value
@@ -2579,9 +2594,13 @@ public:
// dtor -- not virtual because this class has no inheritors
~CActivityToSequenceMapping()
- {
+ {
if ( m_pSequenceTuples != NULL )
{
+ if ( m_pSequenceTuples->pActivityModifiers != NULL )
+ {
+ delete[] m_pSequenceTuples->pActivityModifiers;
+ }
delete[] m_pSequenceTuples;
}
}
@@ -2612,6 +2631,9 @@ public:
/// A more efficient version of the old SelectWeightedSequence() function in animation.cpp.
int SelectWeightedSequence( CStudioHdr *pstudiohdr, int activity, int curSequence );
+ // selects the sequence with the most matching modifiers
+ int SelectWeightedSequenceFromModifiers( CStudioHdr *pstudiohdr, int activity, CUtlSymbol *pActivityModifiers, int iModifierCount );
+
// Actually a big array, into which the hash values index.
SequenceTuple *m_pSequenceTuples;
unsigned int m_iSequenceTuplesCount; // (size of the whole array)
@@ -2656,6 +2678,19 @@ public:
return m_ActivityToSequence.SelectWeightedSequence( this, activity, curSequence );
}
+ inline int SelectWeightedSequenceFromModifiers( int activity, CUtlSymbol *pActivityModifiers, int iModifierCount )
+ {
+#if STUDIO_SEQUENCE_ACTIVITY_LAZY_INITIALIZE
+ // We lazy-initialize the header on demand here, because CStudioHdr::Init() is
+ // called from the constructor, at which time the this pointer is illegitimate.
+ if ( !m_ActivityToSequence.IsInitialized() )
+ {
+ m_ActivityToSequence.Initialize( this );
+ }
+#endif
+ return m_ActivityToSequence.SelectWeightedSequenceFromModifiers( this, activity, pActivityModifiers, iModifierCount );
+ }
+
/// True iff there is at least one sequence for the given activity.
inline bool HaveSequenceForActivity( int activity )
{