Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
UFrameIT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FrameIT
UFrameIT
Commits
cf14ee66
Commit
cf14ee66
authored
2 years ago
by
Tobias Schöner
Browse files
Options
Downloads
Patches
Plain Diff
Ring snapping is now smooth
parent
a29d709d
Branches
Branches containing commit
No related tags found
1 merge request
!1
feat: added visualisation for CircleFact; added Torus- and ConeGenerator
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Assets/Scripts/InteractionEngine/WorldCursor.cs
+24
-15
24 additions, 15 deletions
Assets/Scripts/InteractionEngine/WorldCursor.cs
with
24 additions
and
15 deletions
Assets/Scripts/InteractionEngine/WorldCursor.cs
+
24
−
15
View file @
cf14ee66
...
...
@@ -168,25 +168,34 @@ void Update()
#
region
Ring
var
id
=
multipleHits
[
i
].
transform
.
GetComponent
<
FactObject
>().
URI
;
CircleFact
circleFact
=
StageStatic
.
stage
.
factState
[
id
]
as
CircleFact
;
PointFact
middlePoint
=
StageStatic
.
stage
.
factState
[
circleFact
.
Pid1
]
as
PointFact
;
Vector3
middlePoint
=
((
PointFact
)
StageStatic
.
stage
.
factState
[
circleFact
.
Pid1
]).
Point
;
Vector3
edgePoint
=
((
PointFact
)
StageStatic
.
stage
.
factState
[
circleFact
.
Pid2
]).
Point
;
var
normal
=
circleFact
.
normal
;
var
radius
=
circleFact
.
radius
;
// generate circle
int
pointCount
=
multipleHits
[
i
].
transform
.
GetComponentInParent
<
TorusGenerator
>().
ringSegmentCount
;
Vector3
[]
circle
=
new
Vector3
[
pointCount
];
float
slice
=
(
2f
*
Mathf
.
PI
)
/
pointCount
;
for
(
int
j
=
0
;
j
<
pointCount
;
j
++)
{
// generate possible snappoints one the "corners" of the torus mesh
float
angle
=
j
*
slice
;
circle
[
j
]
=
new
Vector3
(
circleFact
.
radius
*
Mathf
.
Sin
(
angle
),
0
,
circleFact
.
radius
*
Mathf
.
Cos
(
angle
))
+
middlePoint
.
Point
;
// project p on circlePlane
var
q
=
multipleHits
[
i
].
point
-
middlePoint
;
var
dist
=
Vector3
.
Dot
(
q
,
normal
);
var
pPlane
=
multipleHits
[
i
].
point
-
(
normal
*
dist
);
// p on circlePlane
// rotate snappoint according to circle normal
circle
[
j
]
=
Quaternion
.
LookRotation
(
new
Vector3
(-
normal
.
z
,
0
,
normal
.
x
),
normal
)
*
circle
[
j
];
// check if projectedPoint and circleCenter are identical
// should never happen in practice due to floating point precision
if
(
pPlane
==
middlePoint
)
{
// can be set to any point on the ring -> set to edgePoint
multipleHits
[
i
].
point
=
edgePoint
;
return
;
}
// get closest cornerPoint
multipleHits
[
i
].
point
=
circle
.
OrderBy
(
p
=>
Vector3
.
Distance
(
p
,
multipleHits
[
i
].
point
)).
First
();
else
{
var
direction
=
(
pPlane
-
middlePoint
).
normalized
;
multipleHits
[
i
].
point
=
middlePoint
+
direction
*
radius
;
}
// cursor orientation should match circle orientation; dont face downwards
if
(
normal
.
y
<
0
)
// if normal faces downwards use inverted normal instead
multipleHits
[
i
].
normal
=
-
normal
;
else
multipleHits
[
i
].
normal
=
normal
;
#
endregion
Ring
}
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