Octree.pkg 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. $#include "Octree.h"
  2. class Octree : public Component
  3. {
  4. void SetSize(const BoundingBox& box, unsigned numLevels);
  5. void Update(const FrameInfo& frame);
  6. void AddManualDrawable(Drawable* drawable);
  7. void RemoveManualDrawable(Drawable* drawable);
  8. // void GetDrawables(OctreeQuery& query) const;
  9. // void Raycast(RayOctreeQuery& query) const;
  10. tolua_outside void OctreeRaycast @ Raycast(PODVector<RayQueryResult> &result, const Ray& ray, RayQueryLevel level, float maxDistance, unsigned char drawableFlags) const;
  11. // void RaycastSingle(RayOctreeQuery& query) const;
  12. tolua_outside RayQueryResult OctreeRaycastSingle @ RaycastSingle(const Ray& ray, RayQueryLevel level, float maxDistance, unsigned char drawableFlags) const;
  13. unsigned GetNumLevels() const;
  14. void QueueUpdate(Drawable* drawable);
  15. void DrawDebugGeometry(bool depthTest);
  16. tolua_readonly tolua_property__get_set unsigned numLevels;
  17. };
  18. ${
  19. static RayQueryResult OctreeRaycastSingle(const Octree* octree, const Ray& ray, RayQueryLevel level, float maxDistance, unsigned char drawableFlags)
  20. {
  21. PODVector<RayQueryResult> result;
  22. RayOctreeQuery query(result, ray, level, maxDistance, drawableFlags);
  23. octree->RaycastSingle(query);
  24. if (!query.result_.Empty())
  25. return query.result_[0];
  26. else
  27. {
  28. RayQueryResult empty;
  29. empty.position_ = Vector3::ZERO;
  30. empty.normal_ = Vector3::ZERO;
  31. empty.distance_ = M_INFINITY;
  32. empty.subObject_ = 0;
  33. return empty;
  34. }
  35. }
  36. static void OctreeRaycast(const Octree* octree, PODVector<RayQueryResult> &result, const Ray& ray, RayQueryLevel level, float maxDistance, unsigned char drawableFlags)
  37. {
  38. RayOctreeQuery query(result,ray,level,maxDistance,drawableFlags);
  39. octree->Raycast(query);
  40. }
  41. $}