Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CppRaytracer
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
Service Desk
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Yoel
CppRaytracer
Commits
6a1098be
Commit
6a1098be
authored
4 years ago
by
Yoel
Browse files
Options
Downloads
Patches
Plain Diff
CirclePlane now has the option to be twofaced
parent
e90c8f13
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
RayTracer/shape/CirclePlane.cpp
+12
-10
12 additions, 10 deletions
RayTracer/shape/CirclePlane.cpp
RayTracer/shape/CirclePlane.h
+2
-1
2 additions, 1 deletion
RayTracer/shape/CirclePlane.h
with
14 additions
and
11 deletions
RayTracer/shape/CirclePlane.cpp
+
12
−
10
View file @
6a1098be
...
@@ -6,9 +6,9 @@
...
@@ -6,9 +6,9 @@
#include
"math.h"
#include
"math.h"
namespace
shapes
{
namespace
shapes
{
CirclePlane
::
CirclePlane
(
float
radius
,
CirclePlane
::
CirclePlane
(
float
radius
,
bool
twofaced
,
const
std
::
shared_ptr
<
material
::
Material
>&
material
)
const
std
::
shared_ptr
<
material
::
Material
>&
material
)
:
radius
(
radius
),
material
(
material
)
{
:
radius
(
radius
),
twofaced
(
twofaced
),
material
(
material
)
{
}
}
std
::
optional
<
cam
::
Hit
>
CirclePlane
::
intersect
(
const
cam
::
Ray
&
r
)
const
{
std
::
optional
<
cam
::
Hit
>
CirclePlane
::
intersect
(
const
cam
::
Ray
&
r
)
const
{
util
::
Vec3
n
(
0
,
1
,
0
);
util
::
Vec3
n
(
0
,
1
,
0
);
...
@@ -18,15 +18,17 @@ std::optional<cam::Hit> CirclePlane::intersect(const cam::Ray& r) const {
...
@@ -18,15 +18,17 @@ std::optional<cam::Hit> CirclePlane::intersect(const cam::Ray& r) const {
float
a
=
util
::
dot
(
d
,
n
);
float
a
=
util
::
dot
(
d
,
n
);
if
(
a
==
0
)
{
if
(
a
==
0
)
{
return
std
::
nullopt
;
return
std
::
nullopt
;
}
else
if
(
a
<
0
)
{
}
else
if
(
a
>
0
)
{
float
t
=
-
x0
[
1
]
/
d
[
1
];
if
(
twofaced
)
util
::
Vec3
t_hitpoint
=
r
(
t
);
n
=
-
n
;
else
if
(
r
.
in_range
(
t
)
&&
t_hitpoint
.
length
()
<=
radius
)
{
return
std
::
optional
<
cam
::
Hit
>
({
t_hitpoint
,
n
,
t
,
material
});
}
else
{
return
std
::
nullopt
;
return
std
::
nullopt
;
}
}
float
t
=
-
x0
[
1
]
/
d
[
1
];
util
::
Vec3
t_hitpoint
=
r
(
t
);
if
(
r
.
in_range
(
t
)
&&
t_hitpoint
.
length
()
<=
radius
)
{
return
std
::
optional
<
cam
::
Hit
>
({
t_hitpoint
,
n
,
t
,
material
});
}
else
{
}
else
{
return
std
::
nullopt
;
return
std
::
nullopt
;
}
}
...
...
This diff is collapsed.
Click to expand it.
RayTracer/shape/CirclePlane.h
+
2
−
1
View file @
6a1098be
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
namespace
shapes
{
namespace
shapes
{
class
CirclePlane
:
public
Light
,
public
Shape
{
class
CirclePlane
:
public
Light
,
public
Shape
{
public:
public:
CirclePlane
(
float
radius
,
CirclePlane
(
float
radius
,
bool
twofaced
,
const
std
::
shared_ptr
<
material
::
Material
>&
material
);
const
std
::
shared_ptr
<
material
::
Material
>&
material
);
std
::
optional
<
cam
::
Hit
>
intersect
(
const
cam
::
Ray
&
r
)
const
override
;
std
::
optional
<
cam
::
Hit
>
intersect
(
const
cam
::
Ray
&
r
)
const
override
;
util
::
AxisAlignedBoundingBox
bounds
()
const
override
;
util
::
AxisAlignedBoundingBox
bounds
()
const
override
;
...
@@ -18,5 +18,6 @@ class CirclePlane : public Light, public Shape {
...
@@ -18,5 +18,6 @@ class CirclePlane : public Light, public Shape {
private:
private:
std
::
shared_ptr
<
material
::
Material
>
material
;
std
::
shared_ptr
<
material
::
Material
>
material
;
const
float
radius
;
const
float
radius
;
const
bool
twofaced
;
};
};
}
// namespace shapes
}
// namespace shapes
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