hkpMoppMachine.h
上传用户:yisoukefu
上传日期:2020-08-09
资源大小:39506k
文件大小:8k
源码类别:

其他游戏

开发平台:

Visual C++

  1. /* 
  2.  * 
  3.  * Confidential Information of Telekinesys Research Limited (t/a Havok). Not for disclosure or distribution without Havok's
  4.  * prior written consent. This software contains code, techniques and know-how which is confidential and proprietary to Havok.
  5.  * Level 2 and Level 3 source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2009 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement.
  6.  * 
  7.  */
  8. //
  9. //
  10. #ifndef HK_COLLIDE2_MOPP_MACHINE_H
  11. #define HK_COLLIDE2_MOPP_MACHINE_H
  12. #include <Common/Base/hkBase.h>
  13. #include <Common/Visualize/Shape/hkDisplayGeometry.h>
  14. #include <Common/Base/Types/Color/hkColor.h>
  15. #include <Physics/Internal/Collide/Mopp/Machine/hkp26Dop.h>
  16. struct hkpMoppPlanesQueryInput
  17. {
  18. public:
  19. HK_DECLARE_NONVIRTUAL_CLASS_ALLOCATOR( HK_MEMORY_CLASS_MOPP, hkpMoppPlanesQueryInput );
  20. enum { HK_MAX_NUM_PLANES = 32 };
  21. /// The number of planes, a maximum of HK_MAX_NUM_PLANES
  22. int m_numPlanes;
  23. /// The planes. The distance to the plane is calculated using:<br>
  24. /// dist = m_planes[x].dot3( position ) + m_planes[x](3)<br>
  25. /// The planes are pointing away from the viewing frustum (they define a convex object)
  26. /// so they have the same direction as the planes in the hkpConvexVerticesShape
  27. const hkVector4 *m_planes;
  28. };
  29. /// Output object for hkpMoppKDopGeometriesVirtualMachine.  One of these is
  30. /// created for each KDop that is found, according to the hkpMoppKDopQuery.
  31. struct hkpMoppInfo
  32. {
  33. HK_DECLARE_NONVIRTUAL_CLASS_ALLOCATOR( HK_MEMORY_CLASS_MOPP, hkpMoppInfo );
  34. /// The 26-plane bounded shape at each node of the mopp
  35. hkp26Dop m_dop;
  36. /// Shapekey of a terminal, if m_isTerminal is true
  37. hkpShapeKey m_shapeKey;
  38. /// The level this hkpMoppInfo represents
  39. hkInt8 m_level;
  40. /// Specifies whether this info represents a terminal.  If it doesn't,
  41. /// it represents an intermediate 
  42. hkBool m_isTerminal;
  43. };
  44. /// Query object for hkpMoppKDopGeometriesVirtualMachine
  45. struct hkpMoppKDopQuery
  46. {
  47. HK_DECLARE_NONVIRTUAL_CLASS_ALLOCATOR( HK_MEMORY_CLASS_MOPP, hkpMoppKDopQuery );
  48. /// Set true to exit after the first hit
  49. hkBool m_earlyExit;
  50. /// Depth of display kdops to display (-1 to just display nodes, 0 to display all)
  51. int m_kdopDepth;
  52. /// Set true to only save kdops that lead to the specified ID.
  53. hkBool m_useSpecifiedID;
  54. unsigned int m_specifiedId;
  55. hkpMoppKDopQuery()
  56. {
  57. m_earlyExit = false;
  58. m_kdopDepth = -1;
  59. m_useSpecifiedID = false;
  60. m_specifiedId = 0;
  61. }
  62. };
  63. class hkpMoppModifier;
  64. extern "C"
  65. {
  66. /// Returns true if the obb hits a mopp leave node
  67. int HK_CALL hkMoppEarlyExitObbVirtualMachine_queryObb(const hkpMoppCode* code, const hkTransform& BvToWorld, const hkVector4& extent, const float& radius);
  68. /// Return all the keys in a mopp. Note: the order of keys in a mopp is consistant.
  69. /// Please read hkpMoppCompilerInput
  70. void HK_CALL hkMoppFindAllVirtualMachine_getAllKeys(   const hkpMoppCode* code, hkArray<hkpShapeKey>* primitives_out);
  71. /// Returns at least keys in a mopp which overlap with the given obb
  72. void HK_CALL hkMoppObbVirtualMachine_queryObb(const hkpMoppCode* code, const hkTransform& BvToWorld, const hkVector4& halfExtent, const float radius, hkArray<hkpShapeKey>* primitives_out);
  73. /// Returns at least keys in a mopp which overlap with the given aabb
  74. void HK_CALL hkMoppObbVirtualMachine_queryAabb(const hkpMoppCode* code, const hkAabb& aabb, hkArray<hkpShapeKey>* primitives_out);
  75. /// Returns at least keys in a mopp which overlap with the given sphere
  76. void HK_CALL hkMoppSphereVirtualMachine_querySphere(const hkpMoppCode* code, const hkSphere &sphere, hkArray<hkpShapeKey>* primitives_out);
  77. /// Query optimized for frustum checks. It reports all hits intersecting the planes (partialHitsOut).
  78. /// and all hits completely inside the convex object defined by the planes (fullyIncludedHitsOut).
  79. void HK_CALL hkMoppUsingFloatAabbVirtualMachine_queryPlanes( const hkpMoppCode* code, const hkpMoppPlanesQueryInput &query, hkArray<hkpShapeKey>* partialHitsOut, hkArray<hkpShapeKey>* fullyIncludedHitsOut);
  80. /// Same as hkMoppUsingFloatAabbVirtualMachine_queryPlanes but instead of returning all hits which are fully included
  81. /// it returns ranges of hits in fullyIncludedHitsOut. 
  82. /// You can use hkMoppFindAllVirtualMachine_getAllKeys to find about the ordering of keys and
  83. /// than either reorder your input or create two mapping arrays.
  84. /// Example:<br>
  85. /// If you call hkMoppFindAllVirtualMachine_getAllKeys you might get the following hits:<br>
  86. /// 1, 3, 2, 7, 5, 4, 8, 6<br>
  87. /// If hkMoppUsingFloatAabbVirtualMachine_queryPlanesOptimized returns the range [3,4], it means all hits between 3 and 4 inclusive,
  88. /// which is 3,2,7,5,4
  89. void HK_CALL hkMoppUsingFloatAabbVirtualMachine_queryPlanesOptimized( const hkpMoppCode* code, const hkpMoppPlanesQueryInput &query, hkArray<hkpShapeKey>* partialHitsOut, hkArray<hkpShapeKey>* fullyIncludedHitsOut);
  90. /// Same as hkMoppUsingFloatAabbVirtualMachine_queryPlanes, but using a sphere instead of a convex object
  91. void HK_CALL hkMoppUsingFloatAabbVirtualMachine_querySphere( const hkpMoppCode* code, const hkSphere &query, hkArray<hkpShapeKey>* partialHitsOut, hkArray<hkpShapeKey>* fullyIncludedHitsOut);
  92. /// Same as hkMoppUsingFloatAabbVirtualMachine_queryPlanesOptimized, but using a sphere instead of a convex object
  93. void HK_CALL hkMoppUsingFloatAabbVirtualMachine_querySphereOptimized( const hkpMoppCode* code, const hkSphere &query, hkArray<hkpShapeKey>* partialHitsOut, hkArray<hkpShapeKey>* fullyIncludedHitsOut);
  94. /// Queries the mopp and calls shouldTerminalBeRemoved on at least all nodes which overlap the input aabbs.
  95. /// modifierOut returns whether you want to remove a node or not.
  96. /// For every subtree which only has 'to-be-removed' nodes the address ADDR of the root node of this
  97. /// subtree is calculated and m_modifierOut->addTerminalRemoveInfo(ADDR) called. If you set the moppcode at
  98. /// this relative address to zero, you will effectively disable this subtree.<br>
  99. /// In short:
  100. ///   - call queryAabb with an aabb containing all your nodes you want to remove
  101. ///   - for every node you want to remove, return true in you implementation of hkpMoppModifier::shouldTerminalBeRemoved
  102. ///   - remember all mopp code addressed in hkpMoppModifier::addTerminalRemoveInfo
  103. ///   - change the mopp at all those addresses to zero to apply the mopp changes.
  104. ///   - optional: if you remember all the places you have changed, than you can undo your changes
  105. void HK_CALL hkMoppModifyVirtualMachine_queryAabb( const hkpMoppCode* code, const hkAabb& aabb, hkpMoppModifier* modifierOut );
  106. /// 
  107. void HK_CALL hkMoppKDopGeometriesVirtualMachine_query( const hkpMoppCode* code, const hkpMoppKDopQuery &query, hkpMoppInfo* kDopGeometries );
  108. }
  109. #endif // HK_COLLIDE2_MOPP_MACHINE_H
  110. /*
  111. * Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20090216)
  112. * Confidential Information of Havok.  (C) Copyright 1999-2009
  113. * Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok
  114. * Logo, and the Havok buzzsaw logo are trademarks of Havok.  Title, ownership
  115. * rights, and intellectual property rights in the Havok software remain in
  116. * Havok and/or its suppliers.
  117. * Use of this software for evaluation purposes is subject to and indicates
  118. * acceptance of the End User licence Agreement for this product. A copy of
  119. * the license is included with this software and is also available at www.havok.com/tryhavok.
  120. */