socket_definitions.py 114 KB

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