CapsAdmin

Untitled

May 30th, 2012
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.61 KB | None | 0 0
  1. void Nav::GetNearestNodes(lua_State* L, const Vector &Pos, const float Range)
  2. {
  3.     int count = 1;
  4.     struct kdres *results;
  5.     double pt[3] = { Pos.x, Pos.y, Pos.z };
  6.    
  7.     ILuaObject *NodeTable = Lua()->GetNewTable();
  8.     NodeTable->Push();
  9.    
  10.     results = kd_nearest_range( NodeTree, pt, Range );
  11.     while( !kd_res_end( results ) )
  12.     {
  13.         PushNode(L, (Node*)kd_res_item_data( results ));
  14.         ILuaObject *ObjNode = Lua()->GetObject(-1);
  15.             NodeTable->SetMember((float)count, ObjNode);
  16.         ObjNode->UnReference();
  17.        
  18.         Lua()->Pop();
  19.         count++
  20.         kd_res_next( results );
  21.     }
  22.  
  23.     NodeTable->UnReference();
  24.     kd_res_free( results );
  25. }
Advertisement
Add Comment
Please, Sign In to add comment