Arma 3
BettIR (Legacy v0.2.1)
Leopard20 Oct 19, 2020 @ 4:04am
Suggestions
Hello, thanks for this useful mod!

I'd like to suggest an improvement.

I noticed that in "handleVisionModeChange" script, you're doing:

_handle = [] spawn BettIR_fnc_updateUnitList; BettIR_UnitList_LastUpdate = time; // EachFrame handler isn't in scheduled environment so it's safer to update this variable manually waitUntil {isNull _handle};

I think you intended to "spawn" the code so that it would be scheduled and not cause frame drop.

But:
1. The function itself is scheduled.(waitUntil)
2. The waitUntil itself is just wasting performance.

To fix this, simply change it to:
[] call BettIR_fnc_updateUnitList; BettIR_UnitList_LastUpdate = time; // EachFrame handler isn't in scheduled environment so it's safer to update this variable manually

Also, I noticed that you're using setPosATL with modelToWorld.(AGL)
Please note that ATL position is not the same as AGL position. You can simply verify this if you test your mod on a ship or carrier.

Again, to fix this, you should use setPos instead. Contrary to what a lot of people think, position format in setPos (AGL) is not the same as the position format in getPos (AGLS). So that's the position format you should use here.
Alternatively, you can use modelToWorldWorld with setPosASL.

I hope this helps.

Regards
Last edited by Leopard20; Oct 19, 2020 @ 5:27am
< >
Showing 1-11 of 11 comments
Vestarr  [developer] Oct 19, 2020 @ 5:13am 
Hi Leo,
Thanks for the suggestions! Very good call actually.
I'm a beginner scripter so I still get some ideas wrong :D Some of the things also seem to be a relic of the initial testing days.
Also good point with the AGL/ATL, I'll test it and I'll try to fix it ASAP because I can see how it could be causing problems.
Leopard20 Oct 19, 2020 @ 5:56am 
No problem!
Another improvement I can suggest is that when you want to find if a string exists in an array of strings, use find instead of findIf.

I noticed that you convert the hmd/weapon item names to lower case. All item class names have the correct case corresponding to their config name, so converting the case is not really necessary.

But if you still want to do it that way, it's perfectly fine.

Since you've already converted the item class names to lower case when you get the compatible ones (fnc_getCompatibleNVGs.sqf), simply use:
BettIR_CompatibleAttachments find toLower (_weaponsItems select 1); BettIR_CompatibleNVGs find toLower (hmd _x);
They are a several times faster (also, they are case-sensitive)

Another thing I'd like to mention is that the == operator performs non-case-sensitive comparison between strings. So
"HeLLo" == "hello"

So even if you were using array findIf {_x == "someString"}, the case wouldn't matter at all. (but like I said, always try to use find where possible, because it uses binary comparison and it's several times faster)

when you want case-sensitive comparison, use isEqualTo.
Vestarr  [developer] Oct 19, 2020 @ 6:38am 
> All item class names have the correct case corresponding to their config name, so converting the case is not really necessary.

Yes, but it requires the developers to keep the same case in their compat config as the addon creator

> Another thing I'd like to mention is that the == operator performs non-case-sensitive comparison between strings.

Oh, that's cool, I wasn't aware of that.

> always try to use find where possible, because it uses binary comparison and it's several times faster)
Will it return the index of it though? If so, I'm more than happy to put it in!

Also thanks for all the above - I've updated the mod and the ASL positioning is in the release 0.2.1
Leopard20 Oct 19, 2020 @ 6:57am 
> Will it return the index of it though? If so, I'm more than happy to put it in!
Of course. Their purpose is the same. In fact, find is even older. findIf was implemented so that it could do things that find can't. (albeit, in a slower way)
https://community.bistudio.com/wiki/find
https://community.bistudio.com/wiki/findIf

simply put, findIf is always executing a code (what you put in { }) for each element and evaluates its return, so it is slower.


> Yes, but it requires the developers to keep the same case in their compat config as the addon creator
If you simply copy their config classes, you don't have to worry about it anymore. They will always be the same. But as I mentioned, it doesn't matter since you already convert all class names to lower case. So all's good here! :)


anyway, what I wrote above:
_attachmentIndex = BettIR_CompatibleAttachments find toLower (_weaponsItems select 1); _nvgIndex = BettIR_CompatibleNVGs find toLower (hmd _x);
is all you have to change to make it faster. And it will be compatible with your code.
Last edited by Leopard20; Oct 19, 2020 @ 7:24am
Vestarr  [developer] Oct 19, 2020 @ 3:20pm 
Thanks man, much appreciated, makes perfect sense. I think I just got confused because Javascript has a find function behaving in a much different way (and JS is my primary language at work).
Anyways, I'll try to implement it in the next update, these are excellent thoughts!
baron556 Oct 19, 2020 @ 10:37pm 
This is awesome, was something the game was always missing and I'm glad it was able to be modded in. Only suggestion I have would be to maybe add the option to use ACE to turn your various illuminators on and off in addition to the keybind. Run through the equipment menu or something like that.
Leopard20 Oct 20, 2020 @ 9:33am 
Hello again.
I was reading the mod description when I noticed the issues:
1 - Laggy in vehicles, potential fix in the pipeline
2 - NVG Illuminator offset vector is not being rotated with the head

1 - To fix the first problem, consider using the visual variant of positions (visual means render time):
https://community.bistudio.com/wiki/modelToWorldVisualWorld

setPosASL can be problematic with visual coordinates. Consider using setPosWorld instead. (it is also in ASL format, although slightly different)
https://community.bistudio.com/wiki/setPosWorld


2 - The second problem can be fixed with some vector math:
For example, the head mounted one is fixed as follows:
_dir = getCameraViewDirection _x; // get the eye position of the unit (local) _eyePos = _x selectionPosition ['head', 'Memory']; // get the offset of the goggles light _nvgOffset = _x getVariable ['BettIR_nvg_illuminator_offset', [0,0,0]]; _relativeDir = _x vectorWorldToModel _dir; _xDir = [_relativeDir#1, -(_relativeDir#0),0]; _zDir = _xDir vectorCrossProduct _relativeDir; _yDir = _relativeDir; _yDir set [2,0]; // add the offset vector to the eye position _eyePos = _eyePos vectorAdd [ (_xDir vectorCos [1,0,0])*_offset#0, (_yDir vectorCos [0,1,0])*_offset#1, (_zDir vectorCos [0,0,1])*_offset#2 ]; _nvgLightPos = _x modelToWorldVisualWorld _eyePos; _lightObject setPosWorld _nvgLightPos; _lightObject setVectorDirAndUp [ _dir, _dir vectorCrossProduct [_dir#1, _dir#0*-1, 0] ];
I didn't test it, but according to my calculations , it should be correct.
Last edited by Leopard20; Oct 20, 2020 @ 9:36am
Vestarr  [developer] Oct 20, 2020 @ 12:35pm 
You absolute legend.
Thanks bud, it will save me some headache.
Should add different Illuminator settings for things like the PEQ15. The Illuminator should be able to project easily out to 200m to make out targets.
cheloco Oct 28, 2020 @ 9:25am 
isso ae
Zoraxon Jun 17, 2021 @ 9:06am 
Great mod, but I do have one suggestion: Can we have an adjustable intensity of the weapon and goggle illuminator? I've found that in buildings, the goggle light tends to wash out a lot, and is super bright against any 1x optic. Having an "intensity" slider could help to reduce that glare/wash in close range, and let it still be useful at long range as well
< >
Showing 1-11 of 11 comments
Per page: 1530 50