BsPhysicsCommon.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsCorePrerequisites.h"
  5. #include "BsVector3.h"
  6. namespace BansheeEngine
  7. {
  8. /** Information about a single contact point during physics collision. */
  9. struct ContactPoint
  10. {
  11. Vector3 position; /**< Contact point in world space. */
  12. Vector3 normal; /**< Normal pointing from the second shape to the first shape. */
  13. /** Impulse applied to the objects to keep them from penetrating. Divide by simulation step to get the force. */
  14. float impulse;
  15. float separation; /**< Determines how far are the objects. Negative value denotes penetration. */
  16. };
  17. /** Information about a collision between two physics objects. */
  18. struct CollisionData
  19. {
  20. Collider* colliderRaw; /**< Collider that was hit. */
  21. /**
  22. * Component of the collider that was hit. Can be null if collider is not owned by a component, in which case
  23. * use ::colliderRaw directly.
  24. */
  25. HCollider collider;
  26. // Note: Not too happy this is heap allocated, use static allocator?
  27. Vector<ContactPoint> contactPoints; /**< Information about all the contact points for the hit */
  28. };
  29. /** Determines what parent, if any, owns a physics object. */
  30. enum class PhysicsOwnerType
  31. {
  32. None, /** No parent, object is used directly. */
  33. Component, /** Object is used by a C++ Component. */
  34. Script /** Object is used by the scripting system. */
  35. };
  36. /** Contains information about a parent for a physics object. */
  37. struct PhysicsObjectOwner
  38. {
  39. PhysicsOwnerType type = PhysicsOwnerType::None; /**< Type of owner. */
  40. void* ownerData = nullptr; /**< Data managed by the owner. */
  41. };
  42. }