@@ -108,25 +108,25 @@ void BaseCamera::init()
108108{
109109 if (d_position.isSet ())
110110 {
111- if (!d_orientation.isSet ())
111+ if (!d_orientation. isSet () && d_lookAt .isSet ())
112112 {
113113 d_distance.setValue ((d_lookAt.getValue () - d_position.getValue ()).norm ());
114114
115- const Quat q = getOrientationFromLookAt (d_position.getValue (), d_lookAt.getValue ());
115+ const Quat q = getOrientationFromLookAt (d_position.getValue (), d_lookAt.getValue ());
116116 d_orientation.setValue (q);
117117 }
118- else if (!d_lookAt.isSet ())
118+ else if (!d_lookAt. isSet () && d_orientation .isSet ())
119119 {
120- // distance assumed to be set
121- if (!d_distance.isSet ())
122- msg_warning () << " Missing distance parameter ; taking default value (0.0, 0.0, 0.0)" ;
120+ // distance assumed to be set
121+ if (!d_distance.isSet ())
122+ msg_warning () << " Missing distance parameter. Will use default value (0.0, 0.0, 0.0) to compute lookAt " ;
123123
124124 const type::Vec3 lookat = getLookAtFromOrientation (d_position.getValue (), d_distance.getValue (), d_orientation.getValue ());
125125 d_lookAt.setValue (lookat);
126126 }
127- else
127+ else if (!d_lookAt. isSet () && !d_orientation. isSet ())
128128 {
129- msg_warning () << " Too many missing parameters ; taking default .. ." ;
129+ msg_warning () << " Too many missing parameters: If camera position is set, please also specify the orientation and lookAt value (or at least one of the two). Will use default values ." ;
130130 b_setDefaultParameters = true ;
131131 }
132132 }
@@ -143,7 +143,7 @@ void BaseCamera::init()
143143 }
144144 else
145145 {
146- msg_warning () << " Too many missing parameters ; taking default .. ." ;
146+ msg_warning () << " Too many missing parameters: If camera position is not set, please specify at least the lookAt and orientation to compute the position. Will use default values ." ;
147147 b_setDefaultParameters = true ;
148148 }
149149 }
@@ -167,13 +167,6 @@ void BaseCamera::reinit()
167167 updateOutputData ();
168168}
169169
170- void BaseCamera::bwdInit ()
171- {
172- d_minBBox.setValue (getContext ()->f_bbox .getValue ().minBBox ());
173- d_maxBBox.setValue (getContext ()->f_bbox .getValue ().maxBBox ());
174-
175- updateOutputData ();
176- }
177170
178171void BaseCamera::translate (const type::Vec3& t)
179172{
@@ -720,6 +713,9 @@ void BaseCamera::fitSphere(const type::Vec3 ¢er, SReal radius)
720713
721714void BaseCamera::fitBoundingBox (const type::Vec3 &min, const type::Vec3 &max)
722715{
716+ if (!b_setDefaultParameters)
717+ return ;
718+
723719 SReal diameter = std::max (fabs (max[1 ]-min[1 ]), fabs (max[0 ]-min[0 ]));
724720 diameter = std::max ((SReal)fabs (max[2 ]-min[2 ]), diameter);
725721 const type::Vec3 center = (min + max)*0.5 ;
@@ -915,9 +911,11 @@ void BaseCamera::updateOutputData()
915911 // TODO: other info to update
916912 d_minBBox.setValue (getContext ()->f_bbox .getValue ().minBBox ());
917913 d_maxBBox.setValue (getContext ()->f_bbox .getValue ().maxBBox ());
918-
919- d_zNear.setValue (currentZNear);
920- d_zFar.setValue (currentZFar);
914+ if (d_computeZClip.getValue ())
915+ {
916+ d_zNear.setValue (currentZNear);
917+ d_zFar.setValue (currentZFar);
918+ }
921919}
922920
923921void BaseCamera::handleEvent (sofa::core::objectmodel::Event* event)
0 commit comments