Commit 8f8fdcf4 authored by Sylvain Thery's avatar Sylvain Thery

resolution bug picking frame_manip (rotation)

amelioration picking translation
bug IcoSphere(1) dans Pickable
parent df7aef97
...@@ -182,28 +182,11 @@ public: ...@@ -182,28 +182,11 @@ public:
*/ */
void lockPicking(unsigned int axis); void lockPicking(unsigned int axis);
/// lock translations for picking only
void lockPickingTranslations();
/// lock rotations for picking only
void lockPickingRotations();
/// lock scales for picking only
void lockPickingScales();
/** /**
* unlock an axis (only for pinking) * unlock an axis (only for pinking)
*/ */
void unlockPicking(unsigned int axis); void unlockPicking(unsigned int axis);
/// unlock translations for picking only
void unlockPickingTranslations();
/// unlock rotations for picking only
void unlockPickingRotations();
/// unlock scales for picking only
void unlockPickingScales();
/** /**
* is an axis locked (only for pinking) * is an axis locked (only for pinking)
*/ */
......
...@@ -429,7 +429,7 @@ public: ...@@ -429,7 +429,7 @@ public:
* @param par number of parallels * @param par number of parallels
* @param mer number of meridians * @param mer number of meridians
*/ */
IcoSphere(unsigned int sub=1); IcoSphere(unsigned int sub=5);
/** /**
......
...@@ -312,13 +312,17 @@ unsigned int FrameManipulator::pick(const Geom::Vec3f& PP, const Geom::Vec3f& VV ...@@ -312,13 +312,17 @@ unsigned int FrameManipulator::pick(const Geom::Vec3f& PP, const Geom::Vec3f& VV
// intersection possible between line and frame (10% margin)? // intersection possible between line and frame (10% margin)?
float dist2 = Geom::squaredDistanceLine2Point<Geom::Vec3f>(P,V,V*V,origin); float dist2 = Geom::squaredDistanceLine2Point<Geom::Vec3f>(P,V,V*V,origin);
if (dist2 > (1.05))
float distMax= std::max(m_lengthAxes[0],std::max(m_lengthAxes[1],m_lengthAxes[2]));
distMax *=3.6f;
distMax= std::max(distMax,1.0f+ring_half_width);
if (dist2 > distMax*distMax)
return NONE; return NONE;
// click on center // click on center
if (dist2 < 0.02f*0.02f) if (dist2 < 0.02f*0.02f)
{ {
// if (! m_locked_axis[CENTER])
if (axisPickable(CENTER)) if (axisPickable(CENTER))
return CENTER; return CENTER;
else else
...@@ -384,42 +388,57 @@ unsigned int FrameManipulator::pick(const Geom::Vec3f& PP, const Geom::Vec3f& VV ...@@ -384,42 +388,57 @@ unsigned int FrameManipulator::pick(const Geom::Vec3f& PP, const Geom::Vec3f& VV
if (axisPickable(Xt) || axisPickable(Xs)) if (axisPickable(Xt) || axisPickable(Xs))
{ {
Geom::Vec3f PX(1.0f,0.0f,0.0f); Geom::Vec3f PX(3.6f*m_lengthAxes[0],0.0f,0.0f);
dist_target[0] = sqrt(Geom::squaredDistanceLine2Seg(P, V, V*V, origin, PX)) ; dist_target[0] = sqrt(Geom::squaredDistanceLine2Seg(P, V, V*V, origin, PX)) ;
if (fabs(dist_target[0]) < 0.02f) if (fabs(dist_target[0]) < 0.02f)
{ {
if ( (Qz - origin).norm() > m_lengthAxes[0]) if (axisPickable(Xt) && !axisPickable(Xs))
dist_cam[0] = (P-PX)*(P-PX); dist_cam[0] = (P-PX)*(P-PX);
else else
dist_cam[6] = (P-origin)*(P-origin); {
if ( Qz.norm() > m_lengthAxes[0])
dist_cam[0] = (P-PX)*(P-PX);
else
dist_cam[6] = P*P;
}
} }
} }
if (axisPickable(Yt) || axisPickable(Ys)) if (axisPickable(Yt) || axisPickable(Ys))
{ {
Geom::Vec3f PY(0.0f,1.0f,0.0f); Geom::Vec3f PY(0.0f,3.6f*m_lengthAxes[1],0.0f);
dist_target[1] = sqrt(Geom::squaredDistanceLine2Seg(P, V, V*V, origin, PY)) ; dist_target[1] = sqrt(Geom::squaredDistanceLine2Seg(P, V, V*V, origin, PY)) ;
if (fabs(dist_target[1]) < 0.02f ) if (fabs(dist_target[1]) < 0.02f)
{ {
if ((Qz - origin).norm() > m_lengthAxes[1]) if (axisPickable(Yt) && !axisPickable(Ys))
dist_cam[1] = (P-PY)*(P-PY); dist_cam[1] = (P-PY)*(P-PY);
else else
dist_cam[7] = (P-origin)*(P-origin); {
if (Qz.norm() > m_lengthAxes[1])
dist_cam[1] = (P-PY)*(P-PY);
else
dist_cam[7] = P*P;
}
} }
} }
if (axisPickable(Zt) || axisPickable(Zs)) if (axisPickable(Zt) || axisPickable(Zs))
{ {
Geom::Vec3f PZ(0.0f,0.0f,1.0f); Geom::Vec3f PZ(0.0f,0.0f,3.6f*m_lengthAxes[2]);
dist_target[2] = sqrt(Geom::squaredDistanceLine2Seg(P, V, V*V, origin, PZ)); dist_target[2] = sqrt(Geom::squaredDistanceLine2Seg(P, V, V*V, origin, PZ));
if (fabs(dist_target[2]) < 0.02f ) if (fabs(dist_target[2]) < 0.02f )
{ {
if ((Qx - origin).norm() > m_lengthAxes[2]) if (axisPickable(Zt) && !axisPickable(Zs))
dist_cam[2] = (P-PZ)*(P-PZ); dist_cam[2] = (P-PZ)*(P-PZ);
else else
dist_cam[8] = (P-origin)*(P-origin); {
if (Qx.norm() > m_lengthAxes[2])
dist_cam[2] = (P-PZ)*(P-PZ);
else
dist_cam[8] = P*P;
}
} }
} }
......
...@@ -310,6 +310,10 @@ Sphere::Sphere(unsigned int par, unsigned int mer) ...@@ -310,6 +310,10 @@ Sphere::Sphere(unsigned int par, unsigned int mer)
void Sphere::changeTopo(unsigned int parp, unsigned int mer) void Sphere::changeTopo(unsigned int parp, unsigned int mer)
{ {
if (parp<2)
parp=2;
if (mer<2)
mer=2;
// to obtain right number of slice // to obtain right number of slice
unsigned int par = parp-1; unsigned int par = parp-1;
...@@ -438,6 +442,11 @@ Cone::Cone(unsigned int par, unsigned int mer) ...@@ -438,6 +442,11 @@ Cone::Cone(unsigned int par, unsigned int mer)
void Cone::changeTopo(unsigned int par, unsigned int mer) void Cone::changeTopo(unsigned int par, unsigned int mer)
{ {
if (par<2)
par=2;
if (mer<2)
mer=2;
unsigned int merfactor=1; unsigned int merfactor=1;
if (mer<8) if (mer<8)
...@@ -558,10 +567,14 @@ Cylinder::Cylinder(unsigned int par, unsigned int mer) ...@@ -558,10 +567,14 @@ Cylinder::Cylinder(unsigned int par, unsigned int mer)
void Cylinder::changeTopo(unsigned int parp, unsigned int mer) void Cylinder::changeTopo(unsigned int parp, unsigned int mer)
{ {
if (parp<2)
parp=2;
if (mer<2)
mer=2;
// to obtain right number of slice (with almost same code as sphere) // to obtain right number of slice (with almost same code as sphere)
unsigned int par = parp+1; unsigned int par = parp+1;
unsigned int merfactor=1; unsigned int merfactor=1;
if (mer<8) if (mer<8)
...@@ -865,6 +878,8 @@ void IcoSphere::subdivide(std::vector<unsigned int>& triangles, std::vector<Geom ...@@ -865,6 +878,8 @@ void IcoSphere::subdivide(std::vector<unsigned int>& triangles, std::vector<Geom
void IcoSphere::changeTopo(unsigned int sub) void IcoSphere::changeTopo(unsigned int sub)
{ {
if (sub<2)
sub=2;
int subd = int(log(sub/2)/log(2.0))-1; int subd = int(log(sub/2)/log(2.0))-1;
if (subd<0) if (subd<0)
subd=0; subd=0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment