#pragma once
#define MAX_DLIGHTS 32
enum
{
DLIGHT_NO_WORLD_ILLUMINATION = 0x1,
DLIGHT_NO_MODEL_ILLUMINATION = 0x2,
DLIGHT_ADD_DISPLACEMENT_ALPHA = 0x4,
DLIGHT_SUBTRACT_DISPLACEMENT_ALPHA = 0x8,
DLIGHT_DISPLACEMENT_MASK = (DLIGHT_ADD_DISPLACEMENT_ALPHA | DLIGHT_SUBTRACT_DISPLACEMENT_ALPHA),
};
struct ColorRGBExp32
{
unsigned char r, g, b;
signed char exponent;
};
struct dlight_t
{
int flags;
vec3_t origin;
float radius;
ColorRGBExp32 color;
float die;
float decay;
float minlight;
int key;
int style;
vec3_t m_Direction;
float m_InnerAngle;
float m_OuterAngle;
float GetRadius() const
{
// return FastSqrt( radius * radius * ( HL2_BROKEN_MIN_LIGHTING_VALUE / MIN_LIGHTING_VALUE ) );
return radius;
}
// see comments above about HL2_BROKEN_MIN_LIGHTING_VALUE and MIN_LIGHTING_VALUE
// THIS SHOULD ONLY GET CALLED FROM THE ENGINE
float GetRadiusSquared() const
{
// return radius * radius * ( HL2_BROKEN_MIN_LIGHTING_VALUE / MIN_LIGHTING_VALUE );
return radius * radius;
}
// THIS SHOULD ONLY GET CALLED FROM THE ENGINE
float IsRadiusGreaterThanZero() const
{
// don't bother calculating the new radius if you just want to know if it is greater than zero.
return radius > 0.0f;
}
};
class IVEfx
{
public:
enum indices : size_t {
ALLOCDLIGHT = 4,
ALLOCELIGHT = 5,
GETACTIVEDLIGHTS = 6,
GETELIGHTBYKEY = 8,
};
__forceinline dlight_t* CL_AllocDlight(int key) {
return util::get_method<dlight_t* (__thiscall*)(void*, int)>(this, ALLOCDLIGHT)(this, key);
}
__forceinline dlight_t* CL_AllocElight(int key) {
return util::get_method<dlight_t* (__thiscall*)(void*, int)>(this, ALLOCELIGHT)(this, key);
}
__forceinline int CL_GetActiveDLights(dlight_t* pList[MAX_DLIGHTS]) {
return util::get_method<int(__thiscall*)(void*, dlight_t*)>(this, GETACTIVEDLIGHTS)(this, pList[MAX_DLIGHTS]);
}
__forceinline dlight_t* GetElightByKey(int key) {
return util::get_method<dlight_t* (__thiscall*)(void*,int)>(this, GETELIGHTBYKEY)(this, key);
}
};