Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define CHAR_TEX_CONCRETE 'C'
- #define CHAR_TEX_METAL 'M'
- #define CHAR_TEX_DIRT 'D'
- #define CHAR_TEX_VENT 'V'
- #define CHAR_TEX_GRATE 'G'
- #define CHAR_TEX_TILE 'T'
- #define CHAR_TEX_SLOSH 'S'
- #define CHAR_TEX_WOOD 'W'
- #define CHAR_TEX_COMPUTER 'P'
- #define CHAR_TEX_GLASS 'Y'
- #define CHAR_TEX_FLESH 'F'
- #define CHAR_TEX_BLOODYFLESH 'B'
- #define CHAR_TEX_CLIP 'I'
- #define CHAR_TEX_ANTLION 'A'
- #define CHAR_TEX_ALIENFLESH 'H'
- #define CHAR_TEX_FOLIAGE 'O'
- #define CHAR_TEX_SAND 'N'
- #define CHAR_TEX_PLASTIC 'L'
- typedef void* (*CreateClientClassFn)(int entnum, int serialNum);
- typedef void* (*CreateEventFn)();
- typedef float vec_t;
- class __declspec(align(16)) VectorAligned: public Vector
- {
- public:
- inline VectorAligned(void) {};
- inline VectorAligned(vec_t X, vec_t Y, vec_t Z)
- {
- Init(X, Y, Z);
- }
- public:
- explicit VectorAligned(const Vector &vOther)
- {
- Init(vOther.X, vOther.Y, vOther.Z);
- }
- VectorAligned& operator=(const Vector &vOther)
- {
- Init(vOther.X, vOther.Y, vOther.Z);
- return *this;
- }
- float w; // this space is used anyway
- };
- struct Ray_t
- {
- VectorAligned m_Start;
- VectorAligned m_Delta;
- VectorAligned m_StartOffset;
- VectorAligned m_Extents;
- const matrix3x4_t* m_pWorldAxisTransform;
- bool m_IsRay;
- bool m_IsSwept;
- Ray_t(): m_pWorldAxisTransform(NULL) {}
- void Init(Vector& vecStart, Vector& vecEnd)
- {
- m_Delta = vecEnd - vecStart;
- m_IsSwept = (m_Delta.X != 0 && m_Delta.Y != 0 && m_Delta.Z != 0);
- m_Extents.X = m_Extents.Y = m_Extents.Z = 0.0f;
- m_pWorldAxisTransform = NULL;
- m_IsRay = true;
- m_StartOffset.X = m_StartOffset.Y = m_StartOffset.Z = 0.0f;
- m_Start = vecStart;
- }
- };
- template< typename Function > Function call_vfunc(PVOID Base, DWORD Index)
- {
- PDWORD* VTablePointer = (PDWORD*)Base;
- PDWORD VTableFunctionBase = *VTablePointer;
- DWORD dwAddress = VTableFunctionBase[Index];
- return (Function)(dwAddress);
- }
- struct cplane_t
- {
- Vector normal;
- float dist;
- BYTE type;
- BYTE signbits;
- BYTE pad[2];
- };
- struct csurface_t
- {
- const char *name;
- short surfaceProps;
- unsigned short flags;
- };
- struct trace_t
- {
- Vector startpos;
- Vector endpos;
- cplane_t plane;
- float fraction;
- int contents;
- unsigned int dispFlags;
- bool allsolid;
- bool startsolid;
- float fractionleftsolid;
- csurface_t surface;
- int hitgroup;
- short physicsbone;
- unsigned short worldSurfaceIndex;
- DWORD* m_pEntityHit;
- int hitbox;
- };
- struct surfacephysicsparams_t
- {
- // vphysics physical properties
- float friction;
- float elasticity; // collision elasticity - used to compute coefficient of restitution
- float density; // physical density (in kg / m^3)
- float thickness; // material thickness if not solid (sheet materials) in inches
- float dampening;
- };
- struct surfaceaudioparams_t
- {
- // sounds / audio data
- float reflectivity; // like elasticity, but how much sound should be reflected by this surface
- float hardnessFactor; // like elasticity, but only affects impact sound choices
- float roughnessFactor; // like friction, but only affects scrape sound choices
- // audio thresholds
- float roughThreshold; // surface roughness > this causes "rough" scrapes, < this causes "smooth" scrapes
- float hardThreshold; // surface hardness > this causes "hard" impacts, < this causes "soft" impacts
- float hardVelocityThreshold; // collision velocity > this causes "hard" impacts, < this causes "soft" impacts
- // NOTE: Hard impacts must meet both hardnessFactor AND velocity thresholds
- };
- struct surfacesoundnames_t
- {
- unsigned short stepleft;
- unsigned short stepright;
- unsigned short impactSoft;
- unsigned short impactHard;
- unsigned short scrapeSmooth;
- unsigned short scrapeRough;
- unsigned short bulletImpact;
- unsigned short rolling;
- unsigned short breakSound;
- unsigned short strainSound;
- };
- struct surfacesoundhandles_t
- {
- short stepleft;
- short stepright;
- short impactSoft;
- short impactHard;
- short scrapeSmooth;
- short scrapeRough;
- short bulletImpact;
- short rolling;
- short breakSound;
- short strainSound;
- };
- struct surfacegameprops_t
- {
- // game movement data
- float maxSpeedFactor; // Modulates player max speed when walking on this surface
- float jumpFactor; // Indicates how much higher the player should jump when on the surface
- // Game-specific data
- unsigned short material;
- // Indicates whether or not the player is on a ladder.
- unsigned char climbable;
- unsigned char pad;
- };
- //-----------------------------------------------------------------------------
- // Purpose: Each different material has an entry like this
- //-----------------------------------------------------------------------------
- struct surfacedata_t
- {
- surfacephysicsparams_t physics; // physics parameters
- surfaceaudioparams_t audio; // audio parameters
- surfacesoundnames_t sounds; // names of linked sounds
- surfacegameprops_t game; // Game data / properties
- surfacesoundhandles_t soundhandles;
- };
- #define VPHYSICS_SURFACEPROPS_INTERFACE_VERSION "VPhysicsSurfaceProps001"
- class IPhysicsSurfaceProps
- {
- public:
- virtual ~IPhysicsSurfaceProps(void) {}
- // parses a text file containing surface prop keys
- virtual int ParseSurfaceData(const char *pFilename, const char *pTextfile) = 0;
- // current number of entries in the database
- virtual int SurfacePropCount(void) const = 0;
- virtual int GetSurfaceIndex(const char *pSurfacePropName) const = 0;
- virtual void GetPhysicsProperties(int surfaceDataIndex, float *density, float *thickness, float *friction, float *elasticity) const = 0;
- virtual surfacedata_t *GetSurfaceData(int surfaceDataIndex) = 0;
- virtual const char *GetString(unsigned short stringTableIndex) const = 0;
- virtual const char *GetPropName(int surfaceDataIndex) const = 0;
- // sets the global index table for world materials
- // UNDONE: Make this per-CPhysCollide
- virtual void SetWorldMaterialIndexTable(int *pMapArray, int mapSize) = 0;
- // NOTE: Same as GetPhysicsProperties, but maybe more convenient
- virtual void GetPhysicsParameters(int surfaceDataIndex, surfacephysicsparams_t *pParamsOut) const = 0;
- };
- enum TraceType_t
- {
- TRACE_EVERYTHING = 0,
- TRACE_WORLD_ONLY,
- TRACE_ENTITIES_ONLY,
- TRACE_EVERYTHING_FILTER_PROPS,
- };
- //class ITraceFilter
- //{
- //public:
- // virtual bool ShouldHitEntity(IClientEntity *pEntity, int contentsMask) = 0;
- // virtual int GetTraceType() const;
- //};
- class ITraceFilter
- {
- public:
- virtual bool ShouldHitEntity(IHandleEntity *pEntity, int contentsMask) = 0;
- virtual TraceType_t GetTraceType() const = 0;
- };
- //-----------------------------------------------------------------------------
- // Classes are expected to inherit these + implement the ShouldHitEntity method
- //-----------------------------------------------------------------------------
- // This is the one most normal traces will inherit from
- class CTraceFilter: public ITraceFilter
- {
- public:
- bool ShouldHitEntity(IHandleEntity* pEntityHandle, int contentsMask)
- {
- return !(pEntityHandle == pSkip);
- }
- virtual TraceType_t GetTraceType() const
- {
- return TRACE_EVERYTHING;
- }
- void *pSkip;
- };
- class CTraceFilterEntitiesOnly: public ITraceFilter
- {
- public:
- virtual TraceType_t GetTraceType() const
- {
- return TRACE_ENTITIES_ONLY;
- }
- };
- //-----------------------------------------------------------------------------
- // Classes need not inherit from these
- //-----------------------------------------------------------------------------
- class CTraceFilterWorldOnly: public ITraceFilter
- {
- public:
- bool ShouldHitEntity(IHandleEntity *pServerEntity, int contentsMask)
- {
- return false;
- }
- virtual TraceType_t GetTraceType() const
- {
- return TRACE_WORLD_ONLY;
- }
- };
- class CTraceFilterWorldAndPropsOnly: public ITraceFilter
- {
- public:
- bool ShouldHitEntity(IHandleEntity *pServerEntity, int contentsMask)
- {
- return false;
- }
- virtual TraceType_t GetTraceType() const
- {
- return TRACE_EVERYTHING;
- }
- };
- class CTraceFilterHitAll: public CTraceFilter
- {
- public:
- virtual bool ShouldHitEntity(IHandleEntity *pServerEntity, int contentsMask)
- {
- return true;
- }
- };
- class IEngineTrace
- {
- public:
- // Returns the contents mask + entity at a particular world-space position
- virtual int GetPointContents(const Vector &vecAbsPosition, int** ppEntity = NULL) = 0;
- virtual int GetPointContents_WorldOnly(const Vector &vecAbsPosition, int contentsMask = 0) = 0;
- virtual int GetPointContents_Collideable(int *pCollide, const Vector &vecAbsPosition) = 0;
- virtual void ClipRayToEntity(const Ray_t &ray, unsigned int fMask, int *pEnt, trace_t *pTrace) = 0;
- virtual void ClipRayToCollideable(const Ray_t &ray, unsigned int fMask, int *pCollide, trace_t *pTrace) = 0;
- // A version that simply accepts a ray (can work as a traceline or tracehull)
- virtual void TraceRay(const Ray_t &ray, unsigned int fMask, ITraceFilter *pTraceFilter, trace_t *pTrace) = 0;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement