Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
engine
Manage
Activity
Members
Labels
Plan
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sip
engine
Commits
b07c0801
Commit
b07c0801
authored
7 months ago
by
D-AIRY
Browse files
Options
Downloads
Patches
Plain Diff
Updated SMAABBIntersectLine
parent
38470966
No related branches found
No related tags found
1 merge request
!24
Ladder
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/game/FuncLadder.cpp
+52
-46
52 additions, 46 deletions
source/game/FuncLadder.cpp
with
52 additions
and
46 deletions
source/game/FuncLadder.cpp
+
52
−
46
View file @
b07c0801
...
...
@@ -225,70 +225,76 @@ SMAABB CFuncLadder::getBound()
bool
SMAABBIntersectLine
(
const
SMAABB
&
aabb
,
const
float3
&
vStart
,
const
float3
&
vEnd
,
float3
*
pvOut
,
float3
*
pvNormal
)
{
float
min_t
=
0.0f
;
float
max_t
=
1.0f
;
float
3
vPoint
;
SMPLANE
plane
;
float3
vDir
=
vEnd
-
vStart
;
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
if
(
SMIsZero
(
vDir
[
i
]))
plane
=
SMPLANE
(
float3
(
1.0f
,
0.0f
,
0.0f
),
-
aabb
.
vMax
.
x
);
if
(
plane
.
intersectLine
(
&
vPoint
,
vStart
,
vEnd
)
&&
SMIsAABBInsideAABB
(
SMAABB
(
vPoint
,
vPoint
),
aabb
))
{
if
(
vStart
[
i
]
<
aabb
.
vMin
[
i
]
||
vStart
[
i
]
>
aabb
.
vMax
[
i
])
*
pvOut
=
vPoint
;
if
(
pvNormal
)
{
return
(
false
);
*
pvNormal
=
float3
(
1.0f
,
0.0f
,
0.0f
);
}
return
(
true
);
}
float
t1
=
(
aabb
.
vMin
[
i
]
-
vStart
[
i
])
/
vDir
[
i
];
float
t2
=
(
aabb
.
vMax
[
i
]
-
vStart
[
i
])
/
vDir
[
i
];
float
tmin
=
min
(
t1
,
t2
);
float
tmax
=
max
(
t1
,
t2
);
min_t
=
max
(
min_t
,
tmin
);
max_t
=
min
(
max_t
,
tmax
);
if
(
min_t
>
max_t
)
plane
=
SMPLANE
(
float3
(
-
1.0f
,
0.0f
,
0.0f
),
aabb
.
vMin
.
x
);
if
(
plane
.
intersectLine
(
&
vPoint
,
vStart
,
vEnd
)
&&
SMIsAABBInsideAABB
(
SMAABB
(
vPoint
,
vPoint
),
aabb
))
{
return
(
false
);
*
pvOut
=
vPoint
;
if
(
pvNormal
)
{
*
pvNormal
=
float3
(
-
1.0f
,
0.0f
,
0.0f
);
}
return
(
true
);
}
if
(
pvOut
)
plane
=
SMPLANE
(
float3
(
0.0f
,
1.0f
,
0.0f
),
-
aabb
.
vMax
.
y
);
if
(
plane
.
intersectLine
(
&
vPoint
,
vStart
,
vEnd
)
&&
SMIsAABBInsideAABB
(
SMAABB
(
vPoint
,
vPoint
),
aabb
))
{
*
pvOut
=
vStart
+
min_t
*
vDir
;
}
*
pvOut
=
vPoint
;
if
(
pvNormal
)
{
*
pvNormal
=
0.0f
;
*
pvNormal
=
float3
(
0.0f
,
1.0f
,
0.0f
);
}
return
(
true
);
}
if
(
SMIsZero
(
aabb
.
vMin
.
x
-
pvOut
->
x
))
plane
=
SMPLANE
(
float3
(
0.0f
,
-
1.0f
,
0.0f
),
aabb
.
vMin
.
y
);
if
(
plane
.
intersectLine
(
&
vPoint
,
vStart
,
vEnd
)
&&
SMIsAABBInsideAABB
(
SMAABB
(
vPoint
,
vPoint
),
aabb
))
{
pvNormal
->
x
=
-
1.0f
;
}
else
if
(
SMIsZero
(
aabb
.
vMax
.
x
-
pvOut
->
x
))
*
pvOut
=
vPoint
;
if
(
pvNormal
)
{
pvNormal
->
x
=
1.0f
;
*
pvNormal
=
float3
(
0.0f
,
-
1.0f
,
0.0f
)
;
}
else
if
(
SMIsZero
(
aabb
.
vMin
.
y
-
pvOut
->
y
))
{
pvNormal
->
y
=
-
1.0f
;
return
(
true
);
}
else
if
(
SMIsZero
(
aabb
.
vMax
.
y
-
pvOut
->
y
))
plane
=
SMPLANE
(
float3
(
0.0f
,
0.0f
,
1.0f
),
-
aabb
.
vMax
.
z
);
if
(
plane
.
intersectLine
(
&
vPoint
,
vStart
,
vEnd
)
&&
SMIsAABBInsideAABB
(
SMAABB
(
vPoint
,
vPoint
),
aabb
))
{
pvNormal
->
y
=
1.0f
;
}
else
if
(
SMIsZero
(
aabb
.
vMin
.
z
-
pvOut
->
z
))
*
pvOut
=
vPoint
;
if
(
pvNormal
)
{
pvNormal
->
z
=
-
1.0f
;
*
pvNormal
=
float3
(
0.0f
,
0.0f
,
1.0f
)
;
}
else
return
(
true
);
}
plane
=
SMPLANE
(
float3
(
0.0f
,
0.0f
,
-
1.0f
),
aabb
.
vMin
.
z
);
if
(
plane
.
intersectLine
(
&
vPoint
,
vStart
,
vEnd
)
&&
SMIsAABBInsideAABB
(
SMAABB
(
vPoint
,
vPoint
),
aabb
))
{
*
pvOut
=
vPoint
;
if
(
pvNormal
)
{
pvNormal
->
z
=
1.0f
;
*
pvNormal
=
float3
(
0.0f
,
0.0f
,
-
1.0f
)
;
}
return
(
true
);
}
return
(
false
);
}
bool
CFuncLadder
::
rayTest
(
const
float3
&
vStart
,
const
float3
&
vEnd
,
float3
*
pvOut
,
float3
*
pvNormal
,
bool
isRayInWorldSpace
,
bool
bReturnNearestPoint
)
...
...
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
sign in
to comment