Stan` Posted April 22, 2019 Report Share Posted April 22, 2019 Hey guys, I was wondering since we have a lot of calls that goes like this Engine.QueryInterface(component_IID, entity) if that would not be a performance gain to actually cache them in Init functions ? For some small components that might be negligible but maybe for stuff like UnitAI it could make some difference. Quote Link to comment Share on other sites More sharing options...
wraitii Posted April 22, 2019 Report Share Posted April 22, 2019 This exposes us to dangling pointers, as the component pointed-to may very well be deleted at some point (particularly for components referring to other entities). Now 0 A.D. doesn't actually change an entity's templates (i.e. its components) at runtime right now, so we could take some liberties with components of the same entity, but that's probably not something we want to do from a design point of view. Then again, changing components at runtime might be too difficult to ever implement. What we could maybe do is a component cache on the JS side to avoid going back to c++ everytime, but that's also scary for mostly the same reason. At the moment, we have bigger performance concerns imo. 1 Quote Link to comment Share on other sites More sharing options...
Stan` Posted April 22, 2019 Author Report Share Posted April 22, 2019 Sure was just wondering since I remember reading something that stated that the interactions between the two languages were slow. 19 minutes ago, wraitii said: his exposes us to dangling pointers, as the component pointed-to may very well be deleted at some point (particularly for components referring to other entities). That would only be for things refering to this.entity 20 minutes ago, wraitii said: What we could maybe do is a component cache on the JS side to avoid going back to c++ everytime, but that's also scary for mostly the same reason. At the moment, we have bigger performance concerns imo. True. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.