def box_aabb_intersect(bbox_min, bbox_max, ray, direction):
t1 = (bbox_min.x - ray.x) * direction.x t2 = (bbox_max.x - ray.x) * direction.x t3 = (bbox_min.y - ray.y) * direction.y t4 = (bbox_max.y - ray.y) * direction.y t5 = (bbox_min.z - ray.z) * direction.z t6 = (bbox_max.z - ray.z) * direction.z
t_min = max(max(min(t1, t2), min(t3, t4)), min(t5, t6)) t_max = min(min(max(t1, t2), max(t3, t4)), max(t5, t6))
if t_max < 0.0 or t_min > t_max: return
return t_mindef box_aabb_intersect(bbox_min, bbox_max, ray, direction): t1 = (bbox_min.x - ray.x) * direction.x t2 = (bbox_max.x - ray.x) * direction.x t3 = (bbox_min.y - ray.y) * direction.y t4 = (bbox_max.y - ray.y) * direction.y t5 = (bbox_min.z - ray.z) * direction.z t6 = (bbox_max.z - ray.z) * direction.z t_min = max(max(min(t1, t2), min(t3, t4)), min(t5, t6)) t_max = min(min(max(t1, t2), max(t3, t4)), max(t5, t6))
return t_max >= t_min--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/18ab0a86-841b-4390-9999-b23b51665012%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
def box_aabb_intersect(self, m_bbox):
"""
!@Brief Check if ray intersect boundingBox.
@type m_bbox: OpenMaya.MBoundingBox
@param m_bbox: BoundingBox you want to check
@rtype: float
@return: Distance of ray origin and intersect point.
"""
t1 = (m_bbox.min().x - self.__v_origin.x) / self.__v_direction.x
t2 = (m_bbox.max().x - self.__v_origin.x) / self.__v_direction.x
t3 = (m_bbox.min().y - self.__v_origin.y) / self.__v_direction.y
t4 = (m_bbox.max().y - self.__v_origin.y) / self.__v_direction.y
t5 = (m_bbox.min().z - self.__v_origin.z) / self.__v_direction.z
t6 = (m_bbox.max().z - self.__v_origin.z) / self.__v_direction.z
t_min = max(max(min(t1, t2), min(t3, t4)), min(t5, t6))
t_max = min(min(max(t1, t2), max(t3, t4)), max(t5, t6))
# if tmax < 0, ray (line) is intersecting AABB, but the whole AABB is behind us
# if tmin > tmax, ray doesn't intersect AABB
if t_max < 0.0 or t_min > t_max:
return
return t_min, t_max
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/91e425ff-e687-41a0-a5f7-8e3a449aabeb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
That seems correct to you ?
I got into the habit of doing that but I may be wrong...
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/b1abb0d9-541e-45cb-acb2-9331073fa91b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Usually as a maya developper I tried to use what comes from the API...
what a lot of python programmera forget is that you are doing work inside a dcc and thus you need to take the time to learn/ master this platform before coding thing yourself or try to fight it
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/a149eb2c-b060-4159-b464-1825a6b41573%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.