socket_definitions.py 111 KB

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