
    ΍i(                    h    S SK Jr  SrS SKrS SKJrJr  S rSS jr " S S5      r	S	 r
S
 rS rS rg)    )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                   SSK JnJn  Ub  UR                  OSnU R                  nU(       a  UR
                  S:w  a  SnU(       a8  UR                  S5      (       a"  UR                  U" UR                  5      5      nOKUR                  U R                  R                  R                  5      nU(       a  UR                  5       Ul        U R                  R                  R                  nU(       GaK  UR                  S5      (       d  Xtl        UR                  S:X  a,  UR                   R#                  5       R%                  5       nXh-  $ UR                  S:X  a[  UR&                  R(                  R+                  5       R-                  5       nUR/                  5         UR1                  5       Ul        Xh-  $ UR                  S	:X  aK  U R                  R                  R2                  nS
UR4                  S   SS& UR1                  5       Ul        Xh-  $ UR                   R#                  5       R%                  5       n Xh-  $ US:X  aM  U(       aF  UR&                  R(                  R+                  5       R-                  5       nUR/                  5         Xh-  $ US	:X  a@  U R                  R                  R6                  R#                  5       R%                  5       nXh-  $ U" 5       nXh-  $ )ac  
Return a matrix using the operator settings and view context.

:param context: The context to use.
:type context: :class:`bpy.types.Context`
:param operator: The operator, checked for location and rotation properties.
:type operator: :class:`bpy.types.Operator` | None
: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/wildlama/Downloads/blender-5.1.2-linux-x64/5.1/scripts/modules/bpy_extras/object_utils.pyr   r      ss    )(0(<$$$J##Jjoo2
 J..z::%%fZ-@-@&AB%%gmm&:&:&C&CD"*"9"9";J #..33@@))*553w&!**446==?H( ' '!++77>>@IIKH!"*"3"3"5J   )}}++22H#0HLLOAa "*"3"3"5J  "**446==?H  !F*
!++77>>@IIKH!  "X-}}++::DDFMMOH  xH    c                b   U R                   nU R                  =(       d    UR                  nUR                  nUR                   H  nUR                  S5        M     Uc  Uc  SOUR                  nUR                  R                  n[        R                  R                  R                  X15      n	UR                  R                  U	5        U	R                  S5        [        X5      U	l        U R                  n
U
(       a  U
R                  S:w  a  Sn
U
(       a#  U
R                   (       a  U	R#                  U
S5        U(       Ga  UR$                  S:X  Ga  UR                  U	R                  :X  Ga  [        R&                  R(                  R+                  SS9  UR                  S5        [        R&                  R,                  R/                  S	S
9  UR                  S5        UR1                  5         UR2                  R                  nUb4  UR                  R2                  R                  nUb  UR                  Ul        [5        UR                  R6                  5      S:  a>  [5        UR6                  5      S:X  a%  UR6                  R9                  UR:                  5        [        R&                  R,                  R=                  5         U(       a)  [        R                  R>                  RA                  U5        [        R&                  R,                  R/                  SS
9  U	$ XR                  l        U RB                  RD                  RF                  (       a]  U(       aV  URH                  cI  U	R                  nSnUS;   a  SnOUS:X  a  SnUb'  [        R&                  R,                  R/                  US
9  U	$ )a+  
Add an object using the view context and preference to initialize the
location, rotation and layer.

:param context: The context to use.
:type context: :class:`bpy.types.Context`
:param obdata: Valid object data to be used for the new object or None.
:type obdata: :class:`bpy.types.ID` | None
:param operator: The operator, checked for location and rotation properties.
:type operator: :class:`bpy.types.Operator` | None
:param name: Optional name
:type name: str | None
:return: the newly created object in the scene.
:rtype: :class:`bpy.types.Object`
FNObjectTr   EDITDESELECT)actionOBJECT)moder   >   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len	materialsappendactive_material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//P53P3P'22mm
e  |!>xv{{mm""Ghh""40G!!'*t0CG##Jjoo2
  "":t47<<6)gllgll.Jz24 X.4 
 !!((\\++22F!$kk w||%%&*s63C3C/D/I##G$;$;<HHOO""6*V, N  '##77&..0 jj!Dy()D#GGNN+++6Nr4   c                  J    \ rS rSr% S rS\S'   S\S'   S\S'   \S	 5       rS
rg)r      c                Z    U R                   S:X  a  U R                  R                  5         gg)zLUpdate callback for the align property, resets rotation for world alignment.r   N)r$   r   zero)self_contexts     r3   align_update_callback%AddObjectHelper.align_update_callback   s#    :: MM  !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                2    UR                   R                  SL $ )z
Check the scene is not linked from a library.

:param context: The context.
:type context: :class:`bpy.types.Context`
:return: True when the scene is local (not linked from a library).
:rtype: bool
N)r   rd   )clsr0   s     r3   pollAddObjectHelper.poll   s     }}$$,,r4    N)	__name__
__module____qualname____firstlineno__rt   __annotations__classmethodrx   __static_attributes__rz   r4   r3   r   r      s9    !
	 	  
 	- 	-r4   r   c                v    U R                   nU(       a&  UR                  S:X  a  UR                  R                  $ g)z
Return scale which should be applied on object
data to align it to grid scale.

:param context: The context.
:type context: :class:`bpy.types.Context`
:return: The grid scale.
:rtype: float
r   g      ?)r   r   overlaygrid_scale_unit)r0   r   s     r3   r   r      s2     ##Jjoo2!!111r4   c           	     :   [        U5      nU R                  nUR                  R                  nUR                  5        HZ  nUR	                  USS9(       a  M  XE   nUR
                  S:X  d  M0  UR                  S:X  d  MB  [        X[        X5      U-  5        M\     g)z
Scale an operator's distance values by the grid size.

:param operator: The operator to scale.
:type operator: :class:`bpy.types.Operator`
:param context: The context.
:type context: :class:`bpy.types.Context`
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1N!&&())')??%.H}}(X-=-=-K2Z?A	 )r4   c                D   SSK Jn  UR                  R                  5       R	                  5       U-  nUR
                  * nUR                  nUR                  U S9SS  Vs/ s H  owPM     nnUR                  S:w  a0  US:X  a  U" S5      $ U Vs/ s H  owUR
                  U-  -  * PM     nnUS	   R                  US
   R                  pUS
   R                  US   R                  pUR                  U	-
  X-
  -  nUR                  U-
  X-
  -  nU" XU45      $ s  snf s  snf )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.

:param scene: Scene to use for frame size.
:type scene: :class:`bpy.types.Scene`
:param obj: Camera object.
:type obj: :class:`bpy.types.Object`
:param 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   )r   Nr   ORTHOr   )      ?r   r         )r   r   rR   
normalizedr*   zrO   
view_framer   xy)r   objcoordr   co_localr   cameravframemin_xmax_xmin_ymax_yr   r   s                  r3   r	   r	      s   . !**,557%?H	AXXF)))6r:;:1Q:E;{{g8/**/45u!ACC!G}%uE58::uQxzz58::uQxzz5	e	.A	e	.A1) <
 6s   DDc                    U R                   nU(       aE  UR                  (       a4  U(       a,  UR                  S1SR                  U R                  5      5        gg)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.

:param obj: Object to check.
:type obj: :class:`bpy.types.Object`
:param operator: Currently running operator to report the error through. Use None to suppress emitting the message.
:type operator: :class:`bpy.types.Operator` | None
:return: True if the shape key was locked.
:rtype: bool
ERRORz&The active shape key of {:s} is lockedTF)active_shape_key
lock_shapereportformatrL   )r   r1   keys      r3   r
   r
   $  sD     

C
s~~OOWI'O'V'VWZW_W_'`ar4   )NN)
__future__r   __all__rN   	bpy.propsr   r   r   r   r   r   r   r	   r
   rz   r4   r3   <module>r      sI   
 # 8vPf#- #-L&A,*Zr4   