04-24-2015, 10:15 PM
But why bother with a shared pointer? The vast majority of paths are not going to be shared so the memory overhead of the shared_ptr reference count is likely to use more memory overall than just copying the path when needed. I'm coming round to the opinion that GetPath and IsCalculationFinished should be combined. Under the current API they can only be safely called together, so if they are part of the same method that enforces safely. Then the client is responsible for keeping hold of the path if they want to look at it again. cPathFinder is not thread safe so I'm no convinced we should expose the mob instances of the pathfinder to Lua. Instead cPathFinder should be exposed to lua through a dedicated wrapper which handles thread safety. Mobs can however safely expose the cPath object to lua because it is immutable. It is much easier to safely export a copy of the cPath to lua than the original object, which woudl then have complicated lifetime issues.