Skip to content

Commit 63eef0d

Browse files
committed
Implemented raycast, so camera cannot go over walls
1 parent 456e01d commit 63eef0d

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

CustomCameraVPlus.vcxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
<ClInclude Include="script.h" />
2020
<ClInclude Include="utils.h" />
2121
</ItemGroup>
22+
<ItemGroup>
23+
<None Include="CustomCameraVPlus.ini" />
24+
</ItemGroup>
25+
<ItemGroup>
26+
<Text Include="Install.txt" />
27+
</ItemGroup>
2228
<PropertyGroup Label="Globals">
2329
<ProjectGuid>{8D82F34A-1D64-465B-84B1-37F89AD3D20B}</ProjectGuid>
2430
<Keyword>Win32Proj</Keyword>

script.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,6 +1649,20 @@ void updateCam3pNfsAlgorithm()
16491649

16501650
setCamPos(customCam, camPosFinal);
16511651

1652+
// Raycast //
1653+
int ray = WORLDPROBE::_START_SHAPE_TEST_RAY(posCenter.x(), posCenter.y(), posCenter.z(), camPosFinal.x(), camPosFinal.y(), camPosFinal.z(), 1, veh, 7);
1654+
1655+
Vector3 endCoords, surfaceNormal;
1656+
BOOL hit;
1657+
Entity entityHit = 0;
1658+
1659+
WORLDPROBE::GET_SHAPE_TEST_RESULT(ray, &hit, &endCoords, &surfaceNormal, &entityHit);
1660+
1661+
if (hit) {
1662+
setCamPos(customCam, toV3f(endCoords) + (finalQuat3P * front * 0.1f));
1663+
}
1664+
// End raycast //
1665+
16521666
Vector3f rotEuler = QuatToEuler(finalQuat3P);
16531667

16541668
rotEuler[1] = 0.f;

0 commit comments

Comments
 (0)