mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 18:44:00 +02:00
Made several ViewFrustum methods const since they don't modify the class
This commit is contained in:
parent
9b34427570
commit
e1da39e2bb
2 changed files with 17 additions and 9 deletions
|
@ -105,7 +105,7 @@ void ViewFrustum::calculate() {
|
|||
|
||||
}
|
||||
|
||||
void ViewFrustum::dump() {
|
||||
void ViewFrustum::dump() const {
|
||||
|
||||
printLog("position.x=%f, position.y=%f, position.z=%f\n", _position.x, _position.y, _position.z);
|
||||
printLog("direction.x=%f, direction.y=%f, direction.z=%f\n", _direction.x, _direction.y, _direction.z);
|
||||
|
@ -158,17 +158,25 @@ const char* ViewFrustum::debugPlaneName (int plane) const {
|
|||
}
|
||||
|
||||
|
||||
int ViewFrustum::pointInFrustum(const glm::vec3& point) {
|
||||
int ViewFrustum::pointInFrustum(const glm::vec3& point) const {
|
||||
|
||||
//printf("ViewFrustum::pointInFrustum() point=%f,%f,%f\n",point.x,point.y,point.z);
|
||||
//dump();
|
||||
|
||||
int result = INSIDE;
|
||||
for(int i=0; i < 6; i++) {
|
||||
if (_planes[i].distance(point) < 0) {
|
||||
float distance = _planes[i].distance(point);
|
||||
|
||||
//printf("plane[%d] %s -- distance=%f \n",i,debugPlaneName(i),distance);
|
||||
|
||||
if (distance < 0) {
|
||||
return OUTSIDE;
|
||||
}
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
int ViewFrustum::sphereInFrustum(const glm::vec3& center, float radius) {
|
||||
int ViewFrustum::sphereInFrustum(const glm::vec3& center, float radius) const {
|
||||
int result = INSIDE;
|
||||
float distance;
|
||||
for(int i=0; i < 6; i++) {
|
||||
|
@ -182,7 +190,7 @@ int ViewFrustum::sphereInFrustum(const glm::vec3& center, float radius) {
|
|||
}
|
||||
|
||||
|
||||
int ViewFrustum::boxInFrustum(const AABox& box) {
|
||||
int ViewFrustum::boxInFrustum(const AABox& box) const {
|
||||
|
||||
printf("ViewFrustum::boxInFrustum() box.corner=%f,%f,%f x=%f\n",
|
||||
box.getCorner().x,box.getCorner().y,box.getCorner().z,box.getSize().x);
|
||||
|
|
|
@ -90,13 +90,13 @@ public:
|
|||
|
||||
ViewFrustum();
|
||||
|
||||
void dump();
|
||||
void dump() const;
|
||||
|
||||
enum {OUTSIDE, INTERSECT, INSIDE};
|
||||
|
||||
int pointInFrustum(const glm::vec3& point);
|
||||
int sphereInFrustum(const glm::vec3& center, float radius);
|
||||
int boxInFrustum(const AABox& box);
|
||||
int pointInFrustum(const glm::vec3& point) const;
|
||||
int sphereInFrustum(const glm::vec3& center, float radius) const;
|
||||
int boxInFrustum(const AABox& box) const;
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue