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
2c3c4650
Commit
2c3c4650
authored
4 years ago
by
Yoel
Browse files
Options
Downloads
Patches
Plain Diff
Minor test-function changes and intro of shape-test. CircPlane tests done
parent
070bcbca
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/testing/Testing.cpp
+35
-3
35 additions, 3 deletions
RayTracer/testing/Testing.cpp
RayTracer/testing/Testing.h
+1
-0
1 addition, 0 deletions
RayTracer/testing/Testing.h
with
36 additions
and
3 deletions
RayTracer/testing/Testing.cpp
+
35
−
3
View file @
2c3c4650
...
...
@@ -6,6 +6,8 @@
#include
<limits>
#include
"../camera/Ray.h"
#include
"../material/DiffuseMaterial.h"
#include
"../shape/CirclePlane.h"
#include
"../tools/AxisAlignedBoundingBox.h"
#include
"../tools/Mat4.h"
#include
"../tools/Vec3.h"
...
...
@@ -226,7 +228,7 @@ void mat4_test() {
std
::
cout
<<
"passed."
<<
std
::
endl
;
}
{
std
::
cout
<<
" factory methods: "
;
std
::
cout
<<
"
factory methods: "
;
util
::
Mat4
s
=
util
::
scale
(
util
::
Vec3
(
2
,
3
,
4
));
assert
((
s
[{
0
,
0
}])
==
2
&&
(
s
[{
1
,
1
}])
==
3
&&
(
s
[{
2
,
2
}])
==
4
);
util
::
Mat4
t
=
util
::
translate
(
util
::
Vec3
(
1
,
-
3
,
4
));
...
...
@@ -246,7 +248,7 @@ void mat4_test() {
std
::
cout
<<
"passed."
<<
std
::
endl
;
}
{
std
::
cout
<<
" transform: "
;
std
::
cout
<<
"
transform: "
;
auto
round_to_5
=
[](
float
x
)
{
int
temp
=
x
*
100000
;
return
temp
/
100000.0
;
...
...
@@ -263,7 +265,7 @@ void mat4_test() {
std
::
cout
<<
"passed."
<<
std
::
endl
;
}
{
std
::
cout
<<
" position: "
;
std
::
cout
<<
"
position: "
;
util
::
Mat4
x
({
0
,
0
,
0
,
3
,
0
,
0
,
1
,
5
,
1
,
2
,
3
,
-
4
,
2
,
2
,
2
,
2
});
util
::
Vec3
vec
=
x
.
position
();
assert
(
vec
[
0
]
==
3
&&
vec
[
1
]
==
5
&&
vec
[
2
]
==
-
4
);
...
...
@@ -435,4 +437,34 @@ void axisalignedboundingbox_test() {
std
::
cout
<<
"all util::AxisAlignedBoundingBox tests passed."
<<
std
::
endl
<<
std
::
endl
;
}
void
shape_test
()
{
std
::
cout
<<
"======================"
<<
std
::
endl
;
std
::
cout
<<
" Testing Shapes "
<<
std
::
endl
;
std
::
cout
<<
"======================"
<<
std
::
endl
;
{
std
::
cout
<<
" CirclePlane: "
;
auto
red_material
=
std
::
make_shared
<
material
::
DiffuseMaterial
>
(
util
::
Vec3
(
1
,
0
,
0
));
shapes
::
CirclePlane
circ_plane
(
5.0
,
red_material
);
cam
::
Ray
direct_ray
(
util
::
Vec3
(
0
,
3
,
0
),
util
::
Vec3
(
0.3
,
-
1
,
0.2
),
0
,
100
,
false
);
cam
::
Ray
bounding_ray
(
util
::
Vec3
(
4.6
,
-
1
,
4
),
util
::
Vec3
(
-
0.1
,
1
,
0.5
),
0
,
100
,
false
);
cam
::
Ray
missing_ray
(
util
::
Vec3
(
4.6
,
-
1
,
4
),
util
::
Vec3
(
-
0.1
,
-
1
,
0.5
),
0
,
100
,
false
);
assert
(
circ_plane
.
bounds
().
intersects
(
direct_ray
));
assert
(
circ_plane
.
bounds
().
intersects
(
bounding_ray
));
assert
(
!
circ_plane
.
bounds
().
intersects
(
missing_ray
));
assert
(
circ_plane
.
intersect
(
direct_ray
)
!=
nullptr
);
assert
(
circ_plane
.
intersect
(
bounding_ray
)
==
nullptr
);
assert
(
circ_plane
.
intersect
(
missing_ray
)
==
nullptr
);
std
::
cout
<<
"passed."
<<
std
::
endl
;
}
std
::
cout
<<
"all shapes::Shape tests passed."
<<
std
::
endl
;
}
}
// namespace test
This diff is collapsed.
Click to expand it.
RayTracer/testing/Testing.h
+
1
−
0
View file @
2c3c4650
...
...
@@ -5,4 +5,5 @@ void vec3_test();
void
mat4_test
();
void
ray_test
();
void
axisalignedboundingbox_test
();
void
shape_test
();
}
// namespace test
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