Jump to content

Recommended Posts

Added: Possibility to enable / disable UI control directly in configs

Why bother adding this stuff if you won't document it?

Share this post


Link to post
Share on other sites
I thought I'd ask this here instead of mission editing.

I put the following code into the debug console:

varA = (1 / 10000) + (3 / 10000);
varB = 4 / 10000;
diag_log format ["varA: %1", varA];
diag_log format ["varB: %1", varB];
diag_log format ["varA == varB: %1", varA == varB];
diag_log format ["varA isEqualTo varB: %1", varA isEqualTo varB];

So we're checking if 0.0004 is equal to 0.0004

This is printed in .rpt:

"varA: 0.0004"
"varB: 0.0004"
"varA == varB: false"
"varA isEqualTo varB: false"

Why is this? Is there some inherent inaccuracy when comparing small numbers? I'm aware there's a floating point accuracy but I wouldn't know if that's related or not.

I did compare varB to varB and it returns true. Also if you set varA to 4/10000, then it returns true in comparison. So it's something to do with adding small numbers. Ie (1/10000)+(3/10000) is not the same as 4/10000. (But it is obv). I also tried turning the numbers to string and it returned true, but it's annoying not to know when to check numbers directly or when to use string comparison (which also has it's own problems with big and small numbers).

It is because of single precision floating point used in Arma. Unfortunately if you go too big or too small, this is what you will get.

---------- Post added at 08:43 ---------- Previous post was at 08:40 ----------

Why bother adding this stuff if you won't document it?

AFAIK this was meant to be 'enable' param to be added to contol classes, but last time I checked it did not work. You can still use ctrlEnable though but would be much better to have config option too.

Share this post


Link to post
Share on other sites
It is because of single precision floating point used in Arma. Unfortunately if you go too big or too small, this is what you will get.

If I remember correctly, the value of varA isn't even 0.0004, it's just what's shown to you when represented as a string.

@Das Attorney:

Try the same in your browser JS console, which has similar issues. The result is something along these lines, and hence the issue, except the console here shows you the actual value it came up with instead of what Arma's string conversion gives you:

IZ614Qm.png

Depending on needed precision, you can still get around it by doing something like:

_varsEqual = ((abs (_varA - _varB)) < 0.000001);

Edited by Sniperwolf572

Share this post


Link to post
Share on other sites

Maybe avoid division and use multiplication instead? This works:

[color="#FF8040"]varA [color="#8B3E2F"][b]=[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#FF0000"]1[/color] [color="#8B3E2F"][b]*[/b][/color] [color="#FF0000"]0.0001[/color][color="#8B3E2F"][b])[/b][/color] [color="#8B3E2F"][b]+[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#FF0000"]3[/color] [color="#8B3E2F"][b]*[/b][/color] [color="#FF0000"]0.0001[/color][color="#8B3E2F"][b])[/b][/color][color="#8B3E2F"][b];[/b][/color]
varB [color="#8B3E2F"][b]=[/b][/color] [color="#FF0000"]4[/color] [color="#8B3E2F"][b]*[/b][/color] [color="#FF0000"]0.0001[/color][color="#8B3E2F"][b];[/b][/color]
[color="#191970"][b]systemChat[/b][/color] [color="#191970"][b]format[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"varA: %1"[/color][color="#8B3E2F"][b],[/b][/color] varA[color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color]
[color="#191970"][b]systemChat[/b][/color] [color="#191970"][b]format[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"varB: %1"[/color][color="#8B3E2F"][b],[/b][/color] varB[color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color]
[color="#191970"][b]systemChat[/b][/color] [color="#191970"][b]format[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"varA == varB: %1"[/color][color="#8B3E2F"][b],[/b][/color] varA [color="#8B3E2F"][b]=[/b][/color][color="#8B3E2F"][b]=[/b][/color] varB[color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color]
[color="#191970"][b]systemChat[/b][/color] [color="#191970"][b]format[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"varA isEqualTo varB: %1"[/color][color="#8B3E2F"][b],[/b][/color] varA [color="#191970"][b]isEqualTo[/b][/color] varB[color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color]  [/color]

Share this post


Link to post
Share on other sites

Anybody got an idea when every single uniform/vest/weapon got prefixed with Item_/Vest_/Weapon_ respectively? It seems like scripts don't actually react to it. Example:

removeAllWeapons this; newGun = [this, "Weapon_LMG_Mk200_F", 4] call BIS_fnc_addWeapon;

Function doesn't react as expected.

removeAllWeapons this; newGun = [this, "LMG_Mk200_F", 4] call BIS_fnc_addWeapon;

Function works as expected, yet the weapon classname is actually prefixed with Weapon_.

Share this post


Link to post
Share on other sites
Maybe avoid division and use multiplication instead? This works:

[color="#FF8040"]varA [color="#8B3E2F"][b]=[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#FF0000"]1[/color] [color="#8B3E2F"][b]*[/b][/color] [color="#FF0000"]0.0001[/color][color="#8B3E2F"][b])[/b][/color] [color="#8B3E2F"][b]+[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#FF0000"]3[/color] [color="#8B3E2F"][b]*[/b][/color] [color="#FF0000"]0.0001[/color][color="#8B3E2F"][b])[/b][/color][color="#8B3E2F"][b];[/b][/color]
varB [color="#8B3E2F"][b]=[/b][/color] [color="#FF0000"]4[/color] [color="#8B3E2F"][b]*[/b][/color] [color="#FF0000"]0.0001[/color][color="#8B3E2F"][b];[/b][/color]
[color="#191970"][b]systemChat[/b][/color] [color="#191970"][b]format[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"varA: %1"[/color][color="#8B3E2F"][b],[/b][/color] varA[color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color]
[color="#191970"][b]systemChat[/b][/color] [color="#191970"][b]format[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"varB: %1"[/color][color="#8B3E2F"][b],[/b][/color] varB[color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color]
[color="#191970"][b]systemChat[/b][/color] [color="#191970"][b]format[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"varA == varB: %1"[/color][color="#8B3E2F"][b],[/b][/color] varA [color="#8B3E2F"][b]=[/b][/color][color="#8B3E2F"][b]=[/b][/color] varB[color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color]
[color="#191970"][b]systemChat[/b][/color] [color="#191970"][b]format[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"varA isEqualTo varB: %1"[/color][color="#8B3E2F"][b],[/b][/color] varA [color="#191970"][b]isEqualTo[/b][/color] varB[color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color]  [/color]

Thanks for the suggestion KK (and also your explanation as well SW), plus that's good to know about multiplying as well. I guess even computers dislike division ;)

Share this post


Link to post
Share on other sites
I guess even computers dislike division ;)

Floating point math is their doom, not just division. :p

In your case, multiplication works, but for example, here's addition and multiplication going wrong:

w76c5ym.png

I believe "ok, close enough" method is the only "safe" solution if you need to compare such floats.

Share this post


Link to post
Share on other sites

From Arma 3 v1.31.127400

Command name changes

visibleWorldToModel -> worldToModelVisual https://community.bistudio.com/wiki/worldToModelVisual

visibleModelToWorld -> modelToWorldVisual https://community.bistudio.com/wiki/modelToWorldVisual

visibleGetDir -> getDirVisual https://community.bistudio.com/wiki/getDirVisual

visibleVectorDir -> vectorDirVisual https://community.bistudio.com/wiki/vectorDirVisual

visibleVectorUp -> vectorUpVisual https://community.bistudio.com/wiki/vectorUpVisual

New commands

getPosVisual https://community.bistudio.com/wiki/getPosVisual

getPosASLVisual https://community.bistudio.com/wiki/getPosASLVisual

NOTE: visibleGetPosATL is still in game in this version.

From Arma 3 v1.31.127416

New commands

getPosATLVisual https://community.bistudio.com/wiki/getPosATLVisual

Edited by Killzone_Kid
correction about name change/new

Share this post


Link to post
Share on other sites

Very nice change to BiS_fnc_MP, will indeed be very useful at clearing up a lot of functions for MP.

Share this post


Link to post
Share on other sites

Is the SetAmmo command broken? I cant seem to get it to work on vehicles. The example provided on the page does nothing.

Edit: this appears to be true for commander turrets such as the GMG on the boats.

Edited by Bumgie

Share this post


Link to post
Share on other sites
Is the SetAmmo command broken? I cant seem to get it to work on vehicles. The example provided on the page does nothing.

Edit: this appears to be true for commander turrets such as the GMG on the boats.

check locality of the turrets, they have to be local to where you execute setAmmo

Share this post


Link to post
Share on other sites

How does getPosVisual behave when underwater? Does it return a Z value above sea level or terrain level? If ASL when underwater, will it return a negative number?

Share this post


Link to post
Share on other sites
How does getPosVisual behave when underwater? Does it return a Z value above sea level or terrain level? If ASL when underwater, will it return a negative number?

Same as visiblePosition, will return z<0 if under water

Share this post


Link to post
Share on other sites

getPosASL returns a different z value than getPosVisual/visiblePosition. I'm not clear on when to use one over the other. Any clarification available?

Share this post


Link to post
Share on other sites
getPosASL returns a different z value than getPosVisual/visiblePosition. I'm not clear on when to use one over the other. Any clarification available?

[table=width: 500, class: grid]

[tr]

[td]Render time[/td]

[td]Simulation time[/td]

[td]Description[/td]

[/tr]

[tr]

[td]getPosVisual / visiblePosition[/td]

[td]getPos / position[/td]

[td]z = 0 on objects with roadways, terrain, water + waves[/td]

[/tr]

[tr]

[td]getPosATLVisual[/td]

[td]getPosATL[/td]

[td]z = 0 on terrain[/td]

[/tr]

[tr]

[td]getPosASLVisual [/td]

[td]getPosASL[/td]

[td]z = 0 on water[/td]

[/tr]

[tr]

[td]N/A[/td]

[td]getPosASLW[/td]

[td]z = 0 on water + waves[/td]

[/tr]

[tr]

[td]N/A[/td]

[td]getPosWorld[/td]

[td]z = 0 on water. Calculated to true model center instead of land contact or bounding center[/td]

[/tr]

[/table]

Edited by Sniperwolf572

Share this post


Link to post
Share on other sites

Thanks for that table SW - I thought it was a keeper so I've pasted it into my project files for reference :)

Also, what's the difference between render time and simulation time?

I know that icons on screen need the render time commands, but what's to stop me from using render commands when doing general scripting?

Is it something to do with the upcoming disconnection between simulation and rendering?

So to get the pos of a tank, I use getPosATL, but to draw a 3d icon on it I use getPosATLVisual?

Why not visual for both?

Edited by Das Attorney

Share this post


Link to post
Share on other sites
Thanks for that table SW - I thought it was a keeper so I've pasted it into my project files for reference :)

No problem, tweaked it a bit to account that getPos and it's counterparts actually return ASLW heights instead of ASL when water is the factor. Hence the disparity in Feints heights between ASL and getPos variants.

Is it something to do with the upcoming disconnection between simulation and rendering?

So to get the pos of a tank, I use getPosATL, but to draw a 3d icon on it I use getPosATLVisual?

Why not visual for both?

I haven't heard about that, but the simulation and rendering should be separate anyway, I currently have no reason to believe they're tied, even tho time acceleration does result in some questionable behavior.

I'm not 100% sure what I'm about to say is correct, but this is how I currently think it is:

"Render time" is updated on a very high frequency (each frame), it's responsible for things you see on the screen, where things visually appear to you.

"Simulation time" is updated on a lower frequency than frames, and then the changes between two simulation "ticks" are interpolated visually on your screen.

So let's say first tick of "Simulation time" says a bullet is at [0,0,0] and the next calculates that the bullet is at [0,0,1]. Between two simulation ticks, let's say 10 frames have elapsed.

In those 10 frames, the "render time" commands will return [0,0,0.1] on the first frame, [0,0,0.2] on the second and so on.

If you position, let's say an icon, on each of those frames according to the "simulation time" commands results, that position will be on [0,0,0] on all the frames until the next "simulation" tick happens. While going by the results of the "render time" you will have correct visual updates at all times.

The difference between the two only matters when something is changing positions and it becomes more obvious the faster that something moves.

Additionally, probably irrelevant to all this, simulation probably runs at a fixed rate, while the render is dependent on how fast your system can push frames. When you change the time acceleration in editor in SP, either the rate of simulation updates increases or they multiply the delta time each frame receives.

When the simulation is tied to the rendering, you get the problems of the old games where if you have a good computer the game will play at an accelerated rate. A good and a hilarious demonstration of this oversight in recent times is in NFS Rivals, observe what happens

when he unlocks the FPS limiter. Edited by Sniperwolf572

Share this post


Link to post
Share on other sites

Thanks for the explanation - I just watched that video which was pretty funny. 2013 game - ouch! :D

I thought I read somewhere on here that they were looking at disconnecting the simulation from the renderer but I can't find any quotes. It's definitely being done for Dayz so maybe I got my RV games mixed up.

Share this post


Link to post
Share on other sites

Good job KK! However I meant (also) the explanation from Sniperwolf (link it, attach a comment, or add on discussion page).

Share this post


Link to post
Share on other sites
;2791742']Good job KK! However I meant (also) the explanation from Sniperwolf (link it' date=' attach a comment, or add on discussion page).[/quote']

added link

Share this post


Link to post
Share on other sites
"Simulation time" is updated on a lower frequency than frames, and then the changes between two simulation "ticks" are interpolated visually on your screen.

I noticed you can see the simulation ticks of the Physx Simulation when you activate EPEVehicles in arma3diag.exe, drive over an obstacle course (where you will get red force markers on the wheels)

Then use splendid cam and slowmo -> the red crosses will flicker depending on the slow down. I slowed it down to 0.03 (so roughly 1/30) and it's ticking faster then 1/sec, so it seems to be faster then 30fps. But not exactly 60fps either.

Doesnt mean the simulation ticks of the rest of the games simulation are the same, but it wouldn't surprise me.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×