Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Courses
Scotty3D
Commits
6b00d484
Commit
6b00d484
authored
Apr 27, 2021
by
TheNumbat
Browse files
some updates
parent
f6d60be2
Changes
2
Show whitespace changes
Inline
Side-by-side
src/gui/manager.h
View file @
6b00d484
...
@@ -36,7 +36,7 @@ struct Color {
...
@@ -36,7 +36,7 @@ struct Color {
RGBv
(
red
,
163
,
66
,
81
);
RGBv
(
red
,
163
,
66
,
81
);
RGBv
(
green
,
124
,
172
,
40
);
RGBv
(
green
,
124
,
172
,
40
);
RGBv
(
blue
,
64
,
127
,
193
);
RGBv
(
blue
,
64
,
127
,
193
);
RGBv
(
yellow
,
2
55
,
22
3
,
0
);
RGBv
(
yellow
,
2
38
,
22
1
,
79
);
RGBv
(
hoverg
,
102
,
204
,
102
);
RGBv
(
hoverg
,
102
,
204
,
102
);
static
Vec3
axis
(
Axis
a
);
static
Vec3
axis
(
Axis
a
);
};
};
...
...
src/gui/widgets.cpp
View file @
6b00d484
...
@@ -41,7 +41,7 @@ Widgets::Widgets() : lines(1.0f) {
...
@@ -41,7 +41,7 @@ Widgets::Widgets() : lines(1.0f) {
y_scl
=
Scene_Object
((
Scene_ID
)
Widget_IDs
::
y_scl
,
{},
Util
::
scale_mesh
());
y_scl
=
Scene_Object
((
Scene_ID
)
Widget_IDs
::
y_scl
,
{},
Util
::
scale_mesh
());
z_scl
=
Scene_Object
((
Scene_ID
)
Widget_IDs
::
z_scl
,
Pose
::
rotated
(
Vec3
{
90.0
f
,
0.0
f
,
0.0
f
}),
z_scl
=
Scene_Object
((
Scene_ID
)
Widget_IDs
::
z_scl
,
Pose
::
rotated
(
Vec3
{
90.0
f
,
0.0
f
,
0.0
f
}),
Util
::
scale_mesh
());
Util
::
scale_mesh
());
xyz_scl
=
Scene_Object
((
Scene_ID
)
Widget_IDs
::
xyz_scl
,
Pose
::
moved
(
Vec3
{
1.0
f
})
,
Util
::
cube_mesh
(
0.15
f
));
xyz_scl
=
Scene_Object
((
Scene_ID
)
Widget_IDs
::
xyz_scl
,
{}
,
Util
::
cube_mesh
(
0.15
f
));
#define setcolor(o, c) o.material.opt.albedo = Spectrum((c).x, (c).y, (c).z);
#define setcolor(o, c) o.material.opt.albedo = Spectrum((c).x, (c).y, (c).z);
setcolor
(
x_mov
,
Color
::
red
);
setcolor
(
x_mov
,
Color
::
red
);
...
@@ -73,9 +73,9 @@ void Widgets::generate_lines(Vec3 pos) {
...
@@ -73,9 +73,9 @@ void Widgets::generate_lines(Vec3 pos) {
add_axis
(((
int
)
axis
+
1
)
%
3
);
add_axis
(((
int
)
axis
+
1
)
%
3
);
add_axis
(((
int
)
axis
+
2
)
%
3
);
add_axis
(((
int
)
axis
+
2
)
%
3
);
}
else
if
(
univ_scl
)
{
}
else
if
(
univ_scl
)
{
add_axis
(
(
int
)
axis
);
add_axis
(
0
);
add_axis
(
((
int
)
axis
)
+
1
)
%
3
);
add_axis
(
1
);
add_axis
(
((
int
)
axis
)
+
2
)
%
3
);
add_axis
(
2
);
}
else
{
}
else
{
add_axis
((
int
)
axis
);
add_axis
((
int
)
axis
);
}
}
...
@@ -159,7 +159,7 @@ void Widgets::render(const Mat4& view, Vec3 pos, float scl) {
...
@@ -159,7 +159,7 @@ void Widgets::render(const Mat4& view, Vec3 pos, float scl) {
z_scl
.
render
(
view
,
true
);
z_scl
.
render
(
view
,
true
);
xyz_scl
.
pose
.
scale
=
scale
;
xyz_scl
.
pose
.
scale
=
scale
;
xyz_scl
.
pose
.
pos
=
pos
+
Vec3
(
0.15
f
*
scl
,
0.15
f
*
scl
,
0.15
f
*
scl
)
;
xyz_scl
.
pose
.
pos
=
pos
;
xyz_scl
.
render
(
view
,
true
);
xyz_scl
.
render
(
view
,
true
);
}
}
}
}
...
@@ -234,36 +234,30 @@ bool Widgets::to_axis(Vec3 obj_pos, Vec3 cam_pos, Vec3 dir, Vec3& hit) {
...
@@ -234,36 +234,30 @@ bool Widgets::to_axis(Vec3 obj_pos, Vec3 cam_pos, Vec3 dir, Vec3& hit) {
bool
Widgets
::
to_axis3
(
Vec3
obj_pos
,
Vec3
cam_pos
,
Vec3
dir
,
Vec3
&
hit
)
{
bool
Widgets
::
to_axis3
(
Vec3
obj_pos
,
Vec3
cam_pos
,
Vec3
dir
,
Vec3
&
hit
)
{
Vec3
axis1
;
Vec3
axis1
{
1.0
f
,
0.0
f
,
0.0
f
};
axis1
[(
int
)
axis
]
=
1.0
f
;
Vec3
axis2
{
0.0
f
,
1.0
f
,
0.0
f
};
Vec3
axis2
;
Vec3
axis3
{
0.0
f
,
0.0
f
,
1.0
f
};
axis2
[((
int
)
axis
+
1
)
%
3
]
=
1.0
f
;
Vec3
axis3
;
axis3
[((
int
)
axis
+
2
)
%
3
]
=
1.0
f
;
Line
select
(
cam_pos
,
dir
);
Line
select
(
cam_pos
,
dir
);
Line
target
(
obj_pos
,
axis1
);
Line
target
(
obj_pos
,
axis1
);
Plane
k
(
obj_pos
,
axis1
);
Plane
l
(
obj_pos
,
axis2
);
Plane
l
(
obj_pos
,
axis2
);
Plane
r
(
obj_pos
,
axis3
);
Plane
r
(
obj_pos
,
axis3
);
Plane
k
(
obj_pos
,
axis
);
Vec3
hit1
,
hit2
,
hit3
;
Vec3
hit1
,
hit2
,
hit3
;
bool
hl
=
l
.
hit
(
select
,
hit1
);
bool
hk
=
k
.
hit
(
select
,
hit1
);
bool
hr
=
r
.
hit
(
select
,
hit2
);
bool
hl
=
l
.
hit
(
select
,
hit2
);
bool
hk
=
k
.
hit
(
select
,
hit3
);
bool
hr
=
r
.
hit
(
select
,
hit3
);
if
(
!
hl
&&
!
hr
&&
!
hk
)
return
false
;
if
(
!
hl
&&
!
hr
&&
!
hk
)
return
false
;
else
if
(
!
hl
&&
!
hk
)
hit
=
hit2
;
Vec3
close
{
FLT_MAX
};
else
if
(
!
hr
&&
!
hk
)
if
(
hk
&&
(
hit1
-
cam_pos
).
norm
()
<
(
close
-
cam_pos
).
norm
())
close
=
hit1
;
hit
=
hit1
;
if
(
hl
&&
(
hit2
-
cam_pos
).
norm
()
<
(
close
-
cam_pos
).
norm
())
close
=
hit2
;
else
if
(
!
hl
&&
!
hr
)
if
(
hr
&&
(
hit3
-
cam_pos
).
norm
()
<
(
close
-
cam_pos
).
norm
())
close
=
hit3
;
hit
=
hit3
;
else
{
hit
=
close
;
Vec3
temp
=
(
hit1
-
cam_pos
).
norm
()
>
(
hit2
-
cam_pos
).
norm
()
?
hit2
:
hit1
;
hit
=
(
temp
-
cam_pos
).
norm
()
>
(
hit3
-
cam_pos
).
norm
()
?
hit3
:
temp
;
}
hit
=
target
.
closest
(
hit
);
return
hit
.
valid
();
return
hit
.
valid
();
}
}
...
@@ -313,8 +307,7 @@ void Widgets::start_drag(Vec3 pos, Vec3 cam, Vec2 spos, Vec3 dir) {
...
@@ -313,8 +307,7 @@ void Widgets::start_drag(Vec3 pos, Vec3 cam, Vec2 spos, Vec3 dir) {
if
(
active
==
Widget_Type
::
bevel
)
{
if
(
active
==
Widget_Type
::
bevel
)
{
bevel_start
=
bevel_end
=
spos
;
bevel_start
=
bevel_end
=
spos
;
}
}
else
if
(
active
==
Widget_Type
::
move
)
{
if
(
active
==
Widget_Type
::
move
)
{
drag_start
=
drag_end
=
hit
;
drag_start
=
drag_end
=
hit
;
}
else
{
}
else
{
drag_start
=
hit
;
drag_start
=
hit
;
...
@@ -359,6 +352,8 @@ void Widgets::drag_to(Vec3 pos, Vec3 cam, Vec2 spos, Vec3 dir, bool scale_invert
...
@@ -359,6 +352,8 @@ void Widgets::drag_to(Vec3 pos, Vec3 cam, Vec2 spos, Vec3 dir, bool scale_invert
if
(
drag_plane
)
if
(
drag_plane
)
good
=
to_plane
(
pos
,
cam
,
dir
,
norm
,
hit
);
good
=
to_plane
(
pos
,
cam
,
dir
,
norm
,
hit
);
else
if
(
univ_scl
)
good
=
to_axis3
(
pos
,
cam
,
dir
,
hit
);
else
else
good
=
to_axis
(
pos
,
cam
,
dir
,
hit
);
good
=
to_axis
(
pos
,
cam
,
dir
,
hit
);
...
@@ -367,7 +362,8 @@ void Widgets::drag_to(Vec3 pos, Vec3 cam, Vec2 spos, Vec3 dir, bool scale_invert
...
@@ -367,7 +362,8 @@ void Widgets::drag_to(Vec3 pos, Vec3 cam, Vec2 spos, Vec3 dir, bool scale_invert
if
(
active
==
Widget_Type
::
move
)
{
if
(
active
==
Widget_Type
::
move
)
{
drag_end
=
hit
;
drag_end
=
hit
;
}
else
if
(
univ_scl
&&
active
==
Widget_Type
::
scale
)
{
}
else
if
(
univ_scl
&&
active
==
Widget_Type
::
scale
)
{
drag_end
=
Vec3
((
hit
-
pos
).
norm
());
float
f
=
(
hit
-
pos
).
norm
()
/
(
drag_start
-
pos
).
norm
();
drag_end
=
Vec3
(
std
::
sqrt
(
f
));
}
else
if
(
active
==
Widget_Type
::
scale
)
{
}
else
if
(
active
==
Widget_Type
::
scale
)
{
drag_end
=
Vec3
{
1.0
f
};
drag_end
=
Vec3
{
1.0
f
};
drag_end
[(
int
)
axis
]
=
(
hit
-
pos
).
norm
()
/
(
drag_start
-
pos
).
norm
();
drag_end
[(
int
)
axis
]
=
(
hit
-
pos
).
norm
()
/
(
drag_start
-
pos
).
norm
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment