CCPUSphereCollider.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /****************************************************************************
  2. Copyright (C) 2013 Henry van Merode. All rights reserved.
  3. Copyright (c) 2015-2017 Chukong Technologies Inc.
  4. http://www.cocos2d-x.org
  5. Permission is hereby granted, free of charge, to any person obtaining a copy
  6. of this software and associated documentation files (the "Software"), to deal
  7. in the Software without restriction, including without limitation the rights
  8. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. copies of the Software, and to permit persons to whom the Software is
  10. furnished to do so, subject to the following conditions:
  11. The above copyright notice and this permission notice shall be included in
  12. all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. THE SOFTWARE.
  20. ****************************************************************************/
  21. #ifndef __CC_PU_PARTICLE_3D_SPHERE_COLLIDER_H__
  22. #define __CC_PU_PARTICLE_3D_SPHERE_COLLIDER_H__
  23. #include "CCPUBaseCollider.h"
  24. #include "extensions/Particle3D/PU/CCPUSphere.h"
  25. #include "base/ccTypes.h"
  26. NS_CC_BEGIN
  27. class CC_DLL PUSphereCollider : public PUBaseCollider
  28. {
  29. public:
  30. // Constants
  31. static const float DEFAULT_RADIUS;
  32. static PUSphereCollider* create();
  33. virtual void preUpdateAffector(float deltaTime) override;
  34. virtual void updatePUAffector(PUParticle3D *particle, float deltaTime) override;
  35. /** Returns the radius of the sphere
  36. */
  37. float getRadius() const;
  38. /** Sets the radius of the sphere
  39. */
  40. void setRadius(const float radius);
  41. /** Returns indication whether the collision is inside or outside of the box
  42. @remarks
  43. If value is true, the collision is inside of the box.
  44. */
  45. bool isInnerCollision(void) const;
  46. /** Set indication whether the collision is inside or outside of the box
  47. @remarks
  48. If value is set to true, the collision is inside of the box.
  49. */
  50. void setInnerCollision(bool innerCollision);
  51. /**
  52. */
  53. void calculateDirectionAfterCollision(PUParticle3D* particle, Vec3 distance, float distanceLength);
  54. virtual void copyAttributesTo (PUAffector* affector) override;
  55. CC_CONSTRUCTOR_ACCESS:
  56. PUSphereCollider(void);
  57. virtual ~PUSphereCollider(void);
  58. protected:
  59. float _radius;
  60. PUSphere _sphere;
  61. Vec3 _predictedPosition;
  62. bool _innerCollision;
  63. };
  64. NS_CC_END
  65. #endif