update caching access function names to align with each other and added some preliminary material consideration for spalling

This commit is contained in:
lambdatiger 2024-01-09 14:00:43 -06:00
parent 278c09e4cb
commit 48d37a96e0
7 changed files with 46 additions and 12 deletions

View File

@ -44,7 +44,7 @@ private _maxFrags = round (linearConversion [0.1, 1.5, _timeSince, ACE_FRAG_COUN
TRACE_3("",_timeSince,CBA_missionTime,_maxFrags);
private _ammoArr = [_ammo] call FUNC(fragInfo);
private _ammoArr = [_ammo] call FUNC(getFragInfo);
_ammoArr params ["_fragRange", "_fragVel", "_fragTypes", "_modFragCount"];
private _heightAGL = (ASLToAGL _posASL)#2;

View File

@ -31,14 +31,13 @@ params [
];
TRACE_5("fnc_doFragRandom", _posASL, _projVel, _heightAGL, _fragType, _fragCnt);
// See CfgAmmo for different frag types
// See cfgAmmoFragSpawner for different frag types
private _hMode = switch (true) do {
case (_heightAGL > 10): {"_top"};
case (_heightAGL > 5): {"_hi"};
default {"_mid"};
};
// Select the cfgAmmo type
private _type = if (count _fragType > 0 &&
{"ace_frag_tiny" isEqualTo (_fragType#0)}) then {
QGVAR(def_tiny_)

View File

@ -66,7 +66,7 @@ systemChat ("dV: " + str _dv + ", caliber: " + str _caliber + ", product: " + st
#endif
if (_explosive > 0) then {
private _fragMod = (_ammo call FUNC(fragInfo))#1;
private _fragMod = (_ammo call FUNC(getFragInfo))#1;
_velMod = _fragMod * _velMod;
};

View File

@ -51,18 +51,19 @@ private _lVelUnit = vectorNormalized _lVel;
private _ammo = typeOf _projectile;
private _dV = vectorMagnitude _lVel - vectorMagnitude _vel;
private _caliber = getNumber (configFile >> "cfgAmmo" >> _ammo >> "caliber"); // !*! optimize this later?
private _deltaMomentum = 0.4 * _caliber * sqrt( _dV * 0.032 );
// scaled momentum change made on caliber-mass assumption ~sqrt(2)/20 * caliber ~= mass
private _deltaMomentum = 0.07071 * _caliber * sqrt( _dV );
TRACE_3("found speed",_dV,_caliber,_deltaMomentum);
if (_deltaMomentum < 1) exitWith {
if (_deltaMomentum < 2) exitWith {
TRACE_1("lowImpulse",_ammo);
};
//** start calculating where the spalling should come !*! could be better **//
private _unitStep = _lVelUnit vectorMultiply 0.05;
private _spallPos = +_lPosASL;
// exit if we hit the ground
if (terrainIntersectASL [_lPosASL vectorAdd _unitStep, _lPosASL]) exitWith {
TRACE_3("terrainIntersect",_lPosASL,_unitStep,_lPosASL);
};
@ -81,16 +82,15 @@ for "_i" from 1 to 20 do
[_spallPos, "green"] call FUNC(dev_sphereDraw);
[_lPosASL vectorAdd _lVelUnit, "orange"] call FUNC(dev_sphereDraw);
[_lPosASL, "orange"] call FUNC(dev_sphereDraw);
private _str = GVAR(materialSpallCache) getOrDefault [str _surfaceType, "["];
_str =_str + str [_dV, _caliber, abs vectorMagnitude (_lPosASL vectorDiff _spallPos)] + ";";
GVAR(materialSpallCache) set [str _surfaceType, _str];
if (_deltaMomentum < 2) exitWith {};
#endif
//***** Passed all other exit withs, performance o'clock */
GVAR(lastSpallTime) = CBA_missionTime;
//***** Select spalled fragment spawner **//
private _material = [_surfaceType] call FUNC(getMaterialInfo);
private _fragSpawnType = switch (true) do
{
case (_deltaMomentum < 3): { QGVAR(spall_tiny) };

View File

@ -16,7 +16,7 @@
* of spherical fragmentation
*
* Example:
* ["B_556x45_Ball"] call ace_frag_fnc_fragInfo;
* ["B_556x45_Ball"] call ace_frag_fnc_getFragInfo;
*
* Public: No
*/

View File

@ -0,0 +1,35 @@
#include "script_component.hpp"
/*
* Author: Lambda.Tiger
* This function returns fragmentation parameters for a specific
* ammo type.
*
* Arguments:
* 0: _ammo <STRING> - cfgAmmo type of ammo to check
*
* Return Value:
* _ammoInfo <ARRAY>
* 0: _fragRange - search range for fragments
* 1: _fragVel - gurney equation calculated velocity
* 2: _fragTypes - array of fragment types
* 3: _fragCount - modified frag count used under assumptions
* of spherical fragmentation
*
* Example:
* ["B_556x45_Ball"] call ace_frag_fnc_getFragInfo;
*
* Public: No
*/
params ["_surfType"];
private _material = GVAR(materialSpallCache) get _surfType;
if !(isNil "_material") exitWith {_material};
private _str = GVAR(materialSpallCache) getOrDefault [str _surfaceType, "["];
_str =_str + str [_dV, _caliber, abs vectorMagnitude (_lPosASL vectorDiff _spallPos)] + ";";
GVAR(materialSpallCache) set [_surfaceType, _material];
_material