From: Braden M. <br...@us...> - 2006-08-31 06:45:37
|
Update of /cvsroot/openvrml/openvrml/src/libopenvrml-gl/openvrml/gl In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv14506/src/libopenvrml-gl/openvrml/gl Modified Files: viewer.cpp Log Message: Made openvrml::color, openvrml::color_rgba, openvrml::vec2f, openvrml::vec2d, openvrml::vec3f, openvrml::vec3d, openvrml::rotation, openvrml::mat4f, and openvrml::quatf POD-structs. This allows safe usage of these types in C APIs. Index: viewer.cpp =================================================================== RCS file: /cvsroot/openvrml/openvrml/src/libopenvrml-gl/openvrml/gl/viewer.cpp,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** viewer.cpp 31 Aug 2006 06:30:51 -0000 1.44 --- viewer.cpp 31 Aug 2006 06:45:34 -0000 1.45 *************** *** 877,882 **** // deformed sphere // ! vec3f p1(p1x, p1y, tb_project_to_sphere(trackballSize, p1x, p1y)); ! vec3f p2(p2x, p2y, tb_project_to_sphere(trackballSize, p2x, p2y)); result.axis((p2 * p1).normalize()); --- 877,888 ---- // deformed sphere // ! const vec3f p1 = ! make_vec3f(p1x, ! p1y, ! tb_project_to_sphere(trackballSize, p1x, p1y)); ! const vec3f p2 = ! make_vec3f(p2x, ! p2y, ! tb_project_to_sphere(trackballSize, p2x, p2y)); result.axis((p2 * p1).normalize()); *************** *** 1872,1877 **** // Normal per face. // ! const vec3f vx(xSpacing, *(h + 1) - *h, 0.0); ! const vec3f vz(0.0, *(h + xDimension) - *h, zSpacing); glNormal3fv(&(vx * vz)[0]); } --- 1878,1885 ---- // Normal per face. // ! const vec3f vx = make_vec3f(xSpacing, *(h + 1) - *h, 0.0); ! const vec3f vz = make_vec3f(0.0, ! *(h + xDimension) - *h, ! zSpacing); glNormal3fv(&(vx * vz)[0]); } *************** *** 2160,2166 **** // Xscp, Yscp, Zscp- columns of xform matrix to align cross section // with spine segments. ! vec3f Xscp(1.0, 0.0, 0.0); ! vec3f Yscp(0.0, 1.0, 0.0); ! vec3f Zscp(0.0, 0.0, 1.0); vec3f lastZ; --- 2168,2174 ---- // Xscp, Yscp, Zscp- columns of xform matrix to align cross section // with spine segments. ! vec3f Xscp = make_vec3f(1.0, 0.0, 0.0); ! vec3f Yscp = make_vec3f(0.0, 1.0, 0.0); ! vec3f Zscp = make_vec3f(0.0, 0.0, 1.0); vec3f lastZ; *************** *** 2182,2186 **** // If the spine is a straight line, compute a constant SCP xform if (spineStraight) { ! const vec3f v1(0.0, 1.0, 0.0); const vec3f v2 = spine.back() - spine.front(); vec3f v3 = v2 * v1; --- 2190,2194 ---- // If the spine is a straight line, compute a constant SCP xform if (spineStraight) { ! const vec3f v1 = make_vec3f(0.0, 1.0, 0.0); const vec3f v2 = spine.back() - spine.front(); vec3f v3 = v2 * v1; *************** *** 2192,2200 **** v3 *= float(1.0 / len); ! const rotation orient(v3, float(acos(v1.dot(v2)))); // Axis/angle ! const mat4f scp = mat4f::rotation(orient); // xform matrix ! Xscp = vec3f(scp[0][0], scp[0][1], scp[0][2]); ! Yscp = vec3f(scp[1][0], scp[1][1], scp[1][2]); ! Zscp = vec3f(scp[2][0], scp[2][1], scp[2][2]); } } --- 2200,2209 ---- v3 *= float(1.0 / len); ! const rotation orient = ! make_rotation(v3, float(acos(v1.dot(v2)))); // Axis/angle ! const mat4f scp = make_rotation_mat4f(orient); // xform matrix ! Xscp = make_vec3f(scp[0][0], scp[0][1], scp[0][2]); ! Yscp = make_vec3f(scp[1][0], scp[1][1], scp[1][2]); ! Zscp = make_vec3f(scp[2][0], scp[2][1], scp[2][2]); } } *************** *** 2204,2208 **** if (orientation.size() == 1 && !fequal<float>()(orientation.front().angle(), 0.0f)) { ! om = mat4f::rotation(orientation.front()); } --- 2213,2217 ---- if (orientation.size() == 1 && !fequal<float>()(orientation.front().angle(), 0.0f)) { ! om = make_rotation_mat4f(orientation.front()); } *************** *** 2288,2292 **** // if (!fequal<float>()(r->angle(), 0.0f)) { ! if (orientation.size() > 1) { om = mat4f::rotation(*r); } for (j = 0; j < crossSection.size(); ++j) { --- 2297,2301 ---- // if (!fequal<float>()(r->angle(), 0.0f)) { ! if (orientation.size() > 1) { om = make_rotation_mat4f(*r); } for (j = 0; j < crossSection.size(); ++j) { *************** *** 3858,3866 **** currentScale); ! const mat4f r = mat4f::rotation(rot); ! const mat4f prevOrientation = mat4f::rotation(currentRotation); ! const mat4f t = mat4f::translation(currentTranslation); const mat4f newCameraTransform = --- 3867,3875 ---- currentScale); ! const mat4f r = make_rotation_mat4f(rot); ! const mat4f prevOrientation = make_rotation_mat4f(currentRotation); ! const mat4f t = make_translation_mat4f(currentTranslation); const mat4f newCameraTransform = *************** *** 3883,3887 **** assert(this->browser()); ! mat4f t = mat4f::translation(vec3f(x, y, z)); viewpoint_node & activeViewpoint = this->browser()->active_viewpoint(); activeViewpoint --- 3892,3896 ---- assert(this->browser()); ! mat4f t = make_translation_mat4f(make_vec3f(x, y, z)); viewpoint_node & activeViewpoint = this->browser()->active_viewpoint(); activeViewpoint *************** *** 3936,3943 **** dy *= dist; dz *= dist; ! const vec3f translation(static_cast<float>(dx), ! static_cast<float>(dy), ! static_cast<float>(dz)); ! mat4f t = mat4f::translation(translation); viewpoint_node & activeViewpoint = this->browser()->active_viewpoint(); const mat4f & userViewTransform = activeViewpoint.user_view_transform(); --- 3945,3952 ---- dy *= dist; dz *= dist; ! const vec3f translation = make_vec3f(static_cast<float>(dx), ! static_cast<float>(dy), ! static_cast<float>(dz)); ! mat4f t = make_translation_mat4f(translation); viewpoint_node & activeViewpoint = this->browser()->active_viewpoint(); const mat4f & userViewTransform = activeViewpoint.user_view_transform(); |