Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Plugin-Plane
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OpenFlipper-Free
Plugin-Plane
Commits
c5d798de
Commit
c5d798de
authored
4 years ago
by
Zain Selman
Browse files
Options
Downloads
Patches
Plain Diff
still doesnt work
parent
9b99187f
No related branches found
No related tags found
1 merge request
!2
Plane interaction
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
PlanePlugin.cc
+26
-13
26 additions, 13 deletions
PlanePlugin.cc
with
26 additions
and
13 deletions
PlanePlugin.cc
+
26
−
13
View file @
c5d798de
...
...
@@ -140,9 +140,10 @@ void PlanePlugin::slotMouseEvent(QMouseEvent *_event) {
det
=
edge1
|
pvec
;
constexpr
double
EPSILON
=
std
::
numeric_limits
<
double
>::
epsilon
()
*
1e2
;
if
(
det
>
-
EPSILON
&&
det
<
EPSILON
)
if
(
det
>
-
EPSILON
&&
det
<
EPSILON
)
{
std
::
cerr
<<
"det within eps!"
<<
std
::
endl
;
return
false
;
}
inv_det
=
1.
f
/
det
;
tvec
=
origin
-
p
;
alpha
=
(
tvec
|
pvec
)
*
inv_det
;
...
...
@@ -216,14 +217,23 @@ void PlanePlugin::slotMouseEvent(QMouseEvent *_event) {
/// compute intersection
{
const
auto
ray_length
=
1e6
;
const
auto
ray_end
=
origin
+
(
viewDirection_
*
ray_length
);
double
u
=
-
1
,
v
=
-
1
,
w
=
-
1
;
// const auto ray_length = 1e6;
// const auto ray_end = origin + (viewDirection_ *
// ray_length);
const
auto
intersect
=
ACG
::
Geometry
::
edgeConvexPolygonIntersection
(
corners
,
origin
,
ray_end
,
result_
);
if
(
!
intersect
)
rayPlaneIntersection
(
origin
,
viewDirection_
,
corners
[
0
],
corners
[
1
],
corners
[
2
],
u
,
v
);
// const auto intersect =
// ACG::Geometry::edgeConvexPolygonIntersection(
// corners, origin, ray_end, result_);
if
(
!
intersect
)
{
std
::
cerr
<<
"no intersection"
<<
std
::
endl
;
return
;
}
w
=
1
-
(
u
+
v
);
result_
=
(
w
*
corners
[
0
])
+
(
u
*
corners
[
1
])
+
(
v
*
corners
[
2
]);
}
// std::cerr << "intersection found at: " << result_ <<
// std::endl; std::cerr << "target_idx: " << target_idx
...
...
@@ -299,6 +309,9 @@ void PlanePlugin::slotMouseEvent(QMouseEvent *_event) {
currWorldPos_
=
(
w
*
p0
)
+
(
u
*
p1
)
+
(
v
*
p2
);
}
std
::
cerr
<<
"click pos: "
<<
result_
<<
std
::
endl
;
std
::
cerr
<<
"drag pos: "
<<
currWorldPos_
<<
std
::
endl
;
/// update vector in worldspace
const
auto
worldSpaceUpdate
=
(
currWorldPos_
-
result_
)
/
2.
;
...
...
@@ -309,7 +322,7 @@ void PlanePlugin::slotMouseEvent(QMouseEvent *_event) {
const
auto
distClickOrigin
=
result_
;
/// 1. translate to origin
plane
.
position
-=
initPos
;
//
plane.position -= initPos;
/*/// 2. rotate to be planar
// const auto n0 = ACG::Vec3f{plane.normal};
...
...
@@ -323,11 +336,10 @@ void PlanePlugin::slotMouseEvent(QMouseEvent *_event) {
/// 3. scale by half updates length
auto
transformation
=
ACG
::
GLMatrixf
(
ACG
::
Matrix4x4f
());
transformation
.
identity
();
// init
auto
scale
=
ACG
::
Vec3f
{(
worldSpaceUpdate
+
distClickOrigin
)
/
distClickOrigin
};
auto
scale
=
(
worldSpaceUpdate
+
distClickOrigin
)
/
distClickOrigin
;
scale
[
2
]
=
1
;
/// we dont do anything in z-dir
transformation
.
scale
(
scale
);
transformation
.
scale
(
scale
[
0
],
scale
[
1
],
scale
[
2
]
);
// const auto xscale = scale[0] * plane.xDirection.length();
// const auto yscale = scale[1] * plane.yDirection.length();
// plane.setSize(xscale, yscale);
...
...
@@ -336,11 +348,12 @@ void PlanePlugin::slotMouseEvent(QMouseEvent *_event) {
// << " ydir: " << plane.yDirection << std::endl;
// std::cerr << "initial click pos: " << distClickOrigin <<
// std::endl; std::cerr << "current click pos: " << currWorldPos_
// << std::endl; std::cerr << "scale: " << scale << std::endl;
// << std::endl;
std
::
cerr
<<
"scale: "
<<
scale
<<
std
::
endl
;
std
::
cerr
<<
"update: "
<<
worldSpaceUpdate
<<
std
::
endl
;
plane
.
transform
(
transformation
);
plane
.
position
+=
initPos
;
//
plane.position += initPos;
plane
.
position
+=
worldSpaceUpdate
;
curPlane_
->
plane
()
=
plane
;
/// overwrite plane
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment