Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add event handler for creating and deleting markers #505

Merged
merged 6 commits into from
Sep 23, 2016

Conversation

commy2
Copy link
Contributor

@commy2 commy2 commented Sep 20, 2016

When merged this pull request will:

  • Adds CBA_fnc_addMarkerEventHandler and CBA_fnc_removeMarkerEventHandler
  • Supports created and deleted events
  • Passes the created or deleted marker name as _this

@bux578 is that what you needed?

@commy2 commy2 added the Feature label Sep 20, 2016
@commy2 commy2 added this to the 3.1 milestone Sep 20, 2016
@bux
Copy link
Contributor

bux commented Sep 20, 2016

@commy2 Looks perfect. How bad could performance suffer if allMapMarkers is checked each frame?
Maybe a slight delay could make sense here?

And what about automatic generated markers like from Blue Force Tracking etc...

@commy2
Copy link
Contributor Author

commy2 commented Sep 20, 2016

How bad could performance suffer if allMapMarkers is checked each frame?

I don't think much. allMapMarkers is not like nearestObjects. It just reads an already existing array out of C++ land afaik.

Maybe a slight delay could make sense here?

maybe. although if you make the delay too big, you could miss some obviously. I guess 0.1 is fine?

And what about automatic generated markers like from Blue Force Tracking etc...

it would execute for every marker that appears in allMapMarkers

@jokoho48
Copy link
Member

why not using a Statemachine?

@commy2
Copy link
Contributor Author

commy2 commented Sep 20, 2016

There are no states here.

@nicolasbadano
Copy link
Contributor

I'm not sure about the delay; all CBA event handlers are instantaneous as far as I know, and having these ones behaving differently might be confusing. Also, it might break some potential usages that require low latency.

It all comes down to the cost of:

private _newAllMapMarkers = allMapMarkers;
if !(_newAllMapMarkers isEqualTo GVAR(oldMarkers)) then {

have you measured the performance of that?

@commy2
Copy link
Contributor Author

commy2 commented Sep 20, 2016

oldMarkers = allMapMarkers;

private _newAllMapMarkers = allMapMarkers; 
if !(_newAllMapMarkers isEqualTo oldMarkers) then {};

0 markers: 0.0036 ms
100 markers: 0.0148 ms

100 markers using private _newAllMapMarkers = allMapMarkers:
0.0137 ms

So allMapMarkers does get slower with many markers placed, but it isn't that bad. Not sure if that should run every frame though.

@nicolasbadano
Copy link
Contributor

This are the theoretical frame decreases of running this every frame with 200 markers (assuming 0.015 x 2 = 0.03 ms):

60.0000 fps ->59.9999 fps
90.0000 fps -> 89.9997 fps
120.0000 fps -> 119.9995 fps

All in all completely unnoticeable.

@commy2
Copy link
Contributor Author

commy2 commented Sep 20, 2016

reverted it :)

@Killswitch00 Killswitch00 merged commit 7e376fe into master Sep 23, 2016
@Killswitch00 Killswitch00 deleted the add-marker-event-handler branch September 23, 2016 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants