§
    ø(g%  ã                  ón   — d dl mZ dZd dlZd dlmZmZ d„ Zdd„Z G d„ d¦  «        Z	d	„ Z
d
„ Zd„ Zd„ ZdS )é    )Úannotations)Úadd_object_align_initÚobject_data_addÚAddObjectHelperÚobject_add_grid_scaleÚ$object_add_grid_scale_apply_operatorÚworld_to_camera_viewÚ+object_report_if_active_shape_key_is_lockedN)ÚFloatVectorPropertyÚEnumPropertyc                ó  — ddl m}m} |�|j        nd}| j        }|r|j        dk    rd}|r9|                     d¦  «        r$|                      ||j        ¦  «        ¦  «        }n?|                     | j	        j
        j        ¦  «        }|r|                     ¦   «         |_        | j        j        j        }|�r2|                     d¦  «        s||_        |j        dk    r-|j                             ¦   «                              ¦   «         }�nq|j        dk    r_|j        j                             ¦   «                              ¦   «         }|                     ¦   «          |                     ¦   «         |_        �n|j        d	k    r=| j	        j
        j        }d
|j        d         dd…<   |                     ¦   «         |_        n¿|j                             ¦   «                              ¦   «         }n“|dk    rG|rE|j        j                             ¦   «                              ¦   «         }|                     ¦   «          nF|d	k    r6| j	        j
        j                             ¦   «                              ¦   «         }n
 |¦   «         }||z  S )ax  
    Return a matrix using the operator settings and view context.

    :arg context: The context to use.
    :type context: :class:`bpy.types.Context`
    :arg operator: The operator, checked for location and rotation properties.
    :type operator: :class:`bpy.types.Operator`
    :return: the matrix from the context and settings.
    :rtype: :class:`mathutils.Matrix`
    r   )ÚMatrixÚVectorNÚVIEW_3DÚlocationÚrotationÚWORLDÚVIEWÚCURSOR)ç        r   r   é   )Ú	mathutilsr   r   Ú
propertiesÚ
space_dataÚtypeÚis_property_setÚTranslationr   ÚsceneÚcursorÚto_translationÚpreferencesÚeditÚobject_alignÚalignr   Ú	to_matrixÚto_4x4Ú	region_3dÚview_matrixÚto_3x3ÚinvertedÚ
resize_4x4Úto_eulerÚmatrixÚcolÚrotation_euler)	ÚcontextÚoperatorr   r   r   r   r   Úadd_align_preferencer   s	            ú]/home/blender/git/blender-v430/install_release/4.3/scripts/modules/bpy_extras/object_utils.pyr   r      s€  € ð )Ð(Ð(Ð(Ð(Ð(Ð(Ð(Ø(0Ð(<�Ô$Ð$À$€JàÔ#€JØð �j”o¨Ò2Ð2Øˆ
ð ð <�J×.Ò.¨zÑ:Ô:ð <Ø×%Ò% f f¨ZÔ-@Ñ&AÔ&AÑBÔBˆˆà×%Ò% g¤mÔ&:Ô&CÑDÔDˆàð 	<Ø"*×"9Ò"9Ñ";Ô";ˆJÔð #Ô.Ô3Ô@ÐØñ  Ø×)Ò)¨*Ñ5Ô5ð 	4à3ˆJÔàÔ˜wÒ&Ð&Ø!Ô*×4Ò4Ñ6Ô6×=Ò=Ñ?Ô?ˆH‰HØÔ Ò'Ð'Ø!Ô+Ô7×>Ò>Ñ@Ô@×IÒIÑKÔKˆHØ×ÒÑ!Ô!Ð!Ø"*×"3Ò"3Ñ"5Ô"5ˆJÔÑØÔ Ò)Ð)Ø”}Ô+Ô2ˆHØ#0ˆHŒL˜ŒO˜A˜a˜CÑ Ø"*×"3Ò"3Ñ"5Ô"5ˆJÔÐà!Ô*×4Ò4Ñ6Ô6×=Ò=Ñ?Ô?ˆHˆHà  FÒ*Ð*°
Ð*Ø!Ô+Ô7×>Ò>Ñ@Ô@×IÒIÑKÔKˆHØ×ÒÑ!Ô!Ð!Ð!Ø! XÒ-Ð-Ø”}Ô+Ô:×DÒDÑFÔF×MÒMÑOÔOˆHˆHà�v‘x”xˆHà�hÑÐó    c                ó<  — | j         }| j        p|j        }|j        }|j        D ]}|                     d¦  «         Œ|€|€dn|j        }|j        j        }t          j	        j         
                    ||¦  «        }	|j                             |	¦  «         |	                     d¦  «         t          | |¦  «        |	_        | j        }
|
r|
j        dk    rd}
|
r|
j        r|	                     |
d¦  «         |�rA|j        dk    �r5|j        |	j        k    �r$t          j        j                             d¬¦  «         |                     d¦  «         t          j        j                             d	¬
¦  «         |                     d¦  «         |                     ¦   «          |j        j        }|�|j	        j        j        }|�|j        |_        t          j        j                             ¦   «          |r$t          j	        j                             |¦  «         t          j        j                             d¬
¦  «         ne|	|j        _        | j        j        j        rH|rF|j         €?|	j        }d}|dv rd}n|dk    rd}|�%t          j        j                             |¬
¦  «         |	S )aF  
    Add an object using the view context and preference to initialize the
    location, rotation and layer.

    :arg context: The context to use.
    :type context: :class:`bpy.types.Context`
    :arg obdata: Valid object data to used for the new object or None.
    :type obdata: :class:`bpy.types.ID` | None
    :arg operator: The operator, checked for location and rotation properties.
    :type operator: :class:`bpy.types.Operator`
    :arg name: Optional name
    :type name: str
    :return: the newly created object in the scene.
    :rtype: :class:`bpy.types.Object`
    FNÚObjectTr   ÚEDITÚDESELECT)ÚactionÚOBJECT)Úmode>   ÚFONTÚMESHÚMETAÚCURVEÚCURVESÚLATTICEÚSURFACEÚARMATUREÚGPENCILÚEDIT_GPENCIL)!Ú
view_layerÚlayer_collectionÚactive_layer_collectionÚ
collectionÚobjectsÚ
select_setÚnameÚactiveÚbpyÚdataÚnewÚlinkr   Úmatrix_worldr   r   Ú
local_viewÚlocal_view_setr;   ÚopsÚmeshÚ
select_allÚobjectÚmode_setÚupdateÚ	uv_layersÚjoinÚmeshesÚremover!   r"   Úuse_enter_edit_modeÚlibrary)r0   Úobdatar1   rL   ÚlayerrG   Úscene_collectionÚobÚobj_actÚobj_newr   Úuv_newÚuv_actÚobtyper;   s                  r3   r   r   U   sš  € ð  Ô€EØÔ/ÐP°5Ô3PÐØ'Ô2ÐàŒmð ð ˆØ
�Š�eÑÔÐÐà€|Ø!˜>ˆxˆx¨v¬{ˆàŒmÔ"€GÝŒhÔ×"Ò" 4¨Ñ0Ô0€GØÔ×!Ò! 'Ñ*Ô*Ð*Ø×Ò�tÑÔÐÝ0°¸(ÑCÔC€GÔàÔ#€JØð �j”o¨Ò2Ð2Øˆ
àð 5ØÔ ð 	5Ø×"Ò" :¨tÑ4Ô4Ð4àñ "7�7”< 6Ò)Ñ)¨g¬l¸g¼lÒ.JÑ.JÝŒŒ×Ò zÐÑ2Ô2Ð2Ø×Ò˜4Ñ Ô Ð ÝŒŒ×Ò XÐÑ.Ô.Ð.à×Ò˜4Ñ Ô Ð Ø�Š‰Œˆð
 Ô!Ô(ˆØÐØ”\Ô+Ô2ˆFØÐ!Ø$œk�”åŒŒ×ÒÑÔÐØð 	+ÝŒHŒO×"Ò" 6Ñ*Ô*Ð*åŒŒ×Ò VÐÑ,Ô,Ð,Ð,à&ˆŒÔØÔÔ#Ô7ð 
	7Øð 	7˜&œ.Ð0Ø œ�Ø�ØÐjÐjÐjØ!�D�DØ˜yÒ(Ð(Ø)�DàÐ#Ý”G”N×+Ò+°Ð+Ñ6Ô6Ð6à€Nr4   c                  óJ   — e Zd ZU d„ Zded<   ded<   ded<   ed„ ¦   «         Zd	S )
r   c                óR   — | j         dk    r| j                             ¦   «          d S d S )Nr   )r$   r   Úzero)ÚselfÚ_contexts     r3   Úalign_update_callbackz%AddObjectHelper.align_update_callback¥   s1   € ØŒ:˜Ò Ð ØŒM×ÒÑ Ô Ð Ð Ð ð !Ð r4   a  EnumProperty(name='Align', items=(('WORLD', 'World', 'Align the new object to the world'), ('VIEW', 'View', 'Align the new object to the view'), ('CURSOR', '3D Cursor', 'Use the 3D cursor orientation for the new object')), default='WORLD', update=AddObjectHelper.align_update_callback)r$   z;FloatVectorProperty(name='Location', subtype='TRANSLATION')r   z5FloatVectorProperty(name='Rotation', subtype='EULER')r   c                ó   — |j         j        d u S )N)r   r`   )Úclsr0   s     r3   ÚpollzAddObjectHelper.poll¼   s   € àŒ}Ô$¨Ð,Ð,r4   N)Ú__name__Ú
__module__Ú__qualname__ro   Ú__annotations__Úclassmethodrr   © r4   r3   r   r   ¤   s|   € € € € € € ð!ð !ð !ð	ð 	ð 	ñ 	ðð ð ñ ðð ð ñ ð
 ð-ð -ñ „[ð-ð -ð -r4   r   c                óF   — | j         }|r|j        dk    r|j        j        S dS )z[
    Return scale which should be applied on object
    data to align it to grid scale
    r   g      ð?)r   r   ÚoverlayÚgrid_scale_unit)r0   r   s     r3   r   r   Á   s1   € ð Ô#€Jàð 2�j”o¨Ò2Ð2ØÔ!Ô1Ð1àˆ3r4   c           	     ó&  — t          |¦  «        }| j        }|j        j        }|                     ¦   «         D ]Y}|                     |d¬¦  «        s@||         }|j        dk    r-|j        dk    r"t          | |t          | |¦  «        |z  ¦  «         ŒZdS )z>
    Scale an operators distance values by the grid size.
    F)ÚghostÚLENGTHÚDISTANCEN)	r   r   Úbl_rnaÚkeysr   ÚunitÚsubtypeÚsetattrÚgetattr)r1   r0   Ú
grid_scaler   Úproperties_defÚprop_idÚprop_defs          r3   r   r   Ï   s¹   € õ
 ' wÑ/Ô/€JàÔ$€JØÔ&Ô1€NØ!×&Ò&Ñ(Ô(ð Að AˆØ×)Ò)¨'¸Ð)Ñ?Ô?ð 	AØ% gÔ.ˆHØŒ} Ò(Ð(¨XÔ-=ÀÒ-KÐ-KÝ˜ 'Ý ¨'Ñ2Ô2°ZÑ?ñAô Að Aøð	Að Ar4   c                óò  ‡— ddl m} |j                             ¦   «                              ¦   «         |z  }|j         Š|j        }d„ |                     | ¬¦  «        dd…         D ¦   «         }|j        dk    r‰dk    r |d	¦  «        S ˆfd
„|D ¦   «         }|d         j	        |d         j	        }}|d         j
        |d         j
        }
}	|j	        |z
  ||z
  z  }|j
        |	z
  |
|	z
  z  } |||‰f¦  «        S )a  
    Returns the camera space coords for a 3d point.
    (also known as: normalized device coordinates - NDC).

    Where (0, 0) is the bottom left and (1, 1)
    is the top right of the camera frame.
    values outside 0-1 are also supported.
    A negative 'z' value means the point is behind the camera.

    Takes shift-x/y, lens angle and sensor size into account
    as well as perspective/ortho projections.

    :arg scene: Scene to use for frame size.
    :type scene: :class:`bpy.types.Scene`
    :arg obj: Camera object.
    :type obj: :class:`bpy.types.Object`
    :arg coord: World space location.
    :type coord: :class:`mathutils.Vector`
    :return: a vector where X and Y map to the view plane and
       Z is the depth on the view axis.
    :rtype: :class:`mathutils.Vector`
    r   )r   c                ó   — g | ]}|‘ŒS rx   rx   )Ú.0Úvs     r3   ú
<listcomp>z(world_to_camera_view.<locals>.<listcomp>ý   s   € Ð;Ð;Ð;�1ˆQÐ;Ð;Ð;r4   )r   Nr   ÚORTHOr   )ç      à?r�   r   c                ó,   •— g | ]}||j         ‰z  z   ‘ŒS rx   )Úz)rŒ   r�   r’   s     €r3   rŽ   z(world_to_camera_view.<locals>.<listcomp>  s&   ø€ Ð5Ð5Ð5¨!�q˜AœC !™G‘}Ð%Ð5Ð5Ð5r4   é   é   )r   r   rR   Ú
normalizedr*   r’   rO   Ú
view_framer   ÚxÚy)r   ÚobjÚcoordr   Úco_localÚcameraÚframeÚmin_xÚmax_xÚmin_yÚmax_yr—   r˜   r’   s                @r3   r	   r	   à   s"  ø€ ð. !Ð Ð Ð Ð Ð àÔ×*Ò*Ñ,Ô,×5Ò5Ñ7Ô7¸%Ñ?€HØ	Œˆ€AàŒX€FØ;Ð;˜×)Ò)°Ð)Ñ6Ô6°r¸°rÔ:Ð;Ñ;Ô;€EØ„{�gÒÐØ�Š8ˆ8Ø�6˜/Ñ*Ô*Ð*à5Ð5Ð5Ð5¨uÐ5Ñ5Ô5ˆEà˜”8”:˜u Qœxœzˆ5€EØ˜”8”:˜u Qœxœzˆ5€Eà	Œ�eÑ	 ¨¡Ñ.€AØ	Œ�eÑ	 ¨¡Ñ.€Aàˆ6�1�a˜�)ÑÔÐr4   c                óŒ   — | j         }|r:|j        r3|r/|                     dhd                     | j        ¦  «        ¦  «         dS dS )aå  
    Checks if the active shape key of the specified object is locked, and reports an error if so.

    If the object has no shape keys, there is nothing to lock, and the function returns False.

    :arg obj: Object to check.
    :type obj: :class:`bpy.types.Object`
    :arg operator: Currently running operator to report the error through. Use None to suppress emitting the message.
    :type operator: :class:`bpy.types.Operator`
    :return: True if the shape key was locked.
    ÚERRORz&The active shape key of {:s} is lockedTF)Úactive_shape_keyÚ
lock_shapeÚreportÚformatrL   )r™   r1   Úkeys      r3   r
   r
     sY   € ð Ô
€Cà
ð ˆsŒ~ð Øð 	bØ�OŠO˜W˜IÐ'O×'VÒ'VÐWZÔW_Ñ'`Ô'`ÑaÔaÐaàˆtàˆ5r4   )NN)Ú
__future__r   Ú__all__rN   Ú	bpy.propsr   r   r   r   r   r   r   r	   r
   rx   r4   r3   ú<module>r¬      sî   ðð
 #Ð "Ð "Ð "Ð "Ð "ð€ð €
€
€
ðð ð ð ð ð ð ð ð8ð 8ð 8ðvLð Lð Lð Lð^-ð -ð -ð -ð -ñ -ô -ð -ð:ð ð ðAð Að Að"*ð *ð *ðZð ð ð ð r4   