Octree.pkg 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. // 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 DrawDebugGeometry(bool depthTest);
  15. tolua_readonly tolua_property__get_set unsigned numLevels;
  16. };
  17. ${
  18. static RayQueryResult OctreeRaycastSingle(const Octree* octree, const Ray& ray, RayQueryLevel level, float maxDistance, unsigned char drawableFlags)
  19. {
  20. PODVector<RayQueryResult> result;
  21. RayOctreeQuery query(result, ray, level, maxDistance, drawableFlags);
  22. octree->RaycastSingle(query);
  23. if (!query.result_.Empty())
  24. return query.result_[0];
  25. else
  26. {
  27. RayQueryResult empty;
  28. empty.drawable_ = 0;
  29. empty.node_ = 0;
  30. empty.distance_ = M_INFINITY;
  31. empty.subObject_ = 0;
  32. return empty;
  33. }
  34. }
  35. $}