socket_definitions.py 120 KB

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