From 5946fad926aea24331429df24b7c6d063d9124e3 Mon Sep 17 00:00:00 2001 From: Wakbub Date: Sat, 15 Sep 2018 02:11:15 +0200 Subject: [PATCH 1/3] CBA_fnc_getVolume not calculating volume correctly. Optional parameter added to specify greater precision. --- addons/common/fnc_getVolume.sqf | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/addons/common/fnc_getVolume.sqf b/addons/common/fnc_getVolume.sqf index 495a4245a..f87a50093 100644 --- a/addons/common/fnc_getVolume.sqf +++ b/addons/common/fnc_getVolume.sqf @@ -3,26 +3,36 @@ Function: CBA_fnc_getVolume Description: - Return the volume of an object based on the object's model's bounding box. + Return the volume of the bounding box of an object's model. + An optional parameter can specify the calculation to use either boundingBox or boundingBoxReal. Parameters: - _object - an object to calculate the volume of + 0: _object - Object to calculate the volume of + 1: _real - false: use boundingBox, true: use boundingBoxReal (optional, default: true) Returns: - _volume - the volume + _volume - Volume of the bounding box Examples: (begin example) - _volume = _vehicle call CBA_fnc_getVolume + // Less precise volume using boundingBox + _volume = [_vehicle, false] call CBA_fnc_getVolume + + // More precise volume using boundingBoxReal + volume = [_vehicle] call CBA_fnc_getVolume (end) Author: - Rommel + Anton ---------------------------------------------------------------------------- */ SCRIPT(getVolume); -params [["_object", objNull, [objNull]]]; - -private _bounds = (boundingBox _object) select 1; +params [ + ["_object", objNull, [objNull]], + ["_real", true, [true]] +]; -(_bounds select 0) * (_bounds select 1) * (_bounds select 2) +private _boundingBox = [boundingBox _object, boundingBoxReal _object] select _real; +_boundingBox params ["_leftBackBottom", "_rightFrontTop"]; +(_rightFrontTop vectorDiff _leftBackBottom) params ["_width", "_length", "_height"]; +_width * _length * _height From 3a65e299c4cd254d3699dae8fb308968648e5004 Mon Sep 17 00:00:00 2001 From: Wakbub Date: Sat, 15 Sep 2018 12:01:51 +0200 Subject: [PATCH 2/3] Removed optional parameter --- addons/common/fnc_getVolume.sqf | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/addons/common/fnc_getVolume.sqf b/addons/common/fnc_getVolume.sqf index f87a50093..07882eede 100644 --- a/addons/common/fnc_getVolume.sqf +++ b/addons/common/fnc_getVolume.sqf @@ -4,22 +4,17 @@ Function: CBA_fnc_getVolume Description: Return the volume of the bounding box of an object's model. - An optional parameter can specify the calculation to use either boundingBox or boundingBoxReal. + The bounding box is retrieved using boundingBoxReal instead of boundingBox for more precise measurements. Parameters: - 0: _object - Object to calculate the volume of - 1: _real - false: use boundingBox, true: use boundingBoxReal (optional, default: true) + _object - Object to calculate the volume of Returns: _volume - Volume of the bounding box Examples: (begin example) - // Less precise volume using boundingBox - _volume = [_vehicle, false] call CBA_fnc_getVolume - - // More precise volume using boundingBoxReal - volume = [_vehicle] call CBA_fnc_getVolume + volume = _vehicle call CBA_fnc_getVolume (end) Author: @@ -27,12 +22,8 @@ Author: ---------------------------------------------------------------------------- */ SCRIPT(getVolume); -params [ - ["_object", objNull, [objNull]], - ["_real", true, [true]] -]; +params [["_object", objNull, [objNull]]]; -private _boundingBox = [boundingBox _object, boundingBoxReal _object] select _real; -_boundingBox params ["_leftBackBottom", "_rightFrontTop"]; +(boundingBoxReal _object) params ["_leftBackBottom", "_rightFrontTop"]; (_rightFrontTop vectorDiff _leftBackBottom) params ["_width", "_length", "_height"]; _width * _length * _height From 310b8b43d898507a395da38e3e69e4daac2ea845 Mon Sep 17 00:00:00 2001 From: commy2 Date: Mon, 17 Sep 2018 10:44:36 +0200 Subject: [PATCH 3/3] scripting style in header --- addons/common/fnc_getVolume.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/common/fnc_getVolume.sqf b/addons/common/fnc_getVolume.sqf index 07882eede..392d28569 100644 --- a/addons/common/fnc_getVolume.sqf +++ b/addons/common/fnc_getVolume.sqf @@ -14,7 +14,7 @@ Returns: Examples: (begin example) - volume = _vehicle call CBA_fnc_getVolume + private _volume = _vehicle call CBA_fnc_getVolume (end) Author: