-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.cpp
More file actions
executable file
·39 lines (30 loc) · 866 Bytes
/
common.cpp
File metadata and controls
executable file
·39 lines (30 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "common.h"
#pragma GCC diagnostic ignored "-Wextra"
#include <dtUtil/boundingshapeutils.h>
#include <dtUtil/log.h>
#include <climits>
#include <cstdlib>
#include <cstdlib>
#pragma GCC diagnostic warning "-Wextra"
bool GetBoundingBox(osg::BoundingBox & BB, dtCore::DeltaDrawable & drawable)
{
osg::Node* node = drawable.GetOSGNode();
if (node != 0)
{
dtUtil::BoundingBoxVisitor bbv;
node->accept(bbv);
// no copy constructor for osg::BB...
BB.set(bbv.mBoundingBox._min, bbv.mBoundingBox._max);
return true;
}
LOG_WARNING("No valid osg node of drawable when asking for bounding box.");
return false;
}
float random(float min,float max)
{
return min + (max-min)*(float)rand()/(float)RAND_MAX;
}
int random(int min,int max)
{
return min + (int)((float)(max-min)*(float)rand()/(float)RAND_MAX);
}