socket_definitions.py 116 KB

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