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

View File

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