socket_definitions.py 113 KB

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