
    ai                     X    S SK r S SKr " S S\ R                  R                  5      r\4rg)    Nc                   l    \ rS rSrSrSrSS1rSr\S 5       r	S r
\S	 5       rS
 rS rS rS rS rSrg)WORLD_OT_convert_volume_to_mesh	   zConvert the volume of a world to a mesh. The world's volume used to be rendered by EEVEE Legacy. Conversion is needed for it to render properlyzConvert VolumeREGISTERUNDOzworld.convert_volume_to_meshc                     U R                  U5      nU(       d  gUR                  nUR                  S5      n[        UR                  S   R
                  5      $ )NFEEVEEVolume)
_world_get	node_treeget_output_nodeboolinputslinks)clscontextworldntreenodes        Z/home/wildlama/Downloads/blender-5.1.2-linux-x64/5.1/scripts/startup/bl_operators/world.pypoll$WORLD_OT_convert_volume_to_mesh.poll   sI    w'$$W-DKK)//00    c                 P   U R                   nUR                  U5      nUR                  nUR                  nUR	                  S5      nSR                  UR                  5      n[        R                  R                  R                  U5      nUR                  R                  R                  R                  U5        [        R                  R                  R                  U5      n	[        R                  R                   R                  Xy5      n
SU
R"                  l        [&        R                  " 5       n[&        R(                  R+                  USSS9  UR-                  U	5        UR/                  5         U	R0                   HB  nUR2                  (       d  UR4                  (       a  M'  U	R0                  R7                  U5        MD     [        R                  R8                  R                  U5      nU	R8                  R;                  U5        UR                  nUR<                  R?                  5         UR<                  R                  S5        UR	                  S5      n/ nU RA                  X5        U RC                  UUURD                  S   UURD                  S   U5        U RG                  UU5        URH                  S:X  ah  UR<                  R                  SS	9nUR<                  R                  S
S	9nURJ                  R                  URL                  S   URD                  S   5        URD                  S   RJ                   H  nURJ                  R7                  U5        M      UR                   R                  U
5        U
RO                  S5        XR                   l(        SUl)        S1$ )Nr	   z{:s}_volumeFr   g     j@)subdivisionsradiusShaderNodeOutputMaterialr
   )typeShaderNodeBsdfTransparentTFINISHED)*	__class__r   
view_layerr   r   formatnamebpydatacollectionsnewlayer_collection
collectionchildrenlinkmeshesobjectsdisplayshow_shadowsbmeshopscreate_icosphereto_meshfree
attributesis_internalis_requiredremove	materialsappendnodesclear_sync_rna_properties_sync_node_inputr   _sync_linkstargetr   outputs
select_setactiveuse_eevee_finite_volume)selfr   r   r   r"   
world_treeworld_outputr$   r*   meshobjectbm	attributematerialvolume_treevolume_outputlinks_to_add
all_outputtransparentr,   s                       r   execute'WORLD_OT_convert_volume_to_mesh.execute   s   nnw'''
__
!11':##EJJ/XX))--d3
##..77<<ZH xx""4(!!%%d1&+#YY[		""2Ac"B


4
	 I$$	(=(=OO""9- )
 88%%))$/h'((!89#33G<!!->  *)	
 	l3 7*$**..4N.OJ%++//5P/QK!!+"5"5a"8*:K:KA:NO !''177D##D) 8 	'$$*!(-%|r   c                 Z    [        U SS 5      =n(       a  U$ U R                  R                  $ )Nr   )getattrscener   )r   r   s     r   r   *WORLD_OT_convert_volume_to_mesh._world_get[   s+    GWd3353L}}"""r   c                 8   U R                  X55        UR                   Hy  nUR                  nU R                  XU5      n	UR                  R                  UR                  R                  5      n
UR                  R                  U	R                  U
   U5        M{     g N)	r>   r   	from_node
_sync_noderB   findfrom_socketr$   r(   )rF   dst_treedst_node
dst_socketsrc_node
src_socketrP   src_linksrc_linked_nodedst_linked_nodefrom_socket_indexs              r   r?   0WORLD_OT_convert_volume_to_mesh._sync_node_inputa   s     	!!*9"((H&00O"oohVO ( 0 0 5 5h6J6J6O6O PNN''(9: )r   c                     UR                   UR                  ;   a  UR                  UR                      $ UR                  R                  UR                  5      nU R	                  XB5        U R                  XX#5        U$ )z
Find the counter part of the src_node in dst_tree. When found return the counter part. When not found
create the counter part, sync it and return the created node.
)r$   r<   r(   	bl_idnamer>   _sync_node_inputs)rF   r_   rb   rP   r`   s        r   r\   *WORLD_OT_convert_volume_to_mesh._sync_nodeu   sd     ==HNN*>>(--00>>%%h&8&89!!(5x8Jr   c           	          UR                   R                   H?  nUR                  (       a  M  UR                  nUS;   a  M*  [	        X[        X$5      5        MA     g )N>   rj   bl_static_type)bl_rna
propertiesis_readonly
identifiersetattrrV   )rF   dstsrcrna_prop	attr_names        r   r>   4WORLD_OT_convert_volume_to_mesh._sync_rna_properties   sH    

--H## ++I;;CGC$;< .r   c           	          [        [        UR                  5      5       H4  nUR                  U   nUR                  U   nU R                  XXsXd5        M6     g rZ   )rangelenr   r?   )rF   r_   r`   rb   rP   indexrc   ra   s           r   rk   1WORLD_OT_convert_volume_to_mesh._sync_node_inputs   sJ     3x/0E!/J!/J!!(jJe 1r   c                     g rZ    )rF   r_   rP   s      r   r@   +WORLD_OT_convert_volume_to_mesh._sync_links   s    
 	r   r   N)__name__
__module____qualname____firstlineno____doc__bl_label
bl_optionsrj   classmethodr   rS   staticmethodr   r?   r\   r>   rk   r@   __static_attributes__r   r   r   r   r   	   sb    uHf%J.I1 1?B # #
(&=
fr   r   )r%   r1   typesOperatorr   classesr   r   r   <module>r      s2   
  Zcii&8&8 Z| $r   