Ok got you. Good to know that you figured it. Just a quick note about your
implementation specific to python. It is better not to have attribute
starting with __ if you want to those attributes that attribute to be
subclassed. Python interpreter does a name mangling for attributes starting
with __ so that if class Foo has an attribute __bar, it would always refer
to the Foo__bar and subclasses cannot override it. If a subclass Baz(Foo)
tries to override __bar, it is simply not allowed.

In your example code, I see that you have __v_origin.x being used. That
means __v_origin.x cannot be subclassed. If your intended purpose is such,
then you are on the right path, if not then you need to name it _v_origin
instead of __v_origin.


On Fri, May 19, 2017 at 6:40 PM, Rémi Deletrain <[email protected]>
wrote:

> Thank you for your answer Alok,
> After much rereading and viewing other script on the internet I saw my
> error ... you have to replace the * by / for each "edge" ...
>
> I have only one condition that tells me whether I have an intersection or
> not. In this case I return None. The script that will call this function
> will have to make the verification namely: If it's none I do what? This is
> not None so I have the min, max values ​​of my intersection
>
> 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 [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/python_inside_maya/91e425ff-e687-41a0-a5f7-
> 8e3a449aabeb%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/91e425ff-e687-41a0-a5f7-8e3a449aabeb%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



--

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPaTLMSPYzhKFrLQE-eovuLJTPnWXNjyXnkShG0um%2BRu4PighQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to