socket_definitions.py 119 KB

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