added impact angle calculation handle to minimize spawning spall inside walls

This commit is contained in:
lambdatiger 2024-01-09 19:03:12 -06:00
parent 210a876c0c
commit acb7249039
2 changed files with 30 additions and 25 deletions

View File

@ -22,7 +22,7 @@ params [
// "",
["_lPosASL", [0, 0, 0]],
["_lVel", [0, 0, 0]],
// "",
["_sNorm", [0, 0, 0]],
// "",
// "",
["_surfaceType", ""],
@ -48,7 +48,6 @@ private _vel = if (alive _projectile) then {
} else {
[0, 0, 0]
};
private _lVelUnit = vectorNormalized _lVel;
// Find spall speed / fragment
@ -67,9 +66,15 @@ private _material = [_surfaceType] call FUNC(getMaterialInfo);
TRACE_1("materialCacheRetrieved",_material);
//** start calculating where the spalling should come !*! could be better **//
private _lVelUnit = vectorNormalized _lVel;
private _unitStep = _lVelUnit vectorMultiply 0.05;
private _spallPos = +_lPosASL;
if (120 > acos ((vectorNormalized _lVelUnit) vectorDotProduct _sNorm)) then {
_spallPos = _spallPos vectorAdd (_unitStep vectorMultiply 5);
};
if (terrainIntersectASL [_lPosASL vectorAdd _unitStep, _lPosASL]) exitWith {
TRACE_3("terrainIntersect",_lPosASL,_unitStep,_lPosASL);
};
@ -92,7 +97,7 @@ if GVAR(dbgSphere) then {
};
#endif
//***** Passed all other exit withs, performance o'clock */
//***** Passed all exit withs *****//
GVAR(lastSpallTime) = CBA_missionTime;
//***** Select spalled fragment spawner **//

View File

@ -58,7 +58,7 @@ if (GVAR(spallEnabled) && {_shouldSpall}) then
"HitPart",
{
params ["_proj", "_hitObj", "",
"_posASL", "_vel", "", "",
"_posASL", "_vel", "_sNorm", "",
"", "_surfType"
];
private _shotPrnt = getShotParents _proj;
@ -67,12 +67,12 @@ if (GVAR(spallEnabled) && {_shouldSpall}) then
if (isServer) then {
[
LINKFUNC(doSpallMomentum),
[_proj, _hitObj, _posASL, _vel, _surfType, _shotPrnt, _ammo, _vUp]
[_proj, _hitObj, _posASL, _vel, _sNorm, _surfType, _ammo, _shotPrnt, _vUp]
] call CBA_fnc_execNextFrame;
} else {
[
QGVAR(spall_eh),
[_proj, _hitObj, _posASL, _vel, _surfType, _shotPrnt, _ammo, _vUp]
[_proj, _hitObj, _posASL, _vel, _sNorm, _surfType, _ammo, _shotPrnt, _vUp]
] call CBA_fnc_serverEvent;
};
}