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
e5d4d5c3
Commit
e5d4d5c3
authored
4 years ago
by
Yoel
Browse files
Options
Downloads
Patches
Plain Diff
group now has bool for auto rebuild. added setBounds method
parent
eab7b922
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
RayTracer/shape/Group.cpp
+17
-9
17 additions, 9 deletions
RayTracer/shape/Group.cpp
RayTracer/shape/Group.h
+6
-3
6 additions, 3 deletions
RayTracer/shape/Group.h
with
23 additions
and
12 deletions
RayTracer/shape/Group.cpp
+
17
−
9
View file @
e5d4d5c3
...
...
@@ -4,12 +4,15 @@
#include
"../tools/Vec3.h"
namespace
shapes
{
Group
::
Group
(
const
util
::
Transformation
&
transform
)
:
shapeList
(
std
::
vector
<
std
::
shared_ptr
<
Shape
>>
()),
transform
(
transform
)
{
Group
::
Group
(
const
util
::
Transformation
&
transform
,
bool
rebuildBB
)
:
shapeList
(
std
::
vector
<
std
::
shared_ptr
<
Shape
>>
()),
transform
(
transform
),
rebuildBB
(
rebuildBB
)
{
}
Group
::
Group
(
const
util
::
Mat4
&
matrix
)
Group
::
Group
(
const
util
::
Mat4
&
matrix
,
bool
rebuildBB
)
:
shapeList
(
std
::
vector
<
std
::
shared_ptr
<
Shape
>>
()),
transform
(
util
::
Transformation
(
matrix
))
{
transform
(
util
::
Transformation
(
matrix
)),
rebuildBB
(
rebuildBB
)
{
}
std
::
optional
<
cam
::
Hit
>
Group
::
intersect
(
const
cam
::
Ray
&
r
)
const
{
...
...
@@ -23,10 +26,12 @@ std::optional<cam::Hit> Group::intersect(const cam::Ray& r) const {
if
(
s
->
bounds
().
intersects
(
imagR
))
{
std
::
optional
<
cam
::
Hit
>
temp
=
s
->
intersect
(
imagR
);
if
(
temp
)
{
if
(
!
result
)
{
result
=
temp
;
}
else
if
(
result
->
scalar
()
>
temp
->
scalar
())
{
result
=
temp
;
if
(
imagR
.
in_range
(
temp
->
scalar
()))
{
if
(
!
result
)
{
result
=
temp
;
}
else
if
(
result
->
scalar
()
>
temp
->
scalar
())
{
result
=
temp
;
}
}
}
}
...
...
@@ -43,6 +48,9 @@ std::optional<cam::Hit> Group::intersect(const cam::Ray& r) const {
util
::
AxisAlignedBoundingBox
Group
::
bounds
()
const
{
return
boundingVolume
;
}
void
Group
::
setBounds
(
const
util
::
AxisAlignedBoundingBox
&
bb
)
{
boundingVolume
=
bb
;
}
void
Group
::
add
(
const
Group
&
group
)
{
add
(
std
::
make_shared
<
Group
>
(
group
));
}
...
...
@@ -51,7 +59,7 @@ void Group::add(const ShapeSingleGroup& group) {
}
void
Group
::
add
(
const
std
::
shared_ptr
<
Shape
>&
shape
)
{
shapeList
.
push_back
(
shape
);
rebuildBoundingVolume
();
if
(
rebuildBB
)
rebuildBoundingVolume
();
}
void
Group
::
rebuildBoundingVolume
()
{
...
...
This diff is collapsed.
Click to expand it.
RayTracer/shape/Group.h
+
6
−
3
View file @
e5d4d5c3
...
...
@@ -10,22 +10,25 @@
namespace
shapes
{
class
Group
:
public
Shape
{
public:
Group
(
const
util
::
Transformation
&
trans
);
Group
(
const
util
::
Mat4
&
matrix
);
Group
(
const
util
::
Transformation
&
trans
,
bool
rebuildBB
=
true
);
Group
(
const
util
::
Mat4
&
matrix
,
bool
rebuildBB
=
true
);
std
::
optional
<
cam
::
Hit
>
intersect
(
const
cam
::
Ray
&
r
)
const
override
;
util
::
AxisAlignedBoundingBox
bounds
()
const
override
;
void
setBounds
(
const
util
::
AxisAlignedBoundingBox
&
bb
);
void
add
(
const
Group
&
group
);
void
add
(
const
ShapeSingleGroup
&
group
);
// protected:
void
add
(
const
std
::
shared_ptr
<
shapes
::
Shape
>&
shape
);
std
::
vector
<
std
::
shared_ptr
<
Shape
>>
shapeList
;
private:
void
rebuildBoundingVolume
();
bool
rebuildBB
;
util
::
AxisAlignedBoundingBox
boundingVolume
;
std
::
vector
<
std
::
shared_ptr
<
Shape
>>
shapeList
;
util
::
Transformation
transform
;
};
}
// 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