Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help Possible to set an radius to an object?
Neelke Offline
Senior Member

Posts: 668
Threads: 82
Joined: Apr 2013
Reputation: 26
#5
RE: Possible to set an radius to an object?

As I mentioned in the above thread, Apjjm made that work with radius in 1.2. However, I've been looking at his script for a damn long time trying to figure out everything. I've found these two of his custom functions, relating to Pythagoras Theorem:

const uint32 _SQRTITERATIONS=5; //Maximum number of iterations for sqrt computation
const float  _SQRTDELTA=0.01f; //Margin of error allowable if complete before iteration ceiling

//Determines if two numbers are approximately equal (Differ by no more than epsilon)
bool approx(float &in x, float &in y, float &in epsilon) {
    float delta = x-y;
    return ((delta>0?delta:-delta) <= (epsilon>0?epsilon:-epsilon));
  }

//Sqrt of a number
float sqrt(float &in x) {
  if(x<=0) return 0; //Early out - not valid input.
  uint32 i = 0; float o = x * 0.5f;
  while( i<_SQRTITERATIONS && !approx(o*o,x,_SQRTDELTA) && o != 0)
    { o = 0.5f * (o + x/o); i++; }
  return o;            
}

Derp.
02-28-2015, 12:02 AM
Find


Messages In This Thread
RE: Possible to set an radius to an object? - by Neelke - 02-28-2015, 12:02 AM



Users browsing this thread: 4 Guest(s)