Octree.pkg 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. $#include "Octree.h"
  2. class Octree : public Component
  3. {
  4. void Resize(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. // void RaycastSingle(RayOctreeQuery& query) const;
  11. tolua_outside RayQueryResult OctreeRaycastSingle @ RaycastSingle(const Ray& ray, RayQueryLevel level, float maxDistance, unsigned char drawableFlags) const;
  12. unsigned GetNumLevels() const;
  13. void QueueUpdate(Drawable* drawable);
  14. void QueueReinsertion(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.drawable_ = 0;
  30. empty.node_ = 0;
  31. empty.distance_ = M_INFINITY;
  32. empty.subObject_ = 0;
  33. return empty;
  34. }
  35. }
  36. $}