static variable RNG in Segment.cpp

Bug #388720 reported by Manuel A. Fernandez Montecelo
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mercator
Fix Committed
Medium
Erik Ogenvik

Bug Description

This is in the middle of Segment.cpp, between functions, so it's difficult to spot.

Being static might cause threading issues (maybe not in this case if it's accessed read-only, I don't know).

Also, the out of namespace function randHalf() is directly below it.

Maybe there's a better place to put both of them, and if RNG would have threading issues, it would be better to have one instance per object.

// the random number generator
static WFMath::MTRand rng;

// generate a rand num between -0.5...0.5
inline float randHalf()
{
    //return (float) rand() / RAND_MAX - 0.5f;
    double r=rng();
    return r - 0.5;
}

Al Riddoch (alriddoch)
Changed in mercator:
assignee: nobody → Al Riddoch (alriddoch)
importance: Undecided → Medium
status: New → Confirmed
Changed in mercator:
assignee: Al Riddoch (alriddoch) → Erik Hjortsberg (erik-hjortsberg)
status: Confirmed → Fix Committed
Revision history for this message
Al Riddoch (alriddoch) wrote :

Nice fix, like it.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.