socket_definitions.py 120 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055
  1. import bpy
  2. from bpy.types import NodeSocket, NodeSocketStandard
  3. # Classes which do not have default_value
  4. # needed to detect when there is an error updating dynamic nodes
  5. no_default_value= frozenset({
  6. 'MantisSocket',
  7. 'RelationshipSocket',
  8. 'DeformerSocket',
  9. 'xFormSocket',
  10. 'GeometrySocket',
  11. 'GenericRotationSocket',
  12. 'CustomPropSocket',
  13. 'FCurveSocket',
  14. 'DriverSocket',
  15. 'DriverVariableSocket',
  16. 'xFormParameterSocket',
  17. 'MorphTargetSocket',
  18. 'KeyframeSocket',
  19. 'WildcardSocket',
  20. })
  21. # the sockets that do not have this field do not transfer data.
  22. # instead, it is the link itself which is meaningful.
  23. from bpy.app import version as bpy_version
  24. parent_classes = (NodeSocket)
  25. if bpy_version == (4,5,0): # THere is a bug that requires the socket type to inherit from a Blender class
  26. from bpy.types import NodeSocketGeometry # so we will just inherit from NodeSocketGeometry
  27. parent_classes = (NodeSocketGeometry, NodeSocket)
  28. class MantisSocket(parent_classes):
  29. is_valid_interface_type=False
  30. enum_display_type="TABS" # TABS or DROPDOWN
  31. category : bpy.props.StringProperty()
  32. @property
  33. def interface_type(self):
  34. # this is stupid but it is the fastest way to implement this
  35. # TODO: refactor this, it should be a class property
  36. if hasattr(self, "color"):
  37. return map_color_to_socket_type(self.color)
  38. return map_color_to_socket_type(self.color_simple)
  39. def draw(self, context, layout, node, text):
  40. ChooseDraw(self, context, layout, node, text)
  41. def draw_color(self, context, node):
  42. return self.color
  43. @classmethod
  44. def draw_color_simple(self):
  45. return self.color_simple
  46. def socket_update_get_root_tree(self, context):
  47. context = bpy.context
  48. if not context.space_data:
  49. return None
  50. if not hasattr(context.space_data, "path"):
  51. return None
  52. try:
  53. root_tree = context.space_data.path[0].node_tree
  54. except IndexError: # not in the UI, for example, in a script instead.
  55. return None
  56. if root_tree is None:
  57. return None
  58. if root_tree.is_executing or root_tree.is_exporting or not root_tree.do_live_update:
  59. return None
  60. return root_tree
  61. def overlay_toggle_update(self, context):
  62. prRed("BENIS BENIS BENIS")
  63. root_tree = socket_update_get_root_tree(self, context)
  64. if root_tree is None: return
  65. parsed_tree = self.node.id_data.parsed_tree
  66. if hasattr(self.node, "display_update"):
  67. self.node.display_update(parsed_tree=parsed_tree, context=context)
  68. root_tree.update_tree(context, force = True)
  69. # and we need to mark the node as un-prepared.
  70. # For now I am not gonna try to resolve the overlay value from the UI.
  71. def overlay_text_update(self, context):
  72. prPurple("BENIS BENIS BENIS")
  73. root_tree = socket_update_get_root_tree(self, context)
  74. if root_tree is None: return
  75. # have to check each one. see default_update NOTE
  76. handled = True
  77. for mantis_node in root_tree.parsed_tree.values():
  78. handled = try_update_mantis_node_for_socket(mantis_node, root_tree, self) and handled
  79. if not handled:
  80. root_tree.update_tree(context, force = True)
  81. root_tree.execute_tree(context)
  82. class MantisSocketOverlayEnabled(MantisSocket):
  83. # this class just needs a couple properties
  84. use_overlay: bpy.props.BoolProperty( default=False, update=overlay_toggle_update)
  85. overlay_text: bpy.props.StringProperty( default="", update=overlay_text_update)
  86. def draw(self, context, layout, node, text):
  87. is_simple_out = ((hasattr(self, "default_value")) and (hasattr(self, "input") and getattr(self, "input")))
  88. if self.is_linked and not is_simple_out:
  89. layout.label( text=text, )
  90. elif hasattr(self, "default_value"):
  91. row = layout.row(align=True)
  92. # We'll show the property or the overlay field here
  93. prop_field = "overlay_text" if self.use_overlay else "default_value"
  94. row.prop(self, prop_field,text=self.name)
  95. # and the button to choose whether or not to use the overlay field
  96. row.prop(self, "use_overlay", text="", icon='CONSOLE', toggle=True)
  97. else:
  98. layout.label(text=self.name)
  99. from .utilities.utilities import (prRed, prGreen, prPurple, prWhite,
  100. prOrange,
  101. wrapRed, wrapGreen, wrapPurple, wrapWhite,
  102. wrapOrange,)
  103. transform_spaces_bone_to = (('WORLD', "World", "World Space"),
  104. ('LOCAL', "Local", "Local Space"),
  105. ('POSE', "Pose", "Pose Space"),
  106. ('CUSTOM', "Custom", "Custom Space"),
  107. ('LOCAL_WITH_PARENT', "Local (With Parent)", "Local Space"),
  108. ('LOCAL_OWNER_ORIENT', "Local (Owner Orientation)", "Local Space"),)
  109. transform_spaces_bone_from = (('WORLD', "World", "World Space"),
  110. ('LOCAL', "Local", "Local Space"),
  111. ('POSE', "Pose", "Pose Space"),
  112. ('CUSTOM', "Custom", "Custom Space"),
  113. ('LOCAL_WITH_PARENT', "Local (With Parent)", "Local Space"),)
  114. transform_spaces_bone_object = (('WORLD', "World", "World Space"),
  115. ('LOCAL', "Local", "Local Space"),
  116. ('POSE', "Pose", "Pose Space"),
  117. ('CUSTOM', "Custom", "Custom Space"),)
  118. transform_spaces_object = (('WORLD', "World", "World Space"),
  119. ('LOCAL', "Local", "Local Space"),
  120. ('CUSTOM', "Custom", "Custom Space"),)
  121. enumRotationOrder =(('AUTO', 'Auto', 'Auto'),
  122. ('XYZ', "XYZ", "XYZ"),
  123. ('XZY', "XZY", "XZY"),
  124. ('ZXY', "ZXY", "ZXY"),
  125. ('ZYX', "ZYX", "ZYX"),
  126. ('YXZ', "YXZ", "YXZ"),
  127. ('YZX', "YZX", "YZX"),
  128. ('QUATERNION', "Quaternion", "Quaternion"),
  129. ('AXIS_ANGLE', "Axis Angle", "Axis Angle"),)
  130. eMatrixFromCurveModes = (('DIVISIONS', "Divisions", "Get a matrix from the curve automattically "
  131. "based on dividing it into pieces."),
  132. ('FACTOR', "Spline Factor", "Get a matrix from a specific factor"
  133. " along the spline."),
  134. ('FACTOR_WITH_TAIL', "Spline Factor (With Tail)",
  135. "Get a matrix from a specific factor along the spline, "
  136. "and place the tail on the curve at a specific factor. "))
  137. eMatrixComposeModes = (('BASIS', "Basis Vectors", "Compose a matrix from basis vectors. "
  138. "Mantis will not automatically orthonormalize them."),
  139. # TODO: Implement # ('BASIS_AUTO', "Basis Ortho Vectors", "Compose a matrix from basis vectors. "
  140. # this feature! # "Mantis will automatically orthonormalize them."),
  141. ('CHANNELS', "Transform Channels", "Compose a matrix from translation, rotation, "
  142. "and scale transform channels."))
  143. # node socket colors:
  144. cFloat = (0.631373, 0.631373, 0.631373, 1.000000)
  145. cColor = (0.780392, 0.780392, 0.160784, 1.000000)
  146. cVector = (0.388235, 0.388235, 0.780392, 1.000000)
  147. cShader = (0.388235, 0.780392, 0.388235, 1.000000)
  148. cInt = (0.058824, 0.521569, 0.149020, 1.000000)
  149. cString = (0.388235, 0.388235, 0.388235, 1.000000)
  150. # cBool = (0.698039, 0.650980, 0.188235, 1.000000)
  151. cParameter = (0.48, 0.24, 0.24, 1.0)
  152. cDriver = (0.88, 0.11, 0.88, 1.0)
  153. cDriverVariable = (0.66, 0.33, 0.04, 1.0)
  154. cFCurve = (0.77, 0.77, 0.11, 1.0)
  155. cKeyframe = (0.06, 0.22, 0.88, 1.0)
  156. cEnable = (0.92, 0.92, 0.92, 1.0)
  157. cBoneCollection = (0.82, 0.82, 0.82, 1.0)
  158. cDeformer = (0.05, 0.08, 0.45, 1.0)
  159. cShapeKey = (0.95, 0.32, 0.05, 1.0)
  160. # custom colors:
  161. cIK = (0.596078, 0.596078, 0.364706, 1.000000) #because it's yellow in Blender
  162. cRelationship = (0.352941, 0.584314, 0.431373, 1.000000) #constraint color
  163. cMatrix = (0.0, 1.0, 0.75, 1)
  164. cxForm = (0.843137, 0.592157, 0.388235, 1.000000) #could even fetch the theme colors...
  165. cTransformSpace = (1.0, 0.4, 0.216, 1.0)
  166. cBool = (0.1, 0.1, 0.1, 1.0)
  167. cBool3 = (0.35, 0.25, 0.18, 1.0)
  168. cRotationOrder = (0.0, 0.8, 0.0, 1.0)
  169. cQuaternion = (0.85, 0.25, 0.18, 1.0)
  170. #
  171. cGeometry = (0.000000, 0.672443, 0.366253, 1.000000)
  172. # think about making colors that are representative of the data's purpose:
  173. # location
  174. # rotation
  175. # scale
  176. # OR make all of it a reference to the type of data within?
  177. def color_equivalent(color_a, color_b):
  178. # because Blender's floating point numbers are not quite equal. pain.
  179. from .base_definitions import FLOAT_EPSILON
  180. for channel_a, channel_b in zip(color_a, color_b):
  181. if abs(channel_a-channel_b) > FLOAT_EPSILON:
  182. return False
  183. return True
  184. def map_color_to_socket_type(socket_color):
  185. # let's get the socket type by color for e.g. wildcard sockets.
  186. # for some reason I can't use match-case here. dumb.
  187. if color_equivalent(socket_color, cFloat):
  188. return "FloatSocket"
  189. if color_equivalent(socket_color, cColor):
  190. return "ColorSetSocket"
  191. if color_equivalent(socket_color, cVector):
  192. return "VectorSocket"
  193. if color_equivalent(socket_color, cInt):
  194. return "IntSocket"
  195. if color_equivalent(socket_color, cDriver):
  196. return "DriverSocket"
  197. if color_equivalent(socket_color, cDriverVariable):
  198. return "DriverVariableSocket"
  199. if color_equivalent(socket_color, cFCurve):
  200. return "FCurveSocket"
  201. if color_equivalent(socket_color, cKeyframe):
  202. return "KeyframeSocket"
  203. if color_equivalent(socket_color, cEnable):
  204. return "BooleanSocket"
  205. if color_equivalent(socket_color, cDeformer):
  206. return "DeformerSocket"
  207. if color_equivalent(socket_color, cShapeKey):
  208. return "MorphTargetSocket"
  209. if color_equivalent(socket_color, cMatrix):
  210. return "MatrixSocket"
  211. if color_equivalent(socket_color, cxForm):
  212. return "xFormSocket"
  213. if color_equivalent(socket_color, cBool):
  214. return "BooleanSocket"
  215. if color_equivalent(socket_color, cBool3):
  216. return "BooleanThreeTupleSocket"
  217. return "StringSocket"
  218. # Hybrid approach: Make same-data, similar purpose have similar colors.
  219. from typing import List
  220. def TellClasses() -> List[MantisSocket]:
  221. return [ #MantisSocket,
  222. #DefaultSocket,
  223. #InputSocket,
  224. MatrixSocket,
  225. xFormSocket,
  226. RelationshipSocket,
  227. DeformerSocket,
  228. GeometrySocket,
  229. GenericRotationSocket,
  230. EnableSocket,
  231. HideSocket,
  232. # InverseKinematicsSocket,
  233. DriverSocket,
  234. DriverVariableSocket,
  235. FCurveSocket,
  236. # LayerMaskSocket,
  237. # LayerMaskInputSocket,
  238. BoneCollectionSocket,
  239. EnumArrayGetOptions,
  240. EnumCustomPropTypeSocket,
  241. CustomPropSocket,
  242. xFormParameterSocket,
  243. ParameterBoolSocket,
  244. ParameterIntSocket,
  245. ParameterFloatSocket,
  246. ParameterVectorSocket,
  247. ParameterStringSocket,
  248. TransformSpaceSocket,
  249. BooleanSocket,
  250. InvertedBooleanSocket,
  251. BooleanThreeTupleSocket,
  252. RotationOrderSocket,
  253. QuaternionSocket,
  254. QuaternionSocketAA,
  255. UnsignedIntSocket,
  256. IntSocket,
  257. StringSocket,
  258. CollectionDeclarationSocket,
  259. ColorSetDisplaySocket,
  260. ColorSetSocket,
  261. EnumMetaRigSocket,
  262. EnumMetaBoneSocket,
  263. EnumArmature,
  264. EnumExistingBoneSocket,
  265. EnumCurveSocket,
  266. EnumWidgetLibrarySocket,
  267. BoolUpdateParentNode,
  268. # LabelSocket,
  269. IKChainLengthSocket,
  270. EnumInheritScale,
  271. EnumRotationMix,
  272. EnumRotationMixCopyTransforms,
  273. EnumMaintainVolumeStretchTo,
  274. EnumRotationStretchTo,
  275. EnumTrackAxis,
  276. EnumUpAxis,
  277. EnumFollowPathForwardAxis,
  278. EnumFloorAxis,
  279. EnumLockAxis,
  280. EnumLimitMode,
  281. EnumYScaleMode,
  282. EnumXZScaleMode,
  283. EnumTransformationMap,
  284. EnumTransformationRotationMode,
  285. EnumTransformationRotationOrder,
  286. EnumTransformationTranslationMixMode,
  287. EnumTransformationRotationMixMode,
  288. EnumTransformationScaleMixMode,
  289. EnumTransformationAxes,
  290. EnumBBoneHandleType,
  291. # Shrinkwrap
  292. EnumShrinkwrapTypeSocket,
  293. EnumShrinkwrapFaceCullSocket,
  294. EnumShrinkwrapProjectAxisSocket,
  295. EnumShrinkwrapModeSocket,
  296. # Geometry Attribute
  297. EnumGeometryAttributeDataTypeSocket,
  298. EnumGeometryAttributeDomainSocket,
  299. EnumMixModeGeometryAttribute,
  300. # Deformers
  301. EnumSkinning,
  302. MorphTargetSocket,
  303. #
  304. FloatSocket,
  305. FloatPositiveSocket,
  306. FloatFactorSocket,
  307. FloatAngleSocket,
  308. VectorSocket,
  309. VectorEulerSocket,
  310. VectorTranslationSocket,
  311. VectorScaleSocket,
  312. # Drivers
  313. EnumDriverVariableType,
  314. EnumDriverVariableEvaluationSpace,
  315. EnumDriverVariableTransformChannel,
  316. EnumDriverRotationMode,
  317. EnumDriverType,
  318. KeyframeSocket,
  319. EnumKeyframeInterpolationTypeSocket,
  320. EnumKeyframeBezierHandleTypeSocket,
  321. EnumLatticeInterpolationTypeSocket,
  322. EnumCorrectiveSmoothTypeSocket,
  323. eFCrvExtrapolationMode,
  324. # other enums
  325. EnumArmatureDisplayType,
  326. EnumDisplayType,
  327. # Math
  328. MathFloatOperation,
  329. MathVectorOperation,
  330. MatrixTransformOperation,
  331. #conditions
  332. EnumCompareOperation,
  333. # modes, options for node operations
  334. EnumMatrixFromCurveMode,
  335. EnumComposeMatrixModes,
  336. # Schema
  337. WildcardSocket,
  338. # xFormArraySocket,
  339. # RelationshipArraySocket,
  340. # BooleanArraySocket,
  341. # IntArraySocket,
  342. # FloatArraySocket,
  343. # BooleanThreeTupleArraySocket,
  344. # VectorArraySocket,
  345. # QuaternionArraySocket,
  346. # MatrixArraySocket,
  347. # StringArraySocket,
  348. ]
  349. def Tell_bl_idnames(): # reroute nodes
  350. return [cls.bl_idname for cls in TellClasses()]#+["NodeSocketColor"]
  351. def tell_valid_bl_idnames():
  352. valid_classes = filter(lambda cls : cls.is_valid_interface_type, [cls for cls in TellClasses()])
  353. return (cls.bl_idname for cls in valid_classes)
  354. enum_default_xForm_values =(
  355. ('NONE', "None", "None - fail if unconnected (RECOMMENDED)."),
  356. ('ARMATURE', "Generated Armature", "Generate an armature automatically. "
  357. "PLEASE use this only for development and testing. "
  358. "If you use this as a feature in your rigs you will be sorry."),)
  359. # Custom Interface Types give the user the ability to set properties for the interface
  360. # we'll define a base class, and generate the individual classes from the base class
  361. # but we'll leave the option to define a few of them directly.
  362. from bpy.types import NodeTreeInterfaceSocket
  363. def interface_socket_update(self, context):
  364. from .execution.overlays import fill_root_tree_overlays, parser_handle_text
  365. from itertools import chain
  366. # so what I need to do here is:
  367. # - if this is the root tree, and the interface has connections, invalidate them
  368. # - or if the root tree node is using an overlay, update it directly
  369. # - if there are any overlay-tagged, invalidate them
  370. root_tree = socket_update_get_root_tree(self, context)
  371. if root_tree is None: return # happens on startup or if e.g. tree is executing
  372. parsed_tree = root_tree.parsed_tree
  373. if len(parsed_tree) == 0: return # nothing to do here
  374. # get the mContext
  375. # HACK HACK HACK this is so ugly
  376. keys = list(parsed_tree.keys())
  377. mContext = None; i=0
  378. while mContext is None:
  379. mantis_node = parsed_tree[ keys[i] ]
  380. mContext = mantis_node.mContext; i+=1
  381. if i > len(keys): return # no mContext found
  382. # should exit immediately, the first node probably has it
  383. if self.id_data.name == root_tree.name:
  384. # checc for node group inputs and recursively reset execution for their children
  385. for node in root_tree.nodes:
  386. if node.bl_idname in {'NodeGroupInput'}:
  387. for o in node.outputs:
  388. for l in o.links:
  389. # We're in the root tree, that makes this easier
  390. if mantis_node := parsed_tree.get( (None, l.to_node.name) ):
  391. #rebuild the tree, it's unlikely the root tree change will not require this
  392. root_tree.update_tree(force=True)
  393. try: # if only I had a goto in this confounded language
  394. prPurple(f"Executing tree after interface change")
  395. root_tree.execute_tree(context)
  396. except Exception as e:
  397. prRed("Automatic Tree Execution failed because of %s" % e)
  398. return
  399. else: # The overlays in the root tree get set directly, let's handle that here, also
  400. for socket in chain(node.inputs, node.outputs):
  401. value = None
  402. if hasattr(socket, 'default_value'):
  403. value = socket.default_value
  404. if hasattr(socket, 'use_overlay') and socket.use_overlay:
  405. value = parser_handle_text(socket.overlay_text)
  406. if isinstance(value, str) and '$' in value:
  407. if socket.name == 'Schema Length': # this one has to force a new parse
  408. root_tree.update_tree(force=True) # because it modifies tree topology
  409. try: # if only I had a goto in this confounded language
  410. prPurple(f"Executing tree after interface change")
  411. root_tree.execute_tree(context)
  412. except Exception as e:
  413. prRed("Automatic Tree Execution failed because of %s" % e)
  414. return
  415. value = fill_root_tree_overlays(mContext, socket.bl_idname, value)
  416. # Now update the overlay-tagged nodes.
  417. for mantis_node_signature, socket_id in mContext.tagged_for_overlay:
  418. if socket_id == 'Schema Length': break # break to force update
  419. # We always need to parse again after changing schema length
  420. mantis_node = parsed_tree.get(mantis_node_signature)
  421. if mantis_node:
  422. from .utilities.utilities import get_ui_node
  423. if mantis_node.ui_signature is None: break # can't update it
  424. ui_node = get_ui_node(mantis_node.ui_signature, root_tree)
  425. if ui_node:
  426. if socket_id == 'socket': # this is an anonymous output in a simple-input node
  427. ui_socket = ui_node.outputs[0]
  428. else:
  429. if (ui_socket := ui_node.inputs.get(socket_id)) is None:
  430. for socket in ui_node.inputs:
  431. if socket_id == socket.identifier: break
  432. else: # Failed to update it, just update the tree.
  433. break
  434. # Now we have the ui socket
  435. mantis_node.ui_modify_socket(ui_socket, ui_socket.name)
  436. else:
  437. return
  438. # if we break from the for loop above, we failed to update the socket and have to update the tree
  439. root_tree.update_tree(force=True)
  440. try:
  441. prPurple(f"Executing tree after interface change")
  442. root_tree.execute_tree(context)
  443. except Exception as e:
  444. prRed("Automatic Tree Execution failed because of %s" % e)
  445. # TODO: I can update these values instead of resetting them
  446. interface_default_value_description="The default value of the socket when it is not connected."
  447. class MantisInterfaceSocketBaseClass():
  448. is_array : bpy.props.BoolProperty(default =False, update=interface_socket_update,
  449. description="Whether the socket is an array, otherwise it is constant." )
  450. is_connection : bpy.props.BoolProperty(default =False, update=interface_socket_update,
  451. description="If the socket is a connection or not. Ensure this is always paired"
  452. " with an input and an output." )
  453. connected_to : bpy.props.StringProperty(default="", update=interface_socket_update,
  454. description="The name of the socket this one is connected to." )
  455. # we are just gonna use ONE base class (it's easier)
  456. # so generate ALL properties and show only what is needed.
  457. default_string : bpy.props.StringProperty(default="", update=interface_socket_update,
  458. description=interface_default_value_description, )
  459. default_float : bpy.props.FloatProperty(default=0.0, update=interface_socket_update,
  460. description=interface_default_value_description, )
  461. default_vector : bpy.props.FloatVectorProperty( size = 3, default = (0.0, 0.0, 0.0, ),
  462. description=interface_default_value_description, update=interface_socket_update,)
  463. default_int : bpy.props.IntProperty(default=0, update=interface_socket_update,
  464. description=interface_default_value_description, )
  465. default_bool : bpy.props.BoolProperty(default=False, update=interface_socket_update,
  466. description=interface_default_value_description, )
  467. default_bool_vector : bpy.props.BoolVectorProperty(subtype = "XYZ", update=interface_socket_update,
  468. description=interface_default_value_description, )
  469. default_xForm : bpy.props.EnumProperty( default = 'NONE', update = interface_socket_update,
  470. items=enum_default_xForm_values, description=interface_default_value_description,)
  471. def interface_draw(self, context, layout):
  472. if not self.is_connection:
  473. layout.prop(self, "is_array", text="Is Array", toggle=True,)
  474. if not self.is_array and self.id_data.bl_idname == 'SchemaTree':
  475. layout.prop(self, "is_connection", text="Is Connection", toggle=True,)
  476. if False: # DISABLED for now because it will take a big change to Schema to make this work.
  477. if self.is_connection: # only show this if in a Schema AND set to is_connection
  478. layout.prop(self, "connected_to", text="Connected To", toggle=True,)
  479. # Different classes to handle different data types. In the future, these should also
  480. # have settable min/max and such where appropriate
  481. def interface_string_draw(self, context, layout):
  482. layout.prop(self, "default_string", text="Default Value", toggle=True,)
  483. interface_draw(self, context, layout)
  484. def interface_float_draw(self, context, layout):
  485. layout.prop(self, "default_float", text="Default Value", toggle=True,)
  486. interface_draw(self, context, layout)
  487. def interface_vector_draw(self, context, layout):
  488. layout.prop(self, "default_vector", text="Default Value", toggle=True,)
  489. interface_draw(self, context, layout)
  490. def interface_int_draw(self, context, layout):
  491. layout.prop(self, "default_int", text="Default Value", toggle=True,)
  492. interface_draw(self, context, layout)
  493. def interface_bool_draw(self, context, layout):
  494. layout.prop(self, "default_bool", text="Default Value", toggle=True,)
  495. interface_draw(self, context, layout)
  496. def interface_bool_vector_draw(self, context, layout):
  497. layout.prop(self, "default_bool_vector", text="Default Value", toggle=True,)
  498. interface_draw(self, context, layout)
  499. def interface_xform_draw(self, context, layout):
  500. if self.in_out == 'INPUT':
  501. layout.prop(self, "default_xForm", text="Default Value", toggle=True,)
  502. interface_draw(self, context, layout)
  503. def generate_custom_interface_types():
  504. generated_classes = []
  505. # copied from above
  506. valid_classes = filter(lambda cls : cls.is_valid_interface_type, [cls for cls in TellClasses()])
  507. for cls in valid_classes:
  508. name = cls.__name__ + "Interface"
  509. my_interface_draw = interface_draw
  510. # set the right draw function by the value's type
  511. match map_color_to_socket_type(cls.color_simple): #there has to be a better way to do this
  512. case "BooleanSocket":
  513. my_interface_draw = interface_bool_draw
  514. case "IntSocket":
  515. my_interface_draw = interface_int_draw
  516. case "FloatSocket":
  517. my_interface_draw = interface_float_draw
  518. case "BooleanThreeTupleSocket":
  519. my_interface_draw = interface_bool_vector_draw
  520. case "VectorSocket":
  521. my_interface_draw = interface_vector_draw
  522. case "StringSocket":
  523. my_interface_draw = interface_string_draw
  524. case "xFormSocket":
  525. my_interface_draw = interface_xform_draw
  526. case _:
  527. my_interface_draw = interface_draw
  528. interface = type(
  529. name,
  530. (MantisInterfaceSocketBaseClass, NodeTreeInterfaceSocket,),
  531. {
  532. "draw" : my_interface_draw,
  533. "bl_idname" : name,
  534. "bl_socket_idname" : cls.bl_idname,
  535. "socket_type" : cls.bl_idname,
  536. },
  537. )
  538. generated_classes.append(interface)
  539. return generated_classes
  540. # Was setting color like this:
  541. # color : bpy.props.FloatVectorProperty(size = 4, default = cFCurve,)
  542. # but this didn't work when Blender automatically generated interface classes?
  543. # so changed it to color = cVariable
  544. # but for color-changing sockets, if I make them, this won' work? Maybe?
  545. #
  546. # I actually think I was wrong about all of that lol
  547. # TODO change it back, dingus
  548. ########################################################################
  549. # Update Callbacks
  550. ########################################################################
  551. def socket_update(mantis_node, ui_socket, socket_name=None):
  552. node_updated = mantis_node.ui_modify_socket(ui_socket, socket_name)
  553. if not node_updated: # so that we can tag its dependencies
  554. mantis_node.reset_execution_recursive()
  555. return node_updated
  556. def default_update(ui_socket, context, do_execute=True):
  557. if not context:
  558. context = bpy.context
  559. root_tree = socket_update_get_root_tree(ui_socket, context)
  560. if root_tree is None: return
  561. # if it is a Schema Node, it will fail the checks below -- but we need it to update the tree.
  562. from .base_definitions import SchemaUINode
  563. if isinstance(ui_socket.node, SchemaUINode):
  564. # This was causing infinite loops before checking for is_updating
  565. # It seems to be happening when adding/removing links that are in schema trees
  566. # even if they are not connected to the schema node
  567. # I suspect that this completely disables this feature... whatever. TODO checc this
  568. if ui_socket.node.is_updating: return
  569. updating = ui_socket.node.is_updating
  570. ui_socket.node.is_updating=True
  571. try:
  572. root_tree.update_tree(context, force = True)
  573. prPurple(f"Executing tree after socket change: {ui_socket.node.name}:{ui_socket.name}")
  574. root_tree.execute_tree(context)
  575. finally:
  576. ui_socket.node.is_updating=updating
  577. return
  578. if hasattr(ui_socket.node, "initialized"):
  579. if not ui_socket.node.initialized: return
  580. elif hasattr(ui_socket.node, 'is_updating'):
  581. if ui_socket.node.is_updating: return
  582. else: return
  583. # if the socket has survived THAT ordeal, then the context is OK.
  584. # first, we try to update the Mantis tree in-situ.
  585. # Some nodes can update their b-objects, others will have to force-update the tree
  586. # because we just modified the data without modifying the topology of the graph.
  587. # finally, try and execute it if mantis couldn't update the b_objects itself.
  588. from .base_definitions import array_output_types
  589. mantis_updated=True
  590. if (ui_socket.node.bl_idname in ["MantisNodeGroup", "MantisSchemaGroup"]):
  591. mantis_updated=False # this kind of socket can't be updated here (yet)
  592. root_tree.update_tree(context, force=True)
  593. elif ui_socket.node.bl_idname in array_output_types:
  594. mantis_updated=False
  595. root_tree.update_tree(context, force=True)
  596. elif hasattr(ui_socket, 'default_value'):
  597. # NOTE: there may be many mantis nodes for each UI node... so we need to try all of them.
  598. for mantis_node in root_tree.parsed_tree.values():
  599. # we may not have to regenerate the tree; try and update the socket
  600. # the 'and' here ensures we trigger an update if even one of the mantis nodes fails
  601. mantis_updated = try_update_mantis_node_for_socket(mantis_node, root_tree, ui_socket) and mantis_updated
  602. # we want to force it if we have made an unhandled change inside of a schema.
  603. root_tree.update_tree(context, force = (mantis_updated == False))
  604. root_tree.display_update(context)
  605. if mantis_updated==False:
  606. try:
  607. prPurple(f"Executing tree after socket change: {ui_socket.node.name}:{ui_socket.name}")
  608. root_tree.execute_tree(context)
  609. except Exception as e:
  610. prRed("Automatic Tree Execution failed because of %s" % e)
  611. def try_update_mantis_node_for_socket(mantis_node, node_tree, ui_socket):
  612. # we may not have to regenerate the tree; try and update the socket
  613. from .utilities.utilities import tree_from_mantis_node
  614. # check to see if the mantis node is in the same ui-tree as this ui_socket
  615. if mantis_node.ui_signature is None: return False# autogenerated nodes
  616. if mantis_node.ui_signature[-1] == ui_socket.node.name and \
  617. tree_from_mantis_node(mantis_node.ui_signature, node_tree) == ui_socket.node.id_data:
  618. node_updated = True
  619. from .misc_nodes import SimpleInputNode
  620. if isinstance(mantis_node, SimpleInputNode):
  621. node_updated = socket_update(mantis_node, ui_socket)
  622. for l in mantis_node.outputs[ui_socket.name].links:
  623. node_updated = node_updated and socket_update(l.to_node, ui_socket, l.to_socket)
  624. else:
  625. node_updated = socket_update(mantis_node, ui_socket)
  626. # execute the tree if even one node didn't update
  627. return node_updated
  628. return False
  629. def update_socket(self, context,):
  630. default_update(self,context)
  631. def driver_variable_socket_update(self, context):
  632. default_update(self,context)
  633. def driver_socket_update(self, context):
  634. default_update(self,context)
  635. def update_mute_socket(self, context):
  636. self.node.mute = not self.default_value
  637. default_update(self,context)
  638. def update_hide_socket(self, context):
  639. self.node.mute = self.default_value
  640. default_update(self,context)
  641. def ik_chain_length_update_socket(self, context):
  642. default_update(self,context)
  643. # self.node.update_chain_length(context)
  644. def update_parent_node(self, context):
  645. default_update(self,context)
  646. if hasattr(self.node, "display_update"):
  647. self.node.display_update(context)
  648. def update_metarig_armature(self, context,):
  649. if self.search_prop:
  650. self.node.armature = self.search_prop.name
  651. self.node.inputs[1].armature = self.search_prop
  652. default_update(self,context)
  653. def update_metarig_posebone(self, context,):
  654. self.node.pose_bone = self.default_value
  655. default_update(self,context)
  656. def update_socket_external_load(self, context):
  657. # this is a socket update for sockets that load data from a pack
  658. # e.g. widget, metarig, curve, or component selector sockets
  659. # currently no plans to add any but widgets, but whatever
  660. default_update(self, context)
  661. self.previous_value = self.default_value # this is all I need to do lol
  662. items = get_widget_library_items(self, context) # feels silly to do this here
  663. for item in items:
  664. if item[0] == self.default_value:
  665. self.previous_index = item[-1]
  666. break
  667. ########################################################################
  668. # Sockets
  669. ########################################################################
  670. text_only_output_types = ["NodeGroupInput", "NodeGroupOutput", "SchemaArrayInput",
  671. "SchemaArrayInputGet", "SchemaArrayInputAll", "SchemaConstInput",
  672. "SchemaIncomingConnection"]
  673. def ChooseDraw(self, context, layout, node, text, icon = "NONE", use_enum=True, nice_bool=True, icon_only=False):
  674. invert_checkbox = False
  675. if hasattr(self, "invert") and self.invert == True:
  676. invert_checkbox=True
  677. # TEXT ONLY
  678. if self.node.bl_idname in text_only_output_types:
  679. layout.label(text=text)
  680. elif hasattr(self, "display_text") and self.display_text and self.is_linked:
  681. layout.label(text=self.display_text)
  682. else:
  683. # ENUM VALUES (this is a HACK, fix it later)
  684. if ('Enum' in self.bl_idname) and (use_enum):
  685. if not (self.is_output or self.is_linked):
  686. if self.__class__.enum_display_type == 'DROPDOWN':
  687. layout.prop(self, "default_value",)
  688. else:
  689. layout.prop_tabs_enum(self, "default_value",)
  690. else:
  691. layout.prop(text=text)
  692. # for OUTPUT sockets that take INPUT (confusing name!)
  693. elif ((hasattr(self, "default_value")) and hasattr(self, "input") and getattr(self, "input")):
  694. # for simple input nodes
  695. layout.prop(self, "default_value", text=text, toggle=nice_bool, slider=True)
  696. # for INPUTS that are NOT CONNECTED
  697. elif (hasattr(self, "default_value")) and not (self.is_output or self.is_linked):
  698. # DO: expose these values as parameters for this function
  699. # and set them for each socket.
  700. if icon == 'NONE': icon_only = False
  701. elif icon_only == True : text = "" # "real" icon-only looks bad for strings, need to check other props types.
  702. layout.prop(self, "default_value", text=text, toggle=nice_bool, slider=True, icon=icon,
  703. invert_checkbox=invert_checkbox)
  704. # CONNECTED sockets and outputs without input fields
  705. else:
  706. layout.label(text=text)
  707. def CollectionSocketDraw(socket, context, layout, node, text):
  708. # create the UI objects
  709. indent_length = len(socket.collection_path.split('>'))
  710. layout.alignment = 'EXPAND'
  711. # label_col = layout.row()
  712. label_col = layout.split(factor=0.20)
  713. label_col.alignment = 'LEFT' # seems backwards?
  714. label_col.scale_x = 9.0
  715. x_split = label_col.split(factor=0.35)
  716. x_split.scale_x=2.0
  717. x_split.alignment = 'RIGHT'
  718. operator_col = layout.row()
  719. # operator_col = layout
  720. operator_col.alignment = 'RIGHT' # seems backwards?
  721. operator_col.scale_x = 1.0
  722. # x_split = operator_col.split(factor=0.5)
  723. # x_split.scale_x = 0.5
  724. # x_split.alignment = 'RIGHT'
  725. # Now fill in the text and operators and such
  726. label_text = socket.collection_path.split('>')[-1]
  727. if indent_length > 1:
  728. label_text = '└'+label_text #┈ use this character to extend
  729. for indent in range(indent_length):
  730. if indent <= 1: continue
  731. indent_text = ' ▹ '
  732. label_text=indent_text+label_text
  733. op_props = x_split.operator('mantis.collection_remove')
  734. op_props.socket_invoked = socket.identifier
  735. label_col.label(text=label_text)
  736. op_props = operator_col.operator('mantis.collection_add_new')
  737. op_props.socket_invoked = socket.identifier
  738. # this works well enough!
  739. class RelationshipSocket(MantisSocket):
  740. # Description string
  741. '''Relationship'''
  742. # Optional identifier string. If not explicitly defined, the python class name is used.
  743. bl_idname = 'RelationshipSocket'
  744. bl_label = "Relationship"
  745. color_simple = cRelationship
  746. color : bpy.props.FloatVectorProperty(default=cRelationship, size=4)
  747. input : bpy.props.BoolProperty(default =False,)
  748. is_valid_interface_type=True
  749. class DeformerSocket(MantisSocket):
  750. # Description string
  751. '''Deformer'''
  752. # Optional identifier string. If not explicitly defined, the python class name is used.
  753. bl_idname = 'DeformerSocket'
  754. bl_label = "Deformer"
  755. is_valid_interface_type=True
  756. color_simple = cDeformer
  757. color : bpy.props.FloatVectorProperty(default=cDeformer, size=4)
  758. input : bpy.props.BoolProperty(default =False,)
  759. class MatrixSocket(MantisSocket):
  760. '''Matrix Input Output'''
  761. bl_idname = 'MatrixSocket'
  762. bl_label = "Matrix"
  763. default_value : bpy.props.FloatVectorProperty(
  764. default = (1.0, 0.0, 0.0, 0.0,
  765. 0.0, 1.0, 0.0, 0.0,
  766. 0.0, 0.0, 1.0, 0.0,
  767. 0.0, 0.0, 0.0, 1.0),
  768. size=16,
  769. update = update_socket,)
  770. color_simple = cMatrix
  771. color : bpy.props.FloatVectorProperty(default=cMatrix, size=4)
  772. input : bpy.props.BoolProperty(default =False,)
  773. is_valid_interface_type=True
  774. # Optional function for drawing the socket input value
  775. def draw(self, context, layout, node, text):
  776. layout.label(text=text)
  777. def draw_color(self, context, node):
  778. return self.color
  779. @classmethod
  780. def draw_color_simple(self):
  781. return self.color_simple
  782. # Utility functions to make handling the 16 numbers more bearable
  783. def SetValue(self, mat):
  784. self.default_value = ( mat[0][0], mat[0][1], mat[0][2], mat[0][3],
  785. mat[1][0], mat[1][1], mat[1][2], mat[1][3],
  786. mat[2][0], mat[2][1], mat[2][2], mat[2][3],
  787. mat[3][0], mat[3][1], mat[3][2], mat[3][3], )
  788. def TellBoneLength(self):
  789. return self.default_value[15]
  790. class xFormSocket(MantisSocket):
  791. '''xFrom Input Output'''
  792. bl_idname = 'xFormSocket'
  793. bl_label = "xForm"
  794. color_simple = cxForm
  795. color : bpy.props.FloatVectorProperty(default=cxForm, size=4)
  796. input : bpy.props.BoolProperty(default =False,)
  797. is_valid_interface_type=True
  798. class GeometrySocket(MantisSocket):
  799. '''Geometry Input Output'''
  800. bl_idname = 'GeometrySocket'
  801. bl_label = "Geometry"
  802. color_simple = cGeometry
  803. color : bpy.props.FloatVectorProperty(default=cGeometry, size=4)
  804. input : bpy.props.BoolProperty(default =False,)
  805. is_valid_interface_type=True
  806. class GenericRotationSocket(MantisSocket):
  807. '''Custom node socket type'''
  808. bl_idname = 'GenericRotationSocket'
  809. bl_label = "Rotation"
  810. color = (0.0,0.0,0.0,0.0)
  811. input : bpy.props.BoolProperty(default =False,)
  812. ###############################
  813. class EnableSocket(MantisSocket):
  814. '''Custom node socket type'''
  815. bl_idname = 'EnableSocket'
  816. bl_label = "Enable"
  817. default_value: bpy.props.BoolProperty(default=True, update = update_mute_socket,)
  818. color_simple = cEnable
  819. color : bpy.props.FloatVectorProperty(default=cEnable, size=4)
  820. input : bpy.props.BoolProperty(default =False,)
  821. def draw(self, context, layout, node, text):
  822. ChooseDraw(self, context, layout, node, text, nice_bool=False)
  823. def draw_color(self, context, node):
  824. return self.color
  825. @classmethod
  826. def draw_color_simple(self):
  827. return self.color_simple
  828. class HideSocket(MantisSocket):
  829. '''Custom node socket type'''
  830. bl_idname = 'HideSocket'
  831. bl_label = "Hide"
  832. default_value: bpy.props.BoolProperty(default=False, update = update_hide_socket,)
  833. color_simple = cEnable
  834. color : bpy.props.FloatVectorProperty(default=cEnable, size=4)
  835. input : bpy.props.BoolProperty(default =False,)
  836. def draw(self, context, layout, node, text):
  837. ChooseDraw(self, context, layout, node, text, nice_bool=False)
  838. def draw_color(self, context, node):
  839. return self.color
  840. @classmethod
  841. def draw_color_simple(self):
  842. return self.color_simple
  843. class FCurveSocket(MantisSocket):
  844. '''fCurve'''
  845. bl_idname = 'FCurveSocket'
  846. bl_label = "fCurve"
  847. color_simple = cFCurve
  848. color : bpy.props.FloatVectorProperty(default=cFCurve, size=4)
  849. input : bpy.props.BoolProperty(default =False, update = update_socket)
  850. is_valid_interface_type=True
  851. def init(self):
  852. self.display_shape = 'CIRCLE_DOT'
  853. class DriverSocket(MantisSocket):
  854. '''Driver'''
  855. bl_idname = 'DriverSocket'
  856. bl_label = "Driver"
  857. color_simple = cDriver
  858. color : bpy.props.FloatVectorProperty(default=cDriver, size=4)
  859. input : bpy.props.BoolProperty(default =False, update = update_socket)
  860. is_valid_interface_type=True
  861. def init(self):
  862. self.display_shape = 'CIRCLE_DOT'
  863. class DriverVariableSocket(MantisSocket):
  864. '''Driver'''
  865. bl_idname = 'DriverVariableSocket'
  866. bl_label = "Driver Variable"
  867. color_simple = cDriverVariable
  868. color : bpy.props.FloatVectorProperty(default=cDriverVariable, size=4)
  869. input : bpy.props.BoolProperty(default =False, update = update_socket)
  870. is_valid_interface_type=True
  871. def init(self):
  872. self.display_shape = 'CIRCLE_DOT'
  873. def get_transform_space(self, context):
  874. if "Owner" in self.name:
  875. return transform_spaces_bone_from
  876. else:
  877. return transform_spaces_bone_to
  878. class TransformSpaceSocket(MantisSocket):
  879. '''Custom node socket type'''
  880. bl_idname = 'TransformSpaceSocket'
  881. bl_label = "Transform Space"
  882. default_value: bpy.props.EnumProperty(
  883. name="Space Transform",
  884. description="Space Transform",
  885. items=get_transform_space,
  886. default=0,
  887. update = update_socket,)
  888. color_simple = cTransformSpace
  889. color : bpy.props.FloatVectorProperty(default=cTransformSpace, size=4)
  890. input : bpy.props.BoolProperty(default =False,)
  891. class BooleanSocket(MantisSocket):
  892. '''Custom node socket type'''
  893. bl_idname = 'BooleanSocket'
  894. bl_label = "Boolean"
  895. default_value: bpy.props.BoolProperty(update = update_socket,)
  896. color_simple = cBool
  897. color : bpy.props.FloatVectorProperty(default=cBool, size=4)
  898. input : bpy.props.BoolProperty(default =False,)
  899. is_valid_interface_type=True
  900. class InvertedBooleanSocket(MantisSocket):
  901. '''Custom node socket type'''
  902. bl_idname = 'InvertedBooleanSocket'
  903. bl_label = "Inverted Boolean"
  904. default_value: bpy.props.BoolProperty(update = update_socket,)
  905. color_simple = cBool
  906. color : bpy.props.FloatVectorProperty(default=cBool, size=4)
  907. input : bpy.props.BoolProperty(default =False,)
  908. invert : bpy.props.BoolProperty(default=True,)
  909. is_valid_interface_type=False
  910. class BooleanThreeTupleSocket(MantisSocket):
  911. # Description string
  912. '''Custom node socket type'''
  913. # Optional identifier string. If not explicitly defined, the python class name is used.
  914. bl_idname = 'BooleanThreeTupleSocket'
  915. bl_label = "Boolean Vector"
  916. default_value: bpy.props.BoolVectorProperty(subtype = "XYZ",update = update_socket,)
  917. color_simple = cBool3
  918. color : bpy.props.FloatVectorProperty(default=cBool3, size=4)
  919. input : bpy.props.BoolProperty(default =False,)
  920. is_valid_interface_type=True
  921. class RotationOrderSocket(MantisSocket):
  922. '''Custom node socket type'''
  923. bl_idname = 'RotationOrderSocket'
  924. bl_label = "Rotation Order"
  925. default_value: bpy.props.EnumProperty(
  926. name="Rotation Order",
  927. description="Rotation Order",
  928. items=enumRotationOrder,
  929. default='AUTO',
  930. update = update_socket,)
  931. color_simple = cRotationOrder
  932. color : bpy.props.FloatVectorProperty(default=cRotationOrder, size=4)
  933. input : bpy.props.BoolProperty(default =False,)
  934. class QuaternionSocket(MantisSocket):
  935. '''Custom node socket type'''
  936. bl_idname = 'QuaternionSocket'
  937. bl_label = "Quaternion"
  938. default_value: bpy.props.FloatVectorProperty(
  939. subtype = "QUATERNION",
  940. size = 4,
  941. default = (1.0, 0.0, 0.0, 0.0,),
  942. update = update_socket,)
  943. color_simple = cQuaternion
  944. color : bpy.props.FloatVectorProperty(default=cQuaternion, size=4)
  945. input : bpy.props.BoolProperty(default =False,)
  946. class QuaternionSocketAA(MantisSocket):
  947. '''Custom node socket type'''
  948. bl_idname = 'QuaternionSocketAA'
  949. bl_label = "Axis Angle Quaternion"
  950. color_simple = cQuaternion
  951. color : bpy.props.FloatVectorProperty(default=cQuaternion, size=4)
  952. input : bpy.props.BoolProperty(default =False,)
  953. default_value: bpy.props.FloatVectorProperty(
  954. subtype = "AXISANGLE",
  955. size = 4,
  956. default = (1.0, 0.0, 0.0, 0.0,),
  957. update = update_socket,)
  958. class IntSocket(MantisSocketOverlayEnabled):
  959. '''Custom node socket type'''
  960. bl_idname = 'IntSocket'
  961. bl_label = "Integer"
  962. default_value: bpy.props.IntProperty(default=0, update = update_socket, soft_min=-256, soft_max=256)
  963. color_simple = cInt
  964. color : bpy.props.FloatVectorProperty(default=cInt, size=4)
  965. input : bpy.props.BoolProperty(default =False,)
  966. is_valid_interface_type=True
  967. class UnsignedIntSocket(MantisSocketOverlayEnabled):
  968. '''Unsigned Integer Socket'''
  969. bl_idname = 'UnsignedIntSocket'
  970. bl_label = "Unsigned Integer"
  971. default_value: bpy.props.IntProperty(default=0, update = update_socket, min=0, soft_max=256, max=2**13)
  972. color_simple = cInt
  973. color : bpy.props.FloatVectorProperty(default=cInt, size=4)
  974. input : bpy.props.BoolProperty(default =False,)
  975. is_valid_interface_type=True
  976. class StringSocket(MantisSocket):
  977. """Float Input socket"""
  978. bl_idname = 'StringSocket'
  979. bl_label = "String"
  980. default_value : bpy.props.StringProperty(default = "", update = update_socket,)
  981. color_simple = cString
  982. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  983. icon : bpy.props.StringProperty(default = "NONE",)
  984. input : bpy.props.BoolProperty(default =False,)
  985. display_text : bpy.props.StringProperty(default="")
  986. is_valid_interface_type=True
  987. # def init(self):
  988. # if self.node.bl_idname == 'UtilityBoneProperties':
  989. # self.display_shape='CIRCLE_DOT'
  990. def draw(self, context, layout, node, text):
  991. ChooseDraw(self, context, layout, node, text, icon=self.icon, icon_only=True,)
  992. def draw_color(self, context, node):
  993. return self.color
  994. @classmethod
  995. def draw_color_simple(self):
  996. return self.color_simple
  997. def collection_declaration_get_default_value(self):
  998. return self.collection_path
  999. class CollectionDeclarationSocket(MantisSocket):
  1000. """Socket for declaring a collection"""
  1001. bl_idname = 'CollectionDeclarationSocket'
  1002. bl_label = "Collection"
  1003. default_value : bpy.props.StringProperty(get=collection_declaration_get_default_value)
  1004. collection_path : bpy.props.StringProperty(default="")
  1005. color_simple = cBoneCollection
  1006. color : bpy.props.FloatVectorProperty(default=cBoneCollection, size=4)
  1007. icon : bpy.props.StringProperty(default = "NONE",)
  1008. input : bpy.props.BoolProperty(default =True,)
  1009. display_text : bpy.props.StringProperty(default="")
  1010. is_valid_interface_type=False
  1011. def draw(self, context, layout, node, text):
  1012. CollectionSocketDraw(self, context, layout, node, text)
  1013. def draw_color(self, context, node):
  1014. return self.color
  1015. @classmethod
  1016. def draw_color_simple(self):
  1017. return self.color_simple
  1018. class BoneCollectionSocket(MantisSocket):
  1019. """Collection socket"""
  1020. bl_idname = 'BoneCollectionSocket'
  1021. bl_label = "Collection"
  1022. default_value: bpy.props.StringProperty(default = "Collection", update = update_socket,)
  1023. input : bpy.props.BoolProperty(default =False,)
  1024. color_simple = cBoneCollection
  1025. color : bpy.props.FloatVectorProperty(default=cBoneCollection, size=4)
  1026. is_valid_interface_type=True
  1027. def get_bone_theme_color(socket, prop,):
  1028. from bpy import context
  1029. color_index=socket.color_index
  1030. color_set = context.preferences.themes[0].bone_color_sets[color_index]
  1031. return getattr(color_set, prop )
  1032. def get_active_color(socket):
  1033. if socket is None:
  1034. from bpy import context
  1035. return context.preferences.themes[0].view_3d.bone_pose_active
  1036. return get_bone_theme_color(socket, 'active')
  1037. def get_normal_color(socket):
  1038. if socket is None:
  1039. from bpy import context
  1040. return context.preferences.themes[0].view_3d.bone_solid
  1041. return get_bone_theme_color(socket, 'normal')
  1042. def get_select_color(socket):
  1043. if socket is None:
  1044. from bpy import context
  1045. return context.preferences.themes[0].view_3d.bone_pose
  1046. return get_bone_theme_color(socket, 'select')
  1047. def get_color_set_value(socket,):
  1048. return [ socket.active_color[0],
  1049. socket.active_color[1],
  1050. socket.active_color[2],
  1051. socket.normal_color[0],
  1052. socket.normal_color[1],
  1053. socket.normal_color[2],
  1054. socket.selected_color[0],
  1055. socket.selected_color[1],
  1056. socket.selected_color[2],]
  1057. class ColorSetDisplaySocket(MantisSocket):
  1058. """Socket for displaying a bone color theme"""
  1059. bl_idname = 'ColorSetDisplaySocket'
  1060. bl_label = "Color Set"
  1061. default_value : bpy.props.FloatVectorProperty(get=get_color_set_value, size=9)
  1062. color_simple = cColor
  1063. color : bpy.props.FloatVectorProperty(default=cColor, size=4)
  1064. icon : bpy.props.StringProperty(default = "NONE",)
  1065. input : bpy.props.BoolProperty(default =False,)
  1066. display_text : bpy.props.StringProperty(default="")
  1067. color_index : bpy.props.IntProperty(default=0)
  1068. active_color : bpy.props.FloatVectorProperty(
  1069. name='Active Color', size=3, subtype='COLOR_GAMMA',
  1070. get=get_active_color )
  1071. normal_color : bpy.props.FloatVectorProperty(
  1072. name='Normal Color', size=3, subtype='COLOR_GAMMA',
  1073. get=get_normal_color )
  1074. selected_color : bpy.props.FloatVectorProperty(
  1075. name='Selected Color', size=3, subtype='COLOR_GAMMA',
  1076. get=get_select_color )
  1077. is_valid_interface_type=False
  1078. def draw(self, context, layout, node, text):
  1079. layout.prop( text='', data=self,
  1080. property='active_color', )
  1081. layout.prop( text='', data=self,
  1082. property='normal_color',)
  1083. layout.prop( text='', data=self,
  1084. property='selected_color',)
  1085. def draw_color(self, context, node):
  1086. return self.color
  1087. @classmethod
  1088. def draw_color_simple(self):
  1089. return self.color_simple
  1090. class ColorSetSocket(MantisSocket):
  1091. """Socket for setting a bone color"""
  1092. bl_idname = 'ColorSetSocket'
  1093. bl_label = "Custom Color Set"
  1094. default_value : bpy.props.FloatVectorProperty(get=get_color_set_value, size=9)
  1095. color_simple = cColor
  1096. color : bpy.props.FloatVectorProperty(default=cColor, size=4)
  1097. icon : bpy.props.StringProperty(default = "NONE",)
  1098. input : bpy.props.BoolProperty(default = True,)
  1099. display_text : bpy.props.StringProperty(default="")
  1100. active_color : bpy.props.FloatVectorProperty(
  1101. name='Active Color', size=3, subtype='COLOR_GAMMA',
  1102. default=get_active_color(None),)
  1103. normal_color : bpy.props.FloatVectorProperty(
  1104. name='Normal Color', size=3, subtype='COLOR_GAMMA',
  1105. default=get_normal_color(None),)
  1106. selected_color : bpy.props.FloatVectorProperty(
  1107. name='Selected Color', size=3, subtype='COLOR_GAMMA',
  1108. default=get_select_color(None),)
  1109. is_valid_interface_type=True
  1110. def draw(self, context, layout, node, text):
  1111. inherit_color_socket = self.node.inputs.get("Inherit Color")
  1112. if (self.is_output == False) and (self.is_linked == True):
  1113. layout.label(text=self.name)
  1114. elif self.node.bl_idname in text_only_output_types:
  1115. layout.label(text=self.name)
  1116. elif inherit_color_socket and inherit_color_socket.default_value == True:
  1117. layout.label(text='Using Inherit Color.')
  1118. else:
  1119. layout.prop( text='Color Set', data=self,
  1120. property='active_color', )
  1121. layout.prop( text='', data=self,
  1122. property='normal_color',)
  1123. layout.prop( text='', data=self,
  1124. property='selected_color',)
  1125. if self.node.bl_idname == 'InputColorSetPallete':
  1126. ops_props = layout.operator('mantis.color_pallete_socket_remove')
  1127. ops_props.tree_invoked = self.node.id_data.name
  1128. ops_props.node_invoked = self.node.name
  1129. ops_props.socket_invoked = self.identifier
  1130. def draw_color(self, context, node):
  1131. return self.color
  1132. @classmethod
  1133. def draw_color_simple(self):
  1134. return self.color_simple
  1135. eArrayGetOptions =(
  1136. ('CAP', "Cap", "Fail if the index is out of bounds."),
  1137. ('WRAP', "Wrap", "Wrap around to the beginning of the array once the idex goes out of bounds."),
  1138. ('HOLD', "Hold", "Reuse the last element of the array if the index is out of bounds."),)
  1139. class EnumArrayGetOptions(MantisSocket):
  1140. '''Custom node socket type'''
  1141. bl_idname = 'EnumArrayGetOptions'
  1142. bl_label = "OoB Behaviour"
  1143. default_value: bpy.props.EnumProperty(
  1144. items=eArrayGetOptions,
  1145. name="OoB Behaviour",
  1146. description="Out-of-bounds behaviour.",
  1147. default = 'HOLD',
  1148. update = update_socket,)
  1149. color_simple = cString
  1150. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1151. input : bpy.props.BoolProperty(default =False,)
  1152. #####################################################################################
  1153. # Parameters
  1154. #####################################################################################
  1155. eCustomPropType = (
  1156. ('BOOL' , "Boolean", "Boolean", 0),
  1157. ('INT' , "Int" , "Integer", 1),
  1158. ('FLOAT' , "Float" , "Floating Point Number", 2),
  1159. ('VECTOR' , "Vector" , "Vector", 3),
  1160. ('STRING' , "String" , "String", 4),
  1161. )
  1162. class EnumCustomPropTypeSocket(MantisSocket):
  1163. """Custom Property Type"""
  1164. bl_idname = 'EnumCustomPropTypeSocket'
  1165. bl_label = "Property Type"
  1166. color_simple = cString
  1167. default_value: bpy.props.EnumProperty(
  1168. items=eCustomPropType,
  1169. description="Custom Property Type",
  1170. default = 'BOOL',
  1171. update = update_socket,)
  1172. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1173. input : bpy.props.BoolProperty(default =False,)
  1174. class CustomPropSocket(MantisSocket):
  1175. '''Custom Property'''
  1176. bl_idname = 'CustomPropSocket'
  1177. bl_label = "Custom Property"
  1178. color_simple = cString
  1179. is_valid_interface_type=True
  1180. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1181. input : bpy.props.BoolProperty(default =False,)
  1182. def init(self):
  1183. self.display_shape = 'CIRCLE_DOT'
  1184. class xFormParameterSocket(MantisSocket):
  1185. '''xFrom Parameter'''
  1186. bl_idname = 'xFormParameterSocket'
  1187. bl_label = "xForm Parameter"
  1188. color_simple = cxForm
  1189. color : bpy.props.FloatVectorProperty(default=cxForm, size=4)
  1190. input : bpy.props.BoolProperty(default =False,)
  1191. def init(self):
  1192. self.display_shape = 'CIRCLE_DOT'
  1193. class ParameterBoolSocket(MantisSocket):
  1194. """Boolean Parameter Socket"""
  1195. bl_idname = 'ParameterBoolSocket'
  1196. bl_label = "Boolean Parameter"
  1197. color_simple = cBool
  1198. color : bpy.props.FloatVectorProperty(default=cBool, size=4)
  1199. input : bpy.props.BoolProperty(default =False,)
  1200. #custom properties:
  1201. min:bpy.props.FloatProperty(default = 0)
  1202. max:bpy.props.FloatProperty(default = 1)
  1203. soft_min:bpy.props.FloatProperty(default = 0)
  1204. soft_max:bpy.props.FloatProperty(default = 1)
  1205. description:bpy.props.StringProperty(default = "")
  1206. default_value : bpy.props.BoolProperty(default = False, update = update_socket,)
  1207. def init(self):
  1208. self.display_shape = 'CIRCLE_DOT'
  1209. class ParameterIntSocket(MantisSocket):
  1210. """Integer Parameter socket"""
  1211. bl_idname = 'ParameterIntSocket'
  1212. bl_label = "Integer Parameter"
  1213. default_value : bpy.props.IntProperty(default = 0, update = update_socket,)
  1214. color_simple = cInt
  1215. color : bpy.props.FloatVectorProperty(default=cInt, size=4)
  1216. input : bpy.props.BoolProperty(default =False,)
  1217. #custom properties:
  1218. min:bpy.props.FloatProperty(default = 0)
  1219. max:bpy.props.FloatProperty(default = 1)
  1220. soft_min:bpy.props.FloatProperty(default = 0)
  1221. soft_max:bpy.props.FloatProperty(default = 1)
  1222. description:bpy.props.StringProperty(default = "")
  1223. def init(self):
  1224. self.display_shape = 'CIRCLE_DOT'
  1225. class ParameterFloatSocket(MantisSocket):
  1226. """Float Parameter socket"""
  1227. bl_idname = 'ParameterFloatSocket'
  1228. bl_label = "Float Parameter"
  1229. default_value : bpy.props.FloatProperty(default = 0.0, update = update_socket,)
  1230. color_simple = cFloat
  1231. color : bpy.props.FloatVectorProperty(default=cFloat, size=4)
  1232. input : bpy.props.BoolProperty(default =False,)
  1233. #custom properties:
  1234. min:bpy.props.FloatProperty(default = 0)
  1235. max:bpy.props.FloatProperty(default = 1)
  1236. soft_min:bpy.props.FloatProperty(default = 0)
  1237. soft_max:bpy.props.FloatProperty(default = 1)
  1238. description:bpy.props.StringProperty(default = "")
  1239. def init(self):
  1240. self.display_shape = 'CIRCLE_DOT'
  1241. class ParameterVectorSocket(MantisSocket):
  1242. """Vector Parameter socket"""
  1243. bl_idname = 'ParameterVectorSocket'
  1244. bl_label = "Vector Parameter"
  1245. default_value : bpy.props.FloatVectorProperty(
  1246. default = (0.0, 0.0, 0.0),
  1247. update = update_socket,)
  1248. color_simple = cVector
  1249. color : bpy.props.FloatVectorProperty(default=cVector, size=4)
  1250. input : bpy.props.BoolProperty(default =False,)
  1251. #custom properties:
  1252. description:bpy.props.StringProperty(default = "")
  1253. def init(self):
  1254. self.display_shape = 'CIRCLE_DOT'
  1255. class ParameterStringSocket(MantisSocket):
  1256. """String Parameter socket"""
  1257. bl_idname = 'ParameterStringSocket'
  1258. bl_label = "String Parameter"
  1259. default_value : bpy.props.StringProperty(default = "", update = update_socket,)
  1260. color_simple = cString
  1261. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1262. input : bpy.props.BoolProperty(default =False,)
  1263. #custom properties:
  1264. description:bpy.props.StringProperty(default = "")
  1265. def init(self):
  1266. self.display_shape = 'CIRCLE_DOT'
  1267. #####################################################################################
  1268. # Additional socket types, for special cases
  1269. #####################################################################################
  1270. from bpy.props import PointerProperty, StringProperty
  1271. def poll_is_armature(self, obj):
  1272. return obj.type == "ARMATURE"
  1273. # def poll_is_armature(self, obj):
  1274. # return obj.type == "ARMATURE"
  1275. class EnumMetaRigSocket(MantisSocketOverlayEnabled):
  1276. '''Custom node socket type'''
  1277. bl_idname = 'EnumMetaRigSocket'
  1278. bl_label = "Meta Rig"
  1279. color_simple = cString
  1280. search_prop:PointerProperty(type=bpy.types.Object, poll=poll_is_armature, update=update_metarig_armature)
  1281. def get_default_value(self):
  1282. if self.search_prop:
  1283. return self.search_prop.name
  1284. return ""
  1285. def set_default_value(self, value):
  1286. if ob:= bpy.data.objects.get(value):
  1287. if ob.type == 'ARMATURE':
  1288. self.search_prop=ob
  1289. default_value : StringProperty(name = "", get=get_default_value, set=set_default_value)
  1290. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1291. def draw(self, context, layout, node, text):
  1292. if self.is_output:
  1293. layout.label(text=self.name)
  1294. elif not (self.is_linked):
  1295. row = layout.row(align=True)
  1296. # We'll show the property or the overlay field here
  1297. if self.use_overlay:
  1298. row.prop(self, "overlay_text",text=self.name)
  1299. else:
  1300. row.prop_search(data=self, property="search_prop", search_data=bpy.data,
  1301. search_property="objects", text="", icon="OUTLINER_OB_ARMATURE",
  1302. results_are_suggestions=True)
  1303. # and the button to choose whether or not to use the overlay field
  1304. row.prop(self, "use_overlay", text="", icon='CONSOLE', toggle=True)
  1305. elif hasattr(self.node, "armature"):
  1306. layout.label(text=self.node.armature)
  1307. # TODO: we should actually use the parsed tree to query this info directly, since this socket may belong to a node group in/out
  1308. # which doesn't have this parameter. whatever.
  1309. else:
  1310. layout.label(text=self.name)
  1311. def draw_color(self, context, node):
  1312. return self.color
  1313. @classmethod
  1314. def draw_color_simple(self):
  1315. return self.color_simple
  1316. # I donno why but I can't just subclass the above. hmm.so this is a duplicate
  1317. class EnumArmature(MantisSocket):
  1318. bl_idname = "EnumArmature"
  1319. bl_label = "Armature"
  1320. color_simple = cString
  1321. search_prop:PointerProperty(type=bpy.types.Object, poll=poll_is_armature, update=update_metarig_armature)
  1322. def get_default_value(self):
  1323. if self.search_prop:
  1324. return self.search_prop.name
  1325. return ""
  1326. def set_default_value(self, value):
  1327. if ob:= bpy.data.objects.get(value):
  1328. if ob.type == 'ARMATURE':
  1329. self.search_prop=ob
  1330. default_value : StringProperty(name = "", get=get_default_value, set=set_default_value)
  1331. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1332. def draw(self, context, layout, node, text):
  1333. if self.is_output:
  1334. layout.label(text=self.name)
  1335. elif not (self.is_linked):
  1336. layout.prop_search(data=self, property="search_prop", search_data=bpy.data, search_property="objects", text="", icon="OUTLINER_OB_ARMATURE", results_are_suggestions=True)
  1337. elif hasattr(self.node, "armature"):
  1338. layout.label(text=self.node.armature)
  1339. # TODO: we should actually use the parsed tree to query this info directly, since this socket may belong to a node group in/out
  1340. # which doesn't have this parameter. whatever.
  1341. else:
  1342. layout.label(text=self.name)
  1343. def draw_color(self, context, node):
  1344. return self.color
  1345. @classmethod
  1346. def draw_color_simple(self):
  1347. return self.color_simple
  1348. def poll_is_curve(self, obj):
  1349. return obj.type == "CURVE"
  1350. class EnumCurveSocket(MantisSocket):
  1351. '''Choose a curve'''
  1352. bl_idname = 'EnumCurveSocket'
  1353. bl_label = "Curve"
  1354. is_valid_interface_type=True
  1355. search_prop:PointerProperty(type=bpy.types.Object, poll=poll_is_curve, update=update_socket)
  1356. def get_default_value(self):
  1357. if self.search_prop:
  1358. return self.search_prop.name
  1359. return ""
  1360. def set_default_value(self, value):
  1361. if ob:= bpy.data.objects.get(value):
  1362. if ob.type == 'CURVE':
  1363. self.search_prop=ob
  1364. default_value : StringProperty(name = "", get=get_default_value, set=set_default_value)
  1365. color_simple = cString
  1366. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1367. def draw(self, context, layout, node, text):
  1368. if not (self.is_linked) and not self.is_output:
  1369. layout.prop_search(data=self, property="search_prop", search_data=bpy.data, search_property="objects", text="", icon="CURVE_DATA", results_are_suggestions=True)
  1370. else:
  1371. try:
  1372. layout.label(text=self.search_prop.name)
  1373. except AttributeError: # TODO make this show the graph's result
  1374. layout.label(text=self.name)
  1375. def draw_color(self, context, node):
  1376. return self.color
  1377. @classmethod
  1378. def draw_color_simple(self):
  1379. return self.color_simple
  1380. def SearchPBDraw(self, context, layout, node, text, icon = "NONE", use_enum=True, nice_bool=True, icon_only=False):
  1381. layout.prop_search(data=self, property="default_value", search_data=self.armature.data, search_property="bones", text=text, icon=icon, results_are_suggestions=True)
  1382. class EnumMetaBoneSocket(MantisSocket):
  1383. '''Socket to Get a Bone from an object'''
  1384. bl_idname = 'EnumMetaBoneSocket'
  1385. bl_label = "Bone"
  1386. # this armature property is set by the parent node.
  1387. armature:PointerProperty(type=bpy.types.Object)
  1388. bone:StringProperty()
  1389. def populate_bones_list(self, context):
  1390. # just gonna hardcode the value
  1391. if (meta_rig := self.armature):
  1392. retList = []; i = -1
  1393. retList.append( ('NONE', '', '', 'NONE', i:=i+1 ) )
  1394. for b in meta_rig.data.bones:
  1395. retList.append( (b.name, b.name, "Bone to copy matrix from", "BONE_DATA", i:=i+1 ) )
  1396. return(retList)
  1397. return None
  1398. default_value : StringProperty(name = "", update=update_metarig_posebone)
  1399. color_simple = cString
  1400. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1401. def draw(self, context, layout, node, text):
  1402. if not (self.is_linked):
  1403. if self.armature is None:
  1404. layout.prop(self, "default_value", text="", icon="BONE_DATA",)
  1405. else:
  1406. SearchPBDraw(self, context, layout, node, text="")
  1407. else:
  1408. layout.label(text=self.node.pose_bone)
  1409. def draw_color(self, context, node):
  1410. return self.color
  1411. @classmethod
  1412. def draw_color_simple(self):
  1413. return self.color_simple
  1414. # I don't know why but I can't subclass the above and I had to duplicate it here
  1415. class EnumExistingBoneSocket(MantisSocket):
  1416. '''Socket to Get a Bone from an object'''
  1417. bl_idname = 'EnumExistingBoneSocket'
  1418. bl_label = "Bone"
  1419. color_simple = cString
  1420. # this armature property is set by the parent node.
  1421. armature:PointerProperty(type=bpy.types.Object)
  1422. bone:StringProperty()
  1423. def populate_bones_list(self, context):
  1424. # just gonna hardcode the value
  1425. if (meta_rig := self.armature):
  1426. retList = []; i = -1
  1427. retList.append( ('NONE', '', '', 'NONE', i:=i+1 ) )
  1428. for b in meta_rig.data.bones:
  1429. retList.append( (b.name, b.name, "Bone to copy matrix from", "BONE_DATA", i:=i+1 ) )
  1430. return(retList)
  1431. return None
  1432. default_value : StringProperty(name = "", update=update_metarig_posebone)
  1433. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1434. def draw(self, context, layout, node, text):
  1435. if not (self.is_linked):
  1436. if self.armature is None:
  1437. layout.prop(self, "default_value", text="", icon="BONE_DATA",)
  1438. else:
  1439. SearchPBDraw(self, context, layout, node, text="")
  1440. else:
  1441. layout.label(text=self.node.pose_bone)
  1442. def draw_color(self, context, node):
  1443. return self.color
  1444. @classmethod
  1445. def draw_color_simple(self):
  1446. return self.color_simple
  1447. # TODO: make it so that this makes an item for "missing" widgets
  1448. # for when a widget is moved or deleted
  1449. # Make it read .blend
  1450. # make it read the current directory, too?
  1451. def get_widget_library_items(self, context):
  1452. from .preferences import get_bl_addon_object
  1453. bl_mantis_addon = get_bl_addon_object()
  1454. from os import path as os_path
  1455. prev_name = os_path.split(self.previous_value)[-1]
  1456. default_missing_value = ('MISSING', f'MISSING: {prev_name}', self.previous_value, 'ERROR', self.previous_index)
  1457. return_value = [default_missing_value]
  1458. widget_names={}
  1459. if bl_mantis_addon and bl_mantis_addon.preferences:
  1460. widgets_path = bl_mantis_addon.preferences.WidgetsLibraryFolder
  1461. from os import walk as os_walk
  1462. for path_root, dirs, files, in os_walk(widgets_path):
  1463. # TODO handle .blend files
  1464. for file in files:
  1465. relative_file_name = os_path.join(os_path.sep.join(dirs), file)
  1466. if file.endswith('.obj'):
  1467. widget_names[relative_file_name[:-4]] = relative_file_name
  1468. if widget_names.keys():
  1469. return_value=[]
  1470. # first we select the previous value if it exists
  1471. add_missing_key=False
  1472. add_one=0
  1473. if self.previous_value and self.previous_value not in widget_names.values():
  1474. add_missing_key=True # we need to add the missing key at the previous index
  1475. sorted_keys = list(widget_names.keys())
  1476. sorted_keys.sort()
  1477. for i, name in enumerate(sorted_keys):
  1478. path = widget_names[name]
  1479. if add_missing_key and i == self.previous_index:
  1480. add_one+=1; return_value.append(default_missing_value)
  1481. return_value.append( (path, name, path, 'GIZMO', i+add_one) )
  1482. return return_value
  1483. # THIS is a special socket type that finds the widgets in your widgets library (set in preferences)
  1484. class EnumWidgetLibrarySocket(MantisSocket):
  1485. '''Choose a Wdiget'''
  1486. bl_idname = 'EnumWidgetLibrarySocket'
  1487. bl_label = "Widget"
  1488. is_valid_interface_type=False
  1489. default_value : bpy.props.EnumProperty(
  1490. items=get_widget_library_items,
  1491. name="Widget",
  1492. description="Which widget to use",
  1493. default = 0,
  1494. update = update_socket_external_load,)
  1495. color_simple = cString
  1496. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1497. previous_value : bpy.props.StringProperty(default="")
  1498. previous_index : bpy.props.IntProperty(default=0)
  1499. def draw(self, context, layout, node, text):
  1500. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1501. def draw_color(self, context, node):
  1502. return self.color
  1503. @classmethod
  1504. def draw_color_simple(self):
  1505. return self.color_simple
  1506. class BoolUpdateParentNode(MantisSocket):
  1507. '''Custom node socket type'''
  1508. bl_idname = 'BoolUpdateParentNode'
  1509. bl_label = "Boolean"
  1510. default_value: bpy.props.BoolProperty(default=False, update = update_parent_node)
  1511. color_simple = cBool
  1512. color : bpy.props.FloatVectorProperty(default=cBool, size=4)
  1513. input : bpy.props.BoolProperty(default =False,)
  1514. class IKChainLengthSocket(MantisSocket):
  1515. '''Custom node socket type'''
  1516. bl_idname = 'IKChainLengthSocket'
  1517. bl_label = "IK Chain Length"
  1518. default_value: bpy.props.IntProperty(default=0, update = ik_chain_length_update_socket, min = 0, max = 255)
  1519. color_simple = cInt
  1520. color : bpy.props.FloatVectorProperty(default=cInt, size=4)
  1521. input : bpy.props.BoolProperty(default =False,)
  1522. # Inherit
  1523. eInheritScale = (
  1524. ('FULL', "Full", "Fully inherit scale", 1),
  1525. ('AVERAGE', "Average", "todo", 2),
  1526. ('ALIGNED', "Aligned", "todo", 3),
  1527. ('FIX_SHEAR', "Fix Shear", "todo", 4),
  1528. ('NONE', "None", "todo", 5),
  1529. )
  1530. class EnumInheritScale(MantisSocket):
  1531. '''Custom node socket type'''
  1532. bl_idname = 'EnumInheritScale'
  1533. bl_label = "Inherit Scale"
  1534. default_value: bpy.props.EnumProperty(
  1535. items=eInheritScale,
  1536. name="Inherit Scale",
  1537. description="Inherit Scale",
  1538. default = 'FULL',
  1539. #options = set(),
  1540. update = update_socket,)
  1541. color_simple = cString
  1542. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1543. input : bpy.props.BoolProperty(default =False,)
  1544. # Copy Rotation
  1545. eRotationMix =(
  1546. ('REPLACE', "Replace", "Fully inherit scale", 0),
  1547. ('BEFORE', "Before", "Fully inherit scale", 1),
  1548. ('AFTER', "After", "Fully inherit scale", 2),
  1549. ('ADD', "Add", "Fully inherit scale", 3),
  1550. #todo, but i don't care much
  1551. )
  1552. # TODO HACK
  1553. # do enum_flag as mutually exclusive options here
  1554. class EnumRotationMix(MantisSocket):
  1555. '''Custom node socket type'''
  1556. bl_idname = 'EnumRotationMix'
  1557. bl_label = "Rotation Mix"
  1558. enum_display_type='DROPDOWN'
  1559. default_value: bpy.props.EnumProperty(
  1560. items=eRotationMix,
  1561. name="Rotation Mix",
  1562. description="Rotation Mix",
  1563. default = 'REPLACE',#{'REPLACE'},
  1564. options = set(), # this has to be a set lol
  1565. update = update_socket,)
  1566. color_simple = cString
  1567. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1568. input : bpy.props.BoolProperty(default =False,)
  1569. eRotationMix_copytransforms =(
  1570. ('REPLACE', "Replace (Aligned)", "Fully inherit scale"),
  1571. ('BEFORE', "Before (Aligned)", "Fully inherit scale"),
  1572. ('AFTER', "After (Aligned)", "Fully inherit scale"),
  1573. ('REPLACE_SPLIT', "Replace (Split Channels)", "Fully inherit scale"),
  1574. ('BEFORE_SPLIT', "Before (Split Channels)", "Fully inherit scale"),
  1575. ('AFTER_SPLIT', "After (Split Channels)", "Fully inherit scale"),
  1576. ('REPLACE_FULL', "Replace (Full)", "Fully inherit scale"),
  1577. ('BEFORE_FULL', "Before (Full)", "Fully inherit scale"),
  1578. ('AFTER_FULL', "After (Full)", "Fully inherit scale"),)
  1579. class EnumRotationMixCopyTransforms(MantisSocket):
  1580. '''Custom node socket type'''
  1581. bl_idname = 'EnumRotationMixCopyTransforms'
  1582. bl_label = "Rotation Mix"
  1583. default_value: bpy.props.EnumProperty(
  1584. items=eRotationMix_copytransforms,
  1585. name="Rotation Mix",
  1586. description="Rotation Mix",
  1587. default = 'REPLACE', #{'REPLACE'},
  1588. #options = {'ENUM_FLAG'}, # this sux
  1589. update = update_socket,)
  1590. color_simple = cString
  1591. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1592. input : bpy.props.BoolProperty(default =False,)
  1593. # STRETCH TO
  1594. eMaintainVolumeStretchTo = (('VOLUME_XZX', "XZ", "XZ", 1),
  1595. ('VOLUME_X', "X", "X", 2),
  1596. ('VOLUME_Z', "Z", "Z", 4),
  1597. ('NO_VOLUME', "None", "None", 8),)
  1598. class EnumMaintainVolumeStretchTo(MantisSocket):
  1599. '''Custom node socket type'''
  1600. bl_idname = 'EnumMaintainVolumeStretchToSocket'
  1601. bl_label = "Maintain Volume"
  1602. default_value: bpy.props.EnumProperty(
  1603. items=eMaintainVolumeStretchTo,
  1604. name="Maintain Volume",
  1605. description="Maintain Volume",
  1606. default = 'VOLUME_XZX',
  1607. #options = {'ENUM_FLAG'},
  1608. update = update_socket,)
  1609. color_simple = cString
  1610. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1611. input : bpy.props.BoolProperty(default =False,)
  1612. eRotationStretchTo = (('PLANE_X', "XZ", "XZ", 1),
  1613. ('PLANE_Z', "ZX", "ZX", 2),
  1614. ('SWING_Y', "Swing", "Swing", 4),)
  1615. class EnumRotationStretchTo(MantisSocket):
  1616. '''Custom node socket type'''
  1617. bl_idname = 'EnumRotationStretchTo'
  1618. bl_label = "Rotation"
  1619. default_value: bpy.props.EnumProperty(
  1620. items=eRotationStretchTo,
  1621. name="Rotation",
  1622. description="Rotation",
  1623. default = 'PLANE_X',
  1624. #options = {'ENUM_FLAG'},
  1625. update = update_socket,)
  1626. color_simple = cString
  1627. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1628. input : bpy.props.BoolProperty(default =False,)
  1629. # Track-To
  1630. eTrackAxis = (('TRACK_X', "X", "X", 1),
  1631. ('TRACK_Y', "Y", "Y", 2),
  1632. ('TRACK_Z', "Z", "Z", 4),
  1633. ('TRACK_NEGATIVE_X', "-X", "-X", 8),
  1634. ('TRACK_NEGATIVE_Y', "-Y", "-Y", 16),
  1635. ('TRACK_NEGATIVE_Z', "-Z", "-Z", 32,))
  1636. eUpAxis = (('UP_X', "X", "X", 1),
  1637. ('UP_Y', "Y", "Y", 2),
  1638. ('UP_Z', "Z", "Z", 4),)
  1639. # ugly but I can't change it easily without messing up versioning
  1640. class EnumTrackAxis(MantisSocket):
  1641. '''Custom node socket type'''
  1642. bl_idname = 'EnumTrackAxis'
  1643. bl_label = "Track Axis"
  1644. default_value: bpy.props.EnumProperty(
  1645. items=eTrackAxis,
  1646. name="Track Axis",
  1647. description="Track Axis",
  1648. default = 'TRACK_X',
  1649. #options = {'ENUM_FLAG'},
  1650. update = update_socket,)
  1651. color_simple = cString
  1652. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1653. input : bpy.props.BoolProperty(default =False,)
  1654. class EnumUpAxis(MantisSocket):
  1655. '''Custom node socket type'''
  1656. bl_idname = 'EnumUpAxis'
  1657. bl_label = "Up Axis"
  1658. default_value: bpy.props.EnumProperty(
  1659. items=eUpAxis,
  1660. name="Up Axis",
  1661. description="Up Axis",
  1662. default = 'UP_X',
  1663. #options = {'ENUM_FLAG'},
  1664. update = update_socket,)
  1665. color_simple = cString
  1666. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1667. input : bpy.props.BoolProperty(default =False,)
  1668. # Follow Track Forward axis
  1669. eForwardAxis = (('FORWARD_X', "X", "X", 0),
  1670. ('FORWARD_Y', "Y", "Y", 1),
  1671. ('FORWARD_Z', "Z", "Z", 2),
  1672. ('TRACK_NEGATIVE_X', "-X", "-X", 3),
  1673. ('TRACK_NEGATIVE_Y', "-Y", "-Y", 4),
  1674. ('TRACK_NEGATIVE_Z', "-Z", "-Z", 5),)
  1675. class EnumFollowPathForwardAxis(MantisSocket):
  1676. '''Custom node socket type'''
  1677. bl_idname = 'EnumFollowPathForwardAxis'
  1678. bl_label = "Forward Axis"
  1679. default_value: bpy.props.EnumProperty(
  1680. items=eForwardAxis,
  1681. name="Forward Axis",
  1682. description="Forward Axis",
  1683. default = 'FORWARD_X',
  1684. update = update_socket,)
  1685. color_simple = cString
  1686. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1687. input : bpy.props.BoolProperty(default =False,)
  1688. # Follow Track Forward axis
  1689. eFloorAxis = (('FLOOR_X', "X", "X", 0),
  1690. ('FLOOR_Y', "Y", "Y", 1),
  1691. ('FLOOR_Z', "Z", "Z", 2),
  1692. ('FLOOR_NEGATIVE_X', "-X", "-X", 3),
  1693. ('FLOOR_NEGATIVE_Y', "-Y", "-Y", 4),
  1694. ('FLOOR_NEGATIVE_Z', "-Z", "-Z", 5),)
  1695. class EnumFloorAxis(MantisSocket):
  1696. '''Floor Constraint Axis'''
  1697. bl_idname = 'EnumFloorAxis'
  1698. bl_label = "Floor Axis"
  1699. default_value: bpy.props.EnumProperty(
  1700. items=eFloorAxis,
  1701. name="Floor Axis",
  1702. description="Floor Axis",
  1703. default = 'FLOOR_X',
  1704. update = update_socket,)
  1705. color_simple = cString
  1706. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1707. input : bpy.props.BoolProperty(default =False,)
  1708. # Locked Track
  1709. eLockAxis = (('LOCK_X', "X", "X", 1),
  1710. ('LOCK_Y', "Y", "Y", 2),
  1711. ('LOCK_Z', "Z", "Z", 4),)
  1712. class EnumLockAxis(MantisSocket):
  1713. '''Custom node socket type'''
  1714. bl_idname = 'EnumLockAxis'
  1715. bl_label = "Lock Axis"
  1716. default_value: bpy.props.EnumProperty(
  1717. items=eLockAxis,
  1718. name="Lock Axis",
  1719. description="Lock Axis",
  1720. default = 'LOCK_X',
  1721. #options = {'ENUM_FLAG'},
  1722. update = update_socket,)
  1723. color_simple = cString
  1724. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1725. input : bpy.props.BoolProperty(default =False,)
  1726. # Limit Distance:
  1727. eLimitMode = (('LIMITDIST_INSIDE', "Inside", "Inside",),
  1728. ('LIMITDIST_OUTSIDE', "Outside", "Outside",),
  1729. ('LIMITDIST_ONSURFACE', "On Surface", "On Surface",),)
  1730. class EnumLimitMode(MantisSocket):
  1731. '''Custom node socket type'''
  1732. bl_idname = 'EnumLimitMode'
  1733. bl_label = "Clamp Region"
  1734. default_value: bpy.props.EnumProperty(
  1735. items=eLimitMode,
  1736. name="Clamp Region",
  1737. description="Clamp Region",
  1738. default = 'LIMITDIST_INSIDE',
  1739. update = update_socket,)
  1740. color_simple = cString
  1741. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1742. input : bpy.props.BoolProperty(default =False,)
  1743. # Spline IK
  1744. eYScaleMode = (('NONE', "None", "Don’t scale the X and Z axes.",),
  1745. ('FIT_CURVE', "Fit Curve", "Scale the bones to fit the entire length of the curve.",),
  1746. ('BONE_ORIGINAL', "Bone Original", "Use the original scaling of the bones.",),)
  1747. eXZScaleMode = (('NONE', "None", "Don’t scale the X and Z axes.",),
  1748. ('BONE_ORIGINAL', "Bone Original", "Use the original scaling of the bones.",),
  1749. ('INVERSE_PRESERVE', "Inverse Scale", "Scale of the X and Z axes is the inverse of the Y-Scale.",),
  1750. ('VOLUME_PRESERVE', "Volume Preservation", "Scale of the X and Z axes are adjusted to preserve the volume of the bones.",),)
  1751. class EnumYScaleMode(MantisSocket):
  1752. '''Custom node socket type'''
  1753. bl_idname = 'EnumYScaleMode'
  1754. bl_label = "Y Scale Mode"
  1755. default_value: bpy.props.EnumProperty(
  1756. items=eYScaleMode,
  1757. name="Y Scale Mode",
  1758. description="Y Scale Mode",
  1759. default = 'FIT_CURVE',
  1760. update = update_socket,)
  1761. color_simple = cString
  1762. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1763. input : bpy.props.BoolProperty(default =False,)
  1764. class EnumXZScaleMode(MantisSocket):
  1765. '''Custom node socket type'''
  1766. bl_idname = 'EnumXZScaleMode'
  1767. bl_label = "XZ Scale Mode"
  1768. default_value: bpy.props.EnumProperty(
  1769. items=eXZScaleMode,
  1770. name="XZ Scale Mode",
  1771. description="XZ Scale Mode",
  1772. default = 'NONE',
  1773. update = update_socket,)
  1774. color_simple = cString
  1775. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1776. input : bpy.props.BoolProperty(default =False,)
  1777. eMapxForm = (('LOCATION', "Location", "Location",),
  1778. ('ROTATION', "Rotation", "Rotation",),
  1779. ('SCALE', "Scale", "Scale",),)
  1780. eRotationMode = (('AUTO', 'Auto', 'Automattically Selected.', 0),
  1781. ('XYZ', "XYZ", "Euler using the XYZ rotation order", 1),
  1782. ('XZY', "XZY", "Euler using the XZY rotation order", 2),
  1783. ('ZXY', "ZXY", "Euler using the ZXY rotation order", 3),
  1784. ('ZYX', "ZYX", "Euler using the ZYX rotation order", 4),
  1785. ('YXZ', "YXZ", "Euler using the YXZ rotation order", 5),
  1786. ('YZX', "YZX", "Euler using the YZX rotation order", 6),
  1787. ('QUATERNION', "Quaternion", "Quaternion", 7),
  1788. ('SWING_TWIST_X', 'Swing and X Twist.', 'Decompose into a swing rotation to aim the X axis, followed by twist around it.', 8),
  1789. ('SWING_TWIST_Y', 'Swing and Y Twist.', 'Decompose into a swing rotation to aim the Y axis, followed by twist around it.', 9),
  1790. ('SWING_TWIST_Z', 'Swing and Z Twist.', 'Decompose into a swing rotation to aim the Z axis, followed by twist around it.', 10),)
  1791. enumTransformationRotationOrder = enumRotationOrder[:6]
  1792. eTranslationMix =(
  1793. ('ADD', "Add", "", 0),
  1794. ('REPLACE', "Replace", "", 1),
  1795. )
  1796. eScaleMix =(
  1797. ('MULTIPLY', "Multiply", "", 0),
  1798. ('REPLACE', "Replace", "", 1),
  1799. )
  1800. class EnumTransformationMap(MantisSocket):
  1801. '''Custom node socket type'''
  1802. bl_idname = 'EnumTransformationMap'
  1803. bl_label = "Map To/From"
  1804. default_value: bpy.props.EnumProperty(
  1805. items=eMapxForm,
  1806. name="Map To/From",
  1807. description="Map To/From",
  1808. default = 'LOCATION',
  1809. update = update_socket,)
  1810. color_simple = cString
  1811. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1812. input : bpy.props.BoolProperty(default =False,)
  1813. class EnumTransformationRotationMode(MantisSocket):
  1814. '''Custom node socket type'''
  1815. bl_idname = 'EnumTransformationRotationMode'
  1816. bl_label = "Map To/From"
  1817. default_value: bpy.props.EnumProperty(
  1818. items=eRotationMode,
  1819. name="Rotation Mode",
  1820. description="Rotation Mode",
  1821. default = 'AUTO',
  1822. update = update_socket,)
  1823. color_simple = cString
  1824. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1825. input : bpy.props.BoolProperty(default =False,)
  1826. def draw(self, context, layout, node, text):
  1827. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1828. def draw_color(self, context, node):
  1829. return self.color
  1830. @classmethod
  1831. def draw_color_simple(self):
  1832. return self.color_simple
  1833. class EnumTransformationRotationOrder(MantisSocket):
  1834. '''Custom node socket type'''
  1835. bl_idname = 'EnumTransformationRotationOrder'
  1836. bl_label = "Map To/From"
  1837. default_value: bpy.props.EnumProperty(
  1838. items=enumTransformationRotationOrder,
  1839. name="Rotation Order",
  1840. description="Rotation Order",
  1841. default = 'AUTO',
  1842. update = update_socket,)
  1843. color_simple = cString
  1844. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1845. input : bpy.props.BoolProperty(default =False,)
  1846. def draw(self, context, layout, node, text):
  1847. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1848. def draw_color(self, context, node):
  1849. return self.color
  1850. @classmethod
  1851. def draw_color_simple(self):
  1852. return self.color_simple
  1853. class EnumTransformationTranslationMixMode(MantisSocket):
  1854. '''Custom node socket type'''
  1855. bl_idname = 'EnumTransformationTranslationMixMode'
  1856. bl_label = "Mix Mode"
  1857. default_value: bpy.props.EnumProperty(
  1858. items=eTranslationMix,
  1859. name="Mix Translation",
  1860. description="Mix Translation",
  1861. default = 'ADD',
  1862. update = update_socket,)
  1863. color_simple = cString
  1864. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1865. input : bpy.props.BoolProperty(default =False,)
  1866. def draw(self, context, layout, node, text):
  1867. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1868. def draw_color(self, context, node):
  1869. return self.color
  1870. @classmethod
  1871. def draw_color_simple(self):
  1872. return self.color_simple
  1873. class EnumTransformationRotationMixMode(MantisSocket):
  1874. '''Custom node socket type'''
  1875. bl_idname = 'EnumTransformationRotationMixMode'
  1876. bl_label = "Mix Mode"
  1877. default_value: bpy.props.EnumProperty(
  1878. items=eRotationMix,
  1879. name="Mix Rotation",
  1880. description="Mix Rotation",
  1881. default = 'ADD',
  1882. update = update_socket,)
  1883. color_simple = cString
  1884. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1885. input : bpy.props.BoolProperty(default =False,)
  1886. def draw(self, context, layout, node, text):
  1887. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1888. def draw_color(self, context, node):
  1889. return self.color
  1890. @classmethod
  1891. def draw_color_simple(self):
  1892. return self.color_simple
  1893. class EnumTransformationScaleMixMode(MantisSocket):
  1894. '''Custom node socket type'''
  1895. bl_idname = 'EnumTransformationScaleMixMode'
  1896. bl_label = "Mix Mode"
  1897. default_value: bpy.props.EnumProperty(
  1898. items=eScaleMix,
  1899. name="Mix Scale",
  1900. description="Mix Scale",
  1901. default = 'REPLACE',
  1902. update = update_socket,)
  1903. color_simple = cString
  1904. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1905. input : bpy.props.BoolProperty(default =False,)
  1906. def draw(self, context, layout, node, text):
  1907. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1908. def draw_color(self, context, node):
  1909. return self.color
  1910. @classmethod
  1911. def draw_color_simple(self):
  1912. return self.color_simple
  1913. eAxes = (
  1914. ('X', "X", "X", 0),
  1915. ('Y', "Y", "Y", 1),
  1916. ('Z', "Z", "Z", 2),
  1917. )
  1918. class EnumTransformationAxes(MantisSocket):
  1919. '''Custom node socket type'''
  1920. bl_idname = 'EnumTransformationAxes'
  1921. bl_label = "Axes"
  1922. default_value: bpy.props.EnumProperty(
  1923. items=eAxes,
  1924. # name="",
  1925. # description="",
  1926. default = 'X',
  1927. update = update_socket,)
  1928. color_simple = cString
  1929. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1930. input : bpy.props.BoolProperty(default =False,)
  1931. def draw(self, context, layout, node, text):
  1932. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1933. def draw_color(self, context, node):
  1934. return self.color
  1935. @classmethod
  1936. def draw_color_simple(self):
  1937. return self.color_simple
  1938. #
  1939. eBBoneHandleType = (
  1940. ('AUTO', "Automatic", "", 0),
  1941. ('ABSOLUTE', "Absolute", "", 1),
  1942. ('RELATIVE', "Relative", "", 2),
  1943. ('TANGENT', "Tangent", "", 3),
  1944. )
  1945. class EnumBBoneHandleType(MantisSocket):
  1946. '''Custom node socket type'''
  1947. bl_idname = 'EnumBBoneHandleType'
  1948. bl_label = "Axes"
  1949. default_value: bpy.props.EnumProperty(
  1950. items=eBBoneHandleType,
  1951. # name="",
  1952. # description="",
  1953. default = 'AUTO',
  1954. update = update_socket,)
  1955. color_simple = cString
  1956. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1957. input : bpy.props.BoolProperty(default =False,)
  1958. def draw(self, context, layout, node, text):
  1959. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1960. def draw_color(self, context, node):
  1961. return self.color
  1962. @classmethod
  1963. def draw_color_simple(self):
  1964. return self.color_simple
  1965. eShrinkwrapType = (
  1966. ('NEAREST_SURFACE', "Nearest Surface Point",
  1967. "Shrink the location to the nearest target surface.", 0),
  1968. ('PROJECT', "Project", "Shrink the location to the nearest target "
  1969. "surface along a given axis.", 1),
  1970. ('NEAREST_VERTEX', "Nearest Vertex", "Shrink the location to the"
  1971. " nearest target vertex.", 2),
  1972. ('TARGET_PROJECT', "Target Normal Project", "Shrink the location to the"
  1973. " nearest target surface along the interpolated vertex"
  1974. " normals of the target.", 3),
  1975. )
  1976. class EnumShrinkwrapTypeSocket(MantisSocket):
  1977. '''Shrinkwrap Type Socket'''
  1978. bl_idname = 'EnumShrinkwrapTypeSocket'
  1979. bl_label = "Shrinkwrap Type"
  1980. default_value: bpy.props.EnumProperty(
  1981. items=eShrinkwrapType,
  1982. description="Select type of shrinkwrap algorithm for target position",
  1983. default = 'TARGET_PROJECT',
  1984. update = update_socket,)
  1985. color_simple = cString
  1986. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  1987. input : bpy.props.BoolProperty(default =False,)
  1988. def draw(self, context, layout, node, text):
  1989. ChooseDraw(self, context, layout, node, text, use_enum=False)
  1990. def draw_color(self, context, node):
  1991. return self.color
  1992. @classmethod
  1993. def draw_color_simple(self):
  1994. return self.color_simple
  1995. eShrinkwrapFaceCull = (
  1996. ('OFF', "Off", "No Culling.", 0),
  1997. ('FRONT', "Front", "No projection when in front of the face.", 1),
  1998. ('BACK', "Back", "No projection when behind the face.", 2),
  1999. )
  2000. class EnumShrinkwrapFaceCullSocket(MantisSocket):
  2001. '''Shrinkwrap Face Cull method Socket'''
  2002. bl_idname = 'EnumShrinkwrapFaceCullSocket'
  2003. bl_label = "Shrinkwrap Type"
  2004. default_value: bpy.props.EnumProperty(
  2005. items=eShrinkwrapFaceCull,
  2006. description="Stop vertices from projecting to a face on the target"
  2007. " when facing towards/away",
  2008. default = 'OFF',
  2009. update = update_socket,)
  2010. color_simple = cString
  2011. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2012. input : bpy.props.BoolProperty(default =False,)
  2013. def draw(self, context, layout, node, text):
  2014. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2015. def draw_color(self, context, node):
  2016. return self.color
  2017. @classmethod
  2018. def draw_color_simple(self):
  2019. return self.color_simple
  2020. eShrinkwrapProjectAxis = (
  2021. ('POS_X', "+X", "", 0),
  2022. ('POS_Y', "+Y", "", 1),
  2023. ('POS_Z', "+Z", "", 2),
  2024. ('NEG_X', "-X", "", 3),
  2025. ('NEG_Y', "-Y", "", 4),
  2026. ('NEG_Z', "-Z", "", 5), )
  2027. class EnumShrinkwrapProjectAxisSocket(MantisSocket):
  2028. '''Shrinkwrap Projection Axis Socket'''
  2029. bl_idname = 'EnumShrinkwrapProjectAxisSocket'
  2030. bl_label = "Shrinkwrap Projection Axis"
  2031. default_value: bpy.props.EnumProperty(
  2032. items=eShrinkwrapProjectAxis,
  2033. description="Axis constrain to",
  2034. default = 'POS_X',
  2035. update = update_socket,)
  2036. color_simple = cString
  2037. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2038. input : bpy.props.BoolProperty(default =False,)
  2039. def draw(self, context, layout, node, text):
  2040. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2041. def draw_color(self, context, node):
  2042. return self.color
  2043. @classmethod
  2044. def draw_color_simple(self):
  2045. return self.color_simple
  2046. eShrinkwrapMode = (
  2047. ('ON_SURFACE', "On Surface", "The point is constrained to the surface"
  2048. " of the target object, with distance offset towards the"
  2049. " original point location.", 0),
  2050. ('INSIDE', "Inside", "The point is constrained to be inside the target"
  2051. " object", 1),
  2052. ('OUTSIDE', "Outside", "The point is constrained to be outside the "
  2053. "target object.", 2),
  2054. ('OUTSIDE_SURFACE', "Outside Surface", "The point is constrained to the"
  2055. " surface of the target object, with distance"
  2056. " offset always to the outside, towards or away"
  2057. " from the original location.", 3),
  2058. ('ABOVE_SURFACE', "Above Surface", "The point is constrained to the"
  2059. " surface of the target object, with distance offset "
  2060. "applied exactly along the target normal.", 4), )
  2061. class EnumShrinkwrapModeSocket(MantisSocket):
  2062. '''Shrinkwrap Mode Socket'''
  2063. bl_idname = 'EnumShrinkwrapModeSocket'
  2064. bl_label = "Shrinkwrap Mode"
  2065. default_value: bpy.props.EnumProperty(
  2066. items=eShrinkwrapMode,
  2067. description="Select how to constrain the object to the target surface",
  2068. default = 'ON_SURFACE',
  2069. update = update_socket,)
  2070. color_simple = cString
  2071. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2072. input : bpy.props.BoolProperty(default =False,)
  2073. def draw(self, context, layout, node, text):
  2074. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2075. def draw_color(self, context, node):
  2076. return self.color
  2077. @classmethod
  2078. def draw_color_simple(self):
  2079. return self.color_simple
  2080. eDataTypeMode = (
  2081. ('VECTOR', "Vector", "Vector", 0),
  2082. ('QUATERNION', "Quaternion", "", 1),
  2083. ('FLOAT4X4', "4x4 Matrix", "", 2), )
  2084. class EnumGeometryAttributeDataTypeSocket(MantisSocket):
  2085. '''Shrinkwrap Mode Socket'''
  2086. bl_idname = 'EnumGeometryAttributeDataTypeSocket'
  2087. bl_label = "Datatype"
  2088. default_value: bpy.props.EnumProperty(
  2089. items=eDataTypeMode,
  2090. description="Select the data type of the attribute",
  2091. default = 'VECTOR',
  2092. update = update_socket,)
  2093. color_simple = cString
  2094. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2095. input : bpy.props.BoolProperty(default =False,)
  2096. def draw(self, context, layout, node, text):
  2097. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2098. def draw_color(self, context, node):
  2099. return self.color
  2100. @classmethod
  2101. def draw_color_simple(self):
  2102. return self.color_simple
  2103. eDomaineMode = (
  2104. ('POINT', "Point", "Point", 0),
  2105. ('EDGE', "Edge", "Edge", 1),
  2106. ('FACE', "Face", "Face", 2),
  2107. ('FACE_CORNER', "Face Corner", "Face Corner", 3),
  2108. ('SPLINE', "Spline", "Spline", 4),
  2109. ('INSTANCE', "Instance", "Instance", 5), )
  2110. class EnumGeometryAttributeDomainSocket(MantisSocket):
  2111. '''Shrinkwrap Mode Socket'''
  2112. bl_idname = 'EnumGeometryAttributeDomainSocket'
  2113. bl_label = "Domain"
  2114. default_value: bpy.props.EnumProperty(
  2115. items=eDomaineMode,
  2116. description="Select the data type of the attribute",
  2117. default = 'POINT',
  2118. update = update_socket,)
  2119. color_simple = cString
  2120. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2121. input : bpy.props.BoolProperty(default =False,)
  2122. def draw(self, context, layout, node, text):
  2123. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2124. def draw_color(self, context, node):
  2125. return self.color
  2126. @classmethod
  2127. def draw_color_simple(self):
  2128. return self.color_simple
  2129. eMix_geometryattribute =(
  2130. ('REPLACE', "Replace (Aligned)", "Fully inherit scale"),
  2131. ('BEFORE_SPLIT', "Before (Split Channels)", "Fully inherit scale"),
  2132. ('AFTER_SPLIT', "After (Split Channels)", "Fully inherit scale"),
  2133. ('BEFORE_FULL', "Before (Full)", "Fully inherit scale"),
  2134. ('AFTER_FULL', "After (Full)", "Fully inherit scale"),)
  2135. class EnumMixModeGeometryAttribute(MantisSocket):
  2136. '''Custom node socket type'''
  2137. bl_idname = 'EnumMixModeGeometryAttribute'
  2138. bl_label = "Rotation Mix"
  2139. default_value: bpy.props.EnumProperty(
  2140. items=eMix_geometryattribute,
  2141. name="Mix Mode",
  2142. description="Mix mode",
  2143. default = 'REPLACE', #{'REPLACE'},
  2144. #options = {'ENUM_FLAG'}, # this sux
  2145. update = update_socket,)
  2146. color_simple = cString
  2147. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2148. input : bpy.props.BoolProperty(default =False,)
  2149. eSkinningMethod = (('EXISTING_GROUPS', "Use Existing Groups", "Use the existing vertex groups, or create empty groups if not found.",),
  2150. ('AUTOMATIC_HEAT', "Automatic (Heat)", "Use Blender's heatmap automatic skinning",),
  2151. ('COPY_FROM_OBJECT', "Copy from object", "Copy skin weights from the selected object"),)
  2152. class EnumSkinning(MantisSocket):
  2153. '''Custom node socket type'''
  2154. bl_idname = 'EnumSkinning'
  2155. bl_label = "Skinning Method"
  2156. default_value: bpy.props.EnumProperty(
  2157. items=eSkinningMethod,
  2158. name="Skinning Method",
  2159. description="Skinning Method",
  2160. default = 'AUTOMATIC_HEAT',
  2161. update = update_socket,)
  2162. color_simple = cString
  2163. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2164. input : bpy.props.BoolProperty(default =False,)
  2165. class MorphTargetSocket(MantisSocket):
  2166. """Morph Target"""
  2167. bl_idname = 'MorphTargetSocket'
  2168. bl_label = "Morph Target"
  2169. color_simple = cShapeKey
  2170. color : bpy.props.FloatVectorProperty(default=cShapeKey, size=4)
  2171. input : bpy.props.BoolProperty(default =False,)
  2172. is_valid_interface_type=True
  2173. eDriverVariableType = (
  2174. ( 'SINGLE_PROP',
  2175. "Property",
  2176. "Property",
  2177. 1),
  2178. ( 'LOC_DIFF',
  2179. "Distance",
  2180. "Distance",
  2181. 2),
  2182. ( 'ROTATION_DIFF',
  2183. "Rotational Difference",
  2184. "Rotational Difference",
  2185. 3),
  2186. # ( 'TRANSFORMS',
  2187. # "Transform Channel",
  2188. # "Transform Channel",
  2189. # 4),
  2190. )
  2191. class EnumDriverVariableType(MantisSocket):
  2192. '''Custom node socket type'''
  2193. bl_idname = 'EnumDriverVariableType'
  2194. bl_label = "Variable Type"
  2195. default_value: bpy.props.EnumProperty(
  2196. items = eDriverVariableType,
  2197. name = "Variable Type",
  2198. description = "Variable Type",
  2199. default = 'SINGLE_PROP',
  2200. update = driver_variable_socket_update,)
  2201. color_simple = cString
  2202. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2203. input : bpy.props.BoolProperty(default =False,)
  2204. def draw(self, context, layout, node, text):
  2205. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2206. def draw_color(self, context, node):
  2207. return self.color
  2208. @classmethod
  2209. def draw_color_simple(self):
  2210. return self.color_simple
  2211. eDriverVariableEvaluationSpace = (
  2212. ( 'WORLD_SPACE',
  2213. "World",
  2214. "World",
  2215. 1),
  2216. ( 'TRANSFORM_SPACE',
  2217. "Transform",
  2218. "Transform",
  2219. 2),
  2220. ( 'LOCAL_SPACE',
  2221. "Local",
  2222. "Local",
  2223. 3),
  2224. )
  2225. class EnumDriverVariableEvaluationSpace(MantisSocket):
  2226. '''Custom node socket type'''
  2227. bl_idname = 'EnumDriverVariableEvaluationSpace'
  2228. bl_label = "Evaluation Space"
  2229. default_value: bpy.props.EnumProperty(
  2230. items = eDriverVariableEvaluationSpace,
  2231. name = "Evaluation Space",
  2232. description = "Evaluation Space",
  2233. default = 'WORLD_SPACE',
  2234. update = driver_variable_socket_update,)
  2235. color_simple = cString
  2236. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2237. input : bpy.props.BoolProperty(default =False,)
  2238. def draw(self, context, layout, node, text):
  2239. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2240. def draw_color(self, context, node):
  2241. return self.color
  2242. @classmethod
  2243. def draw_color_simple(self):
  2244. return self.color_simple
  2245. eDriverVariableTransformChannel = (
  2246. ("LOC_X", "X Location", "The X-coordinate of an object's location.", 1),
  2247. ("LOC_Y", "Y Location", "The Y-coordinate of an object's location.", 2),
  2248. ("LOC_Z", "Z Location", "The Z-coordinate of an object's location.", 3),
  2249. ("ROT_X", "X Rotation", "Rotation X-axis.", 4),
  2250. ("ROT_Y", "Y Rotation", "Rotation Y-axis.", 5),
  2251. ("ROT_Z", "Z Rotation", "Rotation Z-axis.", 6),
  2252. ("ROT_W", "W Rotation", "Rotation W-axis.", 7),
  2253. ("SCALE_X", "X Scale", "The X-scale of an object's scale.", 8),
  2254. ("SCALE_Y", "Y Scale", "The Y-scale of an object's scale.", 9),
  2255. ("SCALE_Z", "Z Scale", "The Z-scale of an object's scale.", 10),
  2256. ("SCALE_AVG", "Average Scale", "The scale factor of an object's scale.", 11),
  2257. )
  2258. class EnumDriverVariableTransformChannel(MantisSocket):
  2259. '''Custom node socket type'''
  2260. bl_idname = 'EnumDriverVariableTransformChannel'
  2261. bl_label = "Transform Channel"
  2262. default_value: bpy.props.EnumProperty(
  2263. items = eDriverVariableTransformChannel,
  2264. name = "Transform Channel",
  2265. description = "Transform Channel",
  2266. default = 'LOC_X',
  2267. update = driver_variable_socket_update,)
  2268. color_simple = cString
  2269. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2270. input : bpy.props.BoolProperty(default =False,)
  2271. def draw(self, context, layout, node, text):
  2272. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2273. def draw_color(self, context, node):
  2274. return self.color
  2275. @classmethod
  2276. def draw_color_simple(self):
  2277. return self.color_simple
  2278. class EnumDriverRotationMode(MantisSocket):
  2279. '''Custom node socket type'''
  2280. bl_idname = 'EnumDriverRotationMode'
  2281. bl_label = "Rotaton Mode"
  2282. default_value: bpy.props.EnumProperty(
  2283. items = eRotationMode,
  2284. name = "Rotation Mode",
  2285. description = "Rotation Mode",
  2286. default = 'AUTO',
  2287. update = driver_variable_socket_update,)
  2288. color_simple = cString
  2289. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2290. input : bpy.props.BoolProperty(default =False,)
  2291. def draw(self, context, layout, node, text):
  2292. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2293. def draw_color(self, context, node):
  2294. return self.color
  2295. @classmethod
  2296. def draw_color_simple(self):
  2297. return self.color_simple
  2298. #
  2299. eDriverType = (('AVERAGE', 'Average', 'Average', 0),
  2300. ('SUM', "Sum", "Sum", 1),
  2301. ('SCRIPTED', "Scripted", "Scripted Expression", 2),
  2302. ('MIN', "Min", "Minimum", 3),
  2303. ('MAX', "Max", "Maximum", 4),)
  2304. class EnumDriverType(MantisSocket):
  2305. '''Custom node socket type'''
  2306. bl_idname = 'EnumDriverType'
  2307. bl_label = "Driver Type"
  2308. default_value: bpy.props.EnumProperty(
  2309. items = eDriverType,
  2310. name = "Driver Type",
  2311. description = "Driver Type",
  2312. default = 'AVERAGE',
  2313. update = driver_socket_update,)
  2314. color_simple = cString
  2315. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2316. input : bpy.props.BoolProperty(default =False,)
  2317. def draw(self, context, layout, node, text):
  2318. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2319. def draw_color(self, context, node):
  2320. return self.color
  2321. @classmethod
  2322. def draw_color_simple(self):
  2323. return self.color_simple
  2324. # Keyframe
  2325. # Enum for kf handle type
  2326. # enum for interpolation type
  2327. # eventually gonna make it to the fancy stuff
  2328. class FloatSocket(MantisSocketOverlayEnabled):
  2329. """Float Input socket"""
  2330. bl_idname = 'FloatSocket'
  2331. bl_label = "Float"
  2332. is_valid_interface_type=True
  2333. default_value : bpy.props.FloatProperty(default = 0.0, update = update_socket,)
  2334. color_simple = cFloat
  2335. color : bpy.props.FloatVectorProperty(default=cFloat, size=4)
  2336. input : bpy.props.BoolProperty(default =False,)
  2337. class FloatPositiveSocket(MantisSocketOverlayEnabled):
  2338. """Float Input socket"""
  2339. bl_idname = 'FloatPositiveSocket'
  2340. bl_label = "Float (Positive)"
  2341. is_valid_interface_type=True
  2342. default_value : bpy.props.FloatProperty(default = 0.0, min=0, update = update_socket,)
  2343. color_simple = cFloat
  2344. color : bpy.props.FloatVectorProperty(default=cFloat, size=4)
  2345. input : bpy.props.BoolProperty(default =False,)
  2346. class FloatFactorSocket(MantisSocketOverlayEnabled):
  2347. '''xFrom Input Output'''
  2348. bl_idname = 'FloatFactorSocket'
  2349. bl_label = "Float (Factor)"
  2350. is_valid_interface_type=True
  2351. default_value : bpy.props.FloatProperty(
  2352. default = 0.0,
  2353. min = 0.0,
  2354. max=1.0,
  2355. update = update_socket,
  2356. subtype='FACTOR',)
  2357. color_simple = cFloat
  2358. color : bpy.props.FloatVectorProperty(default=cFloat, size=4)
  2359. input : bpy.props.BoolProperty(default =False,)
  2360. class FloatAngleSocket(MantisSocketOverlayEnabled):
  2361. '''xFrom Input Output'''
  2362. bl_idname = 'FloatAngleSocket'
  2363. bl_label = "Float (Angle)"
  2364. is_valid_interface_type=True
  2365. default_value : bpy.props.FloatProperty(
  2366. default = 0.0,
  2367. min = -180,
  2368. max=180,
  2369. update = update_socket,
  2370. subtype='ANGLE',)
  2371. color_simple = cFloat
  2372. color : bpy.props.FloatVectorProperty(default=cFloat, size=4)
  2373. input : bpy.props.BoolProperty(default =False,)
  2374. class VectorSocket(MantisSocket):
  2375. """Vector Input socket"""
  2376. bl_idname = 'VectorSocket'
  2377. bl_label = "Vector"
  2378. is_valid_interface_type=True
  2379. default_value : bpy.props.FloatVectorProperty(
  2380. default = (0.0, 0.0, 0.0),
  2381. update = update_socket,)
  2382. color_simple = cVector
  2383. color : bpy.props.FloatVectorProperty(default=cVector, size=4)
  2384. input : bpy.props.BoolProperty(default =False,)
  2385. class VectorEulerSocket(MantisSocket):
  2386. """Vector Input socket"""
  2387. bl_idname = 'VectorEulerSocket'
  2388. bl_label = "Euler"
  2389. is_valid_interface_type=True
  2390. default_value : bpy.props.FloatVectorProperty(
  2391. default = (0.0, 0.0, 0.0),
  2392. update = update_socket,
  2393. subtype='EULER',)
  2394. color_simple = cVector
  2395. color : bpy.props.FloatVectorProperty(default=cVector, size=4)
  2396. input : bpy.props.BoolProperty(default =False,)
  2397. class VectorTranslationSocket(MantisSocket):
  2398. """Vector Input socket"""
  2399. bl_idname = 'VectorTranslationSocket'
  2400. bl_label = "Vector (Translation)"
  2401. default_value : bpy.props.FloatVectorProperty(
  2402. default = (0.0, 0.0, 0.0),
  2403. update = update_socket,
  2404. subtype='TRANSLATION',)
  2405. color_simple = cVector
  2406. color : bpy.props.FloatVectorProperty(default=cVector, size=4)
  2407. input : bpy.props.BoolProperty(default =False,)
  2408. class VectorScaleSocket(MantisSocket):
  2409. """Vector Input socket"""
  2410. bl_idname = 'VectorScaleSocket'
  2411. bl_label = "Vector (Scale)"
  2412. default_value : bpy.props.FloatVectorProperty(
  2413. default = (1.0, 1.0, 1.0),
  2414. update = update_socket,
  2415. subtype='XYZ',)
  2416. color_simple = cVector
  2417. color : bpy.props.FloatVectorProperty(default=cVector, size=4)
  2418. input : bpy.props.BoolProperty(default =False,)
  2419. class KeyframeSocket(MantisSocket):
  2420. '''Keyframe'''
  2421. bl_idname = 'KeyframeSocket'
  2422. bl_label = "Keyframe"
  2423. is_valid_interface_type=True
  2424. color_simple = cKeyframe
  2425. color : bpy.props.FloatVectorProperty(default=cKeyframe, size=4)
  2426. input : bpy.props.BoolProperty(default =False, update = update_socket)
  2427. def init(self):
  2428. self.display_shape = 'CIRCLE_DOT'
  2429. EnumKeyframeInterpolationType = (('CONSTANT', 'Stepped', 'Stepped'),
  2430. ('LINEAR', "Linear", "Linear"),
  2431. ('BEZIER', "Bezier", "Bezier"),)
  2432. class EnumKeyframeInterpolationTypeSocket(MantisSocket):
  2433. '''Keyframe Interpolation Type'''
  2434. bl_idname = 'EnumKeyframeInterpolationTypeSocket'
  2435. bl_label = "Keyframe Interpolation Type"
  2436. default_value :bpy.props.EnumProperty(
  2437. name="",
  2438. description="Interpolation",
  2439. items=EnumKeyframeInterpolationType,
  2440. default='LINEAR',
  2441. update = update_socket,)
  2442. color_simple = cString
  2443. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2444. input : bpy.props.BoolProperty(default =False, update = update_socket)
  2445. EnumKeyframeBezierHandleType = (('FREE', 'Free', 'Completely independent manually set handle.'),
  2446. ('ALIGNED', "Aligned", "Manually set handle with rotation locked together with its pair."),
  2447. ('VECTOR', "Vector", "Automatic handles that create straight lines."),
  2448. ('AUTO', "Automatic", "Automatic handles that create smooth curves."),
  2449. ('AUTO_CLAMPED', "Auto Clamped", "Automatic handles that create smooth curves which only change direction at keyframes."),)
  2450. class EnumKeyframeBezierHandleTypeSocket(MantisSocket):
  2451. '''Keyframe Bezier Handle Type'''
  2452. bl_idname = 'EnumKeyframeBezierHandleTypeSocket'
  2453. bl_label = "Keyframe Bezier Handle Type"
  2454. default_value :bpy.props.EnumProperty(
  2455. name="",
  2456. description="Handle Type",
  2457. items=EnumKeyframeBezierHandleType,
  2458. default='AUTO_CLAMPED',
  2459. update = update_socket,)
  2460. color_simple = cString
  2461. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2462. input : bpy.props.BoolProperty(default =False, update = update_socket)
  2463. enumExtrapolationMode = (('CONSTANT', 'Constant', 'Constant'),
  2464. ('LINEAR', "Linear", "Linear"),)
  2465. class eFCrvExtrapolationMode(MantisSocket):
  2466. '''FCurve Extrapolation Mode'''
  2467. bl_idname = 'eFCrvExtrapolationMode'
  2468. bl_label = "Extrapolation Mode"
  2469. default_value :bpy.props.EnumProperty(
  2470. name="",
  2471. description="Handle Type",
  2472. items=enumExtrapolationMode,
  2473. default='CONSTANT',
  2474. update = update_socket,)
  2475. color_simple = cString
  2476. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2477. input : bpy.props.BoolProperty(default =False, update = update_socket)
  2478. EnumLatticeInterpolationType = (('KEY_LINEAR', 'Linear', 'Linear Interpolation.'),
  2479. ('KEY_CARDINAL', "Cardinal", "Cardinal Interpolation."),
  2480. ('KEY_CATMULL_ROM', "Catmull Rom", "Catmull Rom Interpolation."),
  2481. ('KEY_BSPLINE', "B-Spline", "B Spline Interpolation."),)
  2482. class EnumLatticeInterpolationTypeSocket(MantisSocket):
  2483. '''Lattice Interpolation Type'''
  2484. bl_idname = 'EnumLatticeInterpolationTypeSocket'
  2485. bl_label = "Lattice Interpolation Type"
  2486. default_value :bpy.props.EnumProperty(
  2487. name="",
  2488. description="Interpolation Type",
  2489. items=EnumLatticeInterpolationType,
  2490. default='KEY_BSPLINE',
  2491. update = update_socket,)
  2492. color_simple = cString
  2493. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2494. input : bpy.props.BoolProperty(default =False, update = update_socket)
  2495. EnumCorrectiveSmoothType = (('SIMPLE', 'Simple', 'Use the average of adjacent edge-vertices.'),
  2496. ('LENGTH_WEIGHTED', "Length Weight", "Use the average of adjacent"
  2497. "edge-vertices weighted by their length."),)
  2498. class EnumCorrectiveSmoothTypeSocket(MantisSocket):
  2499. '''Lattice Interpolation Type'''
  2500. bl_idname = 'EnumCorrectiveSmoothTypeSocket'
  2501. bl_label = "Lattice Interpolation Type"
  2502. default_value :bpy.props.EnumProperty(
  2503. name="",
  2504. description="Interpolation Type",
  2505. items=EnumCorrectiveSmoothType,
  2506. default='SIMPLE',
  2507. update = update_socket,)
  2508. color_simple = cString
  2509. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2510. input : bpy.props.BoolProperty(default =False, update = update_socket)
  2511. enumArmatureDisplayType =( ('OCTAHEDRAL', "Octahedral", "Octahedral"),
  2512. ('STICK', "Stick", "Stick"),
  2513. ('BBONE', "BBone", "BBone"),
  2514. ('ENVELOPE', "Envelope", "Envelope"),
  2515. ('WIRE', "Wire", "Wire"),)
  2516. class EnumArmatureDisplayType(MantisSocket):
  2517. """Float Math Operation"""
  2518. bl_idname = 'EnumArmatureDisplayType'
  2519. bl_label = "Operation"
  2520. default_value :bpy.props.EnumProperty(
  2521. name="",
  2522. description="Display Type",
  2523. items=enumArmatureDisplayType,
  2524. default='OCTAHEDRAL',
  2525. update = update_socket,)
  2526. color_simple = cString
  2527. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2528. input : bpy.props.BoolProperty(default =False,)
  2529. def draw(self, context, layout, node, text):
  2530. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2531. def draw_color(self, context, node):
  2532. return self.color
  2533. @classmethod
  2534. def draw_color_simple(self):
  2535. return self.color_simple
  2536. enumDisplayType =(('ARMATURE_DEFINED', 'Auto', 'Auto'),
  2537. ('OCTAHEDRAL', "Octahedral", "Octahedral"),
  2538. ('STICK', "Stick", "Stick"),
  2539. ('BBONE', "BBone", "BBone"),
  2540. ('ENVELOPE', "Envelope", "Envelope"),
  2541. ('WIRE', "Wire", "Wire"),)
  2542. class EnumDisplayType(MantisSocket):
  2543. """Float Math Operation"""
  2544. bl_idname = 'EnumDisplayType'
  2545. bl_label = "Operation"
  2546. default_value :bpy.props.EnumProperty(
  2547. name="",
  2548. description="Display Type",
  2549. items=enumDisplayType,
  2550. default='ARMATURE_DEFINED',
  2551. update = update_socket,)
  2552. color_simple = cString
  2553. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2554. input : bpy.props.BoolProperty(default =False,)
  2555. def draw(self, context, layout, node, text):
  2556. ChooseDraw(self, context, layout, node, text, use_enum=False)
  2557. def draw_color(self, context, node):
  2558. return self.color
  2559. @classmethod
  2560. def draw_color_simple(self):
  2561. return self.color_simple
  2562. enumFloatOperations = (('ADD', 'Add', 'Add'),
  2563. ('SUBTRACT', "Subtract", "Subtract"),
  2564. ('MULTIPLY', "Multiply", "Multiply"),
  2565. ('DIVIDE', "Divide", "Divide"),
  2566. ('POWER', "Power", "Power"),
  2567. ('FLOOR_DIVIDE', "Floor Divide", "Floor Divide"),
  2568. ('MODULUS', "Modulus", "Modulus"),
  2569. ('ABSOLUTE', "Absolute", "Absolute Value"),
  2570. ('MAXIMUM', "Maximum", "Maximum"),
  2571. ('MINIMUM', "Minimum", "Minimum"),
  2572. ('GREATER THAN', "Greater Than", "Greater Than"),
  2573. ('LESS THAN', "Less Than", "Less Than"),
  2574. ('ARCTAN2', "atan2", "2-argument arctan function"),
  2575. ('FLOOR', "Floor", "the nearest integer lower than input A"),
  2576. ('CEIL', "Ceiling", "the next integer higher than input A"),
  2577. ('ROUND', "Round", "Round to the nearest integer"),)
  2578. class MathFloatOperation(MantisSocket):
  2579. """Float Math Operation"""
  2580. bl_idname = 'MathFloatOperation'
  2581. bl_label = "Operation"
  2582. default_value :bpy.props.EnumProperty(
  2583. name="",
  2584. description="Operation",
  2585. items=enumFloatOperations,
  2586. default='MULTIPLY',
  2587. update = update_socket,)
  2588. color_simple = cString
  2589. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2590. input : bpy.props.BoolProperty(default =False,)
  2591. enumVectorOperations = (('ADD', 'Add', 'Add (Component-wise)'),
  2592. ('SUBTRACT', "Subtract", "Subtract (Component-wise)"),
  2593. ('MULTIPLY', "Multiply", "Multiply (Component-wise)"),
  2594. ('SCALE', "Scale", "Scales vector by input float or average magnitude of input vector's components."),
  2595. ('DIVIDE', "Divide", "Divide (Component-wise)"),
  2596. ('POWER', "Power", "Power (Component-wise)"),
  2597. ('LENGTH', "Length", "Length"),
  2598. ('CROSS', "Cross Product", "Cross product of A X B"),
  2599. ('NORMALIZE', "Normalize", "Returns a normalized vector."),
  2600. ('DOT', "Dot Product", "Dot product of A . B"),
  2601. ('LINEAR_INTERP', "Linear Interpolation", "Linear Interpolation between vectors A and B by factor"))
  2602. class MathVectorOperation(MantisSocket):
  2603. """Vector Math Operation"""
  2604. bl_idname = 'MathVectorOperation'
  2605. bl_label = "Operation"
  2606. default_value :bpy.props.EnumProperty(
  2607. name="",
  2608. description="Operation",
  2609. items=enumVectorOperations,
  2610. default='MULTIPLY',
  2611. update = update_socket,)
  2612. color_simple = cString
  2613. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2614. input : bpy.props.BoolProperty(default =False,)
  2615. enumMatrixTransform = (('TRANSLATE', 'Translate', 'Translate'),
  2616. ('ROTATE_AXIS_ANGLE', "Rotate (Axis-angle)", "Rotates a number of radians around an axis"),
  2617. # ('ROTATE_EULER', "Rotate (Euler)", "Euler Rotation"),
  2618. # ('ROTATE_QUATERNION', "Rotate (Quaternion)", "Quaternion Rotation"),
  2619. ('SCALE', "Scale", "Scale"),)
  2620. class MatrixTransformOperation(MantisSocket):
  2621. """Matrix Transform Operation"""
  2622. bl_idname = 'MatrixTransformOperation'
  2623. bl_label = "Operation"
  2624. default_value :bpy.props.EnumProperty(
  2625. name="",
  2626. description="Operation",
  2627. items=enumMatrixTransform,
  2628. default='TRANSLATE',
  2629. update = update_socket,)
  2630. color_simple = cString
  2631. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2632. input : bpy.props.BoolProperty(default =False,)
  2633. enumIntOperations = (('ADD', 'Add', 'Add'),
  2634. ('SUBTRACT', "Subtract", "Subtract"),
  2635. ('MULTIPLY', "Multiply", "Multiply"),
  2636. ('FLOOR_DIVIDE', "Floor Divide", "Floor Divide"),
  2637. ('POWER', "Power", "Power"),
  2638. ('MODULUS', "Modulus", "Modulus"),
  2639. ('ABSOLUTE', "Absolute", "Absolute Value"),
  2640. ('MAXIMUM', "Maximum", "Maximum"),
  2641. ('MINIMUM', "Minimum", "Minimum"),
  2642. ('GREATER THAN', "Greater Than", "Greater Than"),
  2643. ('LESS THAN', "Less Than", "Less Than"),)
  2644. class MathIntOperation(MantisSocket):
  2645. """Int Math Operation"""
  2646. bl_idname = 'MathIntOperation'
  2647. bl_label = "Operation"
  2648. default_value :bpy.props.EnumProperty(
  2649. name="",
  2650. description="Operation",
  2651. items=enumIntOperations,
  2652. default='MULTIPLY',
  2653. update = update_socket,)
  2654. color_simple = cString
  2655. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2656. input : bpy.props.BoolProperty(default =False,)
  2657. enumCompareOperations = (('EQUAL', "Equal", "Equal"),
  2658. ('NOT_EQUAL', "Not Equal", "Not Equal"),
  2659. ('GREATER_THAN', "Greater Than", "Greater Than"),
  2660. ('GREATER_THAN_EQUAL', "Greater Than or Equal", "Greater Than or Equal"),
  2661. ('LESS_THAN', "Less Than", "Less Than"),
  2662. ('LESS_THAN_EQUAL', "Equal or Less Than", "Equal or Less Than"),)
  2663. class EnumCompareOperation(MantisSocket):
  2664. """Compare Operation"""
  2665. bl_idname = 'EnumCompareOperation'
  2666. bl_label = "Comparison"
  2667. default_value :bpy.props.EnumProperty(
  2668. name="",
  2669. description="Comparison",
  2670. items=enumCompareOperations,
  2671. default='EQUAL',
  2672. update = update_socket,)
  2673. enum_display_type = 'DROPDOWN'
  2674. color_simple = cString
  2675. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2676. input : bpy.props.BoolProperty(default =False,)
  2677. class EnumMatrixFromCurveMode(MantisSocket):
  2678. """Matrix From Curve Mode"""
  2679. bl_idname = 'EnumMatrixFromCurveMode'
  2680. bl_label = "Mode"
  2681. enum_display_type='DROPDOWN'
  2682. default_value :bpy.props.EnumProperty(
  2683. name="",
  2684. description="Mode",
  2685. items=eMatrixFromCurveModes,
  2686. default='DIVISIONS',
  2687. update = update_socket,)
  2688. color_simple = cString
  2689. enum_display_type = 'DROPDOWN'
  2690. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2691. input : bpy.props.BoolProperty(default =False,)
  2692. class EnumComposeMatrixModes(MantisSocket):
  2693. """Compose Matrix Mode"""
  2694. bl_idname = 'EnumComposeMatrixModes'
  2695. bl_label = "Mode"
  2696. enum_display_type='DROPDOWN'
  2697. default_value :bpy.props.EnumProperty(
  2698. name="",
  2699. description="Mode",
  2700. items=eMatrixComposeModes,
  2701. default='BASIS',
  2702. update = update_socket,)
  2703. color_simple = cString
  2704. color : bpy.props.FloatVectorProperty(default=cString, size=4)
  2705. input : bpy.props.BoolProperty(default =False,)
  2706. class WildcardSocket(MantisSocket):
  2707. """Some kind of node socket lol I donno"""
  2708. bl_idname = 'WildcardSocket'
  2709. bl_label = ""
  2710. color_simple = (0.0,0.0,0.0,0.0)
  2711. color : bpy.props.FloatVectorProperty(default=(0.0,0.0,0.0,0.0), size=4)
  2712. input : bpy.props.BoolProperty(default =False,)