BsComponent.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #include "Scene/BsComponent.h"
  4. #include "Scene/BsSceneObject.h"
  5. #include "RTTI/BsComponentRTTI.h"
  6. namespace bs
  7. {
  8. Component::Component()
  9. :mNotifyFlags(TCF_None), mSceneManagerId(-1)
  10. { }
  11. Component::Component(const HSceneObject& parent)
  12. :mNotifyFlags(TCF_None), mSceneManagerId(-1), mParent(parent)
  13. {
  14. setName("Component");
  15. }
  16. Component::~Component()
  17. {
  18. }
  19. bool Component::typeEquals(const Component& other)
  20. {
  21. return getRTTI()->getRTTIId() == other.getRTTI()->getRTTIId();
  22. }
  23. bool Component::calculateBounds(Bounds& bounds)
  24. {
  25. Vector3 position = SO()->getTransform().getPosition();
  26. bounds = Bounds(AABox(position, position), Sphere(position, 0.0f));
  27. return false;
  28. }
  29. void Component::destroy(bool immediate)
  30. {
  31. SO()->destroyComponent(this, immediate);
  32. }
  33. void Component::destroyInternal(GameObjectHandleBase& handle, bool immediate)
  34. {
  35. if (immediate)
  36. GameObjectManager::instance().unregisterObject(handle);
  37. else
  38. GameObjectManager::instance().queueForDestroy(handle);
  39. }
  40. RTTITypeBase* Component::getRTTIStatic()
  41. {
  42. return ComponentRTTI::instance();
  43. }
  44. RTTITypeBase* Component::getRTTI() const
  45. {
  46. return Component::getRTTIStatic();
  47. }
  48. }