Overriding Spatial

I have determined that in order to have my Spatial objects function the way I need them to without causing lag due to code else where in the program in order to complete the same functionality I must override Spatial. However, Spatial has several abstract methods that I don’t need to rewrite. When you use the asset manager’s loadModel() method, and then call one of the abstract methods like get vertexCount() it returns a value. My question is where are these abstract methods being defined so I can just copy it and keep the code as efficient as it already is without my horrible coding?

It sounds like a wrong thing, so why exactly do you think you have to overwrite Spatial? Maybe you better explain us what you want, maybe just maybe there is a better solution for that.

I need to override the collideWith method specifically for effects. And based on what is currently being suggested in the recent meetings me and my team have been having, possible more.

Spatial is an abstract class, the engine extends it in Geometry (=a spatial with a mesh) and Node. So you should override one of these two and not Spatial, but then you may have also to edit other parts (ie the model loader) that produce geometries and nodes in order to make them use your custom class, so IMO instead of that you’d better to make an external method that handles the collision check in the way you want and use it instead of spatial.collideWith.

collideWith() is really the only useful thing you can’t override in a control. So in the rare case where you can’t just organize your scene graph better to avoid colliding with those spatials then you may (rarely) want to extend either Geometry or Node… but never Spatial.

It would be better to know more about what the issue is as we might be able to suggest courses of action that won’t cause you extra pain later.

You could theoretically write a wrapper which inhertis Spatial. Hand over your specific Spatial (geometry, node, whatever) to your wrapper in the costructor. Now pass the method calls to your wrapped spatial and do what ever you wish in collidWith method. That way you can preserve the wrapped spatials method and decorate it wit custom behaviour. easy to test as well. Can be an ellegant thing.
But still think that is not the best solution.

Not so easy to do if you do not control the instantiation of Nodes or Geometries. Like if you load models from the assetmanager.

Load and wrap, I dont see any problems. But yeah still think if we would get more infos from OP we could give better advices :slight_smile: