Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uva
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Taddeüs Kroes
uva
Commits
3897acd6
Commit
3897acd6
authored
14 years ago
by
Taddeüs Kroes
Browse files
Options
Downloads
Patches
Plain Diff
- Fixed some minor errors in the report.
parent
5f6c1008
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
graphics/ass7/intersection.c
+101
-10
101 additions, 10 deletions
graphics/ass7/intersection.c
os/ass3/report/report.tex
+15
-10
15 additions, 10 deletions
os/ass3/report/report.tex
with
116 additions
and
20 deletions
graphics/ass7/intersection.c
+
101
−
10
View file @
3897acd6
/* Computer Graphics, Assignment, Ray-tracing 2
*
* Student name ....
* Student email ...
* Collegekaart ....
* Date ............
* Comments ........
*
*
* (always fill in these fields before submitting!!)
* Student name .... Sander van Veen & Taddeus Kroes
* Student email ... sandervv@gmail.com & taddeuskroes@hotmail.com
* Collegekaart .... ... & 6054129
* Date ............ 07.11.2010
*/
#include
<math.h>
...
...
@@ -123,7 +119,7 @@ ray_intersects_triangle(intersection_point* ip, triangle tri,
// Check if the given sphere is intersected by the given ray.
// See Shirley et.al., section 10.3.1
// Returns 1 if there is an intersection (and sets the appropriate
// fields of ip), or 0 otherwise.
// fields of ip), or 0 otherwise.
inner_node_left_child
static
int
ray_intersects_sphere
(
intersection_point
*
ip
,
sphere
sph
,
vec3
ray_origin
,
vec3
ray_direction
)
...
...
@@ -166,6 +162,78 @@ ray_intersects_sphere(intersection_point* ip, sphere sph,
return
1
;
}
// Check if a BVH node's bounding box has an intersection on a ray between t0
// and t1. Save this point if it is closer than an already found intersection.
static
void
intersect_node
(
bvh_node
*
node
,
intersection_point
*
ip
,
vec3
ray_origin
,
vec3
ray_direction
,
float
t0
,
float
t1
)
{
bvh_node
*
left
,
*
right
;
float
t_min_l
,
t_max_l
,
t_min_r
,
t_max_r
;
int
right_intersect
;
if
(
!
(
node
->
is_leaf
)
)
{
// Inner node, check bounding boxes of children
left
=
inner_node_left_child
(
node
);
right
=
inner_node_right_child
(
node
);
// If the right child's bounding box is closer than the left one,
// continue at the right first because there's a higher probability that
// the intersection triangles in left's children will be further away
// than the right's.
// If either of the bounding boxes is already further away than the
// current closest intersection, don't continue with it anyway.
right_intersect
=
bbox_intersect
(
&
t_min_r
,
&
t_max_r
,
right
->
bbox
,
ray_origin
,
ray_direction
,
t0
,
t1
);
if
(
bbox_intersect
(
&
t_min_l
,
&
t_max_l
,
left
->
bbox
,
ray_origin
,
ray_direction
,
t0
,
t1
)
&&
t_min_l
<
ip
->
t
)
{
if
(
right_intersect
)
{
if
(
t_min_r
<
t_min_l
)
{
intersect_node
(
right
,
ip
,
ray_origin
,
ray_direction
,
t_min_r
,
t_max_r
);
intersect_node
(
left
,
ip
,
ray_origin
,
ray_direction
,
t_min_l
,
t_max_l
);
}
else
{
intersect_node
(
left
,
ip
,
ray_origin
,
ray_direction
,
t_min_l
,
t_max_l
);
intersect_node
(
right
,
ip
,
ray_origin
,
ray_direction
,
t_min_r
,
t_max_r
);
}
}
else
{
intersect_node
(
left
,
ip
,
ray_origin
,
ray_direction
,
t_min_l
,
t_max_l
);
}
}
else
if
(
right_intersect
&&
t_min_r
<
ip
->
t
)
{
intersect_node
(
right
,
ip
,
ray_origin
,
ray_direction
,
t_min_r
,
t_max_r
);
}
}
else
{
// Leaf node, find shortest triangle and check if it is closer than the
// current closest intersection
triangle
*
triangles
=
leaf_node_triangles
(
node
);
intersection_point
ip2
;
for
(
int
i
=
0
,
l
=
leaf_node_num_triangles
(
node
);
i
<
l
;
i
++
)
{
if
(
ray_intersects_triangle
(
&
ip2
,
triangles
[
i
],
ray_origin
,
ray_direction
)
&&
ip2
.
t
<
ip
->
t
)
{
*
ip
=
ip2
;
}
}
}
}
// Checks for an intersection of the given ray with the triangles
// stored in the BVH.
//
...
...
@@ -179,7 +247,30 @@ static int
find_first_intersected_bvh_triangle
(
intersection_point
*
ip
,
vec3
ray_origin
,
vec3
ray_direction
)
{
return
0
;
float
t0
,
t1
;
// Set found distance to infinity so that any intersection will be closer
ip
->
t
=
C_INFINITY
;
// If the root has no intersection, none of the BVH nodes does
//
// Note that this step if mkes the program less efficient when the root's
// bounding box has a relatively large surface in the camera screen (has
// lot of ray intersections). This is because every ray intersecting a
// triangle is now tested one time more and every non-intersection ray is
// tested one time less. So, when raytracing large objects, omitting this
// step would be advisable.
if
(
!
bbox_intersect
(
&
t0
,
&
t1
,
bvh_root
->
bbox
,
ray_origin
,
ray_direction
,
0
.
0
,
C_INFINITY
)
)
{
return
0
;
}
// Walk through the BVH tree recursively, starting at the root
intersect_node
(
bvh_root
,
ip
,
ray_origin
,
ray_direction
,
t0
,
t1
);
// If an intersection was found, the infinite distance should be overwritten
return
ip
->
t
!=
C_INFINITY
;
}
// Returns the nearest hit of the given ray with objects in the scene
...
...
This diff is collapsed.
Click to expand it.
os/ass3/report/report.tex
+
15
−
10
View file @
3897acd6
...
...
@@ -88,7 +88,7 @@ In Linux maakt \texttt{fork()} gebruik van \emph{copy-on-write} voor het
geheugen. Daardoor zal
\texttt
{
fork()
}
alleen CPU-tijd en geheugen nodig hebben
om de
\emph
{
page tables
}
te kopie
\"
eren en de nieuwe
\emph
{
task structure
}
aan
te maken voor het kindproces. Het gevolg is dat het forken van een proces
relatief gezien een goedkope operatie.
relatief gezien een goedkope operatie
is
.
\subsection
{
Data oversturen tussen processen
}
...
...
@@ -152,7 +152,7 @@ direct doorgestuurd naar een buffer waaruit de MySQL server leest.
In de taal C is het mogelijk om een actie uit te voeren, als een signaal wordt
verstuurd naar een applicatie. Door middel van de functie
\texttt
{
sigaction()
}
kan de oude signal handler worden opgevraagd
of
een nieuwe signal handler worden
kan de oude signal handler worden opgevraagd
en
een nieuwe signal handler worden
ingesteld. Voor de meeste signals is de handler standaard op
\texttt
{
SIGIGN
}
gezet (
\emph
{
ignore
}
; geen actie uitvoeren).
...
...
@@ -166,10 +166,11 @@ over, maar krijgen de standaard signal handlers toegewezen.
\begin{tabular}
{
|l|l|
}
\hline
SIGINT
&
Interrupt van toetsenbord (CTRL + C wordt ingedrukt)
\\
SIGKILL
&
Kill signal (kill -9 proces
\_
id)
\\
SIGKILL
&
Kill signal (kill -9
\emph
{
proces
\_
id
}
)
\\
SIGSEGV
&
Invalid memory reference (resulteert in een segfault)
\\
SIGPIPE
&
Broken pipe: write to pipe, no readers (verbroken ssh connectie)
\\
SIGTERM
&
Termination signal (kill proces
\_
id)
\\
SIGCHLD
&
Kindproces is getermineerd
\\
\hline
\end{tabular}
\caption
{
Veel gebruikte signals in POSIX-compatible besturingssystemen.
}
...
...
@@ -178,21 +179,23 @@ SIGTERM & Termination signal (kill proces\_id) \\
Het is mogelijk om in de taal C met de functie
\texttt
{
kill()
}
een signal te
sturen naar een proces. Dit kan ook vanuit de shell met het gelijknamige
commando
\texttt
{
kill
}
, eventueel gevolgd door
\texttt
{
-s
}
en het nummer van de
signal die dient te worden verstuurt. Het sturen van signals in de taal C kwam
niet verder aan bod in dit practicum en wordt daarom niet verder behandeld.
signal die dient te worden verstuurd. Het sturen van signals in de taal C komt
niet verder aan bod in dit practicum en zal daarom niet verder worden
behandeld.
\pagebreak
\section
{
De opdracht
}
Door middel van de C
functie
\texttt
{
getchar()
}
binnen een
\emph
{
while
}
-loop
Door middel van de C
-
functie
\texttt
{
getchar()
}
binnen een
\emph
{
while
}
-loop
wordt de invoer van de gebruiker uitgelezen. Witregels en spaties (ascii: 32)
worden genegeerd.
\subsection
{
Fork en pipe implementatie
}
Als er een
\texttt
{
f
}
wordt gelezen, weet de bigfish dat er een nieuwe gup dient
te worden aangemaakt; fork() gebruiken en het kindproces gup() laten aanroepen.
Als er een
\texttt
{
f
}
wordt gelezen, weet de bigfish dat er een nieuwe gup
dient te worden aangemaakt:
\texttt
{
fork()
}
gebruiken en het kindproces
\texttt
{
gup()
}
laten aanroepen.
\begin{lstlisting}
[numbers=none,backgroundcolor=
\color
{
darkgray
}
]
switch( (child
_
id = fork()) )
...
...
@@ -222,7 +225,7 @@ if( write(pipe_id[1], &c, 1) <= 0 )
perror("broken pipe.");
\end{lstlisting}
\noindent
en
e
en van de kindprocessen leest vervolgens uit de pipe met
\noindent
en
\'
e
\'
en van de kindprocessen leest vervolgens uit de pipe met
\texttt
{
read()
}
.
\begin{lstlisting}
[numbers=none,backgroundcolor=
\color
{
darkgray
}
]
...
...
@@ -279,7 +282,9 @@ meaningful when establishing a handler for SIGCHLD.} \\
\\
Met die flag worden kindprocessen niet op defunct gezet, maar direct
vrijgegeven. Daardoor is er geen
\texttt
{
wait
()
}
meer nodig binnen de signal
handler.
handler.
\\
Aangezien de opdracht was om w
\'
el een
\texttt
{
wait
}
-
statement te gebruiken,
hebben we deze flag echter niet gebruikt.
\pagebreak
...
...
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