Skip to content

Commit

Permalink
Fixed 64bit portability issue in the bias lighting. Take 2.
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Nov 12, 2009
1 parent 097fff9 commit 2680f75
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
8 changes: 4 additions & 4 deletions doomsday/engine/portable/include/rend_bias.h
Expand Up @@ -47,7 +47,7 @@ typedef struct vilight_s {
typedef struct vertexillum_s {
float color[3]; // Current color of the vertex.
float dest[3]; // Destination color of the vertex.
unsigned int updatetime; // When the value was calculated.
uint updatetime; // When the value was calculated.
short flags;
vilight_t casted[MAX_BIAS_AFFECTED];
} vertexillum_t;
Expand All @@ -68,19 +68,19 @@ typedef struct source_s {
float intensity;
float primaryIntensity;
float sectorLevel[2];
unsigned int lastUpdateTime;
uint lastUpdateTime;
} source_t;

typedef struct biastracker_s {
unsigned int changes[MAX_BIAS_TRACKED];
uint changes[MAX_BIAS_TRACKED];
} biastracker_t;

struct rendpoly_s;
struct rvertex_s;
struct rcolor_s;

extern int useBias; // Bias lighting enabled.
extern unsigned int currentTimeSB;
extern uint currentTimeSB;

void SB_Register(void);
void SB_InitForMap(const char* uniqueId);
Expand Down
16 changes: 9 additions & 7 deletions doomsday/engine/portable/src/rend_bias.c
Expand Up @@ -73,7 +73,7 @@ void SB_EvalPoint(float light[4],

int useBias = false;
int numSources = 0;
unsigned int currentTimeSB;
uint currentTimeSB;

// PRIVATE DATA DEFINITIONS ------------------------------------------------

Expand All @@ -86,7 +86,7 @@ static float biasMax = 1.f;
static int doUpdateAffected = true;
static float biasIgnoreLimit = .005f;
static int lightSpeed = 130;
static unsigned int lastChangeOnFrame;
static uint lastChangeOnFrame;

/**
* BS_EvalPoint uses these, so they must be set before it is called.
Expand Down Expand Up @@ -672,8 +672,9 @@ static void updateAffected2(biassurface_t* bsuf, const struct rvertex_s* rvertic
/**
* Sets/clears a bit in the tracker for the given index.
*/
void SB_TrackerMark(biastracker_t* tracker, int index)
void SB_TrackerMark(biastracker_t* tracker, uint index)
{
// Assume 32-bit uint.
if(index >= 0)
{
tracker->changes[index >> 5] |= (1 << (index & 0x1f));
Expand All @@ -687,8 +688,9 @@ void SB_TrackerMark(biastracker_t* tracker, int index)
/**
* Checks if the given index bit is set in the tracker.
*/
int SB_TrackerCheck(biastracker_t* tracker, int index)
int SB_TrackerCheck(biastracker_t* tracker, uint index)
{
// Assume 32-bit uint.
return (tracker->changes[index >> 5] & (1 << (index & 0x1f))) != 0;
}

Expand All @@ -697,7 +699,7 @@ int SB_TrackerCheck(biastracker_t* tracker, int index)
*/
void SB_TrackerApply(biastracker_t* dest, const biastracker_t* src)
{
int i;
uint i;

for(i = 0; i < MAX_BIAS_TRACKED; ++i)
{
Expand All @@ -710,7 +712,7 @@ void SB_TrackerApply(biastracker_t* dest, const biastracker_t* src)
*/
void SB_TrackerClear(biastracker_t* dest, const biastracker_t* src)
{
int i;
uint i;

for(i = 0; i < MAX_BIAS_TRACKED; ++i)
{
Expand All @@ -724,7 +726,7 @@ void SB_TrackerClear(biastracker_t* dest, const biastracker_t* src)
static boolean SB_ChangeInAffected(biasaffection_t* affected,
biastracker_t* changed)
{
uint i;
uint i;

for(i = 0; i < MAX_BIAS_AFFECTED; ++i)
{
Expand Down

0 comments on commit 2680f75

Please sign in to comment.