CCPUInterParticleCollider.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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_INNER_PARTICLE_COLLIDER_H__
  22. #define __CC_PU_PARTICLE_3D_INNER_PARTICLE_COLLIDER_H__
  23. #include "CCPUBaseCollider.h"
  24. #include "base/ccTypes.h"
  25. NS_CC_BEGIN
  26. struct PUParticle3D;
  27. class CC_DLL PUParticle3DInterParticleCollider : public PUBaseCollider
  28. {
  29. public:
  30. enum InterParticleCollisionResponse
  31. {
  32. IPCR_AVERAGE_VELOCITY,
  33. IPCR_ANGLE_BASED_VELOCITY
  34. };
  35. static PUParticle3DInterParticleCollider* create();
  36. // Constants
  37. static const float DEFAULT_ADJUSTMENT;
  38. static const InterParticleCollisionResponse DEFAULT_COLLISION_RESPONSE;
  39. virtual void prepare() override;
  40. virtual void unPrepare() override;
  41. virtual void updatePUAffector(PUParticle3D *particle, float deltaTime) override;
  42. /** Todo
  43. */
  44. float getAdjustment(void) const;
  45. /** Todo
  46. */
  47. void setAdjustment(float adjustment);
  48. /** Todo
  49. */
  50. InterParticleCollisionResponse getInterParticleCollisionResponse(void) const;
  51. /** Todo
  52. */
  53. void setInterParticleCollisionResponse(InterParticleCollisionResponse interParticleCollisionResponse);
  54. virtual void copyAttributesTo (PUAffector* affector) override;
  55. CC_CONSTRUCTOR_ACCESS:
  56. PUParticle3DInterParticleCollider(void);
  57. virtual ~PUParticle3DInterParticleCollider(void);
  58. protected:
  59. /** Todo
  60. */
  61. bool validateAndExecuteSphereCollision (PUParticle3D* particle1, PUParticle3D* particle2, float timeElapsed);
  62. protected:
  63. float _adjustment;
  64. InterParticleCollisionResponse _interParticleCollisionResponse;
  65. };
  66. NS_CC_END
  67. #endif