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
54ebdf56
Commit
54ebdf56
authored
4 years ago
by
Zain Selman
Browse files
Options
Downloads
Patches
Plain Diff
cleans up. the jittering is not completely gone
parent
4eed6032
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
+15
-43
15 additions, 43 deletions
PlanePlugin.cc
with
15 additions
and
43 deletions
PlanePlugin.cc
+
15
−
43
View file @
54ebdf56
...
@@ -182,11 +182,9 @@ void PlanePlugin::slotMouseEvent(QMouseEvent *_event) {
...
@@ -182,11 +182,9 @@ void PlanePlugin::slotMouseEvent(QMouseEvent *_event) {
origPlane_
=
curPlane_
->
plane
();
origPlane_
=
curPlane_
->
plane
();
QPoint
position
=
_event
->
pos
();
QPoint
position
=
_event
->
pos
();
std
::
cerr
<<
"old plane pos: "
<<
origPlane_
.
position
<<
std
::
endl
;
/// view coords in screenspace, with flipped y-axis at depth of
/// view coords in screenspace, with flipped y-axis at depth of
/// plane
/// plane
ACG
::
Vec3d
viewCoords
=
ACG
::
Vec3d
(
const
auto
viewCoords
=
ACG
::
Vec3d
(
position
.
x
(),
position
.
x
(),
PluginFunctions
::
viewerProperties
().
glState
().
context_height
()
-
PluginFunctions
::
viewerProperties
().
glState
().
context_height
()
-
position
.
y
(),
position
.
y
(),
...
@@ -194,7 +192,7 @@ void PlanePlugin::slotMouseEvent(QMouseEvent *_event) {
...
@@ -194,7 +192,7 @@ void PlanePlugin::slotMouseEvent(QMouseEvent *_event) {
viewStartCoord_
=
viewCoords
;
viewStartCoord_
=
viewCoords
;
//
Example for getting the viewing Ray
//
/ obtain the ray for intersecting with the quad/plane
ACG
::
Vec3d
origin
;
ACG
::
Vec3d
origin
;
PluginFunctions
::
viewerProperties
().
glState
().
viewing_ray
(
PluginFunctions
::
viewerProperties
().
glState
().
viewing_ray
(
position
.
x
(),
position
.
x
(),
...
@@ -202,26 +200,18 @@ void PlanePlugin::slotMouseEvent(QMouseEvent *_event) {
...
@@ -202,26 +200,18 @@ void PlanePlugin::slotMouseEvent(QMouseEvent *_event) {
position
.
y
(),
position
.
y
(),
origin
,
viewDirection_
);
origin
,
viewDirection_
);
/// obtain the 4 corners of the plane
/// compute intersection
std
::
vector
<
ACG
::
Vec3d
>
corners
;
{
{
corners
.
reserve
(
4
);
const
auto
center
=
curPlane_
->
plane
().
position
;
const
auto
center
=
curPlane_
->
plane
().
position
;
const
auto
xdir
=
curPlane_
->
plane
().
xDirection
/
2.
;
const
auto
xdir
=
curPlane_
->
plane
().
xDirection
/
2.
;
const
auto
ydir
=
curPlane_
->
plane
().
yDirection
/
2.
;
const
auto
ydir
=
curPlane_
->
plane
().
yDirection
/
2.
;
corners
.
emplace_back
(
ACG
::
Vec3f
{
center
+
xdir
+
ydir
});
const
auto
p0
=
center
+
xdir
+
ydir
;
corners
.
emplace_back
(
ACG
::
Vec3f
{
center
+
xdir
-
ydir
});
const
auto
p1
=
center
+
xdir
-
ydir
;
corners
.
emplace_back
(
ACG
::
Vec3f
{
center
-
xdir
-
ydir
});
const
auto
p2
=
center
-
xdir
-
ydir
;
corners
.
emplace_back
(
ACG
::
Vec3f
{
center
-
xdir
+
ydir
});
}
/// compute intersection
{
double
u
=
-
1
,
v
=
-
1
,
w
=
-
1
;
double
u
=
-
1
,
v
=
-
1
,
w
=
-
1
;
rayPlaneIntersection
(
origin
,
viewDirection_
,
corners
[
0
],
rayPlaneIntersection
(
origin
,
viewDirection_
,
p0
,
p1
,
p2
,
u
,
v
);
corners
[
1
],
corners
[
2
],
u
,
v
);
w
=
1
-
(
u
+
v
);
w
=
1
-
(
u
+
v
);
result_
=
(
w
*
corners
[
0
])
+
(
u
*
corners
[
1
])
+
(
v
*
corners
[
2
]
);
result_
=
(
w
*
p0
)
+
(
u
*
p1
)
+
(
v
*
p2
);
}
}
if
(
target_idx
==
0
)
if
(
target_idx
==
0
)
...
@@ -230,23 +220,17 @@ void PlanePlugin::slotMouseEvent(QMouseEvent *_event) {
...
@@ -230,23 +220,17 @@ void PlanePlugin::slotMouseEvent(QMouseEvent *_event) {
// We hit a corner so start dragging
// We hit a corner so start dragging
dragging_
=
true
;
dragging_
=
true
;
pickedCorner_
=
target_idx
;
pickedCorner_
=
target_idx
;
// std::cerr << "Picked a plane and id: " << target_idx
// << std::endl;
}
}
}
}
}
}
// std::cerr << "Mouse_Down" << std::endl;
break
;
break
;
}
}
case
QEvent
::
MouseMove
:
{
case
QEvent
::
MouseMove
:
{
// std::cerr << "Mouse_Move" << std::endl;
// We are actually dragging a corner
// We are actually dragging a corner
if
(
dragging_
&&
curPlane_
)
{
if
(
dragging_
&&
curPlane_
)
{
// std::cerr << "Dragging!" << std::endl;
QPoint
position
=
_event
->
pos
();
QPoint
position
=
_event
->
pos
();
...
@@ -284,39 +268,27 @@ void PlanePlugin::slotMouseEvent(QMouseEvent *_event) {
...
@@ -284,39 +268,27 @@ void PlanePlugin::slotMouseEvent(QMouseEvent *_event) {
currWorldPos_
=
(
w
*
p0
)
+
(
u
*
p1
)
+
(
v
*
p2
);
currWorldPos_
=
(
w
*
p0
)
+
(
u
*
p1
)
+
(
v
*
p2
);
}
}
/// relative to plane
const
auto
currWorldPos
=
currWorldPos_
-
plane
.
position
;
const
auto
result
=
result_
-
plane
.
position
;
/// update vector in worldspace
/// update vector in worldspace
const
auto
worldSpaceUpdate
=
(
currWorldPos
_
-
result
_
)
/
2.
;
const
auto
worldSpaceUpdate
=
(
currWorldPos
-
result
)
/
2.
;
const
auto
distClickOrigin
=
result
_
;
const
auto
distClickOrigin
=
result
;
/// scale by half updates length
/// scale by half updates length
auto
transformation
=
ACG
::
GLMatrixf
(
ACG
::
Matrix4x4f
());
transformation
.
identity
();
// init
auto
scale
=
(
worldSpaceUpdate
+
distClickOrigin
)
/
distClickOrigin
;
auto
scale
=
(
worldSpaceUpdate
+
distClickOrigin
)
/
distClickOrigin
;
scale
[
2
]
=
1
;
/// we dont do anything in z-dir
scale
[
2
]
=
1
;
/// we dont do anything in z-dir
const
auto
xscale
=
scale
[
0
]
*
plane
.
xDirection
.
length
();
const
auto
xscale
=
scale
[
0
]
*
plane
.
xDirection
.
length
();
const
auto
yscale
=
scale
[
1
]
*
plane
.
yDirection
.
length
();
const
auto
yscale
=
scale
[
1
]
*
plane
.
yDirection
.
length
();
plane
.
setSize
(
xscale
,
yscale
);
plane
.
setSize
(
xscale
,
yscale
);
std
::
cerr
<<
"scale: "
<<
scale
<<
std
::
endl
;
plane
.
position
+=
worldSpaceUpdate
/
2.
;
plane
.
position
+=
worldSpaceUpdate
;
curPlane_
->
plane
()
=
plane
;
/// overwrite plane
curPlane_
->
plane
()
=
plane
;
/// overwrite plane
/// 0 corner
if
(
pickedCorner_
==
1
)
{
}
/// x corner
if
(
pickedCorner_
==
2
)
{
}
/// xy corner
if
(
pickedCorner_
==
3
)
{
}
/// y corner
if
(
pickedCorner_
==
4
)
{
}
if
(
lastObjId_
>
0
)
if
(
lastObjId_
>
0
)
emit
updatedObject
(
lastObjId_
,
UPDATE_GEOMETRY
);
emit
updatedObject
(
lastObjId_
,
UPDATE_GEOMETRY
);
else
else
...
...
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