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
Merge requests
!24
Ladder
Code
Review changes
Check out branch
Download
Patches
Plain diff
Expand sidebar
Merged
Ladder
ladder
into
branchX
Overview
0
Commits
8
Pipelines
0
Changes
1
Merged
Ladder
D-AIRY
requested to merge
ladder
into
branchX
7 months ago
Overview
0
Commits
8
Pipelines
0
Changes
1
0
0
Merge request reports
Viewing commit
b07c0801
Prev
Next
Show latest version
1 file
+
52
−
46
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
b07c0801
Updated SMAABBIntersectLine
· b07c0801
D-AIRY
authored
7 months ago
source/game/FuncLadder.cpp
+
52
−
46
View file @ b07c0801
Edit in single-file editor
Open in Web IDE
Show full file
@@ -225,77 +225,83 @@ 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
)
plane
=
SMPLANE
(
float3
(
1.0f
,
0.0f
,
0.0f
),
-
aabb
.
vMax
.
x
);
if
(
plane
.
intersectLine
(
&
vPoint
,
vStart
,
vEnd
)
&&
SMIsAABBInsideAABB
(
SMAABB
(
vPoint
,
vPoint
),
aabb
))
{
if
(
SMIsZero
(
vDir
[
i
]))
*
pvOut
=
vPoint
;
if
(
pvNormal
)
{
if
(
vStart
[
i
]
<
aabb
.
vMin
[
i
]
||
vStart
[
i
]
>
aabb
.
vMax
[
i
])
{
return
(
false
);
}
*
pvNormal
=
float3
(
1.0f
,
0.0f
,
0.0f
);
}
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
)
return
(
true
);
}
plane
=
SMPLANE
(
float3
(
-
1.0f
,
0.0f
,
0.0f
),
aabb
.
vMin
.
x
);
if
(
plane
.
intersectLine
(
&
vPoint
,
vStart
,
vEnd
)
&&
SMIsAABBInsideAABB
(
SMAABB
(
vPoint
,
vPoint
),
aabb
))
{
*
pvOut
=
vPoint
;
if
(
pvNormal
)
{
return
(
false
);
*
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
=
float3
(
0.0f
,
1.0f
,
0.0f
);
}
return
(
true
);
}
if
(
pvNormal
)
plane
=
SMPLANE
(
float3
(
0.0f
,
-
1.0f
,
0.0f
),
aabb
.
vMin
.
y
);
if
(
plane
.
intersectLine
(
&
vPoint
,
vStart
,
vEnd
)
&&
SMIsAABBInsideAABB
(
SMAABB
(
vPoint
,
vPoint
),
aabb
))
{
*
pvNormal
=
0.0f
;
if
(
SMIsZero
(
aabb
.
vMin
.
x
-
pvOut
->
x
))
{
pvNormal
->
x
=
-
1.0f
;
}
else
if
(
SMIsZero
(
aabb
.
vMax
.
x
-
pvOut
->
x
))
{
pvNormal
->
x
=
1.0f
;
}
else
if
(
SMIsZero
(
aabb
.
vMin
.
y
-
pvOut
->
y
))
{
pvNormal
->
y
=
-
1.0f
;
}
else
if
(
SMIsZero
(
aabb
.
vMax
.
y
-
pvOut
->
y
))
*
pvOut
=
vPoint
;
if
(
pvNormal
)
{
pvNormal
->
y
=
1.0f
;
*
pvNormal
=
float3
(
0.0f
,
-
1.0f
,
0.0f
)
;
}
else
if
(
SMIsZero
(
aabb
.
vMin
.
z
-
pvOut
->
z
))
return
(
true
);
}
plane
=
SMPLANE
(
float3
(
0.0f
,
0.0f
,
1.0f
),
-
aabb
.
vMax
.
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
)
;
}
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
)
{
assert
(
isRayInWorldSpace
);
SMAABB
aabb
=
getBound
();
SMAABB
aabb
=
getBound
();
if
(
bReturnNearestPoint
)
{
Loading