]> git.leopard-lacewing.eu Git - cgue_weave.git/commitdiff
frustum Fixed
authorPeter Schaefer <schaeferpm@gmail.com>
Thu, 19 May 2016 11:46:34 +0000 (13:46 +0200)
committerPeter Schaefer <schaeferpm@gmail.com>
Thu, 19 May 2016 11:46:34 +0000 (13:46 +0200)
Weave/GLM.h
Weave/Scene/Camera.cpp
Weave/Scene/Scene.cpp

index 9b824708d99abf3e97468bf40496879672021960..cefa0699211f0509f3a198527346d165e8ab2608 100644 (file)
@@ -11,6 +11,10 @@ using glm::vec3;
 using glm::mat4;
 using glm::vec4;
 
+#ifdef  GLM_FORCE_RADIANS ;
+hello
+#endif //  GLM_FORCE_RADIANS ;
+
 using glm::translate;
 using glm::rotate;
 //using glm::scale;
index da5dc8e3d34c9421445f49561781691b264549f5..e091d77f413a19ef32e9cdb2bc9430f25d155a65 100644 (file)
@@ -16,7 +16,7 @@ Camera::Camera(float _yFov, float _xyRatio, float _zNear, float _zFar) :
        xyRatio(_xyRatio),
        zNear(_zNear),
        zFar(_zFar),
-       projection(perspective(yFov, xyRatio, zNear, zFar)),
+       projection(perspective(yFov* (float)M_D2R, xyRatio, zNear, zFar)),
        pitch(0.f),
        yaw(0.f),
        dist(2.f),      //DIST 
@@ -98,7 +98,7 @@ void Camera::updateProjection(float _xyRatio)
 
        xyRatio = _xyRatio;
 
-       projection = perspective(yFov, xyRatio, zNear, zFar);
+       projection = perspective(yFov * (float)M_D2R, xyRatio, zNear, zFar);
 }
 
 void Camera::updateProjection(float _yFov, float _xyRatio, float _zNear, float _zFar)
@@ -111,23 +111,21 @@ void Camera::updateProjection(float _yFov, float _xyRatio, float _zNear, float _
        zNear = _zNear;
        zFar = _zFar;
 
-       tan_alphaY = tan(yFov / 2.f);
-       Icos_alphaX = 1.f / cos(yFov / 2.f*xyRatio);
-       Icos_alphaY = 1.f / cos(yFov / 2.f);
+       tan_alphaY = tan(yFov * (float)M_D2R * .5f);
+       Icos_alphaX = 1.f / cos(atan(tan_alphaY*xyRatio));
+       Icos_alphaY = 1.f / cos(yFov * (float)M_D2R * .5f);
 
-       projection = perspective(yFov, xyRatio, zNear, zFar);
+       projection = perspective(yFov * (float)M_D2R, xyRatio, zNear, zFar);
 }
 
 Camera::FC_stat Camera::frustum_sphere(vec3 _center, float _radius) const
 {
        FC_stat result = FC_INSIDE;
-       //return result;
        vec3 v(_center - cCenter);
        vec3 pVCam(dot(v,cRight), dot(v,cUpVector), dot(v,cFront));
 
        float h2 = pVCam.z * tan_alphaY;
        float w2 = h2 * xyRatio;
-       //float d = _radius * cos
 
        if (_radius == 0) {
                if (pVCam.z > zFar || pVCam.z < zNear)
index 68cdca4504bad27167f2806089b7f99179246e0c..4876350de82c21115a388464346de0367666e98e 100644 (file)
@@ -340,7 +340,7 @@ void Scene::drawSceneObjects(drawTarget _target) const
        for (auto i = SceneObjects.cbegin(); i != SceneObjects.cend(); ++i)
        {
                
-               auto result = camera.frustum_sphere((*i)->getPosition() + (*i)->gModel()->getBox().center());// , (*i)->gModel()->getBox().radius());
+               auto result = camera.frustum_sphere((*i)->getPosition() +(*i)->gModel()->getBox().center() , (*i)->gModel()->getBox().radius());
                if (result == camera.FC_OUTSIDE)
                        continue;
                (*i)->draw(_target);