socket_definitions.py 120 KB

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