Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
lray
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Emeric Verschuur
lray
Commits
d5473b22
Commit
d5473b22
authored
Jun 10, 2008
by
paps
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
No commit message
No commit message
parent
f91956e4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
12 deletions
+43
-12
LrGeometrySphere.cpp
LrGeometrySphere.cpp
+36
-12
LrGeometrySphere.h
LrGeometrySphere.h
+7
-0
No files found.
LrGeometrySphere.cpp
View file @
d5473b22
...
...
@@ -20,17 +20,22 @@
#include "LrGeometrySphere.h"
LrGeometrySphere
::
LrGeometrySphere
()
:
LrGeometry
(
)
:
LrGeometry
(),
m_inside
(
false
)
{
}
LrGeometrySphere
::
LrGeometrySphere
(
const
LrGeometrySphere
&
src
)
:
LrGeometry
(
src
)
:
LrGeometry
(
src
),
m_inside
(
src
.
m_inside
)
{
}
// ###########################################################################
LrGeometrySphere
::
LrGeometrySphere
(
bool
inside
)
:
LrGeometry
(),
m_inside
(
inside
)
{
}
LrGeometrySphere
::~
LrGeometrySphere
()
{
}
...
...
@@ -40,12 +45,13 @@ LrGeometrySphere& LrGeometrySphere::operator = (const LrGeometrySphere& src)
if
(
this
==&
src
)
return
*
this
;
LrGeometry
::
operator
=
(
src
);
m_inside
=
src
.
m_inside
;
return
*
this
;
}
bool
operator
==
(
const
LrGeometrySphere
&
rhs
,
const
LrGeometrySphere
&
lhs
)
{
return
(
const
LrGeometry
&
)
rhs
==
(
const
LrGeometry
&
)
lhs
return
(
const
LrGeometry
&
)
rhs
==
(
const
LrGeometry
&
)
lhs
&&
rhs
.
m_inside
==
lhs
.
m_inside
;
/* and [...] */
;
}
...
...
@@ -67,21 +73,38 @@ bool LrGeometrySphere::getIntersection(const LrRay &ray, LrHit *hit, int fragmen
LrVector
OC
(
ray
.
getOrigin
(),
LrPoint
::
ZERO
);
Real
k
=
OC
*
ray
.
getDirection
();
Real
h2
=
n2
*
OC
*
OC
-
k
*
k
;
// if (h2 > m_radius * m_radius) si rayon n'est pas 1
if
(
h2
>
n2
)
return
false
;
return
false
;
// Real delta = sqrt(m_radius * m_radius - h2); si rayon != 1
Real
delta
=
sqrt
(
n2
-
h2
);
Real
dist
=
(
k
-
delta
)
/
n2
;
Real
dist
=
0.0
;
// si le premier point n'est pas bon, voir avec le second
if
((
dist
<
minBound
)
||
(
dist
>
maxBound
))
/*
if ((dist < minBound) || (dist > maxBound))
{
dist = k + delta;
if ((dist < minBound) || (dist > maxBound))
return
false
;
return false;
}*/
if
(
m_inside
)
{
dist
=
(
k
+
delta
)
/
n2
;
if
(
dist
>
maxBound
)
{
if
(
dist
>
maxBound
)
return
false
;
}
}
else
{
dist
=
(
k
-
delta
)
/
n2
;
if
((
dist
<
minBound
)
||
(
dist
>
maxBound
))
{
if
((
dist
<
minBound
)
||
(
dist
>
maxBound
))
return
false
;
}
}
if
(
hit
!=
NULL
)
...
...
@@ -100,6 +123,7 @@ bool LrGeometrySphere::getIntersection(const LrRay &ray, LrHit *hit, int fragmen
//uv2xyz(u, v, NULL, &normal, &tangent);
//hit->normal = normal;
hit
->
normal
=
LrVector
(
LrPoint
::
ZERO
,
hit
->
point
);
if
(
m_inside
)
hit
->
normal
=
-
hit
->
normal
;
hit
->
normal
.
normalize
();
hit
->
tangent
=
tangent
;
}
...
...
LrGeometrySphere.h
View file @
d5473b22
...
...
@@ -34,6 +34,12 @@ public:
* @param src Référence d'un objet LrGeometrySphere.
*/
LrGeometrySphere
(
const
LrGeometrySphere
&
src
);
/**
* @brief Constructeur personnel
* @param inside indique la sphere est vue de l'interieur ou de pas.
*/
LrGeometrySphere
(
bool
inside
);
/**
* @brief Destructeur.
...
...
@@ -115,6 +121,7 @@ protected:
LrVector
*
normal
,
LrVector
*
tangent
)
const
;
private:
bool
m_inside
;
};
#endif
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