diff options
author | Martin Poirier <theeth@yahoo.com> | 2009-06-20 07:38:34 +0400 |
---|---|---|
committer | Martin Poirier <theeth@yahoo.com> | 2009-06-20 07:38:34 +0400 |
commit | 12bf10be020de1f4031889f78552c77121da3194 (patch) | |
tree | df916ba35e2e711f788d5792097f071c9e5023df | |
parent | bb9323a720483b0c02bf25ecfca9c6ccc8699519 (diff) | |
parent | 7785ead4eb64f9702d7a59060e73b3e121e674a7 (diff) |
2.5 merged 20773:21020
298 files changed, 23038 insertions, 6245 deletions
diff --git a/SConstruct b/SConstruct index 125594f69c5..808fa09bea0 100644 --- a/SConstruct +++ b/SConstruct @@ -404,6 +404,9 @@ dobj = B.buildinfo(env, "dynamic") + B.resources thestatlibs, thelibincs = B.setup_staticlibs(env) thesyslibs = B.setup_syslibs(env) +if env['WITH_BF_PLAYER']: + print("Warning: Game player may not build on 2.5") + if 'blender' in B.targets or not env['WITH_BF_NOBLENDER']: #env.BlenderProg(B.root_build_dir, "blender", dobj , [], mainlist + thestatlibs + thesyslibs, [B.root_build_dir+'/lib'] + thelibincs, 'blender') env.BlenderProg(B.root_build_dir, "blender", dobj + mainlist, [], thestatlibs + thesyslibs, [B.root_build_dir+'/lib'] + thelibincs, 'blender') @@ -465,27 +468,17 @@ if env['OURPLATFORM']!='darwin': dotblenderinstall.append(env.Install(dir=td, source=srcfile)) if env['WITH_BF_PYTHON']: - #-- .blender/scripts - scriptpath='release/scripts' - for dp, dn, df in os.walk(scriptpath): - if 'CVS' in dn: - dn.remove('CVS') - if '.svn' in dn: - dn.remove('.svn') - dir=env['BF_INSTALLDIR']+'/.blender/scripts'+dp[len(scriptpath):] - source=[dp+os.sep+f for f in df] - scriptinstall.append(env.Install(dir=dir,source=source)) - - #-- .blender/ui - scriptpath='release/ui' - for dp, dn, df in os.walk(scriptpath): - if 'CVS' in dn: - dn.remove('CVS') - if '.svn' in dn: - dn.remove('.svn') - dir=env['BF_INSTALLDIR']+'/.blender/ui'+dp[len(scriptpath):] - source=[dp+os.sep+f for f in df] - scriptinstall.append(env.Install(dir=dir,source=source)) + #-- .blender/scripts, .blender/ui, .blender/io + scriptpaths=['release/scripts', 'release/ui', 'release/io'] + for scriptpath in scriptpaths: + for dp, dn, df in os.walk(scriptpath): + if 'CVS' in dn: + dn.remove('CVS') + if '.svn' in dn: + dn.remove('.svn') + dir=env['BF_INSTALLDIR']+'/.blender/'+os.path.basename(scriptpath)+dp[len(scriptpath):] + source=[dp+os.sep+f for f in df] + scriptinstall.append(env.Install(dir=dir,source=source)) #-- icons if env['OURPLATFORM']=='linux2': diff --git a/config/win32-vc-config.py b/config/win32-vc-config.py index 1fc1d219f57..04e87a23ed1 100644 --- a/config/win32-vc-config.py +++ b/config/win32-vc-config.py @@ -9,10 +9,10 @@ BF_FFMPEG_LIBPATH='${BF_FFMPEG}/lib' BF_FFMPEG_LIB = 'avformat-52.lib avcodec-52.lib avdevice-52.lib avutil-50.lib swscale-0.lib' BF_PYTHON = LIBDIR + '/python' -BF_PYTHON_VERSION = '2.5' +BF_PYTHON_VERSION = '2.6' BF_PYTHON_INC = '${BF_PYTHON}/include/python${BF_PYTHON_VERSION}' BF_PYTHON_BINARY = 'python' -BF_PYTHON_LIB = 'python25' +BF_PYTHON_LIB = 'python26' BF_PYTHON_LIBPATH = '${BF_PYTHON}/lib' WITH_BF_OPENAL = True diff --git a/projectfiles_vc9/blender/blender.sln b/projectfiles_vc9/blender/blender.sln index b782f9b8a86..6b58bcfc020 100644 --- a/projectfiles_vc9/blender/blender.sln +++ b/projectfiles_vc9/blender/blender.sln @@ -3,6 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 10.00 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "blender", "blender.vcproj", "{F78B7FC9-DE32-465E-9F26-BB0B6B7A2EAF}"
ProjectSection(ProjectDependencies) = postProject
{E5F2F004-C704-4DCC-A08F-6EB1E38EAB9F} = {E5F2F004-C704-4DCC-A08F-6EB1E38EAB9F}
+ {6E24BF09-9653-4166-A871-F65CC9E98A9B} = {6E24BF09-9653-4166-A871-F65CC9E98A9B}
{A90C4918-4B21-4277-93BD-AF65F30951D9} = {A90C4918-4B21-4277-93BD-AF65F30951D9}
{FB88301F-F725-401B-ACD7-D2ABBF333B71} = {FB88301F-F725-401B-ACD7-D2ABBF333B71}
{98330220-47A6-42E0-9DE4-AD0FF5D204D6} = {98330220-47A6-42E0-9DE4-AD0FF5D204D6}
@@ -11,6 +12,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "blender", "blender.vcproj", {9625642D-6F20-4FB6-A089-BE7441B223E3} = {9625642D-6F20-4FB6-A089-BE7441B223E3}
{D1A9312F-4557-4982-A0F4-4D08508235F4} = {D1A9312F-4557-4982-A0F4-4D08508235F4}
{884D8731-654C-4C7F-9A75-8F37A305BE1E} = {884D8731-654C-4C7F-9A75-8F37A305BE1E}
+ {E645CC32-4823-463E-82F0-46ADDE664018} = {E645CC32-4823-463E-82F0-46ADDE664018}
{7495FE37-933A-4AC1-BB2A-B3FDB4DE4284} = {7495FE37-933A-4AC1-BB2A-B3FDB4DE4284}
{FAF46346-65CC-4DB2-85C4-B99826F79D0C} = {FAF46346-65CC-4DB2-85C4-B99826F79D0C}
{51FB3D48-2467-4BFA-A321-D848252B437E} = {51FB3D48-2467-4BFA-A321-D848252B437E}
@@ -20,6 +22,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "blender", "blender.vcproj", {B093415D-C0F6-4E76-8F5A-6BC1917BCE9E} = {B093415D-C0F6-4E76-8F5A-6BC1917BCE9E}
{DB6BE55D-B6D9-494D-856A-8764FF7BA91D} = {DB6BE55D-B6D9-494D-856A-8764FF7BA91D}
{6461F05D-4698-47AB-A8E8-1CA2ACC9948B} = {6461F05D-4698-47AB-A8E8-1CA2ACC9948B}
+ {0A73055E-4DED-40CD-9F72-9093ED3EEC7E} = {0A73055E-4DED-40CD-9F72-9093ED3EEC7E}
{09222F5E-1625-4FF3-A89A-384D16875EE5} = {09222F5E-1625-4FF3-A89A-384D16875EE5}
{D696C86B-0B53-4471-A50D-5B983A6FA4AD} = {D696C86B-0B53-4471-A50D-5B983A6FA4AD}
{138DD16C-CC78-4F6C-A898-C8DA68D89067} = {138DD16C-CC78-4F6C-A898-C8DA68D89067}
@@ -27,10 +30,13 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "blender", "blender.vcproj", {106AE171-0083-41D6-A949-20DB0E8DC251} = {106AE171-0083-41D6-A949-20DB0E8DC251}
{670EC17A-0548-4BBF-A27B-636C7C188139} = {670EC17A-0548-4BBF-A27B-636C7C188139}
{4C3AB78A-52CA-4276-A041-39776E52D8C8} = {4C3AB78A-52CA-4276-A041-39776E52D8C8}
+ {6B801390-5F95-4F07-81A7-97FBA046AACC} = {6B801390-5F95-4F07-81A7-97FBA046AACC}
{CAE37E91-6570-43AC-A4B4-7A37A4B0FC94} = {CAE37E91-6570-43AC-A4B4-7A37A4B0FC94}
{76D90B92-ECC7-409C-9F98-A8814B90F3C0} = {76D90B92-ECC7-409C-9F98-A8814B90F3C0}
{9C71A793-C177-4CAB-8EC5-923D500B39F8} = {9C71A793-C177-4CAB-8EC5-923D500B39F8}
+ {F90BD995-FFA4-4B18-81E8-FA4322C939E8} = {F90BD995-FFA4-4B18-81E8-FA4322C939E8}
{BB6AA598-B336-4F8B-9DF9-8CAE7BE71C23} = {BB6AA598-B336-4F8B-9DF9-8CAE7BE71C23}
+ {8154A59A-CAED-403D-AB94-BC4E7C032666} = {8154A59A-CAED-403D-AB94-BC4E7C032666}
{3648FB9A-C36F-43AB-AED0-1F1361E67FC7} = {3648FB9A-C36F-43AB-AED0-1F1361E67FC7}
{542A9FA1-B7FF-441C-AE15-054DB31D3488} = {542A9FA1-B7FF-441C-AE15-054DB31D3488}
{E109F1A5-FDD3-4F56-A1C4-96867EEA4C5B} = {E109F1A5-FDD3-4F56-A1C4-96867EEA4C5B}
@@ -132,7 +138,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "blenderplayer", "..\gameeng {BAAE3F2B-BCF8-4E84-B8BA-CFB2D64945FE} = {BAAE3F2B-BCF8-4E84-B8BA-CFB2D64945FE}
{C66F722C-46BE-40C9-ABAE-2EAC7A697EB8} = {C66F722C-46BE-40C9-ABAE-2EAC7A697EB8}
{9625642D-6F20-4FB6-A089-BE7441B223E3} = {9625642D-6F20-4FB6-A089-BE7441B223E3}
+ {D1A9312F-4557-4982-A0F4-4D08508235F4} = {D1A9312F-4557-4982-A0F4-4D08508235F4}
{E645CC32-4823-463E-82F0-46ADDE664018} = {E645CC32-4823-463E-82F0-46ADDE664018}
+ {7495FE37-933A-4AC1-BB2A-B3FDB4DE4284} = {7495FE37-933A-4AC1-BB2A-B3FDB4DE4284}
{FAF46346-65CC-4DB2-85C4-B99826F79D0C} = {FAF46346-65CC-4DB2-85C4-B99826F79D0C}
{51FB3D48-2467-4BFA-A321-D848252B437E} = {51FB3D48-2467-4BFA-A321-D848252B437E}
{FFD3C64A-30E2-4BC7-BC8F-51818C320400} = {FFD3C64A-30E2-4BC7-BC8F-51818C320400}
@@ -153,6 +161,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "blenderplayer", "..\gameeng {9C71A793-C177-4CAB-8EC5-923D500B39F8} = {9C71A793-C177-4CAB-8EC5-923D500B39F8}
{F90BD995-FFA4-4B18-81E8-FA4322C939E8} = {F90BD995-FFA4-4B18-81E8-FA4322C939E8}
{BB6AA598-B336-4F8B-9DF9-8CAE7BE71C23} = {BB6AA598-B336-4F8B-9DF9-8CAE7BE71C23}
+ {8154A59A-CAED-403D-AB94-BC4E7C032666} = {8154A59A-CAED-403D-AB94-BC4E7C032666}
{3648FB9A-C36F-43AB-AED0-1F1361E67FC7} = {3648FB9A-C36F-43AB-AED0-1F1361E67FC7}
{542A9FA1-B7FF-441C-AE15-054DB31D3488} = {542A9FA1-B7FF-441C-AE15-054DB31D3488}
{D8ABD6A5-1B36-4D62-934E-B5C6801130B0} = {D8ABD6A5-1B36-4D62-934E-B5C6801130B0}
@@ -164,6 +173,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "blenderplayer", "..\gameeng {8B8D4FC3-3234-4E54-8376-5AB83D00D164} = {8B8D4FC3-3234-4E54-8376-5AB83D00D164}
{4B6AFCC5-968C-424A-8F20-76E41B3BEF74} = {4B6AFCC5-968C-424A-8F20-76E41B3BEF74}
{0112CAD5-3584-412A-A2E5-1315A00437B4} = {0112CAD5-3584-412A-A2E5-1315A00437B4}
+ {2AE0D2D9-6A7A-44DE-9EFF-99C9E3257B49} = {2AE0D2D9-6A7A-44DE-9EFF-99C9E3257B49}
{5A2EA6DC-1A53-4E87-9166-52870CE3B4EA} = {5A2EA6DC-1A53-4E87-9166-52870CE3B4EA}
{E86B7BDE-C33C-4E55-9433-E74C141D7538} = {E86B7BDE-C33C-4E55-9433-E74C141D7538}
{32CC75E2-EE85-45E6-8E3D-513F58464F43} = {32CC75E2-EE85-45E6-8E3D-513F58464F43}
@@ -579,7 +589,9 @@ Global {8154A59A-CAED-403D-AB94-BC4E7C032666}.3D Plugin Release|Win32.ActiveCfg = Blender Release|Win32
{8154A59A-CAED-403D-AB94-BC4E7C032666}.3D Plugin Release|Win32.Build.0 = Blender Release|Win32
{8154A59A-CAED-403D-AB94-BC4E7C032666}.Blender Debug|Win32.ActiveCfg = Blender Debug|Win32
+ {8154A59A-CAED-403D-AB94-BC4E7C032666}.Blender Debug|Win32.Build.0 = Blender Debug|Win32
{8154A59A-CAED-403D-AB94-BC4E7C032666}.Blender Release|Win32.ActiveCfg = Blender Release|Win32
+ {8154A59A-CAED-403D-AB94-BC4E7C032666}.Blender Release|Win32.Build.0 = Blender Release|Win32
{8154A59A-CAED-403D-AB94-BC4E7C032666}.BlenderPlayer Debug|Win32.ActiveCfg = Blender Debug|Win32
{8154A59A-CAED-403D-AB94-BC4E7C032666}.BlenderPlayer Release|Win32.ActiveCfg = Blender Release|Win32
{8154A59A-CAED-403D-AB94-BC4E7C032666}.Debug|Win32.ActiveCfg = Blender Debug|Win32
@@ -591,7 +603,9 @@ Global {F90BD995-FFA4-4B18-81E8-FA4322C939E8}.3D Plugin Release|Win32.ActiveCfg = 3D Plugin Release|Win32
{F90BD995-FFA4-4B18-81E8-FA4322C939E8}.3D Plugin Release|Win32.Build.0 = 3D Plugin Release|Win32
{F90BD995-FFA4-4B18-81E8-FA4322C939E8}.Blender Debug|Win32.ActiveCfg = Blender Debug|Win32
+ {F90BD995-FFA4-4B18-81E8-FA4322C939E8}.Blender Debug|Win32.Build.0 = Blender Debug|Win32
{F90BD995-FFA4-4B18-81E8-FA4322C939E8}.Blender Release|Win32.ActiveCfg = Blender Release|Win32
+ {F90BD995-FFA4-4B18-81E8-FA4322C939E8}.Blender Release|Win32.Build.0 = Blender Release|Win32
{F90BD995-FFA4-4B18-81E8-FA4322C939E8}.BlenderPlayer Debug|Win32.ActiveCfg = BlenderPlayer Debug|Win32
{F90BD995-FFA4-4B18-81E8-FA4322C939E8}.BlenderPlayer Debug|Win32.Build.0 = BlenderPlayer Debug|Win32
{F90BD995-FFA4-4B18-81E8-FA4322C939E8}.BlenderPlayer Release|Win32.ActiveCfg = BlenderPlayer Release|Win32
@@ -605,7 +619,9 @@ Global {E645CC32-4823-463E-82F0-46ADDE664018}.3D Plugin Release|Win32.ActiveCfg = 3D Plugin Release|Win32
{E645CC32-4823-463E-82F0-46ADDE664018}.3D Plugin Release|Win32.Build.0 = 3D Plugin Release|Win32
{E645CC32-4823-463E-82F0-46ADDE664018}.Blender Debug|Win32.ActiveCfg = Blender Debug|Win32
+ {E645CC32-4823-463E-82F0-46ADDE664018}.Blender Debug|Win32.Build.0 = Blender Debug|Win32
{E645CC32-4823-463E-82F0-46ADDE664018}.Blender Release|Win32.ActiveCfg = Blender Release|Win32
+ {E645CC32-4823-463E-82F0-46ADDE664018}.Blender Release|Win32.Build.0 = Blender Release|Win32
{E645CC32-4823-463E-82F0-46ADDE664018}.BlenderPlayer Debug|Win32.ActiveCfg = BlenderPlayer Debug|Win32
{E645CC32-4823-463E-82F0-46ADDE664018}.BlenderPlayer Debug|Win32.Build.0 = BlenderPlayer Debug|Win32
{E645CC32-4823-463E-82F0-46ADDE664018}.BlenderPlayer Release|Win32.ActiveCfg = BlenderPlayer Release|Win32
@@ -619,7 +635,9 @@ Global {6E24BF09-9653-4166-A871-F65CC9E98A9B}.3D Plugin Release|Win32.ActiveCfg = 3D Plugin Release|Win32
{6E24BF09-9653-4166-A871-F65CC9E98A9B}.3D Plugin Release|Win32.Build.0 = 3D Plugin Release|Win32
{6E24BF09-9653-4166-A871-F65CC9E98A9B}.Blender Debug|Win32.ActiveCfg = Blender Debug|Win32
+ {6E24BF09-9653-4166-A871-F65CC9E98A9B}.Blender Debug|Win32.Build.0 = Blender Debug|Win32
{6E24BF09-9653-4166-A871-F65CC9E98A9B}.Blender Release|Win32.ActiveCfg = Blender Release|Win32
+ {6E24BF09-9653-4166-A871-F65CC9E98A9B}.Blender Release|Win32.Build.0 = Blender Release|Win32
{6E24BF09-9653-4166-A871-F65CC9E98A9B}.BlenderPlayer Debug|Win32.ActiveCfg = BlenderPlayer Debug|Win32
{6E24BF09-9653-4166-A871-F65CC9E98A9B}.BlenderPlayer Debug|Win32.Build.0 = BlenderPlayer Debug|Win32
{6E24BF09-9653-4166-A871-F65CC9E98A9B}.BlenderPlayer Release|Win32.ActiveCfg = BlenderPlayer Release|Win32
@@ -633,7 +651,9 @@ Global {6B801390-5F95-4F07-81A7-97FBA046AACC}.3D Plugin Release|Win32.ActiveCfg = 3D Plugin Release|Win32
{6B801390-5F95-4F07-81A7-97FBA046AACC}.3D Plugin Release|Win32.Build.0 = 3D Plugin Release|Win32
{6B801390-5F95-4F07-81A7-97FBA046AACC}.Blender Debug|Win32.ActiveCfg = Blender Debug|Win32
+ {6B801390-5F95-4F07-81A7-97FBA046AACC}.Blender Debug|Win32.Build.0 = Blender Debug|Win32
{6B801390-5F95-4F07-81A7-97FBA046AACC}.Blender Release|Win32.ActiveCfg = Blender Release|Win32
+ {6B801390-5F95-4F07-81A7-97FBA046AACC}.Blender Release|Win32.Build.0 = Blender Release|Win32
{6B801390-5F95-4F07-81A7-97FBA046AACC}.BlenderPlayer Debug|Win32.ActiveCfg = BlenderPlayer Debug|Win32
{6B801390-5F95-4F07-81A7-97FBA046AACC}.BlenderPlayer Debug|Win32.Build.0 = BlenderPlayer Debug|Win32
{6B801390-5F95-4F07-81A7-97FBA046AACC}.BlenderPlayer Release|Win32.ActiveCfg = BlenderPlayer Release|Win32
@@ -647,7 +667,9 @@ Global {0A73055E-4DED-40CD-9F72-9093ED3EEC7E}.3D Plugin Release|Win32.ActiveCfg = 3D Plugin Release|Win32
{0A73055E-4DED-40CD-9F72-9093ED3EEC7E}.3D Plugin Release|Win32.Build.0 = 3D Plugin Release|Win32
{0A73055E-4DED-40CD-9F72-9093ED3EEC7E}.Blender Debug|Win32.ActiveCfg = Blender Debug|Win32
+ {0A73055E-4DED-40CD-9F72-9093ED3EEC7E}.Blender Debug|Win32.Build.0 = Blender Debug|Win32
{0A73055E-4DED-40CD-9F72-9093ED3EEC7E}.Blender Release|Win32.ActiveCfg = Blender Release|Win32
+ {0A73055E-4DED-40CD-9F72-9093ED3EEC7E}.Blender Release|Win32.Build.0 = Blender Release|Win32
{0A73055E-4DED-40CD-9F72-9093ED3EEC7E}.BlenderPlayer Debug|Win32.ActiveCfg = BlenderPlayer Debug|Win32
{0A73055E-4DED-40CD-9F72-9093ED3EEC7E}.BlenderPlayer Debug|Win32.Build.0 = BlenderPlayer Debug|Win32
{0A73055E-4DED-40CD-9F72-9093ED3EEC7E}.BlenderPlayer Release|Win32.ActiveCfg = BlenderPlayer Release|Win32
@@ -836,8 +858,8 @@ Global {E90C7BC2-CF30-4A60-A8F2-0050D592E358}.Blender Debug|Win32.Build.0 = Blender Debug|Win32
{E90C7BC2-CF30-4A60-A8F2-0050D592E358}.Blender Release|Win32.ActiveCfg = Blender Release|Win32
{E90C7BC2-CF30-4A60-A8F2-0050D592E358}.Blender Release|Win32.Build.0 = Blender Release|Win32
- {E90C7BC2-CF30-4A60-A8F2-0050D592E358}.BlenderPlayer Debug|Win32.ActiveCfg = Blender Debug|Win32
- {E90C7BC2-CF30-4A60-A8F2-0050D592E358}.BlenderPlayer Debug|Win32.Build.0 = Blender Debug|Win32
+ {E90C7BC2-CF30-4A60-A8F2-0050D592E358}.BlenderPlayer Debug|Win32.ActiveCfg = BlenderPlayer Debug|Win32
+ {E90C7BC2-CF30-4A60-A8F2-0050D592E358}.BlenderPlayer Debug|Win32.Build.0 = BlenderPlayer Debug|Win32
{E90C7BC2-CF30-4A60-A8F2-0050D592E358}.BlenderPlayer Release|Win32.ActiveCfg = BlenderPlayer Release|Win32
{E90C7BC2-CF30-4A60-A8F2-0050D592E358}.BlenderPlayer Release|Win32.Build.0 = BlenderPlayer Release|Win32
{E90C7BC2-CF30-4A60-A8F2-0050D592E358}.Debug|Win32.ActiveCfg = 3D Plugin Debug|Win32
@@ -1318,8 +1340,8 @@ Global {DFE7F3E3-E62A-4677-B666-DF0DDF70C359}.Blender Debug|Win32.Build.0 = Blender Debug|Win32
{DFE7F3E3-E62A-4677-B666-DF0DDF70C359}.Blender Release|Win32.ActiveCfg = Blender Release|Win32
{DFE7F3E3-E62A-4677-B666-DF0DDF70C359}.Blender Release|Win32.Build.0 = Blender Release|Win32
- {DFE7F3E3-E62A-4677-B666-DF0DDF70C359}.BlenderPlayer Debug|Win32.ActiveCfg = Blender Release|Win32
- {DFE7F3E3-E62A-4677-B666-DF0DDF70C359}.BlenderPlayer Debug|Win32.Build.0 = Blender Release|Win32
+ {DFE7F3E3-E62A-4677-B666-DF0DDF70C359}.BlenderPlayer Debug|Win32.ActiveCfg = Blender Debug|Win32
+ {DFE7F3E3-E62A-4677-B666-DF0DDF70C359}.BlenderPlayer Debug|Win32.Build.0 = Blender Debug|Win32
{DFE7F3E3-E62A-4677-B666-DF0DDF70C359}.BlenderPlayer Release|Win32.ActiveCfg = Blender Release|Win32
{DFE7F3E3-E62A-4677-B666-DF0DDF70C359}.BlenderPlayer Release|Win32.Build.0 = Blender Release|Win32
{DFE7F3E3-E62A-4677-B666-DF0DDF70C359}.Debug|Win32.ActiveCfg = Blender Debug|Win32
diff --git a/projectfiles_vc9/blender/editors/ED_editors.vcproj b/projectfiles_vc9/blender/editors/ED_editors.vcproj index 8fa89f2c4a5..aaec7a66a55 100644 --- a/projectfiles_vc9/blender/editors/ED_editors.vcproj +++ b/projectfiles_vc9/blender/editors/ED_editors.vcproj @@ -119,7 +119,7 @@ Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\..\lib\windows\QTDevWin\CIncludes;..\..\..\..\lib\windows\sdl\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\build\msvc_9\intern\bsp\include;..\..\..\..\build\msvc_9\intern\ghost\include;..\..\..\..\build\msvc_9\intern\elbeem\include;..\..\..\..\build\msvc_9\intern\opennl\include;..\..\..\..\build\msvc_9\intern\bmfont\include;..\..\..\..\build\msvc_9\intern\blenkey\include;..\..\..\..\build\msvc_9\intern\decimation\include;..\..\..\..\build\msvc_9\intern\memutil\include;..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\build\msvc_9\intern\soundsystem\include;..\..\..\source\blender;..\..\..\source\blender\img;..\..\..\source\blender\verify;..\..\..\source\blender\ftfont;..\..\..\source\blender\misc;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\python;..\..\..\source\blender\editors\include;..\..\..\source\blender\renderui;..\..\..\source\blender\blenloader;..\..\..\source\blender\quicktime;..\..\..\source\blender\blenkernel;..\..\..\source\blender\blenfont;..\..\..\source\blender\makesdna;..\..\..\source\blender\makesrna;..\..\..\source\blender\nodes;..\..\..\source\blender\windowmanager;..\..\..\source\blender\blenpluginapi;..\..\..\source\blender\renderconverter;..\..\..\source\blender\readstreamglue;..\..\..\source\blender\render\extern\include;..\..\..\source\blender\radiosity\extern\include;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\network;..\..\..\source\gameengine\soundsystem\snd_openal;..\..\..\..\build\msvc_9\extern\verse\include;..\..\..\..\lib\windows\pthreads\include;..\..\..\..\lib\windows\ffmpeg\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\source\blender\gpu"
- PreprocessorDefinitions="_DEBUG;WIN32;_LIB;_CONSOLE;GAMEBLENDER;WITH_QUICKTIME;INTERNATIONAL;WITH_BF_INTERNATIONAL;WITH_FREETYPE2;WITH_OPENEXR;WITH_DDS;WITH_BULLET = 1;WITH_FFMPEG"
+ PreprocessorDefinitions="_DEBUG;WIN32;_LIB;_CONSOLE;GAMEBLENDER=1;WITH_QUICKTIME;INTERNATIONAL;WITH_BF_INTERNATIONAL;WITH_FREETYPE2;WITH_OPENEXR;WITH_DDS;WITH_BULLET = 1;WITH_FFMPEG"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
DefaultCharIsUnsigned="true"
@@ -310,6 +310,10 @@ >
</File>
<File
+ RelativePath="..\..\..\source\blender\editors\include\UI_icons.h"
+ >
+ </File>
+ <File
RelativePath="..\..\..\source\blender\editors\include\UI_interface.h"
>
</File>
@@ -727,6 +731,10 @@ >
</File>
<File
+ RelativePath="..\..\..\source\blender\editors\space_buttons\buttons_ops.c"
+ >
+ </File>
+ <File
RelativePath="..\..\..\source\blender\editors\space_buttons\space_buttons.c"
>
</File>
@@ -875,15 +883,15 @@ >
</File>
<File
- RelativePath="..\..\..\source\blender\editors\space_sequencer\sequencer_draw.c"
+ RelativePath="..\..\..\source\blender\editors\space_sequencer\sequencer_buttons.c"
>
</File>
<File
- RelativePath="..\..\..\source\blender\editors\space_sequencer\sequencer_edit.c"
+ RelativePath="..\..\..\source\blender\editors\space_sequencer\sequencer_draw.c"
>
</File>
<File
- RelativePath="..\..\..\source\blender\editors\space_sequencer\sequencer_header.c"
+ RelativePath="..\..\..\source\blender\editors\space_sequencer\sequencer_edit.c"
>
</File>
<File
diff --git a/projectfiles_vc9/blender/makesrna/RNA_rna.vcproj b/projectfiles_vc9/blender/makesrna/RNA_rna.vcproj index 65aa5e6f3f4..d99d14c0979 100644 --- a/projectfiles_vc9/blender/makesrna/RNA_rna.vcproj +++ b/projectfiles_vc9/blender/makesrna/RNA_rna.vcproj @@ -43,7 +43,7 @@ <Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\source\blender\makesdna;..\..\..\source\blender\makesrna;..\..\..\source\blender\blenlib;..\..\..\source\blender\blenkernel;..\..\..\source\blender\windowmanager;..\..\..\source\blender\editors\include"
+ AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\source\blender\imbuf;..\..\..\source\blender\makesdna;..\..\..\source\blender\makesrna;..\..\..\source\blender\blenlib;..\..\..\source\blender\blenkernel;..\..\..\source\blender\windowmanager;..\..\..\source\blender\editors\include"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
diff --git a/projectfiles_vc9/blender/nodes/nodes.vcproj b/projectfiles_vc9/blender/nodes/nodes.vcproj index cbe1954c14e..b8b92ac072b 100644 --- a/projectfiles_vc9/blender/nodes/nodes.vcproj +++ b/projectfiles_vc9/blender/nodes/nodes.vcproj @@ -609,6 +609,10 @@ Name="TEX_nodes"
>
<File
+ RelativePath="..\..\..\source\blender\nodes\intern\TEX_nodes\TEX_at.c"
+ >
+ </File>
+ <File
RelativePath="..\..\..\source\blender\nodes\intern\TEX_nodes\TEX_bricks.c"
>
</File>
diff --git a/projectfiles_vc9/gameengine/blenderhook/KX_blenderhook.vcproj b/projectfiles_vc9/gameengine/blenderhook/KX_blenderhook.vcproj index 8e027fd1854..654cb567fda 100644 --- a/projectfiles_vc9/gameengine/blenderhook/KX_blenderhook.vcproj +++ b/projectfiles_vc9/gameengine/blenderhook/KX_blenderhook.vcproj @@ -43,7 +43,7 @@ <Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\intern\bmfont\include;..\..\..\..\build\msvc_9\intern\soundsystem\include;..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\build\msvc_9\extern\solid\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\blender;..\..\..\source\blender\misc;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\include;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenloader;..\..\..\source\blender\blenkernel;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\ketsji;..\..\..\source\gameengine\network;..\..\..\source\gameengine\rasterizer;..\..\..\source\gameengine\Converter;..\..\..\source\gameengine\gamelogic;..\..\..\source\gameengine\scenegraph;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\Physics\Sumo;..\..\..\source\gameengine\Physics\common;..\..\..\source\gameengine\network\loopbacknetwork;..\..\..\source\gameengine\rasterizer\ras_openglrasterizer;..\..\..\source\gameengine\Physics\Sumo\Fuzzics\include;..\..\..\source\blender\gpu"
+ AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\intern\bmfont\include;..\..\..\..\build\msvc_9\intern\soundsystem\include;..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\build\msvc_9\extern\solid\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\blender;..\..\..\source\blender\misc;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\include;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenloader;..\..\..\source\blender\blenkernel;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\ketsji;..\..\..\source\gameengine\network;..\..\..\source\gameengine\rasterizer;..\..\..\source\gameengine\Converter;..\..\..\source\gameengine\gamelogic;..\..\..\source\gameengine\scenegraph;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\Physics\Sumo;..\..\..\source\gameengine\Physics\common;..\..\..\source\gameengine\network\loopbacknetwork;..\..\..\source\gameengine\rasterizer\ras_openglrasterizer;..\..\..\source\gameengine\Physics\Sumo\Fuzzics\include;..\..\..\source\blender\gpu;..\..\..\source\blender\windowmanager;..\..\..\source\blender\blenfont"
PreprocessorDefinitions="WIN32;_LIB;_DEBUG;WITH_GLEXT;WITH_FFMPEG"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@@ -119,7 +119,7 @@ <Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\intern\bmfont\include;..\..\..\..\build\msvc_9\intern\soundsystem\include;..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\build\msvc_9\extern\solid\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\blender;..\..\..\source\blender\misc;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\include;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenloader;..\..\..\source\blender\blenkernel;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\ketsji;..\..\..\source\gameengine\network;..\..\..\source\gameengine\rasterizer;..\..\..\source\gameengine\Converter;..\..\..\source\gameengine\gamelogic;..\..\..\source\gameengine\scenegraph;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\Physics\Sumo;..\..\..\source\gameengine\Physics\common;..\..\..\source\gameengine\network\loopbacknetwork;..\..\..\source\gameengine\rasterizer\ras_openglrasterizer;..\..\..\source\gameengine\Physics\Sumo\Fuzzics\include;..\..\..\source\blender\gpu"
+ AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\intern\bmfont\include;..\..\..\..\build\msvc_9\intern\soundsystem\include;..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\build\msvc_9\extern\solid\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\blender;..\..\..\source\blender\misc;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\include;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenloader;..\..\..\source\blender\blenkernel;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\ketsji;..\..\..\source\gameengine\network;..\..\..\source\gameengine\rasterizer;..\..\..\source\gameengine\Converter;..\..\..\source\gameengine\gamelogic;..\..\..\source\gameengine\scenegraph;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\Physics\Sumo;..\..\..\source\gameengine\Physics\common;..\..\..\source\gameengine\network\loopbacknetwork;..\..\..\source\gameengine\rasterizer\ras_openglrasterizer;..\..\..\source\gameengine\Physics\Sumo\Fuzzics\include;..\..\..\source\blender\gpu;..\..\..\source\blender\windowmanager;..\..\..\source\blender\blenfont"
PreprocessorDefinitions="NDEBUG;WIN32;_LIB;USE_SUMO_SOLID;WITH_GLEXT;WITH_FFMPEG"
StringPooling="true"
BasicRuntimeChecks="0"
diff --git a/projectfiles_vc9/gameengine/converter/KX_converter.vcproj b/projectfiles_vc9/gameengine/converter/KX_converter.vcproj index a085a7eac2a..64f8b26c7f7 100644 --- a/projectfiles_vc9/gameengine/converter/KX_converter.vcproj +++ b/projectfiles_vc9/gameengine/converter/KX_converter.vcproj @@ -42,7 +42,7 @@ <Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\build\msvc_9\intern\soundsystem\include;..\..\..\..\build\msvc_9\extern\bullet\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\build\msvc_9\extern\solid\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\blender;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\include;..\..\..\source\blender\blenkernel;..\..\..\source\blender\makesdna;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\Ketsji;..\..\..\source\gameengine\physics;..\..\..\source\gameengine\rasterizer;..\..\..\source\gameengine\network;..\..\..\source\gameengine\gamelogic;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\physics\ode;..\..\..\source\gameengine\SceneGraph;..\..\..\source\gameengine\physics\sumo;..\..\..\source\gameengine\physics\BlOde;..\..\..\source\gameengine\physics\dummy;..\..\..\source\gameengine\BlenderRoutines;..\..\..\source\gameengine\ketsji\kxnetwork;..\..\..\source\gameengine\physics\common;..\..\..\source\gameengine\soundsystem\snd_openal;..\..\..\source\gameengine\rasterizer\ras_openglrasterizer;..\..\..\source\gameengine\physics\sumo\fuzzics\include;..\..\..\source\gameengine\soundsystem\snd_blenderwavecache;..\..\..\source\sumo\include;..\..\..\source\sumo\Fuzzics\include;..\..\..\source\gameengine\physics\bullet;..\..\..\source\blender\gpu"
+ AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\build\msvc_9\intern\soundsystem\include;..\..\..\..\build\msvc_9\extern\bullet\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\build\msvc_9\extern\solid\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\blender;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\include;..\..\..\source\blender\blenkernel;..\..\..\source\blender\makesdna;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\Ketsji;..\..\..\source\gameengine\physics;..\..\..\source\gameengine\rasterizer;..\..\..\source\gameengine\network;..\..\..\source\gameengine\gamelogic;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\physics\ode;..\..\..\source\gameengine\SceneGraph;..\..\..\source\gameengine\physics\sumo;..\..\..\source\gameengine\physics\BlOde;..\..\..\source\gameengine\physics\dummy;..\..\..\source\gameengine\BlenderRoutines;..\..\..\source\gameengine\ketsji\kxnetwork;..\..\..\source\gameengine\physics\common;..\..\..\source\gameengine\soundsystem\snd_openal;..\..\..\source\gameengine\rasterizer\ras_openglrasterizer;..\..\..\source\gameengine\physics\sumo\fuzzics\include;..\..\..\source\gameengine\soundsystem\snd_blenderwavecache;..\..\..\source\sumo\include;..\..\..\source\sumo\Fuzzics\include;..\..\..\source\gameengine\physics\bullet;..\..\..\source\blender\gpu;..\..\..\source\blender\windowmanager"
PreprocessorDefinitions="WIN32,_LIB,_DEBUG"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
@@ -117,7 +117,7 @@ <Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\build\msvc_9\intern\soundsystem\include;..\..\..\..\build\msvc_9\extern\bullet\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\build\msvc_9\extern\solid\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\blender;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\include;..\..\..\source\blender\blenkernel;..\..\..\source\blender\makesdna;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\Ketsji;..\..\..\source\gameengine\physics;..\..\..\source\gameengine\rasterizer;..\..\..\source\gameengine\network;..\..\..\source\gameengine\gamelogic;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\physics\ode;..\..\..\source\gameengine\SceneGraph;..\..\..\source\gameengine\physics\sumo;..\..\..\source\gameengine\physics\BlOde;..\..\..\source\gameengine\physics\dummy;..\..\..\source\gameengine\BlenderRoutines;..\..\..\source\gameengine\ketsji\kxnetwork;..\..\..\source\gameengine\physics\common;..\..\..\source\gameengine\soundsystem\snd_openal;..\..\..\source\gameengine\rasterizer\ras_openglrasterizer;..\..\..\source\gameengine\physics\sumo\fuzzics\include;..\..\..\source\gameengine\soundsystem\snd_blenderwavecache;..\..\..\source\sumo\include;..\..\..\source\sumo\Fuzzics\include;..\..\..\source\gameengine\physics\bullet;..\..\..\source\blender\gpu"
+ AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\build\msvc_9\intern\soundsystem\include;..\..\..\..\build\msvc_9\extern\bullet\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\build\msvc_9\extern\solid\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\blender;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\include;..\..\..\source\blender\blenkernel;..\..\..\source\blender\makesdna;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\Ketsji;..\..\..\source\gameengine\physics;..\..\..\source\gameengine\rasterizer;..\..\..\source\gameengine\network;..\..\..\source\gameengine\gamelogic;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\physics\ode;..\..\..\source\gameengine\SceneGraph;..\..\..\source\gameengine\physics\sumo;..\..\..\source\gameengine\physics\BlOde;..\..\..\source\gameengine\physics\dummy;..\..\..\source\gameengine\BlenderRoutines;..\..\..\source\gameengine\ketsji\kxnetwork;..\..\..\source\gameengine\physics\common;..\..\..\source\gameengine\soundsystem\snd_openal;..\..\..\source\gameengine\rasterizer\ras_openglrasterizer;..\..\..\source\gameengine\physics\sumo\fuzzics\include;..\..\..\source\gameengine\soundsystem\snd_blenderwavecache;..\..\..\source\sumo\include;..\..\..\source\sumo\Fuzzics\include;..\..\..\source\gameengine\physics\bullet;..\..\..\source\blender\gpu;..\..\..\source\blender\windowmanager"
PreprocessorDefinitions="NDEBUG,WIN32,_LIB,USE_SUMO_SOLID"
StringPooling="true"
RuntimeLibrary="0"
@@ -193,7 +193,7 @@ <Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\build\msvc_9\intern\soundsystem\include;..\..\..\..\build\msvc_9\extern\bullet\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\build\msvc_9\extern\solid\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\blender;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\include;..\..\..\source\blender\blenkernel;..\..\..\source\blender\makesdna;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\Ketsji;..\..\..\source\gameengine\physics;..\..\..\source\gameengine\rasterizer;..\..\..\source\gameengine\network;..\..\..\source\gameengine\gamelogic;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\physics\ode;..\..\..\source\gameengine\SceneGraph;..\..\..\source\gameengine\physics\sumo;..\..\..\source\gameengine\physics\BlOde;..\..\..\source\gameengine\physics\dummy;..\..\..\source\gameengine\BlenderRoutines;..\..\..\source\gameengine\ketsji\kxnetwork;..\..\..\source\gameengine\physics\common;..\..\..\source\gameengine\soundsystem\snd_openal;..\..\..\source\gameengine\rasterizer\ras_openglrasterizer;..\..\..\source\gameengine\physics\sumo\fuzzics\include;..\..\..\source\gameengine\soundsystem\snd_blenderwavecache;..\..\..\source\sumo\include;..\..\..\source\sumo\Fuzzics\include;..\..\..\source\gameengine\physics\bullet;..\..\..\source\blender\gpu"
+ AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\build\msvc_9\intern\soundsystem\include;..\..\..\..\build\msvc_9\extern\bullet\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\build\msvc_9\extern\solid\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\blender;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\include;..\..\..\source\blender\blenkernel;..\..\..\source\blender\makesdna;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\Ketsji;..\..\..\source\gameengine\physics;..\..\..\source\gameengine\rasterizer;..\..\..\source\gameengine\network;..\..\..\source\gameengine\gamelogic;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\physics\ode;..\..\..\source\gameengine\SceneGraph;..\..\..\source\gameengine\physics\sumo;..\..\..\source\gameengine\physics\BlOde;..\..\..\source\gameengine\physics\dummy;..\..\..\source\gameengine\BlenderRoutines;..\..\..\source\gameengine\ketsji\kxnetwork;..\..\..\source\gameengine\physics\common;..\..\..\source\gameengine\soundsystem\snd_openal;..\..\..\source\gameengine\rasterizer\ras_openglrasterizer;..\..\..\source\gameengine\physics\sumo\fuzzics\include;..\..\..\source\gameengine\soundsystem\snd_blenderwavecache;..\..\..\source\sumo\include;..\..\..\source\sumo\Fuzzics\include;..\..\..\source\gameengine\physics\bullet;..\..\..\source\blender\gpu;..\..\..\source\blender\windowmanager"
PreprocessorDefinitions="WIN32,_LIB,_DEBUG"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@@ -268,7 +268,7 @@ <Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\build\msvc_9\intern\soundsystem\include;..\..\..\..\build\msvc_9\extern\bullet\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\build\msvc_9\extern\solid\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\blender;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\include;..\..\..\source\blender\blenkernel;..\..\..\source\blender\makesdna;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\Ketsji;..\..\..\source\gameengine\physics;..\..\..\source\gameengine\rasterizer;..\..\..\source\gameengine\network;..\..\..\source\gameengine\gamelogic;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\physics\ode;..\..\..\source\gameengine\SceneGraph;..\..\..\source\gameengine\physics\sumo;..\..\..\source\gameengine\physics\BlOde;..\..\..\source\gameengine\physics\dummy;..\..\..\source\gameengine\BlenderRoutines;..\..\..\source\gameengine\ketsji\kxnetwork;..\..\..\source\gameengine\physics\common;..\..\..\source\gameengine\soundsystem\snd_openal;..\..\..\source\gameengine\rasterizer\ras_openglrasterizer;..\..\..\source\gameengine\physics\sumo\fuzzics\include;..\..\..\source\gameengine\soundsystem\snd_blenderwavecache;..\..\..\source\sumo\include;..\..\..\source\sumo\Fuzzics\include;..\..\..\source\gameengine\physics\bullet;..\..\..\source\blender\gpu"
+ AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\build\msvc_9\intern\soundsystem\include;..\..\..\..\build\msvc_9\extern\bullet\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\build\msvc_9\extern\solid\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\blender;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\include;..\..\..\source\blender\blenkernel;..\..\..\source\blender\makesdna;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\Ketsji;..\..\..\source\gameengine\physics;..\..\..\source\gameengine\rasterizer;..\..\..\source\gameengine\network;..\..\..\source\gameengine\gamelogic;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\physics\ode;..\..\..\source\gameengine\SceneGraph;..\..\..\source\gameengine\physics\sumo;..\..\..\source\gameengine\physics\BlOde;..\..\..\source\gameengine\physics\dummy;..\..\..\source\gameengine\BlenderRoutines;..\..\..\source\gameengine\ketsji\kxnetwork;..\..\..\source\gameengine\physics\common;..\..\..\source\gameengine\soundsystem\snd_openal;..\..\..\source\gameengine\rasterizer\ras_openglrasterizer;..\..\..\source\gameengine\physics\sumo\fuzzics\include;..\..\..\source\gameengine\soundsystem\snd_blenderwavecache;..\..\..\source\sumo\include;..\..\..\source\sumo\Fuzzics\include;..\..\..\source\gameengine\physics\bullet;..\..\..\source\blender\gpu;..\..\..\source\blender\windowmanager"
PreprocessorDefinitions="NDEBUG,WIN32,_LIB,USE_SUMO_SOLID"
StringPooling="true"
RuntimeLibrary="2"
@@ -344,7 +344,7 @@ <Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\build\msvc_9\intern\soundsystem\include;..\..\..\..\build\msvc_9\extern\bullet\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\build\msvc_9\extern\solid\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\blender;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\include;..\..\..\source\blender\blenkernel;..\..\..\source\blender\makesdna;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\Ketsji;..\..\..\source\gameengine\physics;..\..\..\source\gameengine\rasterizer;..\..\..\source\gameengine\network;..\..\..\source\gameengine\gamelogic;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\physics\ode;..\..\..\source\gameengine\SceneGraph;..\..\..\source\gameengine\physics\sumo;..\..\..\source\gameengine\physics\BlOde;..\..\..\source\gameengine\physics\dummy;..\..\..\source\gameengine\BlenderRoutines;..\..\..\source\gameengine\ketsji\kxnetwork;..\..\..\source\gameengine\physics\common;..\..\..\source\gameengine\soundsystem\snd_openal;..\..\..\source\gameengine\rasterizer\ras_openglrasterizer;..\..\..\source\gameengine\physics\sumo\fuzzics\include;..\..\..\source\gameengine\soundsystem\snd_blenderwavecache;..\..\..\source\sumo\include;..\..\..\source\sumo\Fuzzics\include;..\..\..\source\gameengine\physics\bullet;..\..\..\source\blender\gpu"
+ AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\build\msvc_9\intern\soundsystem\include;..\..\..\..\build\msvc_9\extern\bullet\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\build\msvc_9\extern\solid\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\blender;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\include;..\..\..\source\blender\blenkernel;..\..\..\source\blender\makesdna;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\Ketsji;..\..\..\source\gameengine\physics;..\..\..\source\gameengine\rasterizer;..\..\..\source\gameengine\network;..\..\..\source\gameengine\gamelogic;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\physics\ode;..\..\..\source\gameengine\SceneGraph;..\..\..\source\gameengine\physics\sumo;..\..\..\source\gameengine\physics\BlOde;..\..\..\source\gameengine\physics\dummy;..\..\..\source\gameengine\BlenderRoutines;..\..\..\source\gameengine\ketsji\kxnetwork;..\..\..\source\gameengine\physics\common;..\..\..\source\gameengine\soundsystem\snd_openal;..\..\..\source\gameengine\rasterizer\ras_openglrasterizer;..\..\..\source\gameengine\physics\sumo\fuzzics\include;..\..\..\source\gameengine\soundsystem\snd_blenderwavecache;..\..\..\source\sumo\include;..\..\..\source\sumo\Fuzzics\include;..\..\..\source\gameengine\physics\bullet;..\..\..\source\blender\gpu;..\..\..\source\blender\windowmanager"
PreprocessorDefinitions="WIN32,_LIB,_DEBUG"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@@ -419,7 +419,7 @@ <Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\build\msvc_9\intern\soundsystem\include;..\..\..\..\build\msvc_9\extern\bullet\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\build\msvc_9\extern\solid\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\blender;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\include;..\..\..\source\blender\blenkernel;..\..\..\source\blender\makesdna;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\Ketsji;..\..\..\source\gameengine\physics;..\..\..\source\gameengine\rasterizer;..\..\..\source\gameengine\network;..\..\..\source\gameengine\gamelogic;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\physics\ode;..\..\..\source\gameengine\SceneGraph;..\..\..\source\gameengine\physics\sumo;..\..\..\source\gameengine\physics\BlOde;..\..\..\source\gameengine\physics\dummy;..\..\..\source\gameengine\BlenderRoutines;..\..\..\source\gameengine\ketsji\kxnetwork;..\..\..\source\gameengine\physics\common;..\..\..\source\gameengine\soundsystem\snd_openal;..\..\..\source\gameengine\rasterizer\ras_openglrasterizer;..\..\..\source\gameengine\physics\sumo\fuzzics\include;..\..\..\source\gameengine\soundsystem\snd_blenderwavecache;..\..\..\source\sumo\include;..\..\..\source\sumo\Fuzzics\include;..\..\..\source\gameengine\physics\bullet;..\..\..\source\blender\gpu"
+ AdditionalIncludeDirectories="..\..\..\..\build\msvc_9\intern\moto\include;..\..\..\..\build\msvc_9\intern\string\include;..\..\..\..\build\msvc_9\intern\guardedalloc\include;..\..\..\..\build\msvc_9\intern\soundsystem\include;..\..\..\..\build\msvc_9\extern\bullet\include;..\..\..\..\build\msvc_9\extern\glew\include;..\..\..\..\build\msvc_9\extern\solid\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\blender;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\include;..\..\..\source\blender\blenkernel;..\..\..\source\blender\makesdna;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\Ketsji;..\..\..\source\gameengine\physics;..\..\..\source\gameengine\rasterizer;..\..\..\source\gameengine\network;..\..\..\source\gameengine\gamelogic;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\physics\ode;..\..\..\source\gameengine\SceneGraph;..\..\..\source\gameengine\physics\sumo;..\..\..\source\gameengine\physics\BlOde;..\..\..\source\gameengine\physics\dummy;..\..\..\source\gameengine\BlenderRoutines;..\..\..\source\gameengine\ketsji\kxnetwork;..\..\..\source\gameengine\physics\common;..\..\..\source\gameengine\soundsystem\snd_openal;..\..\..\source\gameengine\rasterizer\ras_openglrasterizer;..\..\..\source\gameengine\physics\sumo\fuzzics\include;..\..\..\source\gameengine\soundsystem\snd_blenderwavecache;..\..\..\source\sumo\include;..\..\..\source\sumo\Fuzzics\include;..\..\..\source\gameengine\physics\bullet;..\..\..\source\blender\gpu;..\..\..\source\blender\windowmanager"
PreprocessorDefinitions="NDEBUG,WIN32,_LIB,USE_SUMO_SOLID"
StringPooling="true"
RuntimeLibrary="0"
diff --git a/projectfiles_vc9/gameengine/gameplayer/ghost/GP_ghost.vcproj b/projectfiles_vc9/gameengine/gameplayer/ghost/GP_ghost.vcproj index 5cd8a9c469b..60703d2d59a 100644 --- a/projectfiles_vc9/gameengine/gameplayer/ghost/GP_ghost.vcproj +++ b/projectfiles_vc9/gameengine/gameplayer/ghost/GP_ghost.vcproj @@ -72,7 +72,7 @@ <Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386
"
- AdditionalDependencies="odelib.lib fmodvc.lib ws2_32.lib vfw32.lib odbc32.lib odbccp32.lib opengl32.lib glu32.lib openal_static.lib libjpeg.lib dxguid.lib libeay32.lib libpng.lib libz.lib qtmlClient.lib SDL.lib freetype2ST.lib python25_d.lib pthreadVSE2.lib pthreadVC2.lib Half_d.lib Iex_d.lib IlmImf_d.lib IlmThread_d.lib Imath_d.lib avcodec-52.lib avformat-52.lib avutil-50.lib swscale-0.lib avdevice-52.lib"
+ AdditionalDependencies="ws2_32.lib vfw32.lib odbc32.lib odbccp32.lib opengl32.lib glu32.lib openal_static.lib libjpeg.lib dxguid.lib libeay32.lib libpng.lib libz.lib qtmlClient.lib SDL.lib freetype2ST.lib python25_d.lib pthreadVSE2.lib pthreadVC2.lib Half_d.lib Iex_d.lib IlmImf_d.lib IlmThread_d.lib Imath_d.lib avcodec-52.lib avformat-52.lib avutil-50.lib swscale-0.lib avdevice-52.lib"
ShowProgress="0"
OutputFile="..\..\..\..\bin\debug\blenderplayer.exe"
LinkIncremental="2"
@@ -234,10 +234,6 @@ >
</File>
<File
- RelativePath="..\..\..\..\source\blender\blenkernel\bad_level_call_stubs\stubs.c"
- >
- </File>
- <File
RelativePath="..\..\..\..\source\icons\winplayer.rc"
>
<FileConfiguration
diff --git a/release/datafiles/blenderbuttons b/release/datafiles/blenderbuttons Binary files differindex 467e79f024a..963c76fcfa9 100644 --- a/release/datafiles/blenderbuttons +++ b/release/datafiles/blenderbuttons diff --git a/release/scripts/bpymodules/dxfLibrary.py b/release/scripts/bpymodules/dxfLibrary.py index 67528f778e0..ccd8ef9b625 100644 --- a/release/scripts/bpymodules/dxfLibrary.py +++ b/release/scripts/bpymodules/dxfLibrary.py @@ -1,6 +1,6 @@ #dxfLibrary.py : provides functions for generating DXF files # -------------------------------------------------------------------------- -__version__ = "v1.32 - 2009.06.06" +__version__ = "v1.33 - 2009.06.16" __author__ = "Stani Michiels(Stani), Remigiusz Fiedler(migius)" __license__ = "GPL" __url__ = "http://wiki.blender.org/index.php/Scripts/Manual/Export/autodesk_dxf" @@ -20,8 +20,14 @@ IDEAs: TODO: - add support for DXFr14 (needs extended file header) - add support for SPLINEs (possible first in DXFr14 version) +- add user preset for floating point precision (3-16?) History +v1.33 - 2009.06.16 by migius + - modif _point(): converts all coords to floats + - modif LineType class: implement elements + - added VPORT class, incl. defaults + - fix Insert class v1.32 - 2009.06.06 by migius - modif Style class: changed defaults to widthFactor=1.0, obliqueAngle=0.0 - modif Text class: alignment parameter reactivated @@ -88,7 +94,7 @@ _HEADER_POINTS=['insbase','extmin','extmax'] def _point(x,index=0): """Convert tuple to a dxf point""" #print 'deb: _point=', x #------------- - return '\n'.join([' %s\n%s'%((i+1)*10+index,x[i]) for i in range(len(x))]) + return '\n'.join([' %s\n%s'%((i+1)*10+index,float(x[i])) for i in range(len(x))]) def _points(plist): """Convert a list of tuples to dxf points""" @@ -137,8 +143,8 @@ class _Entity(_Call): if parent.layer!=None: result+=' 8\n%s\n'%parent.layer if parent.color!=None: result+=' 62\n%s\n'%parent.color if parent.lineType!=None: result+=' 6\n%s\n'%parent.lineType - #TODO: if parent.lineWeight!=None: result+='370\n%s\n'%parent.lineWeight - #TODO: if parent.visible!=None: result+='60\n%s\n'%parent.visible + # TODO: if parent.lineWeight!=None: result+='370\n%s\n'%parent.lineWeight + # TODO: if parent.visible!=None: result+='60\n%s\n'%parent.visible if parent.lineTypeScale!=None: result+=' 48\n%s\n'%parent.lineTypeScale if parent.elevation!=None: result+=' 38\n%s\n'%parent.elevation if parent.thickness!=None: result+=' 39\n%s\n'%parent.thickness @@ -287,7 +293,7 @@ class Insert(_Entity): self.rotation=rotation def __str__(self): - result=' 0\nINSERT\n 2\n%s\n%s\n%s\n'%\ + result=' 0\nINSERT\n 2\n%s\n%s%s\n'%\ (self.name,self._common(),_point(self.point)) if self.xscale!=None:result+=' 41\n%s\n'%self.xscale if self.yscale!=None:result+=' 42\n%s\n'%self.yscale @@ -383,7 +389,7 @@ class Point(_Entity): def __init__(self,points=None,**common): _Entity.__init__(self,**common) self.points=points - def __str__(self): #TODO: + def __str__(self): # TODO: return ' 0\nPOINT\n%s%s\n' %(self._common(), _points(self.points) ) @@ -515,7 +521,7 @@ class Block(_Collection): self.name=name self.flag=0 self.base=base - def __str__(self): #TODO: + def __str__(self): # TODO: e=''.join([str(x)for x in self.entities]) return ' 0\nBLOCK\n 8\n%s\n 2\n%s\n 70\n%s\n%s\n 3\n%s\n%s 0\nENDBLK\n'%\ (self.layer,self.name.upper(),self.flag,_point(self.base),self.name.upper(),e) @@ -535,15 +541,22 @@ class Layer(_Call): #----------------------------------------------- class LineType(_Call): """Custom linetype""" - def __init__(self,name='continuous',description='Solid line',elements=[],flag=64): - # TODO: Implement lineType elements + def __init__(self,name='CONTINUOUS',description='Solid line',elements=[0.0],flag=0): self.name=name self.description=description self.elements=copy.copy(elements) self.flag=flag def __str__(self): - return ' 0\nLTYPE\n 2\n%s\n 70\n%s\n 3\n%s\n 72\n65\n 73\n%s\n 40\n0.0\n'%\ - (self.name.upper(),self.flag,self.description,len(self.elements)) + result = ' 0\nLTYPE\n 2\n%s\n 70\n%s\n 3\n%s\n 72\n65\n'%\ + (self.name.upper(),self.flag,self.description) + if self.elements: + elements = ' 73\n%s\n' %(len(self.elements)-1) + elements += ' 40\n%s\n' %(self.elements[0]) + for e in self.elements[1:]: + elements += ' 49\n%s\n' %e + result += elements + return result + #----------------------------------------------- class Style(_Call): @@ -566,27 +579,137 @@ class Style(_Call): self.font.upper(),self.bigFont.upper()) #----------------------------------------------- +class VPort(_Call): + def __init__(self,name,flag=0, + leftBottom=(0.0,0.0), + rightTop=(1.0,1.0), + center=(0.5,0.5), + snap_base=(0.0,0.0), + snap_spacing=(0.1,0.1), + grid_spacing=(0.1,0.1), + direction=(0.0,0.0,1.0), + target=(0.0,0.0,0.0), + height=1.0, + ratio=1.0, + lens=50, + frontClipping=0, + backClipping=0, + snap_rotation=0, + twist=0, + mode=0, + circle_zoom=100, + fast_zoom=1, + ucsicon=1, + snap_on=0, + grid_on=0, + snap_style=0, + snap_isopair=0 + ): + self.name=name + self.flag=flag + self.leftBottom=leftBottom + self.rightTop=rightTop + self.center=center + self.snap_base=snap_base + self.snap_spacing=snap_spacing + self.grid_spacing=grid_spacing + self.direction=direction + self.target=target + self.height=float(height) + self.ratio=float(ratio) + self.lens=float(lens) + self.frontClipping=float(frontClipping) + self.backClipping=float(backClipping) + self.snap_rotation=float(snap_rotation) + self.twist=float(twist) + self.mode=mode + self.circle_zoom=circle_zoom + self.fast_zoom=fast_zoom + self.ucsicon=ucsicon + self.snap_on=snap_on + self.grid_on=grid_on + self.snap_style=snap_style + self.snap_isopair=snap_isopair + def __str__(self): + output = [' 0', 'VPORT', + ' 2', self.name, + ' 70', self.flag, + _point(self.leftBottom), + _point(self.rightTop,1), + _point(self.center,2), # View center point (in DCS) + _point(self.snap_base,3), + _point(self.snap_spacing,4), + _point(self.grid_spacing,5), + _point(self.direction,6), #view direction from target (in WCS) + _point(self.target,7), + ' 40', self.height, + ' 41', self.ratio, + ' 42', self.lens, + ' 43', self.frontClipping, + ' 44', self.backClipping, + ' 50', self.snap_rotation, + ' 51', self.twist, + ' 71', self.mode, + ' 72', self.circle_zoom, + ' 73', self.fast_zoom, + ' 74', self.ucsicon, + ' 75', self.snap_on, + ' 76', self.grid_on, + ' 77', self.snap_style, + ' 78', self.snap_isopair + ] + + output_str = '' + for s in output: + output_str += '%s\n' %s + return output_str + + + +#----------------------------------------------- class View(_Call): - def __init__(self,name,flag=0,width=1,height=1,center=(0.5,0.5), - direction=(0,0,1),target=(0,0,0),lens=50, - frontClipping=0,backClipping=0,twist=0,mode=0): + def __init__(self,name,flag=0, + width=1, + height=1, + center=(0.5,0.5), + direction=(0,0,1), + target=(0,0,0), + lens=50, + frontClipping=0, + backClipping=0, + twist=0,mode=0 + ): self.name=name self.flag=flag - self.width=width - self.height=height + self.width=float(width) + self.height=float(height) self.center=center self.direction=direction self.target=target - self.lens=lens - self.frontClipping=frontClipping - self.backClipping=backClipping - self.twist=twist + self.lens=float(lens) + self.frontClipping=float(frontClipping) + self.backClipping=float(backClipping) + self.twist=float(twist) self.mode=mode def __str__(self): - return ' 0\nVIEW\n 2\n%s\n 70\n%s\n 40\n%s\n%s\n 41\n%s\n%s\n%s\n 42\n%s\n 43\n%s\n 44\n%s\n 50\n%s\n 71\n%s\n'%\ - (self.name,self.flag,self.height,_point(self.center),self.width, - _point(self.direction,1),_point(self.target,2),self.lens, - self.frontClipping,self.backClipping,self.twist,self.mode) + output = [' 0', 'VIEW', + ' 2', self.name, + ' 70', self.flag, + ' 40', self.height, + _point(self.center), + ' 41', self.width, + _point(self.direction,1), + _point(self.target,2), + ' 42', self.lens, + ' 43', self.frontClipping, + ' 44', self.backClipping, + ' 50', self.twist, + ' 71', self.mode + ] + output_str = '' + for s in output: + output_str += '%s\n' %s + return output_str #----------------------------------------------- def ViewByWindow(name,leftBottom=(0,0),rightTop=(1,1),**options): @@ -601,7 +724,7 @@ class Drawing(_Collection): """Dxf drawing. Use append or any other list methods to add objects.""" def __init__(self,insbase=(0.0,0.0,0.0),extmin=(0.0,0.0,0.0),extmax=(0.0,0.0,0.0), layers=[Layer()],linetypes=[LineType()],styles=[Style()],blocks=[], - views=[],entities=None,fileName='test.dxf'): + views=[],vports=[],entities=None,fileName='test.dxf'): # TODO: replace list with None,arial if not entities: entities=[] @@ -613,6 +736,7 @@ class Drawing(_Collection): self.linetypes=copy.copy(linetypes) self.styles=copy.copy(styles) self.views=copy.copy(views) + self.vports=copy.copy(vports) self.blocks=copy.copy(blocks) self.fileName=fileName #private @@ -656,7 +780,8 @@ class Drawing(_Collection): header=[self.acadver]+[self._point(attr,getattr(self,attr))+'\n' for attr in _HEADER_POINTS] header=self._section('header',header) - tables=[self._table('ltype',[str(x) for x in self.linetypes]), + tables=[self._table('vport',[str(x) for x in self.vports]), + self._table('ltype',[str(x) for x in self.linetypes]), self._table('layer',[str(x) for x in self.layers]), self._table('style',[str(x) for x in self.styles]), self._table('view',[str(x) for x in self.views]), @@ -740,17 +865,16 @@ def test(): d.append(Line(points=[(0,0,0),(1,1,1)])) d.append(Mtext('Click on Ads\nmultiple lines with mtext',point=(1,1,1),color=5,rotation=90)) d.append(Text('Please donate!',point=(3,0,1))) - d.append(Rectangle(point=(2,2,2),width=4,height=3,color=6,solid=Solid(color=2))) + #d.append(Rectangle(point=(2,2,2),width=4,height=3,color=6,solid=Solid(color=2))) d.append(Solid(points=[(4,4,0),(5,4,0),(7,8,0),(9,9,0)],color=3)) - d.append(PolyLine(points=[(1,1,1),(2,1,1),(2,2,1),(1,2,1)],closed=1,color=1)) + #d.append(PolyLine(points=[(1,1,1),(2,1,1),(2,2,1),(1,2,1)],flag=1,color=1)) #d.saveas('c:\\test.dxf') d.saveas('test.dxf') - #----------------------------------------------------- if __name__=='__main__': if not copy: Draw.PupMenu('Error%t|This script requires a full python install') - else: main() + else: test()
\ No newline at end of file diff --git a/release/scripts/export_obj.py b/release/scripts/export_obj.py index 0edc70a874b..739b02bcbb3 100644 --- a/release/scripts/export_obj.py +++ b/release/scripts/export_obj.py @@ -181,12 +181,89 @@ def copy_images(dest_dir): copyCount+=1 print '\tCopied %d images' % copyCount + +def test_nurbs_compat(ob): + if ob.type != 'Curve': + return False + + for nu in ob.data: + if (not nu.knotsV) and nu.type != 1: # not a surface and not bezier + return True + + return False + +def write_nurb(file, ob, ob_mat): + tot_verts = 0 + cu = ob.data + + # use negative indices + Vector = Blender.Mathutils.Vector + for nu in cu: + + if nu.type==0: DEG_ORDER_U = 1 + else: DEG_ORDER_U = nu.orderU-1 # Tested to be correct + + if nu.type==1: + print "\tWarning, bezier curve:", ob.name, "only poly and nurbs curves supported" + continue + + if nu.knotsV: + print "\tWarning, surface:", ob.name, "only poly and nurbs curves supported" + continue + + if len(nu) <= DEG_ORDER_U: + print "\tWarning, orderU is lower then vert count, skipping:", ob.name + continue + + pt_num = 0 + do_closed = (nu.flagU & 1) + do_endpoints = (do_closed==0) and (nu.flagU & 2) + + for pt in nu: + pt = Vector(pt[0], pt[1], pt[2]) * ob_mat + file.write('v %.6f %.6f %.6f\n' % (pt[0], pt[1], pt[2])) + pt_num += 1 + tot_verts += pt_num + + file.write('g %s\n' % (fixName(ob.name))) # fixName(ob.getData(1)) could use the data name too + file.write('cstype bspline\n') # not ideal, hard coded + file.write('deg %d\n' % DEG_ORDER_U) # not used for curves but most files have it still + + curve_ls = [-(i+1) for i in xrange(pt_num)] + + # 'curv' keyword + if do_closed: + if DEG_ORDER_U == 1: + pt_num += 1 + curve_ls.append(-1) + else: + pt_num += DEG_ORDER_U + curve_ls = curve_ls + curve_ls[0:DEG_ORDER_U] + + file.write('curv 0.0 1.0 %s\n' % (' '.join( [str(i) for i in curve_ls] ))) # Blender has no U and V values for the curve + + # 'parm' keyword + tot_parm = (DEG_ORDER_U + 1) + pt_num + tot_parm_div = float(tot_parm-1) + parm_ls = [(i/tot_parm_div) for i in xrange(tot_parm)] + + if do_endpoints: # end points, force param + for i in xrange(DEG_ORDER_U+1): + parm_ls[i] = 0.0 + parm_ls[-(1+i)] = 1.0 + + file.write('parm u %s\n' % ' '.join( [str(i) for i in parm_ls] )) + + file.write('end\n') + + return tot_verts + def write(filename, objects,\ EXPORT_TRI=False, EXPORT_EDGES=False, EXPORT_NORMALS=False, EXPORT_NORMALS_HQ=False,\ EXPORT_UV=True, EXPORT_MTL=True, EXPORT_COPY_IMAGES=False,\ EXPORT_APPLY_MODIFIERS=True, EXPORT_ROTX90=True, EXPORT_BLEN_OBS=True,\ EXPORT_GROUP_BY_OB=False, EXPORT_GROUP_BY_MAT=False, EXPORT_KEEP_VERT_ORDER=False,\ -EXPORT_POLYGROUPS=False): +EXPORT_POLYGROUPS=False, EXPORT_CURVE_AS_NURBS=True): ''' Basic write function. The context and options must be alredy set This can be accessed externaly @@ -266,6 +343,17 @@ EXPORT_POLYGROUPS=False): # Get all meshes for ob_main in objects: for ob, ob_mat in BPyObject.getDerivedObjects(ob_main): + + # Nurbs curve support + if EXPORT_CURVE_AS_NURBS and test_nurbs_compat(ob): + if EXPORT_ROTX90: + ob_mat = ob_mat * mat_xrot90 + + totverts += write_nurb(file, ob, ob_mat) + + continue + # end nurbs + # Will work for non meshes now! :) # getMeshFromObject(ob, container_mesh=None, apply_modifiers=True, vgroups=True, scn=None) me= BPyMesh.getMeshFromObject(ob, containerMesh, EXPORT_APPLY_MODIFIERS, EXPORT_POLYGROUPS, scn) @@ -585,7 +673,7 @@ def write_ui(filename): EXPORT_MTL, EXPORT_SEL_ONLY, EXPORT_ALL_SCENES,\ EXPORT_ANIMATION, EXPORT_COPY_IMAGES, EXPORT_BLEN_OBS,\ EXPORT_GROUP_BY_OB, EXPORT_GROUP_BY_MAT, EXPORT_KEEP_VERT_ORDER,\ - EXPORT_POLYGROUPS + EXPORT_POLYGROUPS, EXPORT_CURVE_AS_NURBS EXPORT_APPLY_MODIFIERS = Draw.Create(0) EXPORT_ROTX90 = Draw.Create(1) @@ -604,6 +692,7 @@ def write_ui(filename): EXPORT_GROUP_BY_MAT = Draw.Create(0) EXPORT_KEEP_VERT_ORDER = Draw.Create(1) EXPORT_POLYGROUPS = Draw.Create(0) + EXPORT_CURVE_AS_NURBS = Draw.Create(1) # Old UI @@ -693,7 +782,7 @@ def write_ui(filename): EXPORT_MTL, EXPORT_SEL_ONLY, EXPORT_ALL_SCENES,\ EXPORT_ANIMATION, EXPORT_COPY_IMAGES, EXPORT_BLEN_OBS,\ EXPORT_GROUP_BY_OB, EXPORT_GROUP_BY_MAT, EXPORT_KEEP_VERT_ORDER,\ - EXPORT_POLYGROUPS + EXPORT_POLYGROUPS, EXPORT_CURVE_AS_NURBS Draw.Label('Context...', ui_x+9, ui_y+239, 220, 20) Draw.BeginAlign() @@ -726,6 +815,8 @@ def write_ui(filename): Draw.EndAlign() EXPORT_POLYGROUPS = Draw.Toggle('Polygroups', EVENT_REDRAW, ui_x+9, ui_y+95, 120, 20, EXPORT_POLYGROUPS.val, 'Export vertex groups as OBJ groups (one group per face approximation).') + EXPORT_CURVE_AS_NURBS = Draw.Toggle('Nurbs', EVENT_NONE, ui_x+139, ui_y+95, 100, 20, EXPORT_CURVE_AS_NURBS.val, 'Export 3D nurbs curves and polylines as OBJ curves, (bezier not supported).') + Draw.Label('Blender Objects as OBJ:', ui_x+9, ui_y+59, 220, 20) Draw.BeginAlign() @@ -779,6 +870,7 @@ def write_ui(filename): EXPORT_GROUP_BY_MAT = EXPORT_GROUP_BY_MAT.val EXPORT_KEEP_VERT_ORDER = EXPORT_KEEP_VERT_ORDER.val EXPORT_POLYGROUPS = EXPORT_POLYGROUPS.val + EXPORT_CURVE_AS_NURBS = EXPORT_CURVE_AS_NURBS.val base_name, ext = splitExt(filename) @@ -828,7 +920,7 @@ def write_ui(filename): EXPORT_COPY_IMAGES, EXPORT_APPLY_MODIFIERS,\ EXPORT_ROTX90, EXPORT_BLEN_OBS,\ EXPORT_GROUP_BY_OB, EXPORT_GROUP_BY_MAT, EXPORT_KEEP_VERT_ORDER,\ - EXPORT_POLYGROUPS) + EXPORT_POLYGROUPS, EXPORT_CURVE_AS_NURBS) Blender.Set('curframe', orig_frame) diff --git a/release/scripts/flt_properties.py b/release/scripts/flt_properties.py index 4c841e9c0c0..b9d93b5f52d 100644 --- a/release/scripts/flt_properties.py +++ b/release/scripts/flt_properties.py @@ -1,4 +1,3 @@ -#!BPY # flt_properties.py. For setting default OpenFLight ID property types # Copyright (C) 2007 Blender Foundation # diff --git a/release/scripts/import_obj.py b/release/scripts/import_obj.py index 31501173fda..d88f06a2a47 100644 --- a/release/scripts/import_obj.py +++ b/release/scripts/import_obj.py @@ -2,7 +2,7 @@ """ Name: 'Wavefront (.obj)...' -Blender: 248 +Blender: 249 Group: 'Import' Tooltip: 'Load a Wavefront OBJ File, Shift: batch import all dir.' """ @@ -40,7 +40,7 @@ Note, This loads mesh objects and materials only, nurbs and curves are not suppo # ***** END GPL LICENCE BLOCK ***** # -------------------------------------------------------------------------- -from Blender import * +from Blender import Mesh, Draw, Window, Texture, Material, sys import bpy import BPyMesh import BPyImage @@ -166,12 +166,13 @@ def create_materials(filepath, material_libs, unique_materials, unique_material_ del temp_mtl #Create new materials - for name in unique_materials.iterkeys(): - unique_materials[name]= bpy.data.materials.new(name) - - unique_material_images[name]= None, False # assign None to all material images to start with, add to later. + for name in unique_materials: # .keys() + if name != None: + unique_materials[name]= bpy.data.materials.new(name) + unique_material_images[name]= None, False # assign None to all material images to start with, add to later. unique_materials[None]= None + unique_material_images[None]= None, False for libname in material_libs: mtlpath= DIR + libname @@ -536,6 +537,98 @@ def create_mesh(scn, new_objects, has_ngons, CREATE_FGONS, CREATE_EDGES, verts_l me.addVertGroup(group_name) me.assignVertsToGroup(group_name, group_indicies,1.00, Mesh.AssignModes.REPLACE) + +def create_nurbs(scn, context_nurbs, vert_loc, new_objects): + ''' + Add nurbs object to blender, only support one type at the moment + ''' + deg = context_nurbs.get('deg', (3,)) + curv_range = context_nurbs.get('curv_range', None) + curv_idx = context_nurbs.get('curv_idx', []) + parm_u = context_nurbs.get('parm_u', []) + parm_v = context_nurbs.get('parm_v', []) + name = context_nurbs.get('name', 'ObjNurb') + cstype = context_nurbs.get('cstype', None) + + if cstype == None: + print '\tWarning, cstype not found' + return + if cstype != 'bspline': + print '\tWarning, cstype is not supported (only bspline)' + return + if not curv_idx: + print '\tWarning, curv argument empty or not set' + return + if len(deg) > 1 or parm_v: + print '\tWarning, surfaces not supported' + return + + cu = bpy.data.curves.new(name, 'Curve') + cu.flag |= 1 # 3D curve + + nu = None + for pt in curv_idx: + + pt = vert_loc[pt] + pt = (pt[0], pt[1], pt[2], 1.0) + + if nu == None: + nu = cu.appendNurb(pt) + else: + nu.append(pt) + + nu.orderU = deg[0]+1 + + # get for endpoint flag from the weighting + if curv_range and len(parm_u) > deg[0]+1: + do_endpoints = True + for i in xrange(deg[0]+1): + + if abs(parm_u[i]-curv_range[0]) > 0.0001: + do_endpoints = False + break + + if abs(parm_u[-(i+1)]-curv_range[1]) > 0.0001: + do_endpoints = False + break + + else: + do_endpoints = False + + if do_endpoints: + nu.flagU |= 2 + + + # close + ''' + do_closed = False + if len(parm_u) > deg[0]+1: + for i in xrange(deg[0]+1): + #print curv_idx[i], curv_idx[-(i+1)] + + if curv_idx[i]==curv_idx[-(i+1)]: + do_closed = True + break + + if do_closed: + nu.flagU |= 1 + ''' + + ob = scn.objects.new(cu) + new_objects.append(ob) + + +def strip_slash(line_split): + if line_split[-1][-1]== '\\': + if len(line_split[-1])==1: + line_split.pop() # remove the \ item + else: + line_split[-1]= line_split[-1][:-1] # remove the \ from the end last number + return True + return False + + + def get_float_func(filepath): ''' find the float function for this obj file @@ -561,6 +654,7 @@ def load_obj(filepath, SPLIT_OBJECTS= True, SPLIT_GROUPS= True, SPLIT_MATERIALS= True, + ROTATE_X90= True, IMAGE_SEARCH=True, POLYGROUPS=False): ''' @@ -590,6 +684,11 @@ def load_obj(filepath, context_smooth_group= None context_object= None context_vgroup = None + + # Nurbs + context_nurbs = {} + nurbs = [] + context_parm = '' # used by nurbs too but could be used elsewhere has_ngons= False # has_smoothgroups= False - is explicit with len(unique_smooth_groups) being > 0 @@ -604,7 +703,7 @@ def load_obj(filepath, # it means they are multiline- # since we use xreadline we cant skip to the next line # so we need to know weather - multi_line_face= False + context_multi_line= '' print '\tparsing obj file "%s"...' % filepath, time_sub= sys.time() @@ -627,12 +726,11 @@ def load_obj(filepath, # Handel faces lines (as faces) and the second+ lines of fa multiline face here # use 'f' not 'f ' because some objs (very rare have 'fo ' for faces) - elif line.startswith('f') or (line.startswith('l ') and CREATE_EDGES) or multi_line_face: + elif line.startswith('f') or context_multi_line == 'f': - if multi_line_face: + if context_multi_line: # use face_vert_loc_indicies and face_vert_tex_indicies previously defined and used the obj_face line_split= line.split() - multi_line_face= False else: line_split= line[2:].split() @@ -648,14 +746,10 @@ def load_obj(filepath, context_object\ )) - if line_split[-1][-1]== '\\': - multi_line_face= True - if len(line_split[-1])==1: - line_split.pop() # remove the \ item - else: - line_split[-1]= line_split[-1][:-1] # remove the \ from the end last number - - isline= line.startswith('l') + if strip_slash(line_split): + context_multi_line = 'f' + else: + context_multi_line = '' for v in line_split: obj_vert= v.split('/') @@ -672,24 +766,60 @@ def load_obj(filepath, face_vert_loc_indicies.append(vert_loc_index) - if not isline: - if len(obj_vert)>1 and obj_vert[1]: - # formatting for faces with normals and textures us - # loc_index/tex_index/nor_index - - vert_tex_index= int(obj_vert[1])-1 - # Make relative negative vert indicies absolute - if vert_tex_index < 0: - vert_tex_index= len(verts_tex) + vert_tex_index + 1 - - face_vert_tex_indicies.append(vert_tex_index) - else: - # dummy - face_vert_tex_indicies.append(0) + if len(obj_vert)>1 and obj_vert[1]: + # formatting for faces with normals and textures us + # loc_index/tex_index/nor_index + + vert_tex_index= int(obj_vert[1])-1 + # Make relative negative vert indicies absolute + if vert_tex_index < 0: + vert_tex_index= len(verts_tex) + vert_tex_index + 1 + + face_vert_tex_indicies.append(vert_tex_index) + else: + # dummy + face_vert_tex_indicies.append(0) if len(face_vert_loc_indicies) > 4: has_ngons= True + + elif CREATE_EDGES and (line.startswith('l ') or context_multi_line == 'l'): + # very similar to the face load function above with some parts removed + if context_multi_line: + # use face_vert_loc_indicies and face_vert_tex_indicies previously defined and used the obj_face + line_split= line.split() + + else: + line_split= line[2:].split() + face_vert_loc_indicies= [] + face_vert_tex_indicies= [] + + # Instance a face + faces.append((\ + face_vert_loc_indicies,\ + face_vert_tex_indicies,\ + context_material,\ + context_smooth_group,\ + context_object\ + )) + + if strip_slash(line_split): + context_multi_line = 'l' + else: + context_multi_line = '' + + isline= line.startswith('l') + + for v in line_split: + vert_loc_index= int(v)-1 + + # Make relative negative vert indicies absolute + if vert_loc_index < 0: + vert_loc_index= len(verts_loc) + vert_loc_index + 1 + + face_vert_loc_indicies.append(vert_loc_index) + elif line.startswith('s'): if CREATE_SMOOTH_GROUPS: context_smooth_group= line_value(line.split()) @@ -720,6 +850,63 @@ def load_obj(filepath, unique_materials[context_material]= None elif line.startswith('mtllib'): # usemap or usemat material_libs.extend( line.split()[1:] ) # can have multiple mtllib filenames per line + + + # Nurbs support + elif line.startswith('cstype '): + context_nurbs['cstype']= line_value(line.split()) # 'rat bspline' / 'bspline' + elif line.startswith('curv ') or context_multi_line == 'curv': + line_split= line.split() + + curv_idx = context_nurbs['curv_idx'] = context_nurbs.get('curv_idx', []) # incase were multiline + + if not context_multi_line: + context_nurbs['curv_range'] = float_func(line_split[1]), float_func(line_split[2]) + line_split[0:3] = [] # remove first 3 items + + if strip_slash(line_split): + context_multi_line = 'curv' + else: + context_multi_line = '' + + + for i in line_split: + vert_loc_index = int(i)-1 + + if vert_loc_index < 0: + vert_loc_index= len(verts_loc) + vert_loc_index + 1 + + curv_idx.append(vert_loc_index) + + elif line.startswith('parm') or context_multi_line == 'parm': + line_split= line.split() + + if context_multi_line: + context_multi_line = '' + else: + context_parm = line_split[1] + line_split[0:2] = [] # remove first 2 + + if strip_slash(line_split): + context_multi_line = 'parm' + else: + context_multi_line = '' + + if context_parm.lower() == 'u': + context_nurbs.setdefault('parm_u', []).extend( [float_func(f) for f in line_split] ) + elif context_parm.lower() == 'v': # surfaces not suported yet + context_nurbs.setdefault('parm_v', []).extend( [float_func(f) for f in line_split] ) + # else: # may want to support other parm's ? + + elif line.startswith('deg '): + context_nurbs['deg']= [int(i) for i in line.split()[1:]] + elif line.startswith('end'): + # Add the nurbs curve + if context_object: + context_nurbs['name'] = context_object + nurbs.append(context_nurbs) + context_nurbs = {} + context_parm = '' ''' # How to use usemap? depricated? elif line.startswith('usema'): # usemap or usemat @@ -739,6 +926,8 @@ def load_obj(filepath, print '%.4f sec' % (time_new-time_sub) time_sub= time_new + if not ROTATE_X90: + verts_loc[:] = [(v[0], v[2], -v[1]) for v in verts_loc] # deselect all scn = bpy.data.scenes.active @@ -754,6 +943,11 @@ def load_obj(filepath, # Create meshes from the data, warning 'vertex_groups' wont support splitting create_mesh(scn, new_objects, has_ngons, CREATE_FGONS, CREATE_EDGES, verts_loc_split, verts_tex, faces_split, unique_materials_split, unique_material_images, unique_smooth_groups, vertex_groups, dataname) + # nurbs support + for context_nurbs in nurbs: + create_nurbs(scn, context_nurbs, verts_loc, new_objects) + + axis_min= [ 1000000000]*3 axis_max= [-1000000000]*3 @@ -775,6 +969,11 @@ def load_obj(filepath, for ob in new_objects: ob.setSize(scale, scale, scale) + # Better rotate the vert locations + #if not ROTATE_X90: + # for ob in new_objects: + # ob.RotX = -1.570796326794896558 + time_new= sys.time() print '%.4f sec' % (time_new-time_sub) @@ -788,7 +987,7 @@ def load_obj_ui(filepath, BATCH_LOAD= False): if BPyMessages.Error_NoFile(filepath): return - global CREATE_SMOOTH_GROUPS, CREATE_FGONS, CREATE_EDGES, SPLIT_OBJECTS, SPLIT_GROUPS, SPLIT_MATERIALS, CLAMP_SIZE, IMAGE_SEARCH, POLYGROUPS, KEEP_VERT_ORDER + global CREATE_SMOOTH_GROUPS, CREATE_FGONS, CREATE_EDGES, SPLIT_OBJECTS, SPLIT_GROUPS, SPLIT_MATERIALS, CLAMP_SIZE, IMAGE_SEARCH, POLYGROUPS, KEEP_VERT_ORDER, ROTATE_X90 CREATE_SMOOTH_GROUPS= Draw.Create(0) CREATE_FGONS= Draw.Create(1) @@ -800,6 +999,7 @@ def load_obj_ui(filepath, BATCH_LOAD= False): IMAGE_SEARCH= Draw.Create(1) POLYGROUPS= Draw.Create(0) KEEP_VERT_ORDER= Draw.Create(1) + ROTATE_X90= Draw.Create(1) # Get USER Options @@ -886,7 +1086,7 @@ def load_obj_ui(filepath, BATCH_LOAD= False): ui_x -= 165 ui_y -= 90 - global CREATE_SMOOTH_GROUPS, CREATE_FGONS, CREATE_EDGES, SPLIT_OBJECTS, SPLIT_GROUPS, SPLIT_MATERIALS, CLAMP_SIZE, IMAGE_SEARCH, POLYGROUPS, KEEP_VERT_ORDER + global CREATE_SMOOTH_GROUPS, CREATE_FGONS, CREATE_EDGES, SPLIT_OBJECTS, SPLIT_GROUPS, SPLIT_MATERIALS, CLAMP_SIZE, IMAGE_SEARCH, POLYGROUPS, KEEP_VERT_ORDER, ROTATE_X90 Draw.Label('Import...', ui_x+9, ui_y+159, 220, 21) Draw.BeginAlign() @@ -897,13 +1097,15 @@ def load_obj_ui(filepath, BATCH_LOAD= False): Draw.Label('Separate objects by OBJ...', ui_x+9, ui_y+110, 220, 20) Draw.BeginAlign() - SPLIT_OBJECTS = Draw.Toggle('Object', EVENT_REDRAW, ui_x+9, ui_y+89, 70, 21, SPLIT_OBJECTS.val, 'Import OBJ Objects into Blender Objects', do_split) - SPLIT_GROUPS = Draw.Toggle('Group', EVENT_REDRAW, ui_x+79, ui_y+89, 70, 21, SPLIT_GROUPS.val, 'Import OBJ Groups into Blender Objects', do_split) - SPLIT_MATERIALS = Draw.Toggle('Material', EVENT_REDRAW, ui_x+149, ui_y+89, 70, 21, SPLIT_MATERIALS.val, 'Import each material into a seperate mesh (Avoids > 16 per mesh error)', do_split) + SPLIT_OBJECTS = Draw.Toggle('Object', EVENT_REDRAW, ui_x+9, ui_y+89, 55, 21, SPLIT_OBJECTS.val, 'Import OBJ Objects into Blender Objects', do_split) + SPLIT_GROUPS = Draw.Toggle('Group', EVENT_REDRAW, ui_x+64, ui_y+89, 55, 21, SPLIT_GROUPS.val, 'Import OBJ Groups into Blender Objects', do_split) + SPLIT_MATERIALS = Draw.Toggle('Material', EVENT_REDRAW, ui_x+119, ui_y+89, 60, 21, SPLIT_MATERIALS.val, 'Import each material into a seperate mesh (Avoids > 16 per mesh error)', do_split) Draw.EndAlign() # Only used for user feedback - KEEP_VERT_ORDER = Draw.Toggle('Keep Vert Order', EVENT_REDRAW, ui_x+229, ui_y+89, 110, 21, KEEP_VERT_ORDER.val, 'Keep vert and face order, disables split options, enable for morph targets', do_vertorder) + KEEP_VERT_ORDER = Draw.Toggle('Keep Vert Order', EVENT_REDRAW, ui_x+184, ui_y+89, 113, 21, KEEP_VERT_ORDER.val, 'Keep vert and face order, disables split options, enable for morph targets', do_vertorder) + + ROTATE_X90 = Draw.Toggle('-X90', EVENT_REDRAW, ui_x+302, ui_y+89, 38, 21, ROTATE_X90.val, 'Rotate X 90.') Draw.Label('Options...', ui_x+9, ui_y+60, 211, 20) CLAMP_SIZE = Draw.Number('Clamp Scale: ', EVENT_NONE, ui_x+9, ui_y+39, 130, 21, CLAMP_SIZE.val, 0.0, 1000.0, 'Clamp the size to this maximum (Zero to Disable)') @@ -958,6 +1160,7 @@ def load_obj_ui(filepath, BATCH_LOAD= False): SPLIT_OBJECTS.val,\ SPLIT_GROUPS.val,\ SPLIT_MATERIALS.val,\ + ROTATE_X90.val,\ IMAGE_SEARCH.val,\ POLYGROUPS.val ) @@ -971,6 +1174,7 @@ def load_obj_ui(filepath, BATCH_LOAD= False): SPLIT_OBJECTS.val,\ SPLIT_GROUPS.val,\ SPLIT_MATERIALS.val,\ + ROTATE_X90.val,\ IMAGE_SEARCH.val,\ POLYGROUPS.val ) @@ -989,34 +1193,28 @@ if __name__=='__main__' and not DEBUG: else: Window.FileSelector(load_obj_ui, 'Import a Wavefront OBJ', '*.obj') - + # For testing compatibility ''' -# For testing compatibility else: # DEBUG ONLY TIME= sys.time() + DIR = '/fe/obj' import os print 'Searching for files' - os.system('find /fe/obj -iname "*.obj" > /tmp/temp3ds_list') - - print '...Done' - file= open('/tmp/temp3ds_list', 'rU') - lines= file.readlines() - file.close() - - def between(v,a,b): - if v <= max(a,b) and v >= min(a,b): - return True - return False - - for i, _obj in enumerate(lines): - if between(i, 0,20): - _obj= _obj[:-1] - print 'Importing', _obj, '\nNUMBER', i, 'of', len(lines) - _obj_file= _obj.split('/')[-1].split('\\')[-1] - newScn= bpy.data.scenes.new(_obj_file) + def fileList(path): + for dirpath, dirnames, filenames in os.walk(path): + for filename in filenames: + yield os.path.join(dirpath, filename) + + files = [f for f in fileList(DIR) if f.lower().endswith('.obj')] + files.sort() + + for i, obj_file in enumerate(files): + if 0 < i < 20: + print 'Importing', obj_file, '\nNUMBER', i, 'of', len(files) + newScn= bpy.data.scenes.new(os.path.basename(obj_file)) newScn.makeCurrent() - load_obj(_obj, False) + load_obj(obj_file, False, IMAGE_SEARCH=0) print 'TOTAL TIME: %.6f' % (sys.time() - TIME) ''' diff --git a/release/ui/buttons_data_armature.py b/release/ui/buttons_data_armature.py index fd317baf861..c536f6bb87d 100644 --- a/release/ui/buttons_data_armature.py +++ b/release/ui/buttons_data_armature.py @@ -12,12 +12,16 @@ class DataButtonsPanel(bpy.types.Panel): class DATA_PT_skeleton(DataButtonsPanel): __idname__ = "DATA_PT_skeleton" __label__ = "Skeleton" + + def poll(self, context): + return ((context.object and context.object.type == 'ARMATURE') or context.armature) def draw(self, context): + layout = self.layout + ob = context.object arm = context.armature space = context.space_data - layout = self.layout split = layout.split(percentage=0.65) @@ -45,17 +49,17 @@ class DATA_PT_skeleton(DataButtonsPanel): sub = split.column() sub.itemL(text="Layers:") - sub.itemL(text="LAYERS") - #sub.itemR(arm, "layer") - #sub.itemR(arm, "layer_protection") + sub.template_layers(arm, "layer") + sub.itemL(text="Protected Layers:") + sub.template_layers(arm, "layer_protection") class DATA_PT_display(DataButtonsPanel): __idname__ = "DATA_PT_display" __label__ = "Display" def draw(self, context): - arm = context.armature layout = self.layout + arm = context.armature split = layout.split() @@ -74,8 +78,8 @@ class DATA_PT_paths(DataButtonsPanel): __label__ = "Paths" def draw(self, context): - arm = context.armature layout = self.layout + arm = context.armature split = layout.split() @@ -102,8 +106,8 @@ class DATA_PT_ghost(DataButtonsPanel): __label__ = "Ghost" def draw(self, context): - arm = context.armature layout = self.layout + arm = context.armature split = layout.split() diff --git a/release/ui/buttons_data_bone.py b/release/ui/buttons_data_bone.py index 75c201f015e..044f7b93806 100644 --- a/release/ui/buttons_data_bone.py +++ b/release/ui/buttons_data_bone.py @@ -7,15 +7,17 @@ class BoneButtonsPanel(bpy.types.Panel): __context__ = "bone" def poll(self, context): - return (context.bone != None) + return (context.bone or context.edit_bone) class BONE_PT_bone(BoneButtonsPanel): __idname__ = "BONE_PT_bone" __label__ = "Bone" def draw(self, context): - bone = context.bone layout = self.layout + bone = context.bone + if not bone: + bone = context.edit_bone split = layout.split() @@ -35,11 +37,12 @@ class BONE_PT_bone(BoneButtonsPanel): sub.itemR(bone, "multiply_vertexgroup_with_envelope", text="Multiply") sub = split.column() - #sub.itemR(bone, "layer") + sub.itemL(text="Layers:") + sub.template_layers(bone, "layer") + sub.itemL(text="Display:") sub.itemR(bone, "draw_wire", text="Wireframe") - sub.itemR(bone, "editmode_hidden", text="Hide (EditMode)") - sub.itemR(bone, "pose_channel_hidden", text="Hide (PoseMode)") + sub.itemR(bone, "hidden", text="Hide") sub.itemL(text="Curved Bones:") sub.itemR(bone, "bbone_segments", text="Segments") @@ -49,4 +52,3 @@ class BONE_PT_bone(BoneButtonsPanel): sub.itemR(bone, "cyclic_offset") bpy.types.register(BONE_PT_bone) - diff --git a/release/ui/buttons_data_camera.py b/release/ui/buttons_data_camera.py index 362e4f96aa2..db2a1f9db25 100644 --- a/release/ui/buttons_data_camera.py +++ b/release/ui/buttons_data_camera.py @@ -12,12 +12,16 @@ class DataButtonsPanel(bpy.types.Panel): class DATA_PT_camera(DataButtonsPanel): __idname__ = "DATA_PT_camera" __label__ = "Lens" + + def poll(self, context): + return (context.object and context.object.type == 'CAMERA') def draw(self, context): + layout = self.layout + ob = context.object cam = context.camera space = context.space_data - layout = self.layout split = layout.split(percentage=0.65) @@ -62,7 +66,7 @@ class DATA_PT_camera(DataButtonsPanel): class DATA_PT_camera_display(DataButtonsPanel): __idname__ = "DATA_PT_camera_display" __label__ = "Display" - + def draw(self, context): cam = context.camera layout = self.layout diff --git a/release/ui/buttons_data_curve.py b/release/ui/buttons_data_curve.py index b8b7d6a324f..869d29802e1 100644 --- a/release/ui/buttons_data_curve.py +++ b/release/ui/buttons_data_curve.py @@ -7,18 +7,21 @@ class DataButtonsPanel(bpy.types.Panel): __context__ = "data" def poll(self, context): - ob = context.object - return (ob and ob.type == 'CURVE' and context.curve) + return (context.object and context.object.type == 'CURVE' and context.curve) class DATA_PT_shape_curve(DataButtonsPanel): __idname__ = "DATA_PT_shape_curve" __label__ = "Shape" + + def poll(self, context): + return (context.object and context.object.type == 'CURVE') def draw(self, context): + layout = self.layout + ob = context.object curve = context.curve space = context.space_data - layout = self.layout split = layout.split(percentage=0.65) @@ -63,8 +66,8 @@ class DATA_PT_geometry(DataButtonsPanel): __label__ = "Geometry" def draw(self, context): - curve = context.curve layout = self.layout + curve = context.curve split = layout.split() @@ -85,9 +88,9 @@ class DATA_PT_pathanim(DataButtonsPanel): __label__ = "Path Animation" def draw_header(self, context): + layout = self.layout curve = context.curve - layout = self.layout layout.itemR(curve, "path", text="") def draw(self, context): @@ -110,8 +113,8 @@ class DATA_PT_current_curve(DataButtonsPanel): __label__ = "Current Curve" def draw(self, context): - currentcurve = context.curve.curves[0] # XXX layout = self.layout + currentcurve = context.curve.curves[0] # XXX split = layout.split() diff --git a/release/ui/buttons_data_empty.py b/release/ui/buttons_data_empty.py index 7f994c94a07..f97dedcf6cf 100644 --- a/release/ui/buttons_data_empty.py +++ b/release/ui/buttons_data_empty.py @@ -7,16 +7,15 @@ class DataButtonsPanel(bpy.types.Panel): __context__ = "data" def poll(self, context): - ob = context.object - return (ob and ob.type == 'EMPTY') + return (context.object and context.object.type == 'EMPTY') class DATA_PT_empty(DataButtonsPanel): __idname__ = "DATA_PT_empty" __label__ = "Empty" def draw(self, context): - ob = context.object layout = self.layout + ob = context.object layout.itemR(ob, "empty_draw_type") layout.itemR(ob, "empty_draw_size") diff --git a/release/ui/buttons_data_lamp.py b/release/ui/buttons_data_lamp.py index f626eb45ed6..52a60ce617e 100644 --- a/release/ui/buttons_data_lamp.py +++ b/release/ui/buttons_data_lamp.py @@ -22,12 +22,16 @@ class DATA_PT_preview(DataButtonsPanel): class DATA_PT_lamp(DataButtonsPanel): __idname__ = "DATA_PT_lamp" __label__ = "Lamp" + + def poll(self, context): + return ((context.object and context.object.type == 'LAMP') or context.lamp) def draw(self, context): + layout = self.layout + ob = context.object lamp = context.lamp space = context.space_data - layout = self.layout split = layout.split(percentage=0.65) @@ -82,8 +86,8 @@ class DATA_PT_sunsky(DataButtonsPanel): return (lamp and lamp.type == 'SUN') def draw(self, context): - lamp = context.lamp.sky layout = self.layout + lamp = context.lamp.sky row = layout.row() row.itemR(lamp, "sky") @@ -96,7 +100,6 @@ class DATA_PT_sunsky(DataButtonsPanel): split = layout.split() col = split.column() - sub = col.column() sub.active = lamp.sky sub.itemR(lamp, "sky_blend_type", text="Blend Type") @@ -125,8 +128,8 @@ class DATA_PT_shadow(DataButtonsPanel): return (lamp and lamp.type in ('POINT','SUN', 'SPOT', 'AREA')) def draw(self, context): - lamp = context.lamp layout = self.layout + lamp = context.lamp layout.itemR(lamp, "shadow_method", expand=True) @@ -204,8 +207,8 @@ class DATA_PT_spot(DataButtonsPanel): return (lamp and lamp.type == 'SPOT') def draw(self, context): - lamp = context.lamp layout = self.layout + lamp = context.lamp split = layout.split() @@ -236,8 +239,8 @@ class DATA_PT_falloff_curve(DataButtonsPanel): return False def draw(self, context): - lamp = context.lamp layout = self.layout + lamp = context.lamp layout.template_curve_mapping(lamp.falloff_curve) @@ -246,4 +249,4 @@ bpy.types.register(DATA_PT_lamp) bpy.types.register(DATA_PT_shadow) bpy.types.register(DATA_PT_sunsky) bpy.types.register(DATA_PT_spot) -bpy.types.register(DATA_PT_falloff_curve)
\ No newline at end of file +bpy.types.register(DATA_PT_falloff_curve) diff --git a/release/ui/buttons_data_lattice.py b/release/ui/buttons_data_lattice.py index 8f83cbb45f9..ad9b1b518b8 100644 --- a/release/ui/buttons_data_lattice.py +++ b/release/ui/buttons_data_lattice.py @@ -12,12 +12,16 @@ class DataButtonsPanel(bpy.types.Panel): class DATA_PT_lattice(DataButtonsPanel): __idname__ = "DATA_PT_lattice" __label__ = "Lattice" + + def poll(self, context): + return (context.object and context.object.type == 'LATTICE') def draw(self, context): + layout = self.layout + ob = context.object lat = context.lattice space = context.space_data - layout = self.layout split = layout.split(percentage=0.65) diff --git a/release/ui/buttons_data_mesh.py b/release/ui/buttons_data_mesh.py index c3742b38cc1..c103a0f7055 100644 --- a/release/ui/buttons_data_mesh.py +++ b/release/ui/buttons_data_mesh.py @@ -12,12 +12,16 @@ class DataButtonsPanel(bpy.types.Panel): class DATA_PT_mesh(DataButtonsPanel): __idname__ = "DATA_PT_mesh" __label__ = "Mesh" + + def poll(self, context): + return (context.object and context.object.type == 'MESH') def draw(self, context): + layout = self.layout + ob = context.object mesh = context.mesh space = context.space_data - layout = self.layout split = layout.split(percentage=0.65) diff --git a/release/ui/buttons_data_modifier.py b/release/ui/buttons_data_modifier.py index 72b2f29100e..5635529d90e 100644 --- a/release/ui/buttons_data_modifier.py +++ b/release/ui/buttons_data_modifier.py @@ -5,11 +5,7 @@ class DataButtonsPanel(bpy.types.Panel): __space_type__ = "BUTTONS_WINDOW" __region_type__ = "WINDOW" __context__ = "modifier" - - def poll(self, context): - ob = context.object - return (ob and ob.type in ('MESH', 'CURVE', 'SURFACE', 'TEXT', 'LATTICE')) - + class DATA_PT_modifiers(DataButtonsPanel): __idname__ = "DATA_PT_modifiers" __label__ = "Modifiers" @@ -211,6 +207,7 @@ class DATA_PT_modifiers(DataButtonsPanel): layout.itemR(md, "texture") layout.itemR(md, "midlevel") layout.itemR(md, "strength") + layout.itemR(md, "direction") layout.itemR(md, "texture_coordinates") if md.texture_coordinates == 'OBJECT': layout.itemR(md, "texture_coordinate_object", text="Object") @@ -415,4 +412,4 @@ class DATA_PT_modifiers(DataButtonsPanel): col.itemR(md, "width", slider=True) col.itemR(md, "narrowness", slider=True) -bpy.types.register(DATA_PT_modifiers) +bpy.types.register(DATA_PT_modifiers)
\ No newline at end of file diff --git a/release/ui/buttons_data_text.py b/release/ui/buttons_data_text.py index 20503d8d2fd..bce16e78a40 100644 --- a/release/ui/buttons_data_text.py +++ b/release/ui/buttons_data_text.py @@ -7,18 +7,22 @@ class DataButtonsPanel(bpy.types.Panel): __context__ = "data" def poll(self, context): - ob = context.object - return (ob and ob.type == 'TEXT') + return (context.object and context.object.type == 'TEXT' and context.curve) class DATA_PT_shape_text(DataButtonsPanel): __idname__ = "DATA_PT_shape_text" - __label__ = "Shape" + __label__ = "Shape Text" + + def poll(self, context): + ob = context.object + return (context.object and context.object.type == 'TEXT') def draw(self, context): + layout = self.layout + ob = context.object curve = context.curve space = context.space_data - layout = self.layout split = layout.split(percentage=0.65) @@ -59,8 +63,8 @@ class DATA_PT_font(DataButtonsPanel): __label__ = "Font" def draw(self, context): - text = context.curve layout = self.layout + text = context.curve layout.row() layout.itemR(text, "font") @@ -90,8 +94,8 @@ class DATA_PT_paragraph(DataButtonsPanel): __label__ = "Paragraph" def draw(self, context): - text = context.curve layout = self.layout + text = context.curve layout.itemL(text="Align:") layout.itemR(text, "spacemode", expand=True) @@ -109,14 +113,16 @@ class DATA_PT_paragraph(DataButtonsPanel): sub.itemR(text, "x_offset", text="X") sub.itemR(text, "y_offset", text="Y") sub.itemR(text, "wrap") - + +""" class DATA_PT_textboxes(DataButtonsPanel): __idname__ = "DATA_PT_textboxes" __label__ = "Text Boxes" def draw(self, context): - text = context.curve layout = self.layout + text = context.curve +""" bpy.types.register(DATA_PT_shape_text) bpy.types.register(DATA_PT_font) diff --git a/release/ui/buttons_material.py b/release/ui/buttons_material.py index b9816e36dd7..124fba83608 100644 --- a/release/ui/buttons_material.py +++ b/release/ui/buttons_material.py @@ -1,4 +1,4 @@ - + import bpy class MaterialButtonsPanel(bpy.types.Panel): @@ -14,12 +14,12 @@ class MATERIAL_PT_preview(MaterialButtonsPanel): __label__ = "Preview" def poll(self, context): - return (context.material or context.object) + return (context.material or context.material_slot) def draw(self, context): layout = self.layout - mat = context.material + layout.template_preview(mat) class MATERIAL_PT_material(MaterialButtonsPanel): @@ -27,10 +27,11 @@ class MATERIAL_PT_material(MaterialButtonsPanel): __label__ = "Material" def poll(self, context): - return (context.material or context.object) + return (context.material or context.material_slot) def draw(self, context): layout = self.layout + mat = context.material ob = context.object slot = context.material_slot @@ -49,78 +50,263 @@ class MATERIAL_PT_material(MaterialButtonsPanel): layout.itemS() layout.itemR(mat, "type", expand=True) - - row = layout.row() - row.column().itemR(mat, "diffuse_color") - row.column().itemR(mat, "specular_color") - row.column().itemR(mat, "mirror_color") layout.itemR(mat, "alpha", slider=True) + + row = layout.row() + row.active = mat.type in ('SURFACE', 'VOLUME') + row.itemR(mat, "shadeless") + row.itemR(mat, "wireframe") + rowsub = row.row() + rowsub.active = mat.shadeless== False + rowsub.itemR(mat, "tangent_shading") +class MATERIAL_PT_strand(MaterialButtonsPanel): + __idname__= "MATERIAL_PT_strand" + __label__ = "Strand" + __default_closed__ = True + + def draw(self, context): + layout = self.layout + tan = context.material.strand + mat = context.material + + split = layout.split() + + sub = split.column() + sub.itemL(text="Size:") + sub.itemR(tan, "start_size", text="Root") + sub.itemR(tan, "end_size", text="Tip") + sub.itemR(tan, "min_size", text="Minimum") + sub.itemR(tan, "blender_units") + colsub = sub.column() + colsub.active = mat.shadeless== False + colsub.itemR(tan, "tangent_shading") + + sub = split.column() + sub.itemR(tan, "shape") + sub.itemR(tan, "width_fade") + sub.itemR(tan, "uv_layer") + colsub = sub.column() + colsub.active = mat.shadeless== False + colsub.itemR(tan, "surface_diffuse") + colsubsub = colsub.column() + colsubsub.active = tan.surface_diffuse + colsubsub.itemR(tan, "blend_distance", text="Distance") + +class MATERIAL_PT_options(MaterialButtonsPanel): + __idname__= "MATERIAL_PT_options" + __label__ = "Options" + + def draw(self, context): + layout = self.layout + mat = context.material + + split = layout.split() + + sub = split.column() + sub.itemR(mat, "traceable") + sub.itemR(mat, "full_oversampling") + sub.itemR(mat, "sky") + sub.itemR(mat, "exclude_mist") + sub.itemR(mat, "face_texture") + colsub = sub.column() + colsub.active = mat.face_texture + colsub.itemR(mat, "face_texture_alpha") + sub.itemR(mat, "invert_z") + sub.itemR(mat, "light_group") + sub.itemR(mat, "light_group_exclusive") + + sub = split.column() + sub.itemL(text="Shadows:") + sub.itemR(mat, "shadows", text="Recieve") + sub.itemR(mat, "transparent_shadows", text="Recieve Transparent") + sub.itemR(mat, "only_shadow", text="Shadows Only") + sub.itemR(mat, "cast_shadows_only", text="Cast Only") + sub.itemR(mat, "shadow_casting_alpha", text="Casting Alpha", slider=True) + + sub.itemR(mat, "ray_shadow_bias") + colsub = sub.column() + colsub.active = mat.ray_shadow_bias + colsub.itemR(mat, "shadow_ray_bias", text="Raytracing Bias") + sub.itemR(mat, "cast_buffer_shadows") + colsub = sub.column() + colsub.active = mat.cast_buffer_shadows + colsub.itemR(mat, "shadow_buffer_bias", text="Buffer Bias") + +class MATERIAL_PT_diffuse(MaterialButtonsPanel): + __idname__= "MATERIAL_PT_diffuse" + __label__ = "Diffuse" + + def poll(self, context): + mat = context.material + return (mat and mat.type != "HALO") + + def draw(self, context): + layout = self.layout + mat = context.material + + split = layout.split() + + sub = split.column() + sub.itemR(mat, "diffuse_color", text="") + sub.itemR(mat, "object_color") + colsub = sub.column() + colsub.active = mat.shadeless== False + colsub.itemR(mat, "ambient", slider=True) + colsub.itemR(mat, "emit") + sub.itemR(mat, "translucency", slider=True) + + sub = split.column() + sub.active = mat.shadeless== False + sub.itemR(mat, "diffuse_reflection", text="Intensity", slider=True) + sub.itemR(mat, "vertex_color_light") + sub.itemR(mat, "vertex_color_paint") + sub.itemR(mat, "cubic") + + row = layout.row() + row.active = mat.shadeless== False + row.itemR(mat, "diffuse_shader", text="Shader") + + split = layout.split() + split.active = mat.shadeless== False + sub = split.column() + if mat.diffuse_shader == 'OREN_NAYAR': + sub.itemR(mat, "roughness") + sub = split.column() + if mat.diffuse_shader == 'MINNAERT': + sub.itemR(mat, "darkness") + sub = split.column() + if mat.diffuse_shader == 'TOON': + sub.itemR(mat, "diffuse_toon_size", text="Size") + sub = split.column() + sub.itemR(mat, "diffuse_toon_smooth", text="Smooth") + if mat.diffuse_shader == 'FRESNEL': + sub.itemR(mat, "diffuse_fresnel", text="Fresnel") + sub = split.column() + sub.itemR(mat, "diffuse_fresnel_factor", text="Factor") + + layout.itemR(mat, "diffuse_ramp", text="Ramp") + +class MATERIAL_PT_specular(MaterialButtonsPanel): + __idname__= "MATERIAL_PT_specular" + __label__ = "Specular" + + def poll(self, context): + mat = context.material + return (mat and mat.type != "HALO") + + def draw(self, context): + layout = self.layout + mat = context.material + + layout.active = mat.shadeless== False + + split = layout.split() + + sub = split.column() + sub.itemR(mat, "specular_color", text="") + sub = split.column() + sub.itemR(mat, "specular_reflection", text="Intensity", slider=True) + + layout.itemR(mat, "spec_shader", text="Shader") + + split = layout.split() + + sub = split.column() + if mat.spec_shader in ('COOKTORR', 'PHONG'): + sub.itemR(mat, "specular_hardness", text="Hardness") + sub = split.column() + if mat.spec_shader == 'BLINN': + sub.itemR(mat, "specular_hardness", text="Hardness") + sub = split.column() + sub.itemR(mat, "specular_ior", text="IOR") + if mat.spec_shader == 'WARDISO': + sub.itemR(mat, "specular_slope", text="Slope") + sub.itemR(mat, "specular_hardness", text="Hardness") + if mat.spec_shader == 'TOON': + sub.itemR(mat, "specular_toon_size", text="Size") + sub = split.column() + sub.itemR(mat, "specular_toon_smooth", text="Smooth") + + layout.itemR(mat, "specular_ramp", text="Ramp") + class MATERIAL_PT_sss(MaterialButtonsPanel): __idname__= "MATERIAL_PT_sss" __label__ = "Subsurface Scattering" - + __default_closed__ = True + def poll(self, context): mat = context.material return (mat and mat.type == "SURFACE") def draw_header(self, context): + layout = self.layout sss = context.material.subsurface_scattering - layout = self.layout layout.itemR(sss, "enabled", text="") def draw(self, context): layout = self.layout sss = context.material.subsurface_scattering + mat = context.material layout.active = sss.enabled - flow = layout.column_flow() - flow.itemR(sss, "error_tolerance") - flow.itemR(sss, "ior") - flow.itemR(sss, "scale") - - row = layout.row() - row.column().itemR(sss, "color") - row.column().itemR(sss, "radius") + split = layout.split() + split.active = mat.shadeless== False - flow = layout.column_flow() - flow.itemR(sss, "color_factor", slider=True) - flow.itemR(sss, "texture_factor", slider=True) - flow.itemR(sss, "front") - flow.itemR(sss, "back") + sub = split.column() + sub.itemR(sss, "color", text="") + sub.itemL(text="Blend:") + sub.itemR(sss, "color_factor", slider=True) + sub.itemR(sss, "texture_factor", slider=True) + sub.itemL(text="Scattering Weight:") + sub.itemR(sss, "front") + sub.itemR(sss, "back") + sub = split.column() + sub.itemR(sss, "ior") + sub.itemR(sss, "scale") + sub.itemR(sss, "radius", text="RGB Radius") + sub.itemR(sss, "error_tolerance") + class MATERIAL_PT_raymir(MaterialButtonsPanel): __idname__= "MATERIAL_PT_raymir" __label__ = "Ray Mirror" + __default_closed__ = True def poll(self, context): mat = context.material return (mat and mat.type == "SURFACE") def draw_header(self, context): + layout = self.layout raym = context.material.raytrace_mirror - layout = self.layout layout.itemR(raym, "enabled", text="") def draw(self, context): layout = self.layout raym = context.material.raytrace_mirror - layout.active = raym.enabled + mat = context.material + + layout.active = raym.enabled + split = layout.split() sub = split.column() - sub.itemR(raym, "reflect", text="RayMir", slider=True) + sub.itemR(raym, "reflect", text="Reflectivity", slider=True) + sub.itemR(mat, "mirror_color", text="") sub.itemR(raym, "fresnel") sub.itemR(raym, "fresnel_fac", text="Fac", slider=True) sub = split.column() sub.itemR(raym, "gloss", slider=True) - sub.itemR(raym, "gloss_threshold", slider=True) - sub.itemR(raym, "gloss_samples") - sub.itemR(raym, "gloss_anisotropic", slider=True) + colsub = sub.column() + colsub.active = raym.gloss < 1 + colsub.itemR(raym, "gloss_threshold", slider=True, text="Threshold") + colsub.itemR(raym, "gloss_samples", text="Samples") + colsub.itemR(raym, "gloss_anisotropic", slider=True, text="Anisotropic") row = layout.row() row.itemR(raym, "distance", text="Max Dist") @@ -131,23 +317,27 @@ class MATERIAL_PT_raymir(MaterialButtonsPanel): class MATERIAL_PT_raytransp(MaterialButtonsPanel): __idname__= "MATERIAL_PT_raytransp" __label__= "Ray Transparency" - + __default_closed__ = True + def poll(self, context): mat = context.material return (mat and mat.type == "SURFACE") def draw_header(self, context): + layout = self.layout rayt = context.material.raytrace_transparency - layout = self.layout layout.itemR(rayt, "enabled", text="") def draw(self, context): layout = self.layout rayt = context.material.raytrace_transparency + mat = context.material + layout.active = rayt.enabled split = layout.split() + split.active = mat.shadeless== False sub = split.column() sub.itemR(rayt, "ior") @@ -156,14 +346,17 @@ class MATERIAL_PT_raytransp(MaterialButtonsPanel): sub = split.column() sub.itemR(rayt, "gloss", slider=True) - sub.itemR(rayt, "gloss_threshold", slider=True) - sub.itemR(rayt, "gloss_samples") + colsub = sub.column() + colsub.active = rayt.gloss < 1 + colsub.itemR(rayt, "gloss_threshold", slider=True, text="Threshold") + colsub.itemR(rayt, "gloss_samples", text="Samples") flow = layout.column_flow() + flow.active = mat.shadeless== False flow.itemR(rayt, "filter", slider=True) flow.itemR(rayt, "limit") flow.itemR(rayt, "falloff") - flow.itemR(rayt, "specular_opacity", slider=True) + flow.itemR(rayt, "specular_opacity", slider=True, text="Spec Opacity") flow.itemR(rayt, "depth") class MATERIAL_PT_halo(MaterialButtonsPanel): @@ -176,13 +369,14 @@ class MATERIAL_PT_halo(MaterialButtonsPanel): def draw(self, context): layout = self.layout + mat = context.material halo = mat.halo split = layout.split() - col = split.column(align=True) - col.itemL(text="General Settings:") + col = split.column() + col.itemR(mat, "diffuse_color", text="") col.itemR(halo, "size") col.itemR(halo, "hardness") col.itemR(halo, "add", slider=True) @@ -195,15 +389,17 @@ class MATERIAL_PT_halo(MaterialButtonsPanel): col.itemR(halo, "soft") col = split.column() - col = col.column(align=True) + col = col.column() col.itemR(halo, "ring") colsub = col.column() colsub.active = halo.ring colsub.itemR(halo, "rings") + colsub.itemR(mat, "mirror_color", text="") col.itemR(halo, "lines") colsub = col.column() colsub.active = halo.lines colsub.itemR(halo, "line_number", text="Lines") + colsub.itemR(mat, "specular_color", text="") col.itemR(halo, "star") colsub = col.column() colsub.active = halo.star @@ -219,8 +415,11 @@ class MATERIAL_PT_halo(MaterialButtonsPanel): bpy.types.register(MATERIAL_PT_preview) bpy.types.register(MATERIAL_PT_material) +bpy.types.register(MATERIAL_PT_diffuse) +bpy.types.register(MATERIAL_PT_specular) bpy.types.register(MATERIAL_PT_raymir) bpy.types.register(MATERIAL_PT_raytransp) bpy.types.register(MATERIAL_PT_sss) bpy.types.register(MATERIAL_PT_halo) - +bpy.types.register(MATERIAL_PT_strand) +bpy.types.register(MATERIAL_PT_options) diff --git a/release/ui/buttons_objects.py b/release/ui/buttons_objects.py index 6d75146fe5f..3138f447ad2 100644 --- a/release/ui/buttons_objects.py +++ b/release/ui/buttons_objects.py @@ -6,16 +6,13 @@ class ObjectButtonsPanel(bpy.types.Panel): __region_type__ = "WINDOW" __context__ = "object" - def poll(self, context): - return (context.object != None) - class OBJECT_PT_transform(ObjectButtonsPanel): __idname__ = "OBJECT_PT_transform" __label__ = "Transform" def draw(self, context): - ob = context.object layout = self.layout + ob = context.object row = layout.row() row.column().itemR(ob, "location") @@ -27,8 +24,8 @@ class OBJECT_PT_groups(ObjectButtonsPanel): __label__ = "Groups" def draw(self, context): - ob = context.object layout = self.layout + ob = context.object row = layout.row() row.itemR(ob, "pass_index") @@ -38,7 +35,7 @@ class OBJECT_PT_groups(ObjectButtonsPanel): # layout.itemO("OBJECT_OT_add_group"); for group in bpy.data.groups: - if ob in group.objects: + if ob.name in group.objects: col = layout.column(align=True) row = col.box().row() @@ -54,8 +51,8 @@ class OBJECT_PT_display(ObjectButtonsPanel): __label__ = "Display" def draw(self, context): - ob = context.object layout = self.layout + ob = context.object row = layout.row() row.itemR(ob, "max_draw_type", text="Type") @@ -74,8 +71,8 @@ class OBJECT_PT_duplication(ObjectButtonsPanel): __label__ = "Duplication" def draw(self, context): - ob = context.object layout = self.layout + ob = context.object layout.itemR(ob, "dupli_type", expand=True) @@ -108,8 +105,8 @@ class OBJECT_PT_animation(ObjectButtonsPanel): __label__ = "Animation" def draw(self, context): - ob = context.object layout = self.layout + ob = context.object split = layout.split() @@ -131,5 +128,4 @@ bpy.types.register(OBJECT_PT_transform) bpy.types.register(OBJECT_PT_groups) bpy.types.register(OBJECT_PT_display) bpy.types.register(OBJECT_PT_duplication) -bpy.types.register(OBJECT_PT_animation) - +bpy.types.register(OBJECT_PT_animation)
\ No newline at end of file diff --git a/release/ui/buttons_physic_cloth.py b/release/ui/buttons_physic_cloth.py index efa796df5b0..bd65392ad63 100644 --- a/release/ui/buttons_physic_cloth.py +++ b/release/ui/buttons_physic_cloth.py @@ -15,8 +15,7 @@ class Physic_PT_cloth(PhysicButtonsPanel): def draw(self, context): layout = self.layout - md = context.cloth - cloth = md.settings + cloth = context.cloth.settings split = layout.split() @@ -51,16 +50,14 @@ class Physic_PT_cloth_collision(PhysicButtonsPanel): def draw_header(self, context): layout = self.layout - md = context.cloth - cloth = md.collision_settings + cloth = context.cloth.collision_settings layout.itemR(cloth, "enable_collision", text="") def draw(self, context): layout = self.layout + cloth = context.cloth.collision_settings - md = context.cloth - cloth = md.collision_settings layout.active = cloth.enable_collision col = layout.column_flow() @@ -82,16 +79,14 @@ class Physic_PT_cloth_stiffness(PhysicButtonsPanel): def draw_header(self, context): layout = self.layout - md = context.cloth - cloth = md.settings + cloth = context.cloth.settings layout.itemR(cloth, "stiffness_scaling", text="") def draw(self, context): layout = self.layout + cloth = context.cloth.settings - md = context.cloth - cloth = md.settings layout.active = cloth.stiffness_scaling split = layout.split() @@ -108,4 +103,4 @@ class Physic_PT_cloth_stiffness(PhysicButtonsPanel): bpy.types.register(Physic_PT_cloth) bpy.types.register(Physic_PT_cloth_collision) -bpy.types.register(Physic_PT_cloth_stiffness)
\ No newline at end of file +bpy.types.register(Physic_PT_cloth_stiffness) diff --git a/release/ui/buttons_scene.py b/release/ui/buttons_scene.py index e275b888156..df172ea8298 100644 --- a/release/ui/buttons_scene.py +++ b/release/ui/buttons_scene.py @@ -10,10 +10,8 @@ class RENDER_PT_shading(RenderButtonsPanel): __label__ = "Shading" def draw(self, context): - scene = context.scene layout = self.layout - - rd = scene.render_data + rd = context.scene.render_data split = layout.split() @@ -34,10 +32,8 @@ class RENDER_PT_output(RenderButtonsPanel): __label__ = "Output" def draw(self, context): - scene = context.scene layout = self.layout - - rd = scene.render_data + rd = context.scene.render_data layout.itemR(rd, "output_path") @@ -65,17 +61,17 @@ class RENDER_PT_output(RenderButtonsPanel): col = split.column() - if rd.file_format in ("AVIJPEG", "JPEG"): + if rd.file_format in ('AVIJPEG', 'JPEG'): col.itemR(rd, "quality", slider=True) - elif rd.file_format in ("OPENEXR"): + elif rd.file_format == 'OPENEXR': col.itemR(rd, "exr_codec") col.itemR(rd, "exr_half") col = split.column() col.itemR(rd, "exr_zbuf") col.itemR(rd, "exr_preview") - elif rd.file_format in ("JPEG2000"): + elif rd.file_format == 'JPEG2000': row = layout.row() row.itemR(rd, "jpeg_preset") split = layout.split() @@ -86,7 +82,7 @@ class RENDER_PT_output(RenderButtonsPanel): col.itemR(rd, "jpeg_ycc") col.itemR(rd, "exr_preview") - elif rd.file_format in ("CINEON", "DPX"): + elif rd.file_format in ('CINEON', 'DPX'): col.itemR(rd, "cineon_log", text="Convert to Log") colsub = col.column() colsub.active = rd.cineon_log @@ -94,23 +90,54 @@ class RENDER_PT_output(RenderButtonsPanel): colsub.itemR(rd, "cineon_white", text="White") colsub.itemR(rd, "cineon_gamma", text="Gamma") - elif rd.file_format in ("TIFF"): + elif rd.file_format == 'TIFF': col.itemR(rd, "tiff_bit") + + elif rd.file_format == 'FFMPEG': + #row = layout.row() + #row.itemR(rd, "ffmpeg_format") + #row.itemR(rd, "ffmpeg_codec") + split = layout.split() + + col = split.column() + col.itemR(rd, "ffmpeg_video_bitrate") + col.itemL(text="Rate:") + col.itemR(rd, "ffmpeg_minrate", text="Minimum") + col.itemR(rd, "ffmpeg_maxrate", text="Maximum") + col.itemR(rd, "ffmpeg_buffersize", text="Buffer") + + col = split.column() + col.itemR(rd, "ffmpeg_gopsize") + col.itemR(rd, "ffmpeg_autosplit") + col.itemL(text="Mux:") + col.itemR(rd, "ffmpeg_muxrate", text="Rate") + col.itemR(rd, "ffmpeg_packetsize", text="Packet Size") + + row = layout.row() + row.itemL(text="Audio:") + row = layout.row() + #row.itemR(rd, "ffmpeg_audio_codec") + + split = layout.split() + + col = split.column() + col.itemR(rd, "ffmpeg_audio_bitrate") + col = split.column() + col.itemR(rd, "ffmpeg_multiplex_audio") class RENDER_PT_antialiasing(RenderButtonsPanel): __label__ = "Anti-Aliasing" def draw_header(self, context): + layout = self.layout rd = context.scene.render_data - layout = self.layout layout.itemR(rd, "antialiasing", text="") def draw(self, context): - scene = context.scene - rd = scene.render_data - layout = self.layout + rd = context.scene.render_data + layout.active = rd.antialiasing split = layout.split() @@ -131,14 +158,12 @@ class RENDER_PT_render(RenderButtonsPanel): __label__ = "Render" def draw(self, context): - scene = context.scene layout = self.layout - - rd = scene.render_data + rd = context.scene.render_data row = layout.row() - row.itemO("SCREEN_OT_render", text="Render Still", icon=109) - row.item_booleanO("SCREEN_OT_render", "anim", True, text="Render Animation", icon=111) + row.itemO("SCREEN_OT_render", text="Render Still", icon='ICON_IMAGE_COL') + row.item_booleanO("SCREEN_OT_render", "anim", True, text="Render Animation", icon='ICON_SEQUENCE') row = layout.row() row.itemR(rd, "do_composite") @@ -172,9 +197,9 @@ class RENDER_PT_dimensions(RenderButtonsPanel): __label__ = "Dimensions" def draw(self, context): - scene = context.scene layout = self.layout - + + scene = context.scene rd = scene.render_data split = layout.split() @@ -216,10 +241,9 @@ class RENDER_PT_stamp(RenderButtonsPanel): layout.itemR(rd, "stamp", text="") def draw(self, context): - scene = context.scene - rd = scene.render_data - layout = self.layout + rd = context.scene.render_data + layout.active = rd.stamp split = layout.split() @@ -241,8 +265,8 @@ class RENDER_PT_stamp(RenderButtonsPanel): sub.itemR(rd, "render_stamp") colsub = sub.column() colsub.active = rd.render_stamp - colsub.itemR(rd, "stamp_foreground") - colsub.itemR(rd, "stamp_background") + colsub.itemR(rd, "stamp_foreground", slider=True) + colsub.itemR(rd, "stamp_background", slider=True) colsub.itemR(rd, "stamp_font_size", text="Font Size") bpy.types.register(RENDER_PT_render) diff --git a/release/ui/buttons_texture.py b/release/ui/buttons_texture.py index 6110d8eaf5e..de166cef796 100644 --- a/release/ui/buttons_texture.py +++ b/release/ui/buttons_texture.py @@ -7,19 +7,19 @@ class TextureButtonsPanel(bpy.types.Panel): __context__ = "texture" def poll(self, context): - return (context.texture != None) - + return (context.texture != None and context.texture.type != 'NONE') + class TEXTURE_PT_preview(TextureButtonsPanel): __idname__= "TEXTURE_PT_preview" __label__ = "Preview" def poll(self, context): - return (context.texture or context.material) + return (context.material or context.world or context.lamp or context.texture) def draw(self, context): layout = self.layout - tex = context.texture + layout.template_preview(tex) class TEXTURE_PT_texture(TextureButtonsPanel): @@ -27,10 +27,11 @@ class TEXTURE_PT_texture(TextureButtonsPanel): __label__ = "Texture" def poll(self, context): - return (context.texture or context.material or context.world or context.lamp) + return (context.material or context.world or context.lamp or context.texture) def draw(self, context): layout = self.layout + tex = context.texture ma = context.material la = context.lamp @@ -69,37 +70,45 @@ class TEXTURE_PT_texture(TextureButtonsPanel): class TEXTURE_PT_mapping(TextureButtonsPanel): __idname__= "TEXTURE_PT_mapping" __label__ = "Mapping" + + def poll(self, context): + return (context.texture_slot and context.texture and context.texture.type != 'NONE') def draw(self, context): layout = self.layout tex = context.texture_slot + textype = context.texture split = layout.split(percentage=0.3) col = split.column() col.itemL(text="Coordinates:") col = split.column() col.itemR(tex, "texture_coordinates", text="") - - split = layout.split() - col = split.column() + if tex.texture_coordinates == 'UV': - col.itemR(tex, "uv_layer") + row = layout.row() + row.itemR(tex, "uv_layer") elif tex.texture_coordinates == 'OBJECT': - col.itemR(tex, "object") - + row = layout.row() + row.itemR(tex, "object") + + if textype.type in ('IMAGE', 'ENVIRONMENT_MAP'): + split = layout.split(percentage=0.3) + col = split.column() + col.itemL(text="Projection:") + col = split.column() + col.itemR(tex, "mapping", text="") + + split = layout.split() + col = split.column() col.itemR(tex, "from_dupli") - split = layout.split(percentage=0.3) - col = split.column() - col.itemL(text="Projection:") col = split.column() - col.itemR(tex, "mapping", text="") - - row = layout.row() - row.itemR(tex, "x_mapping", text="X") - row.itemR(tex, "y_mapping", text="Y") - row.itemR(tex, "z_mapping", text="Z") + row = col.row() + row.itemR(tex, "x_mapping", text="") + row.itemR(tex, "y_mapping", text="") + row.itemR(tex, "z_mapping", text="") row = layout.row() row.column().itemR(tex, "offset") @@ -108,16 +117,20 @@ class TEXTURE_PT_mapping(TextureButtonsPanel): class TEXTURE_PT_influence(TextureButtonsPanel): __idname__= "TEXTURE_PT_influence" __label__ = "Influence" + + def poll(self, context): + return (context.texture_slot and context.texture and context.texture.type != 'NONE') def draw(self, context): layout = self.layout + textype = context.texture tex = context.texture_slot split = layout.split() col = split.column() - col.itemR(tex, "map_color") + col.itemR(tex, "map_color", text="Diffuse Color") colsub = col.column() colsub.active = tex.map_color colsub.itemR(tex, "color_factor", text="Opacity", slider=True) @@ -167,6 +180,7 @@ class TEXTURE_PT_influence(TextureButtonsPanel): class TEXTURE_PT_colors(TextureButtonsPanel): __idname__= "TEXTURE_PT_colors" __label__ = "Colors" + __default_closed__ = True def draw(self, context): layout = self.layout @@ -177,7 +191,7 @@ class TEXTURE_PT_colors(TextureButtonsPanel): else: split = layout.split() col = split.column() - col.itemR(tex, "rgb_factor") + col.itemR(tex, "rgb_factor", text="Multiply RGB") col = split.column() col.itemL(text="Adjust:") @@ -491,7 +505,7 @@ class TEXTURE_PT_distortednoise(TextureButtonsPanel): split = layout.split() sub = split.column() - sub.itemR(tex, "distortion_amount", text="Amount") + sub.itemR(tex, "distortion_amount", text="Distortion") sub.itemR(tex, "noise_size", text="Size") sub = split.column() @@ -514,4 +528,5 @@ bpy.types.register(TEXTURE_PT_voronoi) bpy.types.register(TEXTURE_PT_distortednoise) bpy.types.register(TEXTURE_PT_colors) bpy.types.register(TEXTURE_PT_mapping) -bpy.types.register(TEXTURE_PT_influence)
\ No newline at end of file +bpy.types.register(TEXTURE_PT_influence) + diff --git a/release/ui/buttons_world.py b/release/ui/buttons_world.py index 8298c0c9b13..d9516cb7900 100644 --- a/release/ui/buttons_world.py +++ b/release/ui/buttons_world.py @@ -17,21 +17,22 @@ class WORLD_PT_preview(WorldButtonsPanel): def draw(self, context): layout = self.layout - world = context.world + layout.template_preview(world) class WORLD_PT_world(WorldButtonsPanel): __label__ = "World" def poll(self, context): - return (context.scene or context.world) + return (context.scene != None) def draw(self, context): + layout = self.layout + scene = context.scene world = context.world space = context.space_data - layout = self.layout split = layout.split(percentage=0.65) @@ -61,8 +62,8 @@ class WORLD_PT_color_correction(WorldButtonsPanel): __label__ = "Color Correction" def draw(self, context): - world = context.world layout = self.layout + world = context.world row = layout.row() row.itemR(world, "exposure") @@ -72,14 +73,15 @@ class WORLD_PT_mist(WorldButtonsPanel): __label__ = "Mist" def draw_header(self, context): + layout = self.layout world = context.world - layout = self.layout layout.itemR(world.mist, "enabled", text="") def draw(self, context): - world = context.world layout = self.layout + world = context.world + layout.active = world.mist.enabled flow = layout.column_flow() @@ -95,14 +97,15 @@ class WORLD_PT_stars(WorldButtonsPanel): __label__ = "Stars" def draw_header(self, context): + layout = self.layout world = context.world - layout = self.layout layout.itemR(world.stars, "enabled", text="") def draw(self, context): - world = context.world layout = self.layout + world = context.world + layout.active = world.stars.enabled flow = layout.column_flow() @@ -115,24 +118,26 @@ class WORLD_PT_ambient_occlusion(WorldButtonsPanel): __label__ = "Ambient Occlusion" def draw_header(self, context): + layout = self.layout world = context.world - layout = self.layout layout.itemR(world.ambient_occlusion, "enabled", text="") def draw(self, context): - world = context.world - ao = world.ambient_occlusion layout = self.layout + ao = context.world.ambient_occlusion + layout.active = ao.enabled layout.itemR(ao, "gather_method", expand=True) if ao.gather_method == 'RAYTRACE': split = layout.split() + col = split.column() col.itemR(ao, "samples") col.itemR(ao, "distance") + col = split.column() col.itemR(ao, "falloff") colsub = col.column() @@ -151,10 +156,12 @@ class WORLD_PT_ambient_occlusion(WorldButtonsPanel): if ao.gather_method == 'APPROXIMATE': split = layout.split() + col = split.column() col.itemR(ao, "passes") col.itemR(ao, "error_tolerance", text="Error") col.itemR(ao, "correction") + col = split.column() col.itemR(ao, "falloff") colsub = col.column() diff --git a/release/ui/space_image.py b/release/ui/space_image.py new file mode 100644 index 00000000000..3623b914942 --- /dev/null +++ b/release/ui/space_image.py @@ -0,0 +1,836 @@ + +import bpy + +class IMAGE_MT_view(bpy.types.Menu): + __space_type__ = "IMAGE_EDITOR" + __label__ = "View" + + def draw(self, context): + layout = self.layout + sima = context.space_data + uv = sima.uv_editor + + show_uvedit = sima.show_uvedit + + layout.itemO("IMAGE_OT_properties") # icon + + layout.itemS() + + layout.itemR(sima, "update_automatically") + # XXX if show_uvedit: + # XXX layout.itemR(uv, "local_view") # "UV Local View", Numpad / + + layout.itemS() + + layout.itemO("IMAGE_OT_view_zoom_in") + layout.itemO("IMAGE_OT_view_zoom_out") + + layout.itemS() + + ratios = [[1, 8], [1, 4], [1, 2], [1, 1], [2, 1], [4, 1], [8, 1]]; + + for a, b in ratios: + text = "Zoom %d:%d" % (a, b) + layout.item_floatO("IMAGE_OT_view_zoom_ratio", "ratio", a/b, text=text) + + layout.itemS() + + if show_uvedit: + layout.itemO("IMAGE_OT_view_selected") + + layout.itemO("IMAGE_OT_view_all") + layout.itemO("SCREEN_OT_screen_full_area") + +class IMAGE_MT_select(bpy.types.Menu): + __space_type__ = "IMAGE_EDITOR" + __label__ = "Select" + + def draw(self, context): + layout = self.layout + + layout.itemO("UV_OT_select_border") + layout.item_booleanO("UV_OT_select_border", "pinned", True) + + layout.itemS() + + layout.itemO("UV_OT_select_all_toggle") + layout.itemO("UV_OT_select_invert") + layout.itemO("UV_OT_unlink_selection") + + layout.itemS() + + layout.itemO("UV_OT_select_pinned") + layout.itemO("UV_OT_select_linked") + +class IMAGE_MT_image(bpy.types.Menu): + __space_type__ = "IMAGE_EDITOR" + __label__ = "Image" + + def draw(self, context): + layout = self.layout + sima = context.space_data + ima = sima.image + + layout.itemO("IMAGE_OT_new") + layout.itemO("IMAGE_OT_open") + + show_render = sima.show_render + + if ima: + if show_render: + layout.itemO("IMAGE_OT_replace") + layout.itemO("IMAGE_OT_reload") + + layout.itemO("IMAGE_OT_save") + layout.itemO("IMAGE_OT_save_as") + + if ima.source == "SEQUENCE": + layout.itemO("IMAGE_OT_save_sequence") + + if not show_render: + layout.itemS() + + if ima.packed_file: + layout.itemO("IMAGE_OT_unpack") + else: + layout.itemO("IMAGE_OT_pack") + + # only for dirty && specific image types : XXX poll? + #if(ibuf && (ibuf->userflags & IB_BITMAPDIRTY)) + if False: + if ima.source in ("FILE", "GENERATED") and ima.type != "MULTILAYER": + layout.item_booleanO("IMAGE_OT_pack", "as_png", True, text="Pack As PNG") + + layout.itemS() + + layout.itemR(sima, "image_painting") + +class IMAGE_MT_uvs_showhide(bpy.types.Menu): + __space_type__ = "IMAGE_EDITOR" + __label__ = "Show/Hide Faces" + + def draw(self, context): + layout = self.layout + + layout.itemO("UV_OT_reveal") + layout.itemO("UV_OT_hide") + layout.item_booleanO("UV_OT_hide", "unselected", True) + +class IMAGE_MT_uvs_transform(bpy.types.Menu): + __space_type__ = "IMAGE_EDITOR" + __label__ = "Transform" + + def draw(self, context): + layout = self.layout + + layout.item_enumO("TFM_OT_transform", "mode", "TRANSLATION") + layout.item_enumO("TFM_OT_transform", "mode", "ROTATION") + layout.item_enumO("TFM_OT_transform", "mode", "RESIZE") + +class IMAGE_MT_uvs_mirror(bpy.types.Menu): + __space_type__ = "IMAGE_EDITOR" + __label__ = "Mirror" + + def draw(self, context): + layout = self.layout + + layout.item_enumO("UV_OT_mirror", "axis", "MIRROR_X") # "X Axis", M, + layout.item_enumO("UV_OT_mirror", "axis", "MIRROR_Y") # "Y Axis", M, + +class IMAGE_MT_uvs_weldalign(bpy.types.Menu): + __space_type__ = "IMAGE_EDITOR" + __label__ = "Weld/Align" + + def draw(self, context): + layout = self.layout + + layout.itemO("UV_OT_weld") # W, 1 + layout.items_enumO("UV_OT_align", "axis") # W, 2/3/4 + + +class IMAGE_MT_uvs(bpy.types.Menu): + __space_type__ = "IMAGE_EDITOR" + __label__ = "UVs" + + def draw(self, context): + layout = self.layout + sima = context.space_data + uv = sima.uv_editor + scene = context.scene + + layout.itemR(uv, "snap_to_pixels") + layout.itemR(uv, "constrain_to_image_bounds") + + layout.itemS() + + layout.itemR(uv, "live_unwrap") + layout.itemO("UV_OT_unwrap") + layout.item_booleanO("UV_OT_pin", "clear", True, text="Unpin") + layout.itemO("UV_OT_pin") + + layout.itemS() + + layout.itemO("UV_OT_pack_islands") + layout.itemO("UV_OT_average_islands_scale") + layout.itemO("UV_OT_minimize_stretch") + layout.itemO("UV_OT_stitch") + + layout.itemS() + + layout.itemM(context, "IMAGE_MT_uvs_transform") + layout.itemM(context, "IMAGE_MT_uvs_mirror") + layout.itemM(context, "IMAGE_MT_uvs_weldalign") + + layout.itemS() + + # XXX layout.itemR(scene, "proportional_editing") + layout.item_menu_enumR(scene, "proportional_editing_falloff") + + layout.itemS() + + layout.itemM(context, "IMAGE_MT_uvs_showhide") + +class IMAGE_HT_header(bpy.types.Header): + __space_type__ = "IMAGE_EDITOR" + + def draw(self, context): + sima = context.space_data + ima = sima.image + layout = self.layout + + show_render = sima.show_render + show_paint = sima.show_paint + show_uvedit = sima.show_uvedit + + layout.template_header(context) + + # menus + if context.area.show_menus: + row = layout.row() + row.itemM(context, "IMAGE_MT_view") + + if show_uvedit: + row.itemM(context, "IMAGE_MT_select") + + # XXX menuname= (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))? "Image*": "Image"; + row.itemM(context, "IMAGE_MT_image") + + if show_uvedit: + row.itemM(context, "IMAGE_MT_uvs") + + layout.template_ID(context, sima, "image", new="IMAGE_OT_new", open="IMAGE_OT_open") + + """ + /* image select */ + + pinflag= (show_render)? 0: UI_ID_PIN; + xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID*)sima->image, ID_IM, &sima->pin, xco, yco, + sima_idpoin_handle, UI_ID_BROWSE|UI_ID_BROWSE_RENDER|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|pinflag); + xco += 8; + """ + + """ + if(ima && !ELEM3(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE, IMA_SRC_VIEWER) && ima->ok) { + /* XXX this should not be a static var */ + static int headerbuttons_packdummy; + + headerbuttons_packdummy = 0; + + if (ima->packedfile) { + headerbuttons_packdummy = 1; + } + if (ima->packedfile && ibuf && (ibuf->userflags & IB_BITMAPDIRTY)) + uiDefIconButBitI(block, TOG, 1, 0 /* XXX B_SIMA_REPACK */, ICON_UGLYPACKAGE, xco,yco,XIC,YIC, &headerbuttons_packdummy, 0, 0, 0, 0, "Re-Pack this image as PNG"); + else + uiDefIconButBitI(block, TOG, 1, 0 /* XXX B_SIMAPACKIMA */, ICON_PACKAGE, xco,yco,XIC,YIC, &headerbuttons_packdummy, 0, 0, 0, 0, "Pack/Unpack this image"); + + xco+= XIC+8; + } + """ + + # uv editing + if show_uvedit: + pass + + """ + /* uv editing */ + if(show_uvedit) { + /* pivot */ + uiDefIconTextButS(block, ICONTEXTROW, B_NOP, ICON_ROTATE, + "Pivot: %t|Bounding Box Center %x0|Median Point %x3|2D Cursor %x1", + xco,yco,XIC+10,YIC, &ar->v2d.around, 0, 3.0, 0, 0, + "Rotation/Scaling Pivot (Hotkeys: Comma, Shift Comma, Period)"); + xco+= XIC + 18; + + /* selection modes */ + uiDefIconButBitS(block, TOG, UV_SYNC_SELECTION, B_REDR, ICON_EDIT, xco,yco,XIC,YIC, &scene->toolsettings->uv_flag, 0, 0, 0, 0, "Sync UV and Mesh Selection"); + xco+= XIC+8; + + if(scene->toolsettings->uv_flag & UV_SYNC_SELECTION) { + uiBlockBeginAlign(block); + + uiDefIconButBitS(block, TOG, SCE_SELECT_VERTEX, B_REDR, ICON_VERTEXSEL, + xco,yco,XIC,YIC, &scene->selectmode, 1.0, 0.0, 0, 0, "Vertex select mode"); + uiDefIconButBitS(block, TOG, SCE_SELECT_EDGE, B_REDR, ICON_EDGESEL, + xco+=XIC,yco,XIC,YIC, &scene->selectmode, 1.0, 0.0, 0, 0, "Edge select mode"); + uiDefIconButBitS(block, TOG, SCE_SELECT_FACE, B_REDR, ICON_FACESEL, + xco+=XIC,yco,XIC,YIC, &scene->selectmode, 1.0, 0.0, 0, 0, "Face select mode"); + + uiBlockEndAlign(block); + } + else { + uiBlockBeginAlign(block); + + uiDefIconButS(block, ROW, B_REDR, ICON_VERTEXSEL, + xco,yco,XIC,YIC, &scene->toolsettings->uv_selectmode, 1.0, UV_SELECT_VERTEX, 0, 0, "Vertex select mode"); + uiDefIconButS(block, ROW, B_REDR, ICON_EDGESEL, + xco+=XIC,yco,XIC,YIC, &scene->toolsettings->uv_selectmode, 1.0, UV_SELECT_EDGE, 0, 0, "Edge select mode"); + uiDefIconButS(block, ROW, B_REDR, ICON_FACESEL, + xco+=XIC,yco,XIC,YIC, &scene->toolsettings->uv_selectmode, 1.0, UV_SELECT_FACE, 0, 0, "Face select mode"); + uiDefIconButS(block, ROW, B_REDR, ICON_LINKEDSEL, + xco+=XIC,yco,XIC,YIC, &scene->toolsettings->uv_selectmode, 1.0, UV_SELECT_ISLAND, 0, 0, "Island select mode"); + + uiBlockEndAlign(block); + + /* would use these if const's could go in strings + * SI_STICKY_LOC SI_STICKY_DISABLE SI_STICKY_VERTEX */ + but = uiDefIconTextButC(block, ICONTEXTROW, B_REDR, ICON_STICKY_UVS_LOC, + "Sticky UV Selection: %t|Disable%x1|Shared Location%x0|Shared Vertex%x2", + xco+=XIC+10,yco,XIC+10,YIC, &(sima->sticky), 0, 3.0, 0, 0, + "Sticky UV Selection (Hotkeys: Shift C, Alt C, Ctrl C)"); + } + + xco+= XIC + 16; + + /* snap options, identical to options in 3d view header */ + uiBlockBeginAlign(block); + + if (scene->snap_flag & SCE_SNAP) { + uiDefIconButBitS(block, TOG, SCE_SNAP, B_REDR, ICON_SNAP_GEO,xco,yco,XIC,YIC, &scene->snap_flag, 0, 0, 0, 0, "Use Snap or Grid (Shift Tab)."); + xco+= XIC; + uiDefButS(block, MENU, B_NOP, "Mode%t|Closest%x0|Center%x1|Median%x2",xco,yco,70,YIC, &scene->snap_target, 0, 0, 0, 0, "Snap Target Mode."); + xco+= 70; + } + else { + uiDefIconButBitS(block, TOG, SCE_SNAP, B_REDR, ICON_SNAP_GEAR,xco,yco,XIC,YIC, &scene->snap_flag, 0, 0, 0, 0, "Snap while Ctrl is held during transform (Shift Tab)."); + xco+= XIC; + } + + uiBlockEndAlign(block); + xco+= 8; + + /* uv layers */ + { + Object *obedit= CTX_data_edit_object(C); + char menustr[34*MAX_MTFACE]; + static int act; + + image_menu_uvlayers(obedit, menustr, &act); + + but = uiDefButI(block, MENU, B_NOP, menustr ,xco,yco,85,YIC, &act, 0, 0, 0, 0, "Active UV Layer for editing."); + // uiButSetFunc(but, do_image_buttons_set_uvlayer_callback, &act, NULL); + + xco+= 85; + } + + xco+= 8; + } + """ + + if ima: + """ + RenderResult *rr; + + /* render layers and passes */ + rr= BKE_image_get_renderresult(scene, ima); + if(rr) { + uiBlockBeginAlign(block); +#if 0 + uiblock_layer_pass_buttons(block, rr, &sima->iuser, B_REDR, xco, 0, 160); +#endif + uiBlockEndAlign(block); + xco+= 166; + } + """ + + # painting + layout.itemR(sima, "image_painting", text="") + + # draw options + row = layout.row(align=True) + row.itemR(sima, "draw_channels", text="", expand=True) + + row = layout.row(align=True) + if ima.type == "COMPOSITE": + row.itemO("IMAGE_OT_record_composite", icon="ICON_REC") + if ima.type == "COMPOSITE" and ima.source in ("MOVIE", "SEQUENCE"): + row.itemO("IMAGE_OT_play_composite", icon="ICON_PLAY") + + layout.itemR(sima, "update_automatically", text="") + +class IMAGE_PT_game_properties(bpy.types.Panel): + __space_type__ = "IMAGE_EDITOR" + __region_type__ = "UI" + __label__ = "Game Properties" + + def draw(self, context): + sima = context.space_data + layout = self.layout + + ima = sima.image + + if ima: + split = layout.split() + + col = split.column(align=True) + col.itemR(ima, "animated") + + subcol = col.column() + subcol.itemR(ima, "animation_start", text="Start") + subcol.itemR(ima, "animation_end", text="End") + subcol.itemR(ima, "animation_speed", text="Speed") + subcol.active = ima.animated + + col = split.column() + col.itemR(ima, "tiles") + + subrow = col.row(align=True) + subrow.itemR(ima, "tiles_x", text="X") + subrow.itemR(ima, "tiles_y", text="Y") + subrow.active = ima.tiles + + col.itemS() + col.itemR(ima, "clamp_x") + col.itemR(ima, "clamp_y") + + col.itemR(ima, "mapping", expand=True) + +bpy.types.register(IMAGE_MT_view) +bpy.types.register(IMAGE_MT_select) +bpy.types.register(IMAGE_MT_image) +bpy.types.register(IMAGE_MT_uvs_showhide) +bpy.types.register(IMAGE_MT_uvs_transform) +bpy.types.register(IMAGE_MT_uvs_mirror) +bpy.types.register(IMAGE_MT_uvs_weldalign) +bpy.types.register(IMAGE_MT_uvs) +bpy.types.register(IMAGE_HT_header) +bpy.types.register(IMAGE_PT_game_properties) + + +import bpy + +class IMAGE_MT_view(bpy.types.Menu): + __space_type__ = "IMAGE_EDITOR" + __label__ = "View" + + def draw(self, context): + layout = self.layout + sima = context.space_data + uv = sima.uv_editor + + show_uvedit = sima.show_uvedit + + layout.itemO("IMAGE_OT_properties") # icon + + layout.itemS() + + layout.itemR(sima, "update_automatically") + # XXX if show_uvedit: + # XXX layout.itemR(uv, "local_view") # "UV Local View", Numpad / + + layout.itemS() + + layout.itemO("IMAGE_OT_view_zoom_in") + layout.itemO("IMAGE_OT_view_zoom_out") + + layout.itemS() + + ratios = [[1, 8], [1, 4], [1, 2], [1, 1], [2, 1], [4, 1], [8, 1]]; + + for a, b in ratios: + text = "Zoom %d:%d" % (a, b) + layout.item_floatO("IMAGE_OT_view_zoom_ratio", "ratio", a/b, text=text) + + layout.itemS() + + if show_uvedit: + layout.itemO("IMAGE_OT_view_selected") + + layout.itemO("IMAGE_OT_view_all") + layout.itemO("SCREEN_OT_screen_full_area") + +class IMAGE_MT_select(bpy.types.Menu): + __space_type__ = "IMAGE_EDITOR" + __label__ = "Select" + + def draw(self, context): + layout = self.layout + + layout.itemO("UV_OT_select_border") + layout.item_booleanO("UV_OT_select_border", "pinned", True) + + layout.itemS() + + layout.itemO("UV_OT_select_all_toggle") + layout.itemO("UV_OT_select_invert") + layout.itemO("UV_OT_unlink_selection") + + layout.itemS() + + layout.itemO("UV_OT_select_pinned") + layout.itemO("UV_OT_select_linked") + +class IMAGE_MT_image(bpy.types.Menu): + __space_type__ = "IMAGE_EDITOR" + __label__ = "Image" + + def draw(self, context): + layout = self.layout + sima = context.space_data + ima = sima.image + + layout.itemO("IMAGE_OT_new") + layout.itemO("IMAGE_OT_open") + + show_render = sima.show_render + + if ima: + if show_render: + layout.itemO("IMAGE_OT_replace") + layout.itemO("IMAGE_OT_reload") + + layout.itemO("IMAGE_OT_save") + layout.itemO("IMAGE_OT_save_as") + + if ima.source == "SEQUENCE": + layout.itemO("IMAGE_OT_save_sequence") + + if not show_render: + layout.itemS() + + if ima.packed_file: + layout.itemO("IMAGE_OT_unpack") + else: + layout.itemO("IMAGE_OT_pack") + + # only for dirty && specific image types : XXX poll? + #if(ibuf && (ibuf->userflags & IB_BITMAPDIRTY)) + if False: + if ima.source in ("FILE", "GENERATED") and ima.type != "MULTILAYER": + layout.item_booleanO("IMAGE_OT_pack", "as_png", True, text="Pack As PNG") + + layout.itemS() + + layout.itemR(sima, "image_painting") + +class IMAGE_MT_uvs_showhide(bpy.types.Menu): + __space_type__ = "IMAGE_EDITOR" + __label__ = "Show/Hide Faces" + + def draw(self, context): + layout = self.layout + + layout.itemO("UV_OT_reveal") + layout.itemO("UV_OT_hide") + layout.item_booleanO("UV_OT_hide", "unselected", True) + +class IMAGE_MT_uvs_transform(bpy.types.Menu): + __space_type__ = "IMAGE_EDITOR" + __label__ = "Transform" + + def draw(self, context): + layout = self.layout + + layout.item_enumO("TFM_OT_transform", "mode", "TRANSLATION") + layout.item_enumO("TFM_OT_transform", "mode", "ROTATION") + layout.item_enumO("TFM_OT_transform", "mode", "RESIZE") + +class IMAGE_MT_uvs_mirror(bpy.types.Menu): + __space_type__ = "IMAGE_EDITOR" + __label__ = "Mirror" + + def draw(self, context): + layout = self.layout + + layout.item_enumO("UV_OT_mirror", "axis", "MIRROR_X") # "X Axis", M, + layout.item_enumO("UV_OT_mirror", "axis", "MIRROR_Y") # "Y Axis", M, + +class IMAGE_MT_uvs_weldalign(bpy.types.Menu): + __space_type__ = "IMAGE_EDITOR" + __label__ = "Weld/Align" + + def draw(self, context): + layout = self.layout + + layout.itemO("UV_OT_weld") # W, 1 + layout.items_enumO("UV_OT_align", "axis") # W, 2/3/4 + + +class IMAGE_MT_uvs(bpy.types.Menu): + __space_type__ = "IMAGE_EDITOR" + __label__ = "UVs" + + def draw(self, context): + layout = self.layout + sima = context.space_data + uv = sima.uv_editor + scene = context.scene + + layout.itemR(uv, "snap_to_pixels") + layout.itemR(uv, "constrain_to_image_bounds") + + layout.itemS() + + layout.itemR(uv, "live_unwrap") + layout.itemO("UV_OT_unwrap") + layout.item_booleanO("UV_OT_pin", "clear", True, text="Unpin") + layout.itemO("UV_OT_pin") + + layout.itemS() + + layout.itemO("UV_OT_pack_islands") + layout.itemO("UV_OT_average_islands_scale") + layout.itemO("UV_OT_minimize_stretch") + layout.itemO("UV_OT_stitch") + + layout.itemS() + + layout.itemM(context, "IMAGE_MT_uvs_transform") + layout.itemM(context, "IMAGE_MT_uvs_mirror") + layout.itemM(context, "IMAGE_MT_uvs_weldalign") + + layout.itemS() + + # XXX layout.itemR(scene, "proportional_editing") + layout.item_menu_enumR(scene, "proportional_editing_falloff") + + layout.itemS() + + layout.itemM(context, "IMAGE_MT_uvs_showhide") + +class IMAGE_HT_header(bpy.types.Header): + __space_type__ = "IMAGE_EDITOR" + + def draw(self, context): + sima = context.space_data + ima = sima.image + layout = self.layout + + show_render = sima.show_render + show_paint = sima.show_paint + show_uvedit = sima.show_uvedit + + layout.template_header(context) + + # menus + if context.area.show_menus: + row = layout.row() + row.itemM(context, "IMAGE_MT_view") + + if show_uvedit: + row.itemM(context, "IMAGE_MT_select") + + # XXX menuname= (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))? "Image*": "Image"; + row.itemM(context, "IMAGE_MT_image") + + if show_uvedit: + row.itemM(context, "IMAGE_MT_uvs") + + layout.template_ID(context, sima, "image", new="IMAGE_OT_new", open="IMAGE_OT_open") + + """ + /* image select */ + + pinflag= (show_render)? 0: UI_ID_PIN; + xco= uiDefIDPoinButs(block, CTX_data_main(C), NULL, (ID*)sima->image, ID_IM, &sima->pin, xco, yco, + sima_idpoin_handle, UI_ID_BROWSE|UI_ID_BROWSE_RENDER|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|pinflag); + xco += 8; + """ + + """ + if(ima && !ELEM3(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE, IMA_SRC_VIEWER) && ima->ok) { + /* XXX this should not be a static var */ + static int headerbuttons_packdummy; + + headerbuttons_packdummy = 0; + + if (ima->packedfile) { + headerbuttons_packdummy = 1; + } + if (ima->packedfile && ibuf && (ibuf->userflags & IB_BITMAPDIRTY)) + uiDefIconButBitI(block, TOG, 1, 0 /* XXX B_SIMA_REPACK */, ICON_UGLYPACKAGE, xco,yco,XIC,YIC, &headerbuttons_packdummy, 0, 0, 0, 0, "Re-Pack this image as PNG"); + else + uiDefIconButBitI(block, TOG, 1, 0 /* XXX B_SIMAPACKIMA */, ICON_PACKAGE, xco,yco,XIC,YIC, &headerbuttons_packdummy, 0, 0, 0, 0, "Pack/Unpack this image"); + + xco+= XIC+8; + } + """ + + # uv editing + if show_uvedit: + pass + + """ + /* uv editing */ + if(show_uvedit) { + /* pivot */ + uiDefIconTextButS(block, ICONTEXTROW, B_NOP, ICON_ROTATE, + "Pivot: %t|Bounding Box Center %x0|Median Point %x3|2D Cursor %x1", + xco,yco,XIC+10,YIC, &ar->v2d.around, 0, 3.0, 0, 0, + "Rotation/Scaling Pivot (Hotkeys: Comma, Shift Comma, Period)"); + xco+= XIC + 18; + + /* selection modes */ + uiDefIconButBitS(block, TOG, UV_SYNC_SELECTION, B_REDR, ICON_EDIT, xco,yco,XIC,YIC, &scene->toolsettings->uv_flag, 0, 0, 0, 0, "Sync UV and Mesh Selection"); + xco+= XIC+8; + + if(scene->toolsettings->uv_flag & UV_SYNC_SELECTION) { + uiBlockBeginAlign(block); + + uiDefIconButBitS(block, TOG, SCE_SELECT_VERTEX, B_REDR, ICON_VERTEXSEL, + xco,yco,XIC,YIC, &scene->selectmode, 1.0, 0.0, 0, 0, "Vertex select mode"); + uiDefIconButBitS(block, TOG, SCE_SELECT_EDGE, B_REDR, ICON_EDGESEL, + xco+=XIC,yco,XIC,YIC, &scene->selectmode, 1.0, 0.0, 0, 0, "Edge select mode"); + uiDefIconButBitS(block, TOG, SCE_SELECT_FACE, B_REDR, ICON_FACESEL, + xco+=XIC,yco,XIC,YIC, &scene->selectmode, 1.0, 0.0, 0, 0, "Face select mode"); + + uiBlockEndAlign(block); + } + else { + uiBlockBeginAlign(block); + + uiDefIconButS(block, ROW, B_REDR, ICON_VERTEXSEL, + xco,yco,XIC,YIC, &scene->toolsettings->uv_selectmode, 1.0, UV_SELECT_VERTEX, 0, 0, "Vertex select mode"); + uiDefIconButS(block, ROW, B_REDR, ICON_EDGESEL, + xco+=XIC,yco,XIC,YIC, &scene->toolsettings->uv_selectmode, 1.0, UV_SELECT_EDGE, 0, 0, "Edge select mode"); + uiDefIconButS(block, ROW, B_REDR, ICON_FACESEL, + xco+=XIC,yco,XIC,YIC, &scene->toolsettings->uv_selectmode, 1.0, UV_SELECT_FACE, 0, 0, "Face select mode"); + uiDefIconButS(block, ROW, B_REDR, ICON_LINKEDSEL, + xco+=XIC,yco,XIC,YIC, &scene->toolsettings->uv_selectmode, 1.0, UV_SELECT_ISLAND, 0, 0, "Island select mode"); + + uiBlockEndAlign(block); + + /* would use these if const's could go in strings + * SI_STICKY_LOC SI_STICKY_DISABLE SI_STICKY_VERTEX */ + but = uiDefIconTextButC(block, ICONTEXTROW, B_REDR, ICON_STICKY_UVS_LOC, + "Sticky UV Selection: %t|Disable%x1|Shared Location%x0|Shared Vertex%x2", + xco+=XIC+10,yco,XIC+10,YIC, &(sima->sticky), 0, 3.0, 0, 0, + "Sticky UV Selection (Hotkeys: Shift C, Alt C, Ctrl C)"); + } + + xco+= XIC + 16; + + /* snap options, identical to options in 3d view header */ + uiBlockBeginAlign(block); + + if (scene->snap_flag & SCE_SNAP) { + uiDefIconButBitS(block, TOG, SCE_SNAP, B_REDR, ICON_SNAP_GEO,xco,yco,XIC,YIC, &scene->snap_flag, 0, 0, 0, 0, "Use Snap or Grid (Shift Tab)."); + xco+= XIC; + uiDefButS(block, MENU, B_NOP, "Mode%t|Closest%x0|Center%x1|Median%x2",xco,yco,70,YIC, &scene->snap_target, 0, 0, 0, 0, "Snap Target Mode."); + xco+= 70; + } + else { + uiDefIconButBitS(block, TOG, SCE_SNAP, B_REDR, ICON_SNAP_GEAR,xco,yco,XIC,YIC, &scene->snap_flag, 0, 0, 0, 0, "Snap while Ctrl is held during transform (Shift Tab)."); + xco+= XIC; + } + + uiBlockEndAlign(block); + xco+= 8; + + /* uv layers */ + { + Object *obedit= CTX_data_edit_object(C); + char menustr[34*MAX_MTFACE]; + static int act; + + image_menu_uvlayers(obedit, menustr, &act); + + but = uiDefButI(block, MENU, B_NOP, menustr ,xco,yco,85,YIC, &act, 0, 0, 0, 0, "Active UV Layer for editing."); + // uiButSetFunc(but, do_image_buttons_set_uvlayer_callback, &act, NULL); + + xco+= 85; + } + + xco+= 8; + } + """ + + if ima: + """ + RenderResult *rr; + + /* render layers and passes */ + rr= BKE_image_get_renderresult(scene, ima); + if(rr) { + uiBlockBeginAlign(block); +#if 0 + uiblock_layer_pass_buttons(block, rr, &sima->iuser, B_REDR, xco, 0, 160); +#endif + uiBlockEndAlign(block); + xco+= 166; + } + """ + + # painting + layout.itemR(sima, "image_painting", text="") + + # draw options + row = layout.row(align=True) + row.itemR(sima, "draw_channels", text="", expand=True) + + row = layout.row(align=True) + if ima.type == "COMPOSITE": + row.itemO("IMAGE_OT_record_composite", icon="ICON_REC") + if ima.type == "COMPOSITE" and ima.source in ("MOVIE", "SEQUENCE"): + row.itemO("IMAGE_OT_play_composite", icon="ICON_PLAY") + + layout.itemR(sima, "update_automatically", text="") + +class IMAGE_PT_game_properties(bpy.types.Panel): + __space_type__ = "IMAGE_EDITOR" + __region_type__ = "UI" + __label__ = "Game Properties" + + def draw(self, context): + sima = context.space_data + layout = self.layout + + ima = sima.image + + if ima: + split = layout.split() + + col = split.column(align=True) + col.itemR(ima, "animated") + + subcol = col.column() + subcol.itemR(ima, "animation_start", text="Start") + subcol.itemR(ima, "animation_end", text="End") + subcol.itemR(ima, "animation_speed", text="Speed") + subcol.active = ima.animated + + col = split.column() + col.itemR(ima, "tiles") + + subrow = col.row(align=True) + subrow.itemR(ima, "tiles_x", text="X") + subrow.itemR(ima, "tiles_y", text="Y") + subrow.active = ima.tiles + + col.itemS() + col.itemR(ima, "clamp_x") + col.itemR(ima, "clamp_y") + + col.itemR(ima, "mapping", expand=True) + +bpy.types.register(IMAGE_MT_view) +bpy.types.register(IMAGE_MT_select) +bpy.types.register(IMAGE_MT_image) +bpy.types.register(IMAGE_MT_uvs_showhide) +bpy.types.register(IMAGE_MT_uvs_transform) +bpy.types.register(IMAGE_MT_uvs_mirror) +bpy.types.register(IMAGE_MT_uvs_weldalign) +bpy.types.register(IMAGE_MT_uvs) +bpy.types.register(IMAGE_HT_header) +bpy.types.register(IMAGE_PT_game_properties) + diff --git a/release/ui/space_text.py b/release/ui/space_text.py index 5c6c5c0d21b..42e5347ce6a 100644 --- a/release/ui/space_text.py +++ b/release/ui/space_text.py @@ -2,12 +2,8 @@ import bpy # temporary -ICON_LINENUMBERS_OFF = 588 -ICON_WORDWRAP_OFF = 584 -ICON_SYNTAX_OFF = 586 ICON_TEXT = 120 ICON_HELP = 1 -ICON_SCRIPTPLUGINS = 1 class TEXT_HT_header(bpy.types.Header): __space_type__ = "TEXT_EDITOR" @@ -21,7 +17,7 @@ class TEXT_HT_header(bpy.types.Header): layout.template_header(context) if context.area.show_menus: - row = layout.row(align=True) + row = layout.row() row.itemM(context, "TEXT_MT_text") if text: row.itemM(context, "TEXT_MT_edit") @@ -30,13 +26,12 @@ class TEXT_HT_header(bpy.types.Header): if text and text.modified: row = layout.row() # row.color(redalert) - row.itemO("TEXT_OT_resolve_conflict", text="", icon=ICON_HELP) + row.itemO("TEXT_OT_resolve_conflict", text="", icon='ICON_HELP') row = layout.row(align=True) - row.itemR(st, "line_numbers", text="", icon=ICON_LINENUMBERS_OFF) - row.itemR(st, "word_wrap", text="", icon=ICON_WORDWRAP_OFF) - row.itemR(st, "syntax_highlight", text="", icon=ICON_SYNTAX_OFF) - # row.itemR(st, "do_python_plugins", text="", icon=ICON_SCRIPTPLUGINS) + row.itemR(st, "line_numbers", text="") + row.itemR(st, "word_wrap", text="") + row.itemR(st, "syntax_highlight", text="") layout.template_ID(context, st, "text", new="TEXT_OT_new", open="TEXT_OT_open", unlink="TEXT_OT_unlink") @@ -63,9 +58,10 @@ class TEXT_PT_properties(bpy.types.Panel): layout = self.layout flow = layout.column_flow() - flow.itemR(st, "line_numbers", icon=ICON_LINENUMBERS_OFF) - flow.itemR(st, "word_wrap", icon=ICON_WORDWRAP_OFF) - flow.itemR(st, "syntax_highlight", icon=ICON_SYNTAX_OFF) + flow.itemR(st, "line_numbers") + flow.itemR(st, "word_wrap") + flow.itemR(st, "syntax_highlight") + flow.itemR(st, "live_edit") flow = layout.column_flow() flow.itemR(st, "font_size") @@ -84,14 +80,14 @@ class TEXT_PT_find(bpy.types.Panel): col = layout.column(align=True) row = col.row() row.itemR(st, "find_text", text="") - row.itemO("TEXT_OT_find_set_selected", text="", icon=ICON_TEXT) + row.itemO("TEXT_OT_find_set_selected", text="", icon='ICON_TEXT') col.itemO("TEXT_OT_find") # replace col = layout.column(align=True) row = col.row() row.itemR(st, "replace_text", text="") - row.itemO("TEXT_OT_replace_set_selected", text="", icon=ICON_TEXT) + row.itemO("TEXT_OT_replace_set_selected", text="", icon='ICON_TEXT') col.itemO("TEXT_OT_replace") # mark @@ -139,8 +135,109 @@ class TEXT_MT_text(bpy.types.Menu): # XXX uiDefIconTextBlockBut(block, text_plugin_scriptsmenu, NULL, ICON_RIGHTARROW_THIN, "Text Plugins", 0, yco-=20, 120, 19, ""); #endif +class TEXT_MT_edit_view(bpy.types.Menu): + __space_type__ = "TEXT_EDITOR" + __label__ = "View" + + def draw(self, context): + layout = self.layout + + layout.item_enumO("TEXT_OT_move", "type", "FILE_TOP", text="Top of File") + layout.item_enumO("TEXT_OT_move", "type", "FILE_BOTTOM", text="Bottom of File") + +class TEXT_MT_edit_select(bpy.types.Menu): + __space_type__ = "TEXT_EDITOR" + __label__ = "Select" + + def draw(self, context): + layout = self.layout + + layout.itemO("TEXT_OT_select_all") + layout.itemO("TEXT_OT_select_line") + +class TEXT_MT_edit_markers(bpy.types.Menu): + __space_type__ = "TEXT_EDITOR" + __label__ = "Markers" + + def draw(self, context): + layout = self.layout + + layout.itemO("TEXT_OT_markers_clear") + layout.itemO("TEXT_OT_next_marker") + layout.itemO("TEXT_OT_previous_marker") + +class TEXT_MT_format(bpy.types.Menu): + __space_type__ = "TEXT_EDITOR" + __label__ = "Format" + + def draw(self, context): + layout = self.layout + + layout.itemO("TEXT_OT_indent") + layout.itemO("TEXT_OT_unindent") + + layout.itemS() + + layout.itemO("TEXT_OT_comment") + layout.itemO("TEXT_OT_uncomment") + + layout.itemS() + + layout.item_menu_enumO("TEXT_OT_convert_whitespace", "type") + +class TEXT_MT_edit_to3d(bpy.types.Menu): + __space_type__ = "TEXT_EDITOR" + __label__ = "Text To 3D Object" + + def draw(self, context): + layout = self.layout + + layout.item_booleanO("TEXT_OT_to_3d_object", "split_lines", False, text="One Object"); + layout.item_booleanO("TEXT_OT_to_3d_object", "split_lines", True, text="One Object Per Line"); + +class TEXT_MT_edit(bpy.types.Menu): + __space_type__ = "TEXT_EDITOR" + __label__ = "Edit" + + def poll(self, context): + st = context.space_data + return st.text != None + + def draw(self, context): + layout = self.layout + + layout.itemO("ED_OT_undo") + layout.itemO("ED_OT_redo") + + layout.itemS() + + layout.itemO("TEXT_OT_cut") + layout.itemO("TEXT_OT_copy") + layout.itemO("TEXT_OT_paste") + + layout.itemS() + + layout.itemM(context, "TEXT_MT_edit_view") + layout.itemM(context, "TEXT_MT_edit_select") + layout.itemM(context, "TEXT_MT_edit_markers") + + layout.itemS() + + layout.itemO("TEXT_OT_jump") + layout.itemO("TEXT_OT_properties") + + layout.itemS() + + layout.itemM(context, "TEXT_MT_edit_to3d") + bpy.types.register(TEXT_HT_header) bpy.types.register(TEXT_PT_properties) bpy.types.register(TEXT_PT_find) bpy.types.register(TEXT_MT_text) +bpy.types.register(TEXT_MT_format) +bpy.types.register(TEXT_MT_edit) +bpy.types.register(TEXT_MT_edit_view) +bpy.types.register(TEXT_MT_edit_select) +bpy.types.register(TEXT_MT_edit_markers) +bpy.types.register(TEXT_MT_edit_to3d) diff --git a/source/Makefile b/source/Makefile index 535a86e9139..2df57f58c73 100644 --- a/source/Makefile +++ b/source/Makefile @@ -162,6 +162,7 @@ COMLIB += $(OCGDIR)/blender/makesdna/$(DEBUG_DIR)libdna.a COMLIB += $(NAN_GUARDEDALLOC)/lib/libguardedalloc.a COMLIB += $(NAN_MEMUTIL)/lib/libmemutil.a COMLIB += $(NAN_PNG)/lib/libpng.a +COMLIB += $(OCGDIR)/blender/gen_python/$(DEBUG_DIR)libgen_python.a ifeq ($(WITH_QUICKTIME), true) COMLIB += $(OCGDIR)/blender/blenderqt/$(DEBUG_DIR)libblenderqt.a @@ -226,6 +227,7 @@ PULIB += $(OCGDIR)/blender/ed_action/$(DEBUG_DIR)libed_action.a PULIB += $(OCGDIR)/blender/ed_nla/$(DEBUG_DIR)libed_nla.a PULIB += $(OCGDIR)/blender/ed_script/$(DEBUG_DIR)libed_script.a PULIB += $(OCGDIR)/blender/ed_text/$(DEBUG_DIR)libed_text.a +PULIB += $(OCGDIR)/blender/ed_logic/$(DEBUG_DIR)libed_logic.a PULIB += $(OCGDIR)/blender/ed_sequencer/$(DEBUG_DIR)libed_sequencer.a PULIB += $(OCGDIR)/blender/ed_file/$(DEBUG_DIR)libed_file.a PULIB += $(OCGDIR)/blender/ed_info/$(DEBUG_DIR)libed_info.a diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h index b5a61f2727f..e871de490f3 100644 --- a/source/blender/blenfont/BLF_api.h +++ b/source/blender/blenfont/BLF_api.h @@ -85,7 +85,7 @@ float BLF_height_default(char *str); void BLF_rotation(float angle); void BLF_clipping(float xmin, float ymin, float xmax, float ymax); void BLF_blur(int size); - +void BLF_kerning(float space); void BLF_enable(int option); void BLF_disable(int option); @@ -117,6 +117,8 @@ void BLF_dir_free(char **dirs, int count); /* font->flags. */ #define BLF_ROTATION (1<<0) #define BLF_CLIPPING (1<<1) +#define BLF_FONT_KERNING (1<<2) +#define BLF_USER_KERNING (1<<3) /* font->mode. */ #define BLF_MODE_TEXTURE 0 diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index 14bc6a33b72..f06c7fb0d28 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -491,3 +491,12 @@ void BLF_mode(int mode) if (font) font->mode= mode; } + +void BLF_kerning(float space) +{ + FontBLF *font; + + font= global_font[global_font_cur]; + if (font) + font->kerning= space; +} diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 1a96dbc13bc..ee4ba0ee71a 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -29,6 +29,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <math.h> #include <ft2build.h> @@ -100,7 +101,7 @@ void blf_font_draw(FontBLF *font, char *str) GlyphBLF *g, *g_prev; FT_Vector delta; FT_UInt glyph_index, g_prev_index; - int pen_x, pen_y; + float pen_x, pen_y, old_pen_x; int i, has_kerning; if (!font->glyph_cache) @@ -138,16 +139,31 @@ void blf_font_draw(FontBLF *font, char *str) else if (font->mode == BLF_MODE_TEXTURE && (!g->tex_data)) g= blf_glyph_add(font, glyph_index, c); - if (has_kerning && g_prev) { + if ((font->flags & BLF_FONT_KERNING) && has_kerning && g_prev) { + old_pen_x= pen_x; delta.x= 0; delta.y= 0; - FT_Get_Kerning(font->face, g_prev_index, glyph_index, FT_KERNING_UNFITTED, &delta); - pen_x += delta.x >> 6; + if (FT_Get_Kerning(font->face, g_prev_index, glyph_index, FT_KERNING_UNFITTED, &delta) == 0) { + pen_x += delta.x >> 6; +/* + if (pen_x < old_pen_x) + pen_x= old_pen_x; +*/ + } + } + + if (font->flags & BLF_USER_KERNING) { + old_pen_x= pen_x; + pen_x += font->kerning; +/* + if (pen_x < old_pen_x) + pen_x= old_pen_x; +*/ } /* do not return this loop if clipped, we want every character tested */ - blf_glyph_render(font, g, (float)pen_x, (float)pen_y); + blf_glyph_render(font, g, pen_x, pen_y); pen_x += g->advance; g_prev= g; @@ -162,7 +178,7 @@ void blf_font_boundbox(FontBLF *font, char *str, rctf *box) FT_Vector delta; FT_UInt glyph_index, g_prev_index; rctf gbox; - int pen_x, pen_y; + float pen_x, pen_y, old_pen_x; int i, has_kerning; if (!font->glyph_cache) @@ -205,12 +221,27 @@ void blf_font_boundbox(FontBLF *font, char *str, rctf *box) else if (font->mode == BLF_MODE_TEXTURE && (!g->tex_data)) g= blf_glyph_add(font, glyph_index, c); - if (has_kerning && g_prev) { + if ((font->flags & BLF_FONT_KERNING) && has_kerning && g_prev) { + old_pen_x= pen_x; delta.x= 0; delta.y= 0; - FT_Get_Kerning(font->face, g_prev_index, glyph_index, FT_KERNING_UNFITTED, &delta); - pen_x += delta.x >> 6; + if (FT_Get_Kerning(font->face, g_prev_index, glyph_index, FT_KERNING_UNFITTED, &delta) == 0) { + pen_x += delta.x >> 6; +/* + if (pen_x < old_pen_x) + old_pen_x= pen_x; +*/ + } + } + + if (font->flags & BLF_USER_KERNING) { + old_pen_x= pen_x; + pen_x += font->kerning; +/* + if (pen_x < old_pen_x) + old_pen_x= pen_x; +*/ } gbox.xmin= g->box.xmin + pen_x; @@ -294,9 +325,10 @@ void blf_font_fill(FontBLF *font) font->clip_rec.xmax= 0.0f; font->clip_rec.ymin= 0.0f; font->clip_rec.ymax= 0.0f; - font->flags= 0; + font->flags= BLF_USER_KERNING | BLF_FONT_KERNING; font->dpi= 0; font->size= 0; + font->kerning= 0.0f; font->cache.first= NULL; font->cache.last= NULL; font->glyph_cache= NULL; diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 142d2145ab2..33a435cc5be 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -213,7 +213,11 @@ GlyphBLF *blf_glyph_texture_add(FontBLF *font, FT_UInt index, unsigned int c) else do_new= 1; - err= FT_Load_Glyph(font->face, index, FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP); + if (font->flags & BLF_FONT_KERNING) + err= FT_Load_Glyph(font->face, index, FT_LOAD_NO_BITMAP); + else + err= FT_Load_Glyph(font->face, index, FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP); + if (err) return(NULL); @@ -328,7 +332,11 @@ GlyphBLF *blf_glyph_bitmap_add(FontBLF *font, FT_UInt index, unsigned int c) else do_new= 1; - err= FT_Load_Glyph(font->face, index, FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP); + if (font->flags & BLF_FONT_KERNING) + err= FT_Load_Glyph(font->face, index, FT_LOAD_NO_BITMAP); + else + err= FT_Load_Glyph(font->face, index, FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP); + if (err) return(NULL); diff --git a/source/blender/blenfont/intern/blf_internal_types.h b/source/blender/blenfont/intern/blf_internal_types.h index 1c55499b568..60446aa93b2 100644 --- a/source/blender/blenfont/intern/blf_internal_types.h +++ b/source/blender/blenfont/intern/blf_internal_types.h @@ -167,6 +167,9 @@ typedef struct FontBLF { /* font size. */ int size; + /* kerning space, user setting. */ + float kerning; + /* max texture size. */ int max_tex_size; diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h index cc10a4071a6..1fb200b94a8 100644 --- a/source/blender/blenkernel/BKE_action.h +++ b/source/blender/blenkernel/BKE_action.h @@ -140,7 +140,7 @@ void framechange_poses_clear_unkeyed(void); void what_does_obaction(struct Scene *scene, struct Object *ob, struct Object *workob, struct bPose *pose, struct bAction *act, char groupname[], float cframe); /* exported for game engine */ -void blend_poses(struct bPose *dst, struct bPose *src, float srcweight, short mode); +void game_blend_poses(struct bPose *dst, struct bPose *src, float srcweight/*, short mode*/); /* was blend_poses */ void extract_pose_from_pose(struct bPose *pose, const struct bPose *src); /* for proxy */ diff --git a/source/blender/blenkernel/BKE_depsgraph.h b/source/blender/blenkernel/BKE_depsgraph.h index b86a58780dc..70b6c1d13f4 100644 --- a/source/blender/blenkernel/BKE_depsgraph.h +++ b/source/blender/blenkernel/BKE_depsgraph.h @@ -36,6 +36,7 @@ struct Scene; struct DagNodeQueue; struct DagForest; struct DagNode; +struct GHash; /* **** DAG relation types *** */ diff --git a/source/blender/blenkernel/BKE_displist.h b/source/blender/blenkernel/BKE_displist.h index c3555c9dd8a..da625b946ce 100644 --- a/source/blender/blenkernel/BKE_displist.h +++ b/source/blender/blenkernel/BKE_displist.h @@ -87,7 +87,7 @@ extern void count_displist(struct ListBase *lb, int *totvert, int *totface); extern void freedisplist(struct ListBase *lb); extern int displist_has_faces(struct ListBase *lb); -extern void makeDispListSurf(struct Scene *scene, struct Object *ob, struct ListBase *dispbase, int forRender); +extern void makeDispListSurf(struct Scene *scene, struct Object *ob, struct ListBase *dispbase, int forRender, int forOrco); extern void makeDispListCurveTypes(struct Scene *scene, struct Object *ob, int forOrco); extern void makeDispListMBall(struct Scene *scene, struct Object *ob); extern void shadeDispList(struct Scene *scene, struct Base *base); diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h index e91039e31f4..4065cbb7007 100644 --- a/source/blender/blenkernel/BKE_modifier.h +++ b/source/blender/blenkernel/BKE_modifier.h @@ -204,7 +204,7 @@ typedef struct ModifierTypeInfo { * * This function is optional. */ - CustomDataMask (*requiredDataMask)(struct ModifierData *md); + CustomDataMask (*requiredDataMask)(struct Object *ob, struct ModifierData *md); /* Free internal modifier data variables, this function should * not free the md variable itself. @@ -272,6 +272,7 @@ int modifier_dependsOnTime(struct ModifierData *md); int modifier_supportsMapping(struct ModifierData *md); int modifier_couldBeCage(struct ModifierData *md); int modifier_isDeformer(struct ModifierData *md); +int modifier_isEnabled(struct ModifierData *md, int required_mode); void modifier_setError(struct ModifierData *md, char *format, ...); void modifiers_foreachObjectLink(struct Object *ob, @@ -302,8 +303,10 @@ int modifiers_indexInObject(struct Object *ob, struct ModifierData *md * evaluation, assuming the data indicated by dataMask is required at the * end of the stack. */ -struct LinkNode *modifiers_calcDataMasks(struct ModifierData *md, - CustomDataMask dataMask); +struct LinkNode *modifiers_calcDataMasks(struct Object *ob, + struct ModifierData *md, + CustomDataMask dataMask, + int required_mode); struct ModifierData *modifiers_getVirtualModifierList(struct Object *ob); #endif diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 09237e74d1d..87ee8f9cab3 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -410,8 +410,9 @@ struct TexResult; #define TEX_NODE_DECOMPOSE 420 #define TEX_NODE_VALTONOR 421 #define TEX_NODE_SCALE 422 +#define TEX_NODE_AT 423 -/* 201-299 reserved. Use like this: TEX_NODE_PROC + TEX_CLOUDS, etc */ +/* 501-599 reserved. Use like this: TEX_NODE_PROC + TEX_CLOUDS, etc */ #define TEX_NODE_PROC 500 #define TEX_NODE_PROC_MAX 600 diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index 9b5d99f6ae6..750f4fba7e6 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -157,6 +157,8 @@ typedef struct PanelType { int space_type; int region_type; + int flag; + /* verify if the panel should draw or not */ int (*poll)(const struct bContext *, struct PanelType *); /* draw header (optional) */ diff --git a/source/blender/blenkernel/depsgraph_private.h b/source/blender/blenkernel/depsgraph_private.h index 78717393baf..47e33c0e81e 100644 --- a/source/blender/blenkernel/depsgraph_private.h +++ b/source/blender/blenkernel/depsgraph_private.h @@ -65,6 +65,7 @@ typedef struct DagNode void * first_ancestor; int ancestor_count; int lay; // accumulated layers of its relations + itself + int scelay; // layers due to being in scene int lasttime; // if lasttime != DagForest->time, this node was not evaluated yet for flushing int BFS_dist; // BFS distance int DFS_dist; // DFS distance @@ -93,6 +94,7 @@ typedef struct DagNodeQueue typedef struct DagForest { ListBase DagNode; + struct GHash *nodeHash; int numNodes; int is_acyclic; int time; // for flushing/tagging, compare with node->lasttime diff --git a/source/blender/blenkernel/intern/BME_tools.c b/source/blender/blenkernel/intern/BME_tools.c index a41307de183..32065ea5151 100644 --- a/source/blender/blenkernel/intern/BME_tools.c +++ b/source/blender/blenkernel/intern/BME_tools.c @@ -191,7 +191,7 @@ static BME_Poly *BME_split_face(BME_Mesh *bm, BME_Poly *f, BME_Vert *v1, BME_Ver nf = BME_SFME(bm,f,v1,v2,nl); nf->flag = f->flag; /* if the edge was selected, select this face, too */ - if (example->flag & SELECT) f->flag |= ME_FACE_SEL; + if (example && (example->flag & SELECT)) f->flag |= ME_FACE_SEL; nf->h = f->h; nf->mat_nr = f->mat_nr; if (nl && example) { diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index bc6e549dc6f..090f256ab9f 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1604,18 +1604,18 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos modifiers_clearErrors(ob); + if(useRenderParams) required_mode = eModifierMode_Render; + else required_mode = eModifierMode_Realtime; + /* we always want to keep original indices */ dataMask |= CD_MASK_ORIGINDEX; - datamasks = modifiers_calcDataMasks(md, dataMask); + datamasks = modifiers_calcDataMasks(ob, md, dataMask, required_mode); curr = datamasks; if(deform_r) *deform_r = NULL; *final_r = NULL; - if(useRenderParams) required_mode = eModifierMode_Render; - else required_mode = eModifierMode_Realtime; - if(useDeform) { if(useDeform > 0 && do_ob_key(scene, ob)) /* shape key makes deform verts */ deformedVerts = mesh_getVertexCos(me, &numVerts); @@ -1628,8 +1628,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos md->scene= scene; - if((md->mode & required_mode) != required_mode) continue; - if(mti->isDisabled && mti->isDisabled(md)) continue; + if(!modifier_isEnabled(md, required_mode)) continue; if(useDeform < 0 && mti->dependsOnTime && mti->dependsOnTime(md)) continue; if(mti->type == eModifierTypeType_OnlyDeform) { @@ -1678,19 +1677,18 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos md->scene= scene; - if((md->mode & required_mode) != required_mode) continue; + if(!modifier_isEnabled(md, required_mode)) continue; if(mti->type == eModifierTypeType_OnlyDeform && !useDeform) continue; if((mti->flags & eModifierTypeFlag_RequiresOriginalData) && dm) { modifier_setError(md, "Modifier requires original data, bad stack position."); continue; } - if(mti->isDisabled && mti->isDisabled(md)) continue; if(needMapping && !modifier_supportsMapping(md)) continue; if(useDeform < 0 && mti->dependsOnTime && mti->dependsOnTime(md)) continue; /* add an orco layer if needed by this modifier */ if(dm && mti->requiredDataMask) { - mask = mti->requiredDataMask(md); + mask = mti->requiredDataMask(ob, md); if(mask & CD_MASK_ORCO) add_orco_dm(ob, NULL, dm, orcodm); } @@ -1860,14 +1858,11 @@ static int editmesh_modifier_is_enabled(ModifierData *md, DerivedMesh *dm) ModifierTypeInfo *mti = modifierType_getInfo(md->type); int required_mode = eModifierMode_Realtime | eModifierMode_Editmode; - if((md->mode & required_mode) != required_mode) return 0; + if(!modifier_isEnabled(md, required_mode)) return 0; if((mti->flags & eModifierTypeFlag_RequiresOriginalData) && dm) { modifier_setError(md, "Modifier requires original data, bad stack position."); return 0; } - if(mti->isDisabled && mti->isDisabled(md)) return 0; - if(!(mti->flags & eModifierTypeFlag_SupportsEditmode)) return 0; - if(md->mode & eModifierMode_DisableTemporary) return 0; return 1; } @@ -1882,6 +1877,7 @@ static void editmesh_calc_modifiers(Scene *scene, Object *ob, EditMesh *em, Deri DerivedMesh *dm, *orcodm = NULL; int i, numVerts = 0, cageIndex = modifiers_getCageIndex(ob, NULL); LinkNode *datamasks, *curr; + int required_mode = eModifierMode_Realtime | eModifierMode_Editmode; modifiers_clearErrors(ob); @@ -1895,7 +1891,7 @@ static void editmesh_calc_modifiers(Scene *scene, Object *ob, EditMesh *em, Deri /* we always want to keep original indices */ dataMask |= CD_MASK_ORIGINDEX; - datamasks = modifiers_calcDataMasks(md, dataMask); + datamasks = modifiers_calcDataMasks(ob, md, dataMask, required_mode); curr = datamasks; for(i = 0; md; i++, md = md->next, curr = curr->next) { @@ -1908,7 +1904,7 @@ static void editmesh_calc_modifiers(Scene *scene, Object *ob, EditMesh *em, Deri /* add an orco layer if needed by this modifier */ if(dm && mti->requiredDataMask) { - mask = mti->requiredDataMask(md); + mask = mti->requiredDataMask(ob, md); if(mask & CD_MASK_ORCO) add_orco_dm(ob, em, dm, orcodm); } diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index bb458cc7e25..f88e249d38c 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -581,6 +581,77 @@ void game_copy_pose(bPose **dst, bPose *src) *dst=out; } + +/* Only allowed for Poses with identical channels */ +void game_blend_poses(bPose *dst, bPose *src, float srcweight/*, short mode*/) +{ + short mode= ACTSTRIPMODE_BLEND; + + bPoseChannel *dchan; + const bPoseChannel *schan; + bConstraint *dcon, *scon; + float dstweight; + int i; + + switch (mode){ + case ACTSTRIPMODE_BLEND: + dstweight = 1.0F - srcweight; + break; + case ACTSTRIPMODE_ADD: + dstweight = 1.0F; + break; + default : + dstweight = 1.0F; + } + + schan= src->chanbase.first; + for (dchan = dst->chanbase.first; dchan; dchan=dchan->next, schan= schan->next){ + if (schan->flag & (POSE_ROT|POSE_LOC|POSE_SIZE)) { + /* replaced quat->matrix->quat conversion with decent quaternion interpol (ton) */ + + /* Do the transformation blend */ + if (schan->flag & POSE_ROT) { + /* quat interpolation done separate */ + if (schan->rotmode == PCHAN_ROT_QUAT) { + float dquat[4], squat[4]; + + QUATCOPY(dquat, dchan->quat); + QUATCOPY(squat, schan->quat); + if (mode==ACTSTRIPMODE_BLEND) + QuatInterpol(dchan->quat, dquat, squat, srcweight); + else { + QuatMulFac(squat, srcweight); + QuatMul(dchan->quat, dquat, squat); + } + + NormalQuat(dchan->quat); + } + } + + for (i=0; i<3; i++) { + /* blending for loc and scale are pretty self-explanatory... */ + if (schan->flag & POSE_LOC) + dchan->loc[i] = (dchan->loc[i]*dstweight) + (schan->loc[i]*srcweight); + if (schan->flag & POSE_SIZE) + dchan->size[i] = 1.0f + ((dchan->size[i]-1.0f)*dstweight) + ((schan->size[i]-1.0f)*srcweight); + + /* euler-rotation interpolation done here instead... */ + // FIXME: are these results decent? + if ((schan->flag & POSE_ROT) && (schan->rotmode)) + dchan->eul[i] = (dchan->eul[i]*dstweight) + (schan->eul[i]*srcweight); + } + dchan->flag |= schan->flag; + } + for(dcon= dchan->constraints.first, scon= schan->constraints.first; dcon && scon; dcon= dcon->next, scon= scon->next) { + /* no 'add' option for constraint blending */ + dcon->enforce= dcon->enforce*(1.0f-srcweight) + scon->enforce*srcweight; + } + } + + /* this pose is now in src time */ + dst->ctime= src->ctime; +} + void game_free_pose(bPose *pose) { if (pose) { @@ -795,6 +866,7 @@ void calc_action_range(const bAction *act, float *start, float *end, int incl_hi /* Copy the data from the action-pose (src) into the pose */ /* both args are assumed to be valid */ /* exported to game engine */ +/* Note! this assumes both poses are aligned, this isnt always true when dealing with user poses */ void extract_pose_from_pose(bPose *pose, const bPose *src) { const bPoseChannel *schan; @@ -805,7 +877,7 @@ void extract_pose_from_pose(bPose *pose, const bPose *src) return; } - for (schan=src->chanbase.first; schan; schan=schan->next, pchan= pchan->next) { + for (schan=src->chanbase.first; (schan && pchan); schan=schan->next, pchan= pchan->next) { copy_pose_channel_data(pchan, schan); } } @@ -1033,75 +1105,6 @@ static void blend_pose_offset_bone(bActionStrip *strip, bPose *dst, bPose *src, VecAddf(dst->cyclic_offset, dst->cyclic_offset, src->cyclic_offset); } - -/* Only allowed for Poses with identical channels */ -void blend_poses(bPose *dst, bPose *src, float srcweight, short mode) -{ - bPoseChannel *dchan; - const bPoseChannel *schan; - bConstraint *dcon, *scon; - float dstweight; - int i; - - switch (mode){ - case ACTSTRIPMODE_BLEND: - dstweight = 1.0F - srcweight; - break; - case ACTSTRIPMODE_ADD: - dstweight = 1.0F; - break; - default : - dstweight = 1.0F; - } - - schan= src->chanbase.first; - for (dchan = dst->chanbase.first; dchan; dchan=dchan->next, schan= schan->next){ - if (schan->flag & (POSE_ROT|POSE_LOC|POSE_SIZE)) { - /* replaced quat->matrix->quat conversion with decent quaternion interpol (ton) */ - - /* Do the transformation blend */ - if (schan->flag & POSE_ROT) { - /* quat interpolation done separate */ - if (schan->rotmode == PCHAN_ROT_QUAT) { - float dquat[4], squat[4]; - - QUATCOPY(dquat, dchan->quat); - QUATCOPY(squat, schan->quat); - if (mode==ACTSTRIPMODE_BLEND) - QuatInterpol(dchan->quat, dquat, squat, srcweight); - else { - QuatMulFac(squat, srcweight); - QuatMul(dchan->quat, dquat, squat); - } - - NormalQuat(dchan->quat); - } - } - - for (i=0; i<3; i++) { - /* blending for loc and scale are pretty self-explanatory... */ - if (schan->flag & POSE_LOC) - dchan->loc[i] = (dchan->loc[i]*dstweight) + (schan->loc[i]*srcweight); - if (schan->flag & POSE_SIZE) - dchan->size[i] = 1.0f + ((dchan->size[i]-1.0f)*dstweight) + ((schan->size[i]-1.0f)*srcweight); - - /* euler-rotation interpolation done here instead... */ - // FIXME: are these results decent? - if ((schan->flag & POSE_ROT) && (schan->rotmode)) - dchan->eul[i] = (dchan->eul[i]*dstweight) + (schan->eul[i]*srcweight); - } - dchan->flag |= schan->flag; - } - for(dcon= dchan->constraints.first, scon= schan->constraints.first; dcon && scon; dcon= dcon->next, scon= scon->next) { - /* no 'add' option for constraint blending */ - dcon->enforce= dcon->enforce*(1.0f-srcweight) + scon->enforce*srcweight; - } - } - - /* this pose is now in src time */ - dst->ctime= src->ctime; -} - typedef struct NlaIpoChannel { struct NlaIpoChannel *next, *prev; float val; diff --git a/source/blender/blenkernel/intern/booleanops.c b/source/blender/blenkernel/intern/booleanops.c index 27b78c6644c..eb3aefe7ee6 100644 --- a/source/blender/blenkernel/intern/booleanops.c +++ b/source/blender/blenkernel/intern/booleanops.c @@ -161,6 +161,7 @@ typedef struct { DerivedMesh *dm; int pos; int offset; + int flip; } FaceIt; static void FaceIt_Destruct(CSG_FaceIteratorDescriptor * iterator) @@ -187,9 +188,15 @@ static void FaceIt_Fill(CSG_IteratorPtr it, CSG_IFace *face) MFace *mfaces = face_it->dm->getFaceArray(face_it->dm); MFace *mface = &mfaces[face_it->pos]; - face->vertex_index[0] = mface->v1; + /* reverse face vertices if necessary */ face->vertex_index[1] = mface->v2; + if( face_it->flip == 0 ) { + face->vertex_index[0] = mface->v1; face->vertex_index[2] = mface->v3; + } else { + face->vertex_index[2] = mface->v1; + face->vertex_index[0] = mface->v3; + } if (mface->v4) { face->vertex_index[3] = mface->v4; face->vertex_number = 4; @@ -213,7 +220,7 @@ static void FaceIt_Reset(CSG_IteratorPtr it) } static void FaceIt_Construct( - CSG_FaceIteratorDescriptor *output, DerivedMesh *dm, int offset) + CSG_FaceIteratorDescriptor *output, DerivedMesh *dm, int offset, Object *ob) { FaceIt *it; if (output == 0) return; @@ -228,6 +235,25 @@ static void FaceIt_Construct( it->offset = offset; it->pos = 0; + /* determine if we will need to reverse order of face vertices */ + if (ob->size[0] < 0.0f) { + if (ob->size[1] < 0.0f && ob->size[2] < 0.0f) { + it->flip = 1; + } else if (ob->size[1] >= 0.0f && ob->size[2] >= 0.0f) { + it->flip = 1; + } else { + it->flip = 0; + } + } else { + if (ob->size[1] < 0.0f && ob->size[2] < 0.0f) { + it->flip = 0; + } else if (ob->size[1] >= 0.0f && ob->size[2] >= 0.0f) { + it->flip = 0; + } else { + it->flip = 1; + } + } + // assign iterator function pointers. output->Step = FaceIt_Step; output->Fill = FaceIt_Fill; @@ -425,7 +451,7 @@ static void BuildMeshDescriptors( struct CSG_VertexIteratorDescriptor * vertex_it) { VertexIt_Construct(vertex_it,dm, ob); - FaceIt_Construct(face_it,dm,face_offset); + FaceIt_Construct(face_it,dm,face_offset,ob); } static void FreeMeshDescriptors( diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index fab9669d55f..7dd868278f4 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -155,7 +155,7 @@ Curve *add_curve(char *name, int type) cu->str= MEM_mallocN(12, "str"); strcpy(cu->str, "Text"); cu->pos= 4; - cu->strinfo= MEM_callocN(12*sizeof(CharInfo), "strinfo"); + cu->strinfo= MEM_callocN(12*sizeof(CharInfo), "strinfo new"); cu->totbox= cu->actbox= 1; cu->tb= MEM_callocN(MAXTEXTBOX*sizeof(TextBox), "textbox"); cu->tb[0].w = cu->tb[0].h = 0.0; diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index dfe3b7ea279..8bb34bde122 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -61,6 +61,8 @@ #include "DNA_view2d_types.h" #include "DNA_view3d_types.h" +#include "BLI_ghash.h" + #include "BKE_action.h" #include "BKE_effect.h" #include "BKE_global.h" @@ -754,6 +756,9 @@ void free_forest(DagForest *Dag) itN = itN->next; MEM_freeN(tempN); } + + BLI_ghash_free(Dag->nodeHash, NULL, NULL); + Dag->nodeHash= NULL; Dag->DagNode.first = NULL; Dag->DagNode.last = NULL; Dag->numNodes = 0; @@ -762,13 +767,9 @@ void free_forest(DagForest *Dag) DagNode * dag_find_node (DagForest *forest,void * fob) { - DagNode *node = forest->DagNode.first; - - while (node) { - if (node->ob == fob) - return node; - node = node->next; - } + if(forest->nodeHash) + return BLI_ghash_lookup(forest->nodeHash, fob); + return NULL; } @@ -794,7 +795,12 @@ DagNode * dag_add_node (DagForest *forest, void * fob) forest->DagNode.first = node; forest->numNodes = 1; } + + if(!forest->nodeHash) + forest->nodeHash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp); + BLI_ghash_insert(forest->nodeHash, fob, node); } + return node; } @@ -1805,17 +1811,10 @@ static void flush_update_node(DagNode *node, unsigned int layer, int curtime) /* node was checked to have lasttime != curtime , and is of type ID_OB */ static unsigned int flush_layer_node(Scene *sce, DagNode *node, int curtime) { - Base *base; DagAdjList *itA; node->lasttime= curtime; - node->lay= 0; - for(base= sce->base.first; base; base= base->next) { - if(node->ob == base->object) { - node->lay= ((Object *)node->ob)->lay; - break; - } - } + node->lay= node->scelay; for(itA = node->child; itA; itA= itA->next) { if(itA->node->type==ID_OB) { @@ -1860,9 +1859,10 @@ static void flush_pointcache_reset(DagNode *node, int curtime, int reset) /* flushes all recalc flags in objects down the dependency tree */ void DAG_scene_flush_update(Scene *sce, unsigned int lay, int time) { - DagNode *firstnode; + DagNode *firstnode, *node; DagAdjList *itA; Object *ob; + Base *base; int lasttime; if(sce->theDag==NULL) { @@ -1879,6 +1879,15 @@ void DAG_scene_flush_update(Scene *sce, unsigned int lay, int time) sce->theDag->time++; // so we know which nodes were accessed lasttime= sce->theDag->time; + + for(base= sce->base.first; base; base= base->next) { + node= dag_get_node(sce->theDag, base->object); + if(node) + node->scelay= base->object->lay; + else + node->scelay= 0; + } + for(itA = firstnode->child; itA; itA= itA->next) if(itA->node->lasttime!=lasttime && itA->node->type==ID_OB) flush_layer_node(sce, itA->node, lasttime); diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index fe138407d54..736165a8a98 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1371,7 +1371,7 @@ static void displist_surf_indices(DispList *dl) } -void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, int forRender) +void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, int forRender, int forOrco) { ListBase *nubase; Nurb *nu; @@ -1388,7 +1388,8 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, int forRende else nubase= &cu->nurb; - curve_calc_modifiers_pre(scene, ob, forRender, &originalVerts, &deformedVerts, &numVerts); + if(!forOrco) + curve_calc_modifiers_pre(scene, ob, forRender, &originalVerts, &deformedVerts, &numVerts); for (nu=nubase->first; nu; nu=nu->next) { if(forRender || nu->hide==0) { @@ -1442,7 +1443,8 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, int forRende tex_space_curve(cu); } - curve_calc_modifiers_post(scene, ob, dispbase, forRender, originalVerts, deformedVerts); + if(!forOrco) + curve_calc_modifiers_post(scene, ob, dispbase, forRender, originalVerts, deformedVerts); } void makeDispListCurveTypes(Scene *scene, Object *ob, int forOrco) @@ -1458,7 +1460,7 @@ void makeDispListCurveTypes(Scene *scene, Object *ob, int forOrco) freedisplist(dispbase); if(ob->type==OB_SURF) { - makeDispListSurf(scene, ob, dispbase, 0); + makeDispListSurf(scene, ob, dispbase, 0, forOrco); } else if (ELEM(ob->type, OB_CURVE, OB_FONT)) { ListBase dlbev; diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index c3cf6e06c09..60a7ffc28d9 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -682,7 +682,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) cu->ulheight = 0.05; if (cu->strinfo==NULL) /* old file */ - cu->strinfo = MEM_callocN((slen+1) * sizeof(CharInfo), "strinfo compat"); + cu->strinfo = MEM_callocN((slen+4) * sizeof(CharInfo), "strinfo compat"); custrinfo= cu->strinfo; if (cu->editfont) @@ -1145,7 +1145,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) if (cu->sepchar==0) { for (i= 0; i<slen; i++) { cha = (uintptr_t) mem[i]; - info = &(cu->strinfo[i]); + info = &(custrinfo[i]); if (info->mat_nr > (ob->totcol)) { /* printf("Error: Illegal material index (%d) in text object, setting to 0\n", info->mat_nr); */ info->mat_nr = 0; diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 8cbf25eaeed..54618813a0b 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -235,17 +235,15 @@ static char *ob_adrcodes_to_paths (int adrcode, int *array_index) *array_index= 1; return "delta_scale"; case OB_DSIZE_Z: *array_index= 2; return "delta_scale"; - -#if 0 - case OB_COL_R: - poin= &(ob->col[0]); break; + case OB_COL_R: + *array_index= 0; return "color"; case OB_COL_G: - poin= &(ob->col[1]); break; + *array_index= 1; return "color"; case OB_COL_B: - poin= &(ob->col[2]); break; + *array_index= 2; return "color"; case OB_COL_A: - poin= &(ob->col[3]); break; - + *array_index= 3; return "color"; +#if 0 case OB_PD_FSTR: if (ob->pd) poin= &(ob->pd->f_strength); break; @@ -545,7 +543,7 @@ static char *material_adrcodes_to_paths (int adrcode, int *array_index) return "ambient"; case MA_SPEC: - return "specularity"; + return "specular_reflection"; case MA_HARD: return "specular_hardness"; @@ -1515,14 +1513,7 @@ void do_versions_ipos_to_animato(Main *main) /* Add AnimData block */ adt= BKE_id_add_animdata(id); - /* IPO first */ - if (ob->ipo) { - ipo_to_animdata(id, ob->ipo, NULL, NULL); - ob->ipo->id.us--; - ob->ipo= NULL; - } - - /* now Action */ + /* Action first - so that Action name get conserved */ if (ob->action) { action_to_animdata(id, ob->action); @@ -1533,6 +1524,13 @@ void do_versions_ipos_to_animato(Main *main) } } + /* IPO second... */ + if (ob->ipo) { + ipo_to_animdata(id, ob->ipo, NULL, NULL); + ob->ipo->id.us--; + ob->ipo= NULL; + } + /* finally NLA */ // XXX todo... for now, new NLA code not hooked up yet, so keep old stuff (but not for too long!) } diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 6ebd68e990f..bf3d27cafbf 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -117,6 +117,72 @@ static struct DerivedMesh *NewBooleanDerivedMesh() {return NULL;} //XXX #include "BIF_meshlaplacian.h" +/* Utility */ + +static int is_last_displist(Object *ob) +{ + Curve *cu = ob->data; + static int curvecount=0, totcurve=0; + + if(curvecount == 0){ + DispList *dl; + + totcurve = 0; + for(dl=cu->disp.first; dl; dl=dl->next) + totcurve++; + } + + curvecount++; + + if(curvecount == totcurve){ + curvecount = 0; + return 1; + } + + return 0; +} + +static DerivedMesh *get_original_dm(Scene *scene, Object *ob, float (*vertexCos)[3], int orco) +{ + DerivedMesh *dm= NULL; + + if(ob->type==OB_MESH) { + dm = CDDM_from_mesh((Mesh*)(ob->data), ob); + + if(vertexCos) { + CDDM_apply_vert_coords(dm, vertexCos); + //CDDM_calc_normals(dm); + } + + if(orco) + DM_add_vert_layer(dm, CD_ORCO, CD_ASSIGN, get_mesh_orco_verts(ob)); + } + else if(ELEM3(ob->type,OB_FONT,OB_CURVE,OB_SURF)) { + Object *tmpobj; + Curve *tmpcu; + + if(is_last_displist(ob)) { + /* copies object and modifiers (but not the data) */ + tmpobj= copy_object(ob); + tmpcu = (Curve *)tmpobj->data; + tmpcu->id.us--; + + /* copies the data */ + tmpobj->data = copy_curve((Curve *) ob->data); + + makeDispListCurveTypes(scene, tmpobj, 1); + nurbs_to_mesh(tmpobj); + + dm = CDDM_from_mesh((Mesh*)(tmpobj->data), tmpobj); + //CDDM_calc_normals(dm); + + free_libblock_us(&G.main->object, tmpobj); + } + } + + return dm; +} + /***/ static int noneModifier_isDisabled(ModifierData *md) @@ -143,7 +209,7 @@ static void curveModifier_copyData(ModifierData *md, ModifierData *target) strncpy(tcmd->name, cmd->name, 32); } -CustomDataMask curveModifier_requiredDataMask(ModifierData *md) +CustomDataMask curveModifier_requiredDataMask(Object *ob, ModifierData *md) { CurveModifierData *cmd = (CurveModifierData *)md; CustomDataMask dataMask = 0; @@ -219,7 +285,7 @@ static void latticeModifier_copyData(ModifierData *md, ModifierData *target) strncpy(tlmd->name, lmd->name, 32); } -CustomDataMask latticeModifier_requiredDataMask(ModifierData *md) +CustomDataMask latticeModifier_requiredDataMask(Object *ob, ModifierData *md) { LatticeModifierData *lmd = (LatticeModifierData *)md; CustomDataMask dataMask = 0; @@ -602,7 +668,7 @@ static void maskModifier_copyData(ModifierData *md, ModifierData *target) strcpy(tmmd->vgroup, mmd->vgroup); } -static CustomDataMask maskModifier_requiredDataMask(ModifierData *md) +static CustomDataMask maskModifier_requiredDataMask(Object *ob, ModifierData *md) { return (1 << CD_MDEFORMVERT); } @@ -3330,7 +3396,7 @@ static void bevelModifier_copyData(ModifierData *md, ModifierData *target) strncpy(tbmd->defgrp_name, bmd->defgrp_name, 32); } -CustomDataMask bevelModifier_requiredDataMask(ModifierData *md) +CustomDataMask bevelModifier_requiredDataMask(Object *ob, ModifierData *md) { BevelModifierData *bmd = (BevelModifierData *)md; CustomDataMask dataMask = 0; @@ -3410,7 +3476,7 @@ static void displaceModifier_copyData(ModifierData *md, ModifierData *target) strncpy(tdmd->uvlayer_name, dmd->uvlayer_name, 32); } -CustomDataMask displaceModifier_requiredDataMask(ModifierData *md) +CustomDataMask displaceModifier_requiredDataMask(Object *ob, ModifierData *md) { DisplaceModifierData *dmd = (DisplaceModifierData *)md; CustomDataMask dataMask = 0; @@ -3753,7 +3819,7 @@ static void uvprojectModifier_copyData(ModifierData *md, ModifierData *target) tumd->aspecty = umd->aspecty; } -CustomDataMask uvprojectModifier_requiredDataMask(ModifierData *md) +CustomDataMask uvprojectModifier_requiredDataMask(Object *ob, ModifierData *md) { CustomDataMask dataMask = 0; @@ -4219,7 +4285,7 @@ int smoothModifier_isDisabled(ModifierData *md) return 0; } -CustomDataMask smoothModifier_requiredDataMask(ModifierData *md) +CustomDataMask smoothModifier_requiredDataMask(Object *ob, ModifierData *md) { SmoothModifierData *smd = (SmoothModifierData *)md; CustomDataMask dataMask = 0; @@ -4448,7 +4514,7 @@ int castModifier_isDisabled(ModifierData *md) return 0; } -CustomDataMask castModifier_requiredDataMask(ModifierData *md) +CustomDataMask castModifier_requiredDataMask(Object *ob, ModifierData *md) { CastModifierData *cmd = (CastModifierData *)md; CustomDataMask dataMask = 0; @@ -5079,7 +5145,7 @@ static void waveModifier_updateDepgraph( } } -CustomDataMask waveModifier_requiredDataMask(ModifierData *md) +CustomDataMask waveModifier_requiredDataMask(Object *ob, ModifierData *md) { WaveModifierData *wmd = (WaveModifierData *)md; CustomDataMask dataMask = 0; @@ -5416,7 +5482,7 @@ static void armatureModifier_copyData(ModifierData *md, ModifierData *target) strncpy(tamd->defgrp_name, amd->defgrp_name, 32); } -CustomDataMask armatureModifier_requiredDataMask(ModifierData *md) +CustomDataMask armatureModifier_requiredDataMask(Object *ob, ModifierData *md) { CustomDataMask dataMask = 0; @@ -5530,7 +5596,7 @@ static void hookModifier_copyData(ModifierData *md, ModifierData *target) strncpy(thmd->name, hmd->name, 32); } -CustomDataMask hookModifier_requiredDataMask(ModifierData *md) +CustomDataMask hookModifier_requiredDataMask(Object *ob, ModifierData *md) { HookModifierData *hmd = (HookModifierData *)md; CustomDataMask dataMask = 0; @@ -5789,7 +5855,7 @@ static void clothModifier_updateDepgraph( } } -CustomDataMask clothModifier_requiredDataMask(ModifierData *md) +CustomDataMask clothModifier_requiredDataMask(Object *ob, ModifierData *md) { CustomDataMask dataMask = 0; @@ -6046,7 +6112,8 @@ static void surfaceModifier_freeData(ModifierData *md) MEM_freeN(surmd->bvhtree); } - surmd->dm->release(surmd->dm); + if(surmd->dm) + surmd->dm->release(surmd->dm); surmd->bvhtree = NULL; surmd->dm = NULL; @@ -6070,7 +6137,7 @@ static void surfaceModifier_deformVerts( /* if possible use/create DerivedMesh */ if(derivedData) surmd->dm = CDDM_copy(derivedData); - else if(ob->type==OB_MESH) surmd->dm = CDDM_from_mesh(ob->data, ob); + else surmd->dm = get_original_dm(md->scene, ob, NULL, 0); if(!ob->pd) { @@ -6172,7 +6239,7 @@ static DerivedMesh *booleanModifier_applyModifier( return derivedData; } -CustomDataMask booleanModifier_requiredDataMask(ModifierData *md) +CustomDataMask booleanModifier_requiredDataMask(Object *ob, ModifierData *md) { CustomDataMask dataMask = (1 << CD_MTFACE) + (1 << CD_MEDGE); @@ -6220,12 +6287,27 @@ static void particleSystemModifier_copyData(ModifierData *md, ModifierData *targ tpsmd->psys = psmd->psys; } -CustomDataMask particleSystemModifier_requiredDataMask(ModifierData *md) +CustomDataMask particleSystemModifier_requiredDataMask(Object *ob, ModifierData *md) { ParticleSystemModifierData *psmd= (ParticleSystemModifierData*) md; - CustomDataMask dataMask = (1 << CD_MTFACE) + (1 << CD_MEDGE); + CustomDataMask dataMask = 0; + Material *ma; + MTex *mtex; int i; + ma= give_current_material(ob, psmd->psys->part->omat); + if(ma) { + for(i=0; i<MAX_MTEX; i++) { + mtex=ma->mtex[i]; + if(mtex && (ma->septex & (1<<i))==0) + if(mtex->pmapto && (mtex->texco & TEXCO_UV)) + dataMask |= (1 << CD_MTFACE); + } + } + + if(psmd->psys->part->tanfac!=0.0) + dataMask |= (1 << CD_MTFACE); + /* ask for vertexgroups if we need them */ for(i=0; i<PSYS_TOT_VG; i++){ if(psmd->psys->vgroup[i]){ @@ -6242,70 +6324,6 @@ CustomDataMask particleSystemModifier_requiredDataMask(ModifierData *md) return dataMask; } -static int is_last_displist(Object *ob) -{ - Curve *cu = ob->data; - static int curvecount=0, totcurve=0; - - if(curvecount==0){ - DispList *dl; - - totcurve=0; - for(dl=cu->disp.first; dl; dl=dl->next){ - totcurve++; - } - } - - curvecount++; - - if(curvecount==totcurve){ - curvecount=0; - return 1; - } - - return 0; -} - -static DerivedMesh *get_original_dm(Scene *scene, Object *ob, float (*vertexCos)[3], int orco) -{ - DerivedMesh *dm= NULL; - - if(ob->type==OB_MESH) { - dm = CDDM_from_mesh((Mesh*)(ob->data), ob); - - if(vertexCos) { - CDDM_apply_vert_coords(dm, vertexCos); - //CDDM_calc_normals(dm); - } - - if(orco) - DM_add_vert_layer(dm, CD_ORCO, CD_ASSIGN, get_mesh_orco_verts(ob)); - } - else if(ELEM3(ob->type,OB_FONT,OB_CURVE,OB_SURF)) { - Object *tmpobj; - Curve *tmpcu; - - if(is_last_displist(ob)) { - /* copies object and modifiers (but not the data) */ - tmpobj= copy_object(ob); - tmpcu = (Curve *)tmpobj->data; - tmpcu->id.us--; - - /* copies the data */ - tmpobj->data = copy_curve((Curve *) ob->data); - - makeDispListCurveTypes(scene, tmpobj, 1); - nurbs_to_mesh(tmpobj); - - dm = CDDM_from_mesh((Mesh*)(tmpobj->data), tmpobj); - //CDDM_calc_normals(dm); - - free_libblock_us(&G.main->object, tmpobj); - } - } - - return dm; -} /* saves the current emitter state for a particle system and calculates particles */ static void particleSystemModifier_deformVerts( @@ -6634,7 +6652,7 @@ static int explodeModifier_dependsOnTime(ModifierData *md) { return 1; } -CustomDataMask explodeModifier_requiredDataMask(ModifierData *md) +CustomDataMask explodeModifier_requiredDataMask(Object *ob, ModifierData *md) { ExplodeModifierData *emd= (ExplodeModifierData*) md; CustomDataMask dataMask = 0; @@ -7548,7 +7566,7 @@ static void meshdeformModifier_copyData(ModifierData *md, ModifierData *target) tmmd->object = mmd->object; } -CustomDataMask meshdeformModifier_requiredDataMask(ModifierData *md) +CustomDataMask meshdeformModifier_requiredDataMask(Object *ob, ModifierData *md) { MeshDeformModifierData *mmd = (MeshDeformModifierData *)md; CustomDataMask dataMask = 0; @@ -7812,10 +7830,12 @@ static void meshdeformModifier_deformVerts( { DerivedMesh *dm; - if(!derivedData && ob->type==OB_MESH) - dm= CDDM_from_mesh(ob->data, ob); - else - dm= derivedData; + if (!derivedData) { + dm= get_original_dm(md->scene, ob, NULL, 0); + if (dm == NULL) return; + } + else dm= derivedData; + modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */ @@ -7927,7 +7947,7 @@ static void shrinkwrapModifier_copyData(ModifierData *md, ModifierData *target) tsmd->subsurfLevels = smd->subsurfLevels; } -CustomDataMask shrinkwrapModifier_requiredDataMask(ModifierData *md) +CustomDataMask shrinkwrapModifier_requiredDataMask(Object *ob, ModifierData *md) { ShrinkwrapModifierData *smd = (ShrinkwrapModifierData *)md; CustomDataMask dataMask = 0; @@ -7961,7 +7981,7 @@ static void shrinkwrapModifier_foreachObjectLink(ModifierData *md, Object *ob, O static void shrinkwrapModifier_deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) { DerivedMesh *dm = NULL; - CustomDataMask dataMask = shrinkwrapModifier_requiredDataMask(md); + CustomDataMask dataMask = shrinkwrapModifier_requiredDataMask(ob, md); /* We implement requiredDataMask but thats not really usefull since mesh_calc_modifiers pass a NULL derivedData or without the modified vertexs applied */ if(dataMask) @@ -7987,7 +8007,7 @@ static void shrinkwrapModifier_deformVerts(ModifierData *md, Object *ob, Derived static void shrinkwrapModifier_deformVertsEM(ModifierData *md, Object *ob, EditMesh *editData, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm = NULL; - CustomDataMask dataMask = shrinkwrapModifier_requiredDataMask(md); + CustomDataMask dataMask = shrinkwrapModifier_requiredDataMask(ob, md); if(dataMask) { @@ -8046,7 +8066,7 @@ static void simpledeformModifier_copyData(ModifierData *md, ModifierData *target memcpy(tsmd->limit, smd->limit, sizeof(tsmd->limit)); } -static CustomDataMask simpledeformModifier_requiredDataMask(ModifierData *md) +static CustomDataMask simpledeformModifier_requiredDataMask(Object *ob, ModifierData *md) { SimpleDeformModifierData *smd = (SimpleDeformModifierData *)md; CustomDataMask dataMask = 0; @@ -8075,7 +8095,7 @@ static void simpledeformModifier_updateDepgraph(ModifierData *md, DagForest *for static void simpledeformModifier_deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) { DerivedMesh *dm = NULL; - CustomDataMask dataMask = simpledeformModifier_requiredDataMask(md); + CustomDataMask dataMask = simpledeformModifier_requiredDataMask(ob, md); /* We implement requiredDataMask but thats not really usefull since mesh_calc_modifiers pass a NULL derivedData or without the modified vertexs applied */ if(dataMask) @@ -8102,7 +8122,7 @@ static void simpledeformModifier_deformVerts(ModifierData *md, Object *ob, Deriv static void simpledeformModifier_deformVertsEM(ModifierData *md, Object *ob, EditMesh *editData, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm = NULL; - CustomDataMask dataMask = simpledeformModifier_requiredDataMask(md); + CustomDataMask dataMask = simpledeformModifier_requiredDataMask(ob, md); /* We implement requiredDataMask but thats not really usefull since mesh_calc_modifiers pass a NULL derivedData or without the modified vertexs applied */ if(dataMask) @@ -8714,7 +8734,20 @@ int modifiers_isParticleEnabled(Object *ob) return (md && md->mode & (eModifierMode_Realtime | eModifierMode_Render)); } -LinkNode *modifiers_calcDataMasks(ModifierData *md, CustomDataMask dataMask) +int modifier_isEnabled(ModifierData *md, int required_mode) +{ + ModifierTypeInfo *mti = modifierType_getInfo(md->type); + + if((md->mode & required_mode) != required_mode) return 0; + if(mti->isDisabled && mti->isDisabled(md)) return 0; + if(md->mode & eModifierMode_DisableTemporary) return 0; + if(required_mode & eModifierMode_Editmode) + if(!(mti->flags & eModifierTypeFlag_SupportsEditmode)) return 0; + + return 1; +} + +LinkNode *modifiers_calcDataMasks(Object *ob, ModifierData *md, CustomDataMask dataMask, int required_mode) { LinkNode *dataMasks = NULL; LinkNode *curr, *prev; @@ -8724,7 +8757,9 @@ LinkNode *modifiers_calcDataMasks(ModifierData *md, CustomDataMask dataMask) ModifierTypeInfo *mti = modifierType_getInfo(md->type); CustomDataMask mask = 0; - if(mti->requiredDataMask) mask = mti->requiredDataMask(md); + if(modifier_isEnabled(md, required_mode)) + if(mti->requiredDataMask) + mask = mti->requiredDataMask(ob, md); BLI_linklist_prepend(&dataMasks, SET_INT_IN_POINTER(mask)); } diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index a83b8817580..0f42ba0d2e2 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -3050,6 +3050,7 @@ static void registerTextureNodes(ListBase *ntypelist) nodeRegisterType(ntypelist, &tex_node_rotate); nodeRegisterType(ntypelist, &tex_node_translate); nodeRegisterType(ntypelist, &tex_node_scale); + nodeRegisterType(ntypelist, &tex_node_at); nodeRegisterType(ntypelist, &tex_node_proc_voronoi); nodeRegisterType(ntypelist, &tex_node_proc_blend); diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 74a754c0ca8..34e69b2d736 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3169,7 +3169,7 @@ static void get_cpa_texture(DerivedMesh *dm, Material *ma, int face_index, float if(ma) for(m=0; m<MAX_MTEX; m++){ mtex=ma->mtex[m]; - if(mtex && (ma->septex & (1<<m))==0){ + if(mtex && (ma->septex & (1<<m))==0 && mtex->pmapto){ float def=mtex->def_var; float var=mtex->varfac; short blend=mtex->blendtype; @@ -3218,7 +3218,7 @@ void psys_get_texture(Object *ob, Material *ma, ParticleSystemModifierData *psmd if(ma) for(m=0; m<MAX_MTEX; m++){ mtex=ma->mtex[m]; - if(mtex && (ma->septex & (1<<m))==0){ + if(mtex && (ma->septex & (1<<m))==0 && mtex->pmapto){ float var=mtex->varfac; float def=mtex->def_var; short blend=mtex->blendtype; diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index c0ef92b489e..52f13eeadb8 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -1300,9 +1300,23 @@ int psys_threads_init_distribution(ParticleThread *threads, Scene *scene, Derive /* for hair, sort by origindex, allows optimizations in rendering */ /* however with virtual parents the children need to be in random order */ if(part->type == PART_HAIR && !(part->childtype==PART_CHILD_FACES && part->parents!=0.0)) { - COMPARE_ORIG_INDEX= dm->getFaceDataArray(dm, CD_ORIGINDEX); - if(COMPARE_ORIG_INDEX) - qsort(index, totpart, sizeof(int), compare_orig_index); + if(from != PART_FROM_PARTICLE) { + COMPARE_ORIG_INDEX = NULL; + + if(from == PART_FROM_VERT) { + if(dm->numVertData) + COMPARE_ORIG_INDEX= dm->getVertDataArray(dm, CD_ORIGINDEX); + } + else { + if(dm->numFaceData) + COMPARE_ORIG_INDEX= dm->getFaceDataArray(dm, CD_ORIGINDEX); + } + + if(COMPARE_ORIG_INDEX) { + qsort(index, totpart, sizeof(int), compare_orig_index); + COMPARE_ORIG_INDEX = NULL; + } + } } /* weights are no longer used except for FROM_PARTICLE, which needs them zeroed for indexing */ @@ -1747,7 +1761,10 @@ void reset_particle(Scene *scene, ParticleData *pa, ParticleSystem *psys, Partic where_is_object_time(scene, ob,pa->time); /* get birth location from object */ - psys_particle_on_emitter(psmd,part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,utan,vtan,0,0); + if(part->tanfac!=0.0) + psys_particle_on_emitter(psmd,part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,utan,vtan,0,0); + else + psys_particle_on_emitter(psmd,part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,0,0,0,0); /* save local coordinates for later */ VECCOPY(tloc,loc); diff --git a/source/blender/blenkernel/intern/sequence.c b/source/blender/blenkernel/intern/sequence.c index 3365af36f8c..bb0665a5b0f 100644 --- a/source/blender/blenkernel/intern/sequence.c +++ b/source/blender/blenkernel/intern/sequence.c @@ -1288,7 +1288,7 @@ static void seq_proxy_build_frame(Scene *scene, Sequence * seq, int cfra, int re depth = 32 is intentionally left in, otherwise ALPHA channels won't work... */ - quality = 90; + quality = seq->strip->proxy->quality; ibuf->ftype= JPG | quality; BLI_make_existing_file(name); @@ -1305,6 +1305,7 @@ static void seq_proxy_build_frame(Scene *scene, Sequence * seq, int cfra, int re void seq_proxy_rebuild(Scene *scene, Sequence * seq) { int cfra; + float rsize = seq->strip->proxy->size; waitcursor(1); @@ -1322,6 +1323,8 @@ void seq_proxy_rebuild(Scene *scene, Sequence * seq) tse->flag &= ~STRIPELEM_PREVIEW_DONE; } + + /* a _lot_ faster for movie files, if we read frames in sequential order */ if (seq->flag & SEQ_REVERSE_FRAMES) { @@ -1330,7 +1333,8 @@ void seq_proxy_rebuild(Scene *scene, Sequence * seq) TStripElem * tse = give_tstripelem(seq, cfra); if (!(tse->flag & STRIPELEM_PREVIEW_DONE)) { - seq_proxy_build_frame(scene, seq, cfra, scene->r.size); +//XXX set_timecursor(cfra); + seq_proxy_build_frame(scene, seq, cfra, rsize); tse->flag |= STRIPELEM_PREVIEW_DONE; } if (blender_test_break()) { @@ -1343,7 +1347,8 @@ void seq_proxy_rebuild(Scene *scene, Sequence * seq) TStripElem * tse = give_tstripelem(seq, cfra); if (!(tse->flag & STRIPELEM_PREVIEW_DONE)) { - seq_proxy_build_frame(scene, seq, cfra, scene->r.size); +//XXX set_timecursor(cfra); + seq_proxy_build_frame(scene, seq, cfra, rsize); tse->flag |= STRIPELEM_PREVIEW_DONE; } if (blender_test_break()) { @@ -1552,7 +1557,8 @@ static int input_have_to_preprocess(Scene *scene, Sequence * seq, TStripElem* se mul = seq->mul; - if(seq->blend_mode == SEQ_BLEND_REPLACE) { + if(seq->blend_mode == SEQ_BLEND_REPLACE && + !(seq->type & SEQ_EFFECT)) { #if 0 // XXX old animation system if (seq->ipo && seq->ipo->curve.first) { do_seq_ipo(scene, seq, cfra); @@ -1897,10 +1903,14 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int input_preprocess(scene, seq, se, cfra); } } else if(seq->type & SEQ_EFFECT) { + int use_preprocess = FALSE; /* should the effect be recalculated? */ if (!build_proxy_run && se->ibuf == 0) { se->ibuf = seq_proxy_fetch(scene, seq, cfra, render_size); + if (se->ibuf) { + use_preprocess = TRUE; + } } if(se->ibuf == 0) { @@ -1913,6 +1923,22 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int se->ibuf= IMB_allocImBuf((short)seqrectx, (short)seqrecty, 32, IB_rect, 0); do_effect(scene, cfra, seq, se); + if (input_have_to_preprocess(scene, seq, se, cfra) && + !build_proxy_run) { + if ((se->se1 && (se->ibuf == se->se1->ibuf)) || + (se->se2 && (se->ibuf == se->se2->ibuf))) { + struct ImBuf * i + = IMB_dupImBuf(se->ibuf); + + IMB_freeImBuf(se->ibuf); + + se->ibuf = i; + } + use_preprocess = TRUE; + } + } + if (use_preprocess) { + input_preprocess(scene, seq, se, cfra); } } else if(seq->type == SEQ_IMAGE) { if(se->ok == STRIPELEM_OK && se->ibuf == 0) { @@ -2067,8 +2093,8 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int // XXX #if 0 if((G.f & G_PLAYANIM)==0 /* bad, is set on do_render_seq */ - && !(sce->r.scemode & R_DOSEQ)) - waitcursor(0); + && !(sce->r.scemode & R_DOSEQ) + && !build_proxy_run) #endif CFRA = oldcfra; @@ -3116,6 +3142,17 @@ void update_changed_seq_and_deps(Scene *scene, Sequence *changed_seq, int len_ch update_changed_seq_recurs(scene, seq, changed_seq, len_change, ibuf_change); } +#if 0 // XXX from 2.4x, needs updating +void free_imbuf_seq() +{ + Scene * sce = G.main->scene.first; + while(sce) { + free_imbuf_seq_editing(sce->ed); + sce= sce->id.next; + } +} +#endif + void free_imbuf_seq_with_ipo(Scene *scene, struct Ipo *ipo) { /* force update of all sequences with this ipo, on ipo changes */ @@ -3140,9 +3177,14 @@ void free_imbuf_seq_with_ipo(Scene *scene, struct Ipo *ipo) /* bad levell call... */ void do_render_seq(RenderResult *rr, int cfra) { + static int recurs_depth = 0 ImBuf *ibuf; - ibuf= give_ibuf_seq(scene, rr->rectx, rr->recty, cfra, 0, scene->r.size); + recurs_depth++; + + ibuf= give_ibuf_seq(rr->rectx, rr->recty, cfra, 0, 100.0); + + recurs_depth--; if(ibuf) { if(ibuf->rect_float) { @@ -3179,7 +3221,7 @@ void do_render_seq(RenderResult *rr, int cfra) on freeing _all_ buffers every time on long timelines...) (schlaile) */ - { + if (recurs_depth == 0) { /* with nested scenes, only free on toplevel... */ uintptr_t mem_in_use; uintptr_t mmap_in_use; uintptr_t max; diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c index 0f2a6179964..bde4b561f26 100644 --- a/source/blender/blenlib/intern/freetypefont.c +++ b/source/blender/blenlib/intern/freetypefont.c @@ -294,9 +294,12 @@ int objchr_to_ftvfontdata(VFont *vfont, FT_ULong charcode) tf->pf->size, 0, &face); + if (err) return FALSE; + } + else { + err = TRUE; + return FALSE; } - else - err= TRUE; // Read the char freetypechar_to_vchar(face, charcode, vfont->data); diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 31f97e1d41d..74226cabba6 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3881,12 +3881,19 @@ static void lib_link_scene(FileData *fd, Main *main) sce->world= newlibadr_us(fd, sce->id.lib, sce->world); sce->set= newlibadr(fd, sce->id.lib, sce->set); sce->ima= newlibadr_us(fd, sce->id.lib, sce->ima); + sce->toolsettings->imapaint.brush= newlibadr_us(fd, sce->id.lib, sce->toolsettings->imapaint.brush); if(sce->toolsettings->sculpt) sce->toolsettings->sculpt->brush= newlibadr_us(fd, sce->id.lib, sce->toolsettings->sculpt->brush); - + if(sce->toolsettings->vpaint) + sce->toolsettings->vpaint->brush= + newlibadr_us(fd, sce->id.lib, sce->toolsettings->vpaint->brush); + if(sce->toolsettings->wpaint) + sce->toolsettings->wpaint->brush= + newlibadr_us(fd, sce->id.lib, sce->toolsettings->wpaint->brush); + sce->toolsettings->skgen_template = newlibadr(fd, sce->id.lib, sce->toolsettings->skgen_template); for(base= sce->base.first; base; base= next) { @@ -4785,6 +4792,14 @@ static void direct_link_screen(FileData *fd, bScreen *sc) } snode->nodetree= snode->edittree= NULL; } + else if(sl->spacetype==SPACE_LOGIC) { + SpaceLogic *slogic= (SpaceLogic *)sl; + + if(slogic->gpd) { + slogic->gpd= newdataadr(fd, slogic->gpd); + direct_link_gpencil(fd, slogic->gpd); + } + } else if(sl->spacetype==SPACE_SEQ) { SpaceSeq *sseq= (SpaceSeq *)sl; if(sseq->gpd) { @@ -9181,6 +9196,34 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } + if (main->versionfile < 249 && main->subversionfile < 2) { + Scene *sce= main->scene.first; + Sequence *seq; + Editing *ed; + + while(sce) { + ed= sce->ed; + if(ed) { + SEQP_BEGIN(ed, seq) { + if (seq->strip && seq->strip->proxy){ + if (sce->r.size != 100.0) { + seq->strip->proxy->size + = sce->r.size; + } else { + seq->strip->proxy->size + = 25.0; + } + seq->strip->proxy->quality =90; + } + } + SEQ_END + } + + sce= sce->id.next; + } + + } + /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ /* WATCH IT 2!: Userdef struct init has to be in src/usiblender.c! */ diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 5cf46b6fd28..0c385911721 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1920,6 +1920,9 @@ static void write_screens(WriteData *wd, ListBase *scrbase) else if(sl->spacetype==SPACE_NODE){ writestruct(wd, DATA, "SpaceNode", 1, sl); } + else if(sl->spacetype==SPACE_LOGIC){ + writestruct(wd, DATA, "SpaceLogic", 1, sl); + } sl= sl->next; } } diff --git a/source/blender/editors/Makefile b/source/blender/editors/Makefile index 8a819195fbd..62bf612b09d 100644 --- a/source/blender/editors/Makefile +++ b/source/blender/editors/Makefile @@ -29,6 +29,6 @@ # Bounces make to subdirectories. SOURCEDIR = source/blender/editors -DIRS = armature mesh animation object sculpt_paint datafiles transform screen curve gpencil physics preview uvedit space_outliner space_time space_view3d interface util space_api space_graph space_image space_node space_buttons space_info space_file space_sound space_action space_nla space_script space_text space_sequencer +DIRS = armature mesh animation object sculpt_paint datafiles transform screen curve gpencil physics preview uvedit space_outliner space_time space_view3d interface util space_api space_graph space_image space_node space_buttons space_info space_file space_sound space_action space_nla space_script space_text space_sequencer space_logic include nan_subdirs.mk diff --git a/source/blender/editors/SConscript b/source/blender/editors/SConscript index a99d21b19a4..9baaf7ae7a5 100644 --- a/source/blender/editors/SConscript +++ b/source/blender/editors/SConscript @@ -29,6 +29,7 @@ SConscript(['datafiles/SConscript', 'space_script/SConscript', 'space_text/SConscript', 'space_sequencer/SConscript', + 'space_logic/SConscript', 'transform/SConscript', 'screen/SConscript', 'sculpt_paint/SConscript', diff --git a/source/blender/editors/animation/anim_channels.c b/source/blender/editors/animation/anim_channels.c index 2944c9519b9..d753f65ff50 100644 --- a/source/blender/editors/animation/anim_channels.c +++ b/source/blender/editors/animation/anim_channels.c @@ -719,17 +719,17 @@ enum { /* defines for setting animation-channel flags */ EnumPropertyItem prop_animchannel_setflag_types[] = { - {ACHANNEL_SETFLAG_CLEAR, "DISABLE", "Disable", ""}, - {ACHANNEL_SETFLAG_ADD, "ENABLE", "Enable", ""}, - {ACHANNEL_SETFLAG_TOGGLE, "TOGGLE", "Toggle", ""}, - {0, NULL, NULL, NULL} + {ACHANNEL_SETFLAG_CLEAR, "DISABLE", 0, "Disable", ""}, + {ACHANNEL_SETFLAG_ADD, "ENABLE", 0, "Enable", ""}, + {ACHANNEL_SETFLAG_TOGGLE, "TOGGLE", 0, "Toggle", ""}, + {0, NULL, 0, NULL, NULL} }; /* defines for set animation-channel settings */ EnumPropertyItem prop_animchannel_settings_types[] = { - {ACHANNEL_SETTING_PROTECT, "PROTECT", "Protect", ""}, - {ACHANNEL_SETTING_MUTE, "MUTE", "Mute", ""}, - {0, NULL, NULL, NULL} + {ACHANNEL_SETTING_PROTECT, "PROTECT", 0, "Protect", ""}, + {ACHANNEL_SETTING_MUTE, "MUTE", 0, "Mute", ""}, + {0, NULL, 0, NULL, NULL} }; diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index 0f5cef51bdb..1813c76d0c4 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -106,10 +106,10 @@ void ANIM_OT_keyingset_add_destination (wmOperatorType *ot) { // XXX: this is also defined in rna_animation.c static EnumPropertyItem prop_mode_grouping_items[] = { - {KSP_GROUP_NAMED, "NAMED", "Named Group", ""}, - {KSP_GROUP_NONE, "NONE", "None", ""}, - {KSP_GROUP_KSNAME, "KEYINGSET", "Keying Set Name", ""}, - {0, NULL, NULL, NULL}}; + {KSP_GROUP_NAMED, "NAMED", 0, "Named Group", ""}, + {KSP_GROUP_NONE, "NONE", 0, "None", ""}, + {KSP_GROUP_KSNAME, "KEYINGSET", 0, "Keying Set Name", ""}, + {0, NULL, 0, NULL, NULL}}; /* identifiers */ ot->name= "Add Keying Set Destination"; diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 9c9be51f010..7155bdd6850 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -1957,9 +1957,9 @@ void auto_align_ebone_tocursor(Scene *scene, View3D *v3d, EditBone *ebone) static EnumPropertyItem prop_calc_roll_types[] = { - {0, "GLOBALUP", "Z-Axis Up", ""}, - {1, "CURSOR", "Z-Axis to Cursor", ""}, - {0, NULL, NULL, NULL} + {0, "GLOBALUP", 0, "Z-Axis Up", ""}, + {1, "CURSOR", 0, "Z-Axis to Cursor", ""}, + {0, NULL, 0, NULL, NULL} }; static int armature_calc_roll_exec(bContext *C, wmOperator *op) @@ -3489,9 +3489,9 @@ static int armature_subdivs_exec(bContext *C, wmOperator *op) void ARMATURE_OT_subdivs(wmOperatorType *ot) { static EnumPropertyItem type_items[]= { - {0, "SIMPLE", "Simple", ""}, - {1, "MULTI", "Multi", ""}, - {0, NULL, NULL}}; + {0, "SIMPLE", 0, "Simple", ""}, + {1, "MULTI", 0, "Multi", ""}, + {0, NULL, 0, NULL, NULL}}; /* identifiers */ ot->name= "subdivs"; @@ -3669,9 +3669,9 @@ static void bone_connect_to_new_parent(ListBase *edbo, EditBone *selbone, EditBo } static EnumPropertyItem prop_editarm_make_parent_types[] = { - {ARM_PAR_CONNECT, "CONNECTED", "Connected", ""}, - {ARM_PAR_OFFSET, "OFFSET", "Keep Offset", ""}, - {0, NULL, NULL, NULL} + {ARM_PAR_CONNECT, "CONNECTED", 0, "Connected", ""}, + {ARM_PAR_OFFSET, "OFFSET", 0, "Keep Offset", ""}, + {0, NULL, 0, NULL, NULL} }; static int armature_parent_set_exec(bContext *C, wmOperator *op) @@ -3785,9 +3785,9 @@ void ARMATURE_OT_parent_set(wmOperatorType *ot) } static EnumPropertyItem prop_editarm_clear_parent_types[] = { - {1, "CLEAR", "Clear Parent", ""}, - {2, "DISCONNECT", "Disconnect Bone", ""}, - {0, NULL, NULL, NULL} + {1, "CLEAR", 0, "Clear Parent", ""}, + {2, "DISCONNECT", 0, "Disconnect Bone", ""}, + {0, NULL, 0, NULL, NULL} }; static void editbone_clear_parent(EditBone *ebone, int mode) @@ -3973,9 +3973,9 @@ static int armature_select_hierarchy_exec(bContext *C, wmOperator *op) void ARMATURE_OT_select_hierarchy(wmOperatorType *ot) { static EnumPropertyItem direction_items[]= { - {BONE_SELECT_PARENT, "PARENT", "Select Parent", ""}, - {BONE_SELECT_CHILD, "CHILD", "Select Child", ""}, - {0, NULL, NULL, NULL} + {BONE_SELECT_PARENT, "PARENT", 0, "Select Parent", ""}, + {BONE_SELECT_CHILD, "CHILD", 0, "Select Child", ""}, + {0, NULL, 0, NULL, NULL} }; /* identifiers */ diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index 0d7bb3c63cc..281f314a546 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -500,9 +500,9 @@ static int pose_select_hierarchy_exec(bContext *C, wmOperator *op) void POSE_OT_select_hierarchy(wmOperatorType *ot) { static EnumPropertyItem direction_items[]= { - {BONE_SELECT_PARENT, "PARENT", "Select Parent", ""}, - {BONE_SELECT_CHILD, "CHILD", "Select Child", ""}, - {0, NULL, NULL, NULL} + {BONE_SELECT_PARENT, "PARENT", 0, "Select Parent", ""}, + {BONE_SELECT_CHILD, "CHILD", 0, "Select Child", ""}, + {0, NULL, 0, NULL, NULL} }; /* identifiers */ diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 45b9a589bd5..466908c562c 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -2475,12 +2475,12 @@ static int set_spline_type_exec(bContext *C, wmOperator *op) void CURVE_OT_spline_type_set(wmOperatorType *ot) { static EnumPropertyItem type_items[]= { - {CU_POLY, "POLY", "Poly", ""}, - {CU_BEZIER, "BEZIER", "Bezier", ""}, - {CU_CARDINAL, "CARDINAL", "Cardinal", ""}, - {CU_BSPLINE, "B_SPLINE", "B-Spline", ""}, - {CU_NURBS, "NURBS", "NURBS", ""}, - {0, NULL, NULL, NULL}}; + {CU_POLY, "POLY", 0, "Poly", ""}, + {CU_BEZIER, "BEZIER", 0, "Bezier", ""}, + {CU_CARDINAL, "CARDINAL", 0, "Cardinal", ""}, + {CU_BSPLINE, "B_SPLINE", 0, "B-Spline", ""}, + {CU_NURBS, "NURBS", 0, "NURBS", ""}, + {0, NULL, 0, NULL, NULL}}; /* identifiers */ ot->name= "Set Spline Type"; @@ -2516,12 +2516,12 @@ static int set_handle_type_exec(bContext *C, wmOperator *op) void CURVE_OT_handle_type_set(wmOperatorType *ot) { static EnumPropertyItem type_items[]= { - {1, "AUTOMATIC", "Automatic", ""}, - {2, "VECTOR", "Vector", ""}, - {3, "TOGGLE_FREE_ALIGN", "Toggle Free/Align", ""}, - {5, "ALIGN", "Align", ""}, - {6, "FREE_ALIGN", "Free Align", ""}, - {0, NULL, NULL, NULL}}; + {1, "AUTOMATIC", 0, "Automatic", ""}, + {2, "VECTOR", 0, "Vector", ""}, + {3, "TOGGLE_FREE_ALIGN", 0, "Toggle Free/Align", ""}, + {5, "ALIGN", 0, "Align", ""}, + {6, "FREE_ALIGN", 0, "Free Align", ""}, + {0, NULL, 0, NULL, NULL}}; /* identifiers */ ot->name= "Set Handle Type"; @@ -3582,9 +3582,9 @@ static int toggle_cyclic_invoke(bContext *C, wmOperator *op, wmEvent *event) void CURVE_OT_cyclic_toggle(wmOperatorType *ot) { static EnumPropertyItem direction_items[]= { - {0, "CYCLIC_U", "Cyclic U", ""}, - {1, "CYCLIC_V", "Cyclic V", ""}, - {0, NULL, NULL, NULL}}; + {0, "CYCLIC_U", 0, "Cyclic U", ""}, + {1, "CYCLIC_V", 0, "Cyclic V", ""}, + {0, NULL, 0, NULL, NULL}}; /* identifiers */ ot->name= "Toggle Cyclic"; @@ -4530,10 +4530,10 @@ static int delete_invoke(bContext *C, wmOperator *op, wmEvent *event) void CURVE_OT_delete(wmOperatorType *ot) { static EnumPropertyItem type_items[] = { - {0, "SELECTED", "Selected", ""}, - {1, "SEGMENT", "Segment", ""}, - {2, "ALL", "All", ""}, - {0, NULL, NULL, NULL}}; + {0, "SELECTED", 0, "Selected", ""}, + {1, "SEGMENT", 0, "Segment", ""}, + {2, "ALL", 0, "All", ""}, + {0, NULL, 0, NULL, NULL}}; /* identifiers */ ot->name= "Delete"; diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index 1b2c8ea6b11..5389db9e2ee 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -607,10 +607,10 @@ static int kill_selection(Object *obedit, int ins) /* 1 == new character */ /******************* set style operator ********************/ static EnumPropertyItem style_items[]= { - {CU_BOLD, "BOLD", "Bold", ""}, - {CU_ITALIC, "ITALIC", "Italic", ""}, - {CU_UNDERLINE, "UNDERLINE", "Underline", ""}, - {0, NULL, NULL, NULL}}; + {CU_BOLD, "BOLD", 0, "Bold", ""}, + {CU_ITALIC, "ITALIC", 0, "Italic", ""}, + {CU_UNDERLINE, "UNDERLINE", 0, "Underline", ""}, + {0, NULL, 0, NULL, NULL}}; static int set_style(bContext *C, int style, int clear) { @@ -873,17 +873,17 @@ void FONT_OT_text_paste(wmOperatorType *ot) /************************ move operator ************************/ static EnumPropertyItem move_type_items[]= { - {LINE_BEGIN, "LINE_BEGIN", "Line Begin", ""}, - {LINE_END, "LINE_END", "Line End", ""}, - {PREV_CHAR, "PREVIOUS_CHARACTER", "Previous Character", ""}, - {NEXT_CHAR, "NEXT_CHARACTER", "Next Character", ""}, - {PREV_WORD, "PREVIOUS_WORD", "Previous Word", ""}, - {NEXT_WORD, "NEXT_WORD", "Next Word", ""}, - {PREV_LINE, "PREVIOUS_LINE", "Previous Line", ""}, - {NEXT_LINE, "NEXT_LINE", "Next Line", ""}, - {PREV_PAGE, "PREVIOUS_PAGE", "Previous Page", ""}, - {NEXT_PAGE, "NEXT_PAGE", "Next Page", ""}, - {0, NULL, NULL, NULL}}; + {LINE_BEGIN, "LINE_BEGIN", 0, "Line Begin", ""}, + {LINE_END, "LINE_END", 0, "Line End", ""}, + {PREV_CHAR, "PREVIOUS_CHARACTER", 0, "Previous Character", ""}, + {NEXT_CHAR, "NEXT_CHARACTER", 0, "Next Character", ""}, + {PREV_WORD, "PREVIOUS_WORD", 0, "Previous Word", ""}, + {NEXT_WORD, "NEXT_WORD", 0, "Next Word", ""}, + {PREV_LINE, "PREVIOUS_LINE", 0, "Previous Line", ""}, + {NEXT_LINE, "NEXT_LINE", 0, "Next Line", ""}, + {PREV_PAGE, "PREVIOUS_PAGE", 0, "Previous Page", ""}, + {NEXT_PAGE, "NEXT_PAGE", 0, "Next Page", ""}, + {0, NULL, 0, NULL, NULL}}; static int move_cursor(bContext *C, int type, int select) { @@ -1164,13 +1164,13 @@ void FONT_OT_line_break(wmOperatorType *ot) /******************* delete operator **********************/ static EnumPropertyItem delete_type_items[]= { - {DEL_ALL, "ALL", "All", ""}, - {DEL_NEXT_CHAR, "NEXT_CHARACTER", "Next Character", ""}, - {DEL_PREV_CHAR, "PREVIOUS_CHARACTER", "Previous Character", ""}, - {DEL_SELECTION, "SELECTION", "Selection", ""}, - {DEL_NEXT_SEL, "NEXT_OR_SELECTION", "Next or Selection", ""}, - {DEL_PREV_SEL, "PREVIOUS_OR_SELECTION", "Previous or Selection", ""}, - {0, NULL, NULL, NULL}}; + {DEL_ALL, "ALL", 0, "All", ""}, + {DEL_NEXT_CHAR, "NEXT_CHARACTER", 0, "Next Character", ""}, + {DEL_PREV_CHAR, "PREVIOUS_CHARACTER", 0, "Previous Character", ""}, + {DEL_SELECTION, "SELECTION", 0, "Selection", ""}, + {DEL_NEXT_SEL, "NEXT_OR_SELECTION", 0, "Next or Selection", ""}, + {DEL_PREV_SEL, "PREVIOUS_OR_SELECTION", 0, "Previous or Selection", ""}, + {0, NULL, 0, NULL, NULL}}; static int delete_exec(bContext *C, wmOperator *op) { @@ -1407,7 +1407,7 @@ void make_editText(Object *obedit) ef->copybuf= MEM_callocN((MAXTEXT+4)*sizeof(wchar_t), "texteditcopybuf"); ef->copybufinfo= MEM_callocN((MAXTEXT+4)*sizeof(CharInfo), "texteditcopybufinfo"); ef->oldstr= MEM_callocN((MAXTEXT+4)*sizeof(wchar_t), "oldstrbuf"); - ef->oldstrinfo= MEM_callocN((MAXTEXT+4)*sizeof(wchar_t), "oldstrbuf"); + ef->oldstrinfo= MEM_callocN((MAXTEXT+4)*sizeof(CharInfo), "oldstrbuf"); } // Convert the original text to wchar_t @@ -1465,9 +1465,9 @@ void free_editText(Object *obedit) /********************** set case operator *********************/ static EnumPropertyItem case_items[]= { - {CASE_LOWER, "LOWER", "Lower", ""}, - {CASE_UPPER, "UPPER", "Upper", ""}, - {0, NULL, NULL, NULL}}; + {CASE_LOWER, "LOWER", 0, "Lower", ""}, + {CASE_UPPER, "UPPER", 0, "Upper", ""}, + {0, NULL, 0, NULL, NULL}}; static int set_case(bContext *C, int ccase) { diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index e3b6572c03a..c104f2034e8 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -119,6 +119,7 @@ int ED_operator_ipo_active(struct bContext *C); int ED_operator_sequencer_active(struct bContext *C); int ED_operator_image_active(struct bContext *C); int ED_operator_nla_active(struct bContext *C); +int ED_operator_logic_active(struct bContext *C); int ED_operator_object_active(struct bContext *C); int ED_operator_editmesh(struct bContext *C); diff --git a/source/blender/editors/include/ED_space_api.h b/source/blender/editors/include/ED_space_api.h index 08d2894ddf7..f2b46369d13 100644 --- a/source/blender/editors/include/ED_space_api.h +++ b/source/blender/editors/include/ED_space_api.h @@ -50,6 +50,7 @@ void ED_spacetype_nla(void); void ED_spacetype_script(void); void ED_spacetype_text(void); void ED_spacetype_sequencer(void); +void ED_spacetype_logic(void); /* calls for instancing and freeing spacetype static data called in WM_init_exit */ diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h new file mode 100644 index 00000000000..a38dfd93c30 --- /dev/null +++ b/source/blender/editors/include/UI_icons.h @@ -0,0 +1,882 @@ +/** + * $Id: + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2009 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/* Note: this is included twice with different #defines for DEF_ICON + once from UI_resources.h for the internal icon enum and once fro interface_api.c for + definition of the RNA enum for he icons */ + +DEF_ICON(ICON_BLENDER) +DEF_ICON(ICON_QUESTION) +DEF_ICON(ICON_ERROR) +DEF_ICON(ICON_BLANK1) // XXX this is used lots, it's not actually 'blank' +DEF_ICON(ICON_TRIA_RIGHT) +DEF_ICON(ICON_TRIA_DOWN) +DEF_ICON(ICON_TRIA_LEFT) +DEF_ICON(ICON_TRIA_UP) +DEF_ICON(ICON_ARROW_LEFTRIGHT) +DEF_ICON(ICON_PLUS) +DEF_ICON(ICON_DISCLOSURE_TRI_DOWN) +DEF_ICON(ICON_DISCLOSURE_TRI_RIGHT) +DEF_ICON(ICON_RADIOBUT_OFF) +DEF_ICON(ICON_RADIOBUT_ON) +DEF_ICON(ICON_MENU_PANEL) +DEF_ICON(ICON_PYTHON) +DEF_ICON(ICON_BLANK003) +DEF_ICON(ICON_DOT) +DEF_ICON(ICON_BLANK004) +DEF_ICON(ICON_X) +DEF_ICON(ICON_BLANK005) +DEF_ICON(ICON_GO_LEFT) +DEF_ICON(ICON_BLANK006) +DEF_ICON(ICON_BLANK007) +DEF_ICON(ICON_BLANK008) +DEF_ICON(ICON_BLANK008b) + + /* ui */ +DEF_ICON(ICON_FULLSCREEN) +DEF_ICON(ICON_SPLITSCREEN) +DEF_ICON(ICON_RIGHTARROW_THIN) +DEF_ICON(ICON_BORDERMOVE) +DEF_ICON(ICON_VIEWZOOM) +DEF_ICON(ICON_ZOOMIN) +DEF_ICON(ICON_ZOOMOUT) +DEF_ICON(ICON_PANEL_CLOSE) +DEF_ICON(ICON_BLANK009) +DEF_ICON(ICON_EYEDROPPER) +DEF_ICON(ICON_BLANK010) +DEF_ICON(ICON_AUTO) +DEF_ICON(ICON_CHECKBOX_DEHLT) +DEF_ICON(ICON_CHECKBOX_HLT) +DEF_ICON(ICON_UNLOCKED) +DEF_ICON(ICON_LOCKED) +DEF_ICON(ICON_PINNED) +DEF_ICON(ICON_UNPINNED) +DEF_ICON(ICON_BLANK015) +DEF_ICON(ICON_RIGHTARROW) +DEF_ICON(ICON_DOWNARROW_HLT) +DEF_ICON(ICON_DOTSUP) +DEF_ICON(ICON_DOTSDOWN) +DEF_ICON(ICON_LINK) +DEF_ICON(ICON_INLINK) +DEF_ICON(ICON_BLANK012b) + + /* various ui */ +DEF_ICON(ICON_HELP) +DEF_ICON(ICON_GHOSTDRAW) +DEF_ICON(ICON_COLOR) +DEF_ICON(ICON_LINKED) +DEF_ICON(ICON_UNLINKED) +DEF_ICON(ICON_HAND) +DEF_ICON(ICON_ZOOM_ALL) +DEF_ICON(ICON_ZOOM_SELECTED) +DEF_ICON(ICON_ZOOM_PREVIOUS) +DEF_ICON(ICON_ZOOM_IN) +DEF_ICON(ICON_ZOOM_OUT) +DEF_ICON(ICON_RENDER_REGION) +DEF_ICON(ICON_BORDER_RECT) +DEF_ICON(ICON_BORDER_LASSO) +DEF_ICON(ICON_FREEZE) +DEF_ICON(ICON_BLANK031) +DEF_ICON(ICON_BLANK032) +DEF_ICON(ICON_BLANK033) +DEF_ICON(ICON_BLANK034) +DEF_ICON(ICON_BLANK035) +DEF_ICON(ICON_BLANK036) +DEF_ICON(ICON_BLANK037) +DEF_ICON(ICON_BLANK038) +DEF_ICON(ICON_BLANK039) +DEF_ICON(ICON_BLANK040) +DEF_ICON(ICON_BLANK040b) + + /* BUTTONS */ +DEF_ICON(ICON_LAMP) +DEF_ICON(ICON_MATERIAL) +DEF_ICON(ICON_TEXTURE) +DEF_ICON(ICON_ANIM) +DEF_ICON(ICON_WORLD) +DEF_ICON(ICON_SCENE) +DEF_ICON(ICON_EDIT) +DEF_ICON(ICON_GAME) +DEF_ICON(ICON_RADIO) +DEF_ICON(ICON_SCRIPT) +DEF_ICON(ICON_PARTICLES) +DEF_ICON(ICON_PHYSICS) +DEF_ICON(ICON_SPEAKER) +DEF_ICON(ICON_BLANK041) +DEF_ICON(ICON_BLANK042) +DEF_ICON(ICON_BLANK043) +DEF_ICON(ICON_BLANK044) +DEF_ICON(ICON_BLANK045) +DEF_ICON(ICON_BLANK046) +DEF_ICON(ICON_BLANK047) +DEF_ICON(ICON_BLANK048) +DEF_ICON(ICON_BLANK049) +DEF_ICON(ICON_BLANK050) +DEF_ICON(ICON_BLANK051) +DEF_ICON(ICON_BLANK052) +DEF_ICON(ICON_BLANK052b) + + /* EDITORS */ +DEF_ICON(ICON_VIEW3D) +DEF_ICON(ICON_IPO) +DEF_ICON(ICON_OOPS) +DEF_ICON(ICON_BUTS) +DEF_ICON(ICON_FILESEL) +DEF_ICON(ICON_IMAGE_COL) +DEF_ICON(ICON_INFO) +DEF_ICON(ICON_SEQUENCE) +DEF_ICON(ICON_TEXT) +DEF_ICON(ICON_IMASEL) +DEF_ICON(ICON_SOUND) +DEF_ICON(ICON_ACTION) +DEF_ICON(ICON_NLA) +DEF_ICON(ICON_SCRIPTWIN) +DEF_ICON(ICON_TIME) +DEF_ICON(ICON_NODE) +DEF_ICON(ICON_BLANK053) +DEF_ICON(ICON_BLANK054) +DEF_ICON(ICON_BLANK055) +DEF_ICON(ICON_BLANK056) +DEF_ICON(ICON_BLANK057) +DEF_ICON(ICON_BLANK058) +DEF_ICON(ICON_BLANK059) +DEF_ICON(ICON_BLANK060) +DEF_ICON(ICON_BLANK061) +DEF_ICON(ICON_BLANK061b) + + /* MODES */ +DEF_ICON(ICON_OBJECT_DATAMODE) // XXX fix this up +DEF_ICON(ICON_EDITMODE_HLT) +DEF_ICON(ICON_FACESEL_HLT) +DEF_ICON(ICON_VPAINT_HLT) +DEF_ICON(ICON_TPAINT_HLT) +DEF_ICON(ICON_WPAINT_HLT) +DEF_ICON(ICON_SCULPTMODE_HLT) +DEF_ICON(ICON_POSE_HLT) +DEF_ICON(ICON_PARTICLEMODE) +DEF_ICON(ICON_BLANK062) +DEF_ICON(ICON_BLANK063) +DEF_ICON(ICON_BLANK064) +DEF_ICON(ICON_BLANK065) +DEF_ICON(ICON_BLANK066) +DEF_ICON(ICON_BLANK067) +DEF_ICON(ICON_BLANK068) +DEF_ICON(ICON_BLANK069) +DEF_ICON(ICON_BLANK070) +DEF_ICON(ICON_BLANK071) +DEF_ICON(ICON_BLANK072) +DEF_ICON(ICON_BLANK073) +DEF_ICON(ICON_BLANK074) +DEF_ICON(ICON_BLANK075) +DEF_ICON(ICON_BLANK076) +DEF_ICON(ICON_BLANK077) +DEF_ICON(ICON_BLANK077b) + + /* DATA */ +DEF_ICON(ICON_SCENE_DATA) +DEF_ICON(ICON_RENDERLAYERS) +DEF_ICON(ICON_WORLD_DATA) +DEF_ICON(ICON_OBJECT_DATA) +DEF_ICON(ICON_MESH_DATA) +DEF_ICON(ICON_CURVE_DATA) +DEF_ICON(ICON_META_DATA) +DEF_ICON(ICON_LATTICE_DATA) +DEF_ICON(ICON_LAMP_DATA) +DEF_ICON(ICON_MATERIAL_DATA) +DEF_ICON(ICON_TEXTURE_DATA) +DEF_ICON(ICON_ANIM_DATA) +DEF_ICON(ICON_CAMERA_DATA) +DEF_ICON(ICON_PARTICLE_DATA) +DEF_ICON(ICON_LIBRARY_DATA_DIRECT) +DEF_ICON(ICON_GROUP) +DEF_ICON(ICON_ARMATURE_DATA) +DEF_ICON(ICON_POSE_DATA) +DEF_ICON(ICON_BONE_DATA) +DEF_ICON(ICON_CONSTRAINT) +DEF_ICON(ICON_SHAPEKEY_DATA) +DEF_ICON(ICON_BLANK079a) +DEF_ICON(ICON_BLANK079) +DEF_ICON(ICON_PACKAGE) +DEF_ICON(ICON_UGLYPACKAGE) +DEF_ICON(ICON_BLANK079b) + + /* DATA */ +DEF_ICON(ICON_BRUSH_DATA) +DEF_ICON(ICON_IMAGE_DATA) +DEF_ICON(ICON_FILE) +DEF_ICON(ICON_FCURVE) +DEF_ICON(ICON_FONT_DATA) +DEF_ICON(ICON_RENDER_RESULT) +DEF_ICON(ICON_SURFACE_DATA) +DEF_ICON(ICON_EMPTY_DATA) +DEF_ICON(ICON_SETTINGS) +DEF_ICON(ICON_BLANK080D) +DEF_ICON(ICON_BLANK080E) +DEF_ICON(ICON_BLANK080F) +DEF_ICON(ICON_BLANK080) +DEF_ICON(ICON_STRANDS) +DEF_ICON(ICON_LIBRARY_DATA_INDIRECT) +DEF_ICON(ICON_BLANK082) +DEF_ICON(ICON_BLANK083) +DEF_ICON(ICON_BLANK084) +DEF_ICON(ICON_GROUP_BONE) +DEF_ICON(ICON_GROUP_VERTEX) +DEF_ICON(ICON_GROUP_VCOL) +DEF_ICON(ICON_GROUP_UVS) +DEF_ICON(ICON_BLANK089) +DEF_ICON(ICON_BLANK090) +DEF_ICON(ICON_RNA) +DEF_ICON(ICON_BLANK090b) + + /* available */ +DEF_ICON(ICON_BLANK092) +DEF_ICON(ICON_BLANK093) +DEF_ICON(ICON_BLANK094) +DEF_ICON(ICON_BLANK095) +DEF_ICON(ICON_BLANK096) +DEF_ICON(ICON_BLANK097) +DEF_ICON(ICON_BLANK098) +DEF_ICON(ICON_BLANK099) +DEF_ICON(ICON_BLANK100) +DEF_ICON(ICON_BLANK101) +DEF_ICON(ICON_BLANK102) +DEF_ICON(ICON_BLANK103) +DEF_ICON(ICON_BLANK104) +DEF_ICON(ICON_BLANK105) +DEF_ICON(ICON_BLANK106) +DEF_ICON(ICON_BLANK107) +DEF_ICON(ICON_BLANK108) +DEF_ICON(ICON_BLANK109) +DEF_ICON(ICON_BLANK110) +DEF_ICON(ICON_BLANK111) +DEF_ICON(ICON_BLANK112) +DEF_ICON(ICON_BLANK113) +DEF_ICON(ICON_BLANK114) +DEF_ICON(ICON_BLANK115) +DEF_ICON(ICON_BLANK116) +DEF_ICON(ICON_BLANK116b) + + /* OUTLINER */ +DEF_ICON(ICON_OUTLINER_OB_EMPTY) +DEF_ICON(ICON_OUTLINER_OB_MESH) +DEF_ICON(ICON_OUTLINER_OB_CURVE) +DEF_ICON(ICON_OUTLINER_OB_LATTICE) +DEF_ICON(ICON_OUTLINER_OB_META) +DEF_ICON(ICON_OUTLINER_OB_LAMP) +DEF_ICON(ICON_OUTLINER_OB_CAMERA) +DEF_ICON(ICON_OUTLINER_OB_ARMATURE) +DEF_ICON(ICON_OUTLINER_OB_FONT) +DEF_ICON(ICON_OUTLINER_OB_SURFACE) +DEF_ICON(ICON_BLANK119) +DEF_ICON(ICON_BLANK120) +DEF_ICON(ICON_BLANK121) +DEF_ICON(ICON_BLANK122) +DEF_ICON(ICON_BLANK123) +DEF_ICON(ICON_BLANK124) +DEF_ICON(ICON_BLANK125) +DEF_ICON(ICON_BLANK126) +DEF_ICON(ICON_BLANK127) +DEF_ICON(ICON_RESTRICT_VIEW_OFF) +DEF_ICON(ICON_RESTRICT_VIEW_ON) +DEF_ICON(ICON_RESTRICT_SELECT_OFF) +DEF_ICON(ICON_RESTRICT_SELECT_ON) +DEF_ICON(ICON_RESTRICT_RENDER_OFF) +DEF_ICON(ICON_RESTRICT_RENDER_ON) +DEF_ICON(ICON_BLANK127b) + + /* OUTLINER */ +DEF_ICON(ICON_OUTLINER_DATA_EMPTY) +DEF_ICON(ICON_OUTLINER_DATA_MESH) +DEF_ICON(ICON_OUTLINER_DATA_CURVE) +DEF_ICON(ICON_OUTLINER_DATA_LATTICE) +DEF_ICON(ICON_OUTLINER_DATA_META) +DEF_ICON(ICON_OUTLINER_DATA_LAMP) +DEF_ICON(ICON_OUTLINER_DATA_CAMERA) +DEF_ICON(ICON_OUTLINER_DATA_ARMATURE) +DEF_ICON(ICON_OUTLINER_DATA_FONT) +DEF_ICON(ICON_OUTLINER_DATA_SURFACE) +DEF_ICON(ICON_OUTLINER_DATA_POSE) +DEF_ICON(ICON_BLANK129) +DEF_ICON(ICON_BLANK130) +DEF_ICON(ICON_BLANK131) +DEF_ICON(ICON_BLANK132) +DEF_ICON(ICON_BLANK133) +DEF_ICON(ICON_BLANK134) +DEF_ICON(ICON_BLANK135) +DEF_ICON(ICON_BLANK136) +DEF_ICON(ICON_BLANK137) +DEF_ICON(ICON_BLANK138) +DEF_ICON(ICON_BLANK139) +DEF_ICON(ICON_BLANK140) +DEF_ICON(ICON_BLANK141) +DEF_ICON(ICON_BLANK142) +DEF_ICON(ICON_BLANK142b) + + /* PRIMITIVES */ +DEF_ICON(ICON_MESH_PLANE) +DEF_ICON(ICON_MESH_CUBE) +DEF_ICON(ICON_MESH_CIRCLE) +DEF_ICON(ICON_MESH_UVSPHERE) +DEF_ICON(ICON_MESH_ICOSPHERE) +DEF_ICON(ICON_MESH_GRID) +DEF_ICON(ICON_MESH_MONKEY) +DEF_ICON(ICON_MESH_TUBE) +DEF_ICON(ICON_MESH_DONUT) +DEF_ICON(ICON_MESH_CONE) +DEF_ICON(ICON_BLANK610) +DEF_ICON(ICON_BLANK611) +DEF_ICON(ICON_LAMP_POINT) +DEF_ICON(ICON_LAMP_SUN) +DEF_ICON(ICON_LAMP_SPOT) +DEF_ICON(ICON_LAMP_HEMI) +DEF_ICON(ICON_LAMP_AREA) +DEF_ICON(ICON_BLANK617) +DEF_ICON(ICON_BLANK618) +DEF_ICON(ICON_BLANK619) +DEF_ICON(ICON_META_PLANE) +DEF_ICON(ICON_META_CUBE) +DEF_ICON(ICON_META_BALL) +DEF_ICON(ICON_META_ELLIPSOID) +DEF_ICON(ICON_META_TUBE) +DEF_ICON(ICON_BLANK625) + + /* PRIMITIVES */ +DEF_ICON(ICON_SURFACE_NCURVE) +DEF_ICON(ICON_SURFACE_NCIRCLE) +DEF_ICON(ICON_SURFACE_NSURFACE) +DEF_ICON(ICON_SURFACE_NTUBE) +DEF_ICON(ICON_SURFACE_NSPHERE) +DEF_ICON(ICON_SURFACE_NDONUT) +DEF_ICON(ICON_BLANK636) +DEF_ICON(ICON_BLANK637) +DEF_ICON(ICON_BLANK638) +DEF_ICON(ICON_CURVE_BEZCURVE) +DEF_ICON(ICON_CURVE_BEZCIRCLE) +DEF_ICON(ICON_CURVE_NCURVE) +DEF_ICON(ICON_CURVE_NCIRCLE) +DEF_ICON(ICON_CURVE_PATH) +DEF_ICON(ICON_BLANK644) +DEF_ICON(ICON_BLANK645) +DEF_ICON(ICON_BLANK646) +DEF_ICON(ICON_BLANK647) +DEF_ICON(ICON_BLANK648) +DEF_ICON(ICON_BLANK649) +DEF_ICON(ICON_BLANK650) +DEF_ICON(ICON_BLANK651) +DEF_ICON(ICON_BLANK652) +DEF_ICON(ICON_BLANK653) +DEF_ICON(ICON_BLANK654) +DEF_ICON(ICON_BLANK655) + + /* EMPTY */ +DEF_ICON(ICON_BLANK660) +DEF_ICON(ICON_BLANK661) +DEF_ICON(ICON_BLANK662) +DEF_ICON(ICON_BLANK663) +DEF_ICON(ICON_BLANK664) +DEF_ICON(ICON_BLANK665) +DEF_ICON(ICON_BLANK666) +DEF_ICON(ICON_BLANK667) +DEF_ICON(ICON_BLANK668) +DEF_ICON(ICON_BLANK669) +DEF_ICON(ICON_BLANK670) +DEF_ICON(ICON_BLANK671) +DEF_ICON(ICON_BLANK672) +DEF_ICON(ICON_BLANK673) +DEF_ICON(ICON_BLANK674) +DEF_ICON(ICON_BLANK675) +DEF_ICON(ICON_BLANK676) +DEF_ICON(ICON_BLANK677) +DEF_ICON(ICON_BLANK678) +DEF_ICON(ICON_BLANK679) +DEF_ICON(ICON_BLANK680) +DEF_ICON(ICON_BLANK681) +DEF_ICON(ICON_BLANK682) +DEF_ICON(ICON_BLANK683) +DEF_ICON(ICON_BLANK684) +DEF_ICON(ICON_BLANK685) + + /* EMPTY */ +DEF_ICON(ICON_BLANK690) +DEF_ICON(ICON_BLANK691) +DEF_ICON(ICON_BLANK692) +DEF_ICON(ICON_BLANK693) +DEF_ICON(ICON_BLANK694) +DEF_ICON(ICON_BLANK695) +DEF_ICON(ICON_BLANK696) +DEF_ICON(ICON_BLANK697) +DEF_ICON(ICON_BLANK698) +DEF_ICON(ICON_BLANK699) +DEF_ICON(ICON_BLANK700) +DEF_ICON(ICON_BLANK701) +DEF_ICON(ICON_BLANK702) +DEF_ICON(ICON_BLANK703) +DEF_ICON(ICON_BLANK704) +DEF_ICON(ICON_BLANK705) +DEF_ICON(ICON_BLANK706) +DEF_ICON(ICON_BLANK707) +DEF_ICON(ICON_BLANK708) +DEF_ICON(ICON_BLANK709) +DEF_ICON(ICON_BLANK710) +DEF_ICON(ICON_BLANK711) +DEF_ICON(ICON_BLANK712) +DEF_ICON(ICON_BLANK713) +DEF_ICON(ICON_BLANK714) +DEF_ICON(ICON_BLANK715) + + /* EMPTY */ +DEF_ICON(ICON_BLANK720) +DEF_ICON(ICON_BLANK721) +DEF_ICON(ICON_BLANK722) +DEF_ICON(ICON_BLANK733) +DEF_ICON(ICON_BLANK734) +DEF_ICON(ICON_BLANK735) +DEF_ICON(ICON_BLANK736) +DEF_ICON(ICON_BLANK737) +DEF_ICON(ICON_BLANK738) +DEF_ICON(ICON_BLANK739) +DEF_ICON(ICON_BLANK740) +DEF_ICON(ICON_BLANK741) +DEF_ICON(ICON_BLANK742) +DEF_ICON(ICON_BLANK743) +DEF_ICON(ICON_BLANK744) +DEF_ICON(ICON_BLANK745) +DEF_ICON(ICON_BLANK746) +DEF_ICON(ICON_BLANK747) +DEF_ICON(ICON_BLANK748) +DEF_ICON(ICON_BLANK749) +DEF_ICON(ICON_BLANK750) +DEF_ICON(ICON_BLANK751) +DEF_ICON(ICON_BLANK752) +DEF_ICON(ICON_BLANK753) +DEF_ICON(ICON_BLANK754) +DEF_ICON(ICON_BLANK755) + + /* EMPTY */ +DEF_ICON(ICON_BLANK760) +DEF_ICON(ICON_BLANK761) +DEF_ICON(ICON_BLANK762) +DEF_ICON(ICON_BLANK763) +DEF_ICON(ICON_BLANK764) +DEF_ICON(ICON_BLANK765) +DEF_ICON(ICON_BLANK766) +DEF_ICON(ICON_BLANK767) +DEF_ICON(ICON_BLANK768) +DEF_ICON(ICON_BLANK769) +DEF_ICON(ICON_BLANK770) +DEF_ICON(ICON_BLANK771) +DEF_ICON(ICON_BLANK772) +DEF_ICON(ICON_BLANK773) +DEF_ICON(ICON_BLANK774) +DEF_ICON(ICON_BLANK775) +DEF_ICON(ICON_BLANK776) +DEF_ICON(ICON_BLANK777) +DEF_ICON(ICON_BLANK778) +DEF_ICON(ICON_BLANK779) +DEF_ICON(ICON_BLANK780) +DEF_ICON(ICON_BLANK781) +DEF_ICON(ICON_BLANK782) +DEF_ICON(ICON_BLANK783) +DEF_ICON(ICON_BLANK784) +DEF_ICON(ICON_BLANK785) + + /* MODIFIERS */ +DEF_ICON(ICON_MODIFIER) +DEF_ICON(ICON_MOD_WAVE) +DEF_ICON(ICON_MOD_BUILD) +DEF_ICON(ICON_MOD_DECIM) +DEF_ICON(ICON_MOD_MIRROR) +DEF_ICON(ICON_MOD_SOFT) +DEF_ICON(ICON_MOD_SUBSURF) +DEF_ICON(ICON_HOOK) +DEF_ICON(ICON_MOD_PHYSICS) +DEF_ICON(ICON_MOD_PARTICLES) +DEF_ICON(ICON_MOD_BOOLEAN) +DEF_ICON(ICON_MOD_EDGESPLIT) +DEF_ICON(ICON_MOD_ARRAY) +DEF_ICON(ICON_MOD_UVPROJECT) +DEF_ICON(ICON_MOD_DISPLACE) +DEF_ICON(ICON_MOD_CURVE) +DEF_ICON(ICON_MOD_LATTICE) +DEF_ICON(ICON_BLANK143) +DEF_ICON(ICON_MOD_ARMATURE) +DEF_ICON(ICON_MOD_SHRINKWRAP) +DEF_ICON(ICON_MOD_CAST) +DEF_ICON(ICON_MOD_MESHDEFORM) +DEF_ICON(ICON_MOD_BEVEL) +DEF_ICON(ICON_MOD_SMOOTH) +DEF_ICON(ICON_MOD_SIMPLEDEFORM) +DEF_ICON(ICON_MOD_MASK) + + /* MODIFIERS */ +DEF_ICON(ICON_MOD_CLOTH) +DEF_ICON(ICON_MOD_EXPLODE) +DEF_ICON(ICON_MOD_FLUIDSIM) +DEF_ICON(ICON_MOD_MULTIRES) +DEF_ICON(ICON_BLANK157) +DEF_ICON(ICON_BLANK158) +DEF_ICON(ICON_BLANK159) +DEF_ICON(ICON_BLANK160) +DEF_ICON(ICON_BLANK161) +DEF_ICON(ICON_BLANK162) +DEF_ICON(ICON_BLANK163) +DEF_ICON(ICON_BLANK164) +DEF_ICON(ICON_BLANK165) +DEF_ICON(ICON_BLANK166) +DEF_ICON(ICON_BLANK167) +DEF_ICON(ICON_BLANK168) +DEF_ICON(ICON_BLANK169) +DEF_ICON(ICON_BLANK170) +DEF_ICON(ICON_BLANK171) +DEF_ICON(ICON_BLANK172) +DEF_ICON(ICON_BLANK173) +DEF_ICON(ICON_BLANK174) +DEF_ICON(ICON_BLANK175) +DEF_ICON(ICON_BLANK176) +DEF_ICON(ICON_BLANK177) +DEF_ICON(ICON_BLANK177b) + + /* ANIMATION */ +DEF_ICON(ICON_REC) +DEF_ICON(ICON_PLAY) +DEF_ICON(ICON_FF) +DEF_ICON(ICON_REW) +DEF_ICON(ICON_PAUSE) +DEF_ICON(ICON_PREV_KEYFRAME) +DEF_ICON(ICON_NEXT_KEYFRAME) +DEF_ICON(ICON_PLAY_AUDIO) +DEF_ICON(ICON_BLANK178) +DEF_ICON(ICON_BLANK179) +DEF_ICON(ICON_BLANK180) +DEF_ICON(ICON_PMARKER_ACT) +DEF_ICON(ICON_PMARKER_SEL) +DEF_ICON(ICON_PMARKER) +DEF_ICON(ICON_MARKER_HLT) +DEF_ICON(ICON_MARKER) +DEF_ICON(ICON_SPACE2) // XXX +DEF_ICON(ICON_SPACE3) // XXX +DEF_ICON(ICON_BLANK181) +DEF_ICON(ICON_KEY_DEHLT) +DEF_ICON(ICON_KEY_HLT) +DEF_ICON(ICON_MUTE_IPO_OFF) +DEF_ICON(ICON_MUTE_IPO_ON) +DEF_ICON(ICON_BLANK182) +DEF_ICON(ICON_BLANK183) +DEF_ICON(ICON_BLANK183b) + + /* available */ +DEF_ICON(ICON_BLANK184) +DEF_ICON(ICON_BLANK185) +DEF_ICON(ICON_BLANK186) +DEF_ICON(ICON_BLANK187) +DEF_ICON(ICON_BLANK188) +DEF_ICON(ICON_BLANK189) +DEF_ICON(ICON_BLANK190) +DEF_ICON(ICON_BLANK191) +DEF_ICON(ICON_BLANK192) +DEF_ICON(ICON_BLANK193) +DEF_ICON(ICON_BLANK194) +DEF_ICON(ICON_BLANK195) +DEF_ICON(ICON_BLANK196) +DEF_ICON(ICON_BLANK197) +DEF_ICON(ICON_BLANK198) +DEF_ICON(ICON_BLANK199) +DEF_ICON(ICON_BLANK200) +DEF_ICON(ICON_BLANK201) +DEF_ICON(ICON_BLANK202) +DEF_ICON(ICON_BLANK203) +DEF_ICON(ICON_BLANK204) +DEF_ICON(ICON_BLANK205) +DEF_ICON(ICON_BLANK206) +DEF_ICON(ICON_BLANK207) +DEF_ICON(ICON_BLANK208) +DEF_ICON(ICON_BLANK208b) + + /* EDITING */ +DEF_ICON(ICON_VERTEXSEL) +DEF_ICON(ICON_EDGESEL) +DEF_ICON(ICON_FACESEL) +DEF_ICON(ICON_LINKEDSEL) +DEF_ICON(ICON_BLANK210) +DEF_ICON(ICON_ROTATE) +DEF_ICON(ICON_CURSOR) +DEF_ICON(ICON_ROTATECOLLECTION) +DEF_ICON(ICON_ROTATECENTER) +DEF_ICON(ICON_ROTACTIVE) +DEF_ICON(ICON_ALIGN) +DEF_ICON(ICON_BLANK211) +DEF_ICON(ICON_SMOOTHCURVE) +DEF_ICON(ICON_SPHERECURVE) +DEF_ICON(ICON_ROOTCURVE) +DEF_ICON(ICON_SHARPCURVE) +DEF_ICON(ICON_LINCURVE) +DEF_ICON(ICON_NOCURVE) +DEF_ICON(ICON_RNDCURVE) +DEF_ICON(ICON_PROP_OFF) +DEF_ICON(ICON_PROP_ON) +DEF_ICON(ICON_PROP_CON) +DEF_ICON(ICON_BLANK212) +DEF_ICON(ICON_BLANK213) +DEF_ICON(ICON_BLANK214) +DEF_ICON(ICON_BLANK214b) + + /* EDITING */ +DEF_ICON(ICON_MAN_TRANS) +DEF_ICON(ICON_MAN_ROT) +DEF_ICON(ICON_MAN_SCALE) +DEF_ICON(ICON_MANIPUL) +DEF_ICON(ICON_BLANK215) +DEF_ICON(ICON_SNAP_GEAR) +DEF_ICON(ICON_SNAP_GEO) +DEF_ICON(ICON_SNAP_NORMAL) +DEF_ICON(ICON_SNAP_VERTEX) +DEF_ICON(ICON_SNAP_EDGE) +DEF_ICON(ICON_SNAP_FACE) +DEF_ICON(ICON_SNAP_VOLUME) +DEF_ICON(ICON_STICKY_UVS_LOC) +DEF_ICON(ICON_STICKY_UVS_DISABLE) +DEF_ICON(ICON_STICKY_UVS_VERT) +DEF_ICON(ICON_CLIPUV_DEHLT) +DEF_ICON(ICON_CLIPUV_HLT) +DEF_ICON(ICON_BLANK219) +DEF_ICON(ICON_SNAP_PEEL_OBJECT) +DEF_ICON(ICON_BLANK221) +DEF_ICON(ICON_GRID) +DEF_ICON(ICON_GEARS) +DEF_ICON(ICON_BLANK224) +DEF_ICON(ICON_BLANK225) +DEF_ICON(ICON_BLANK226) +DEF_ICON(ICON_BLANK226b) + + /* EDITING */ +DEF_ICON(ICON_PASTEDOWN) +DEF_ICON(ICON_COPYDOWN) +DEF_ICON(ICON_PASTEFLIPUP) +DEF_ICON(ICON_PASTEFLIPDOWN) +DEF_ICON(ICON_BLANK227) +DEF_ICON(ICON_BLANK228) +DEF_ICON(ICON_BLANK229) +DEF_ICON(ICON_BLANK230) +DEF_ICON(ICON_BLANK231) +DEF_ICON(ICON_BLANK232) +DEF_ICON(ICON_BLANK233) +DEF_ICON(ICON_BLANK234) +DEF_ICON(ICON_BLANK235) +DEF_ICON(ICON_BLANK236) +DEF_ICON(ICON_BLANK237) +DEF_ICON(ICON_BLANK238) +DEF_ICON(ICON_BLANK239) +DEF_ICON(ICON_BLANK240) +DEF_ICON(ICON_BLANK241) +DEF_ICON(ICON_BLANK242) +DEF_ICON(ICON_BLANK243) +DEF_ICON(ICON_BLANK244) +DEF_ICON(ICON_BLANK245) +DEF_ICON(ICON_BLANK246) +DEF_ICON(ICON_BLANK247) +DEF_ICON(ICON_BLANK247b) + + /* 3D VIEW */ +DEF_ICON(ICON_BBOX) +DEF_ICON(ICON_WIRE) +DEF_ICON(ICON_SOLID) +DEF_ICON(ICON_SMOOTH) +DEF_ICON(ICON_POTATO) +DEF_ICON(ICON_BLANK248) +DEF_ICON(ICON_ORTHO) +DEF_ICON(ICON_BLANK249) +DEF_ICON(ICON_CAMERA) +DEF_ICON(ICON_LOCKVIEW_OFF) +DEF_ICON(ICON_LOCKVIEW_ON) +DEF_ICON(ICON_BLANK250) +DEF_ICON(ICON_AXIS_SIDE) +DEF_ICON(ICON_AXIS_FRONT) +DEF_ICON(ICON_AXIS_TOP) +DEF_ICON(ICON_NDOF_DOM) +DEF_ICON(ICON_NDOF_TURN) +DEF_ICON(ICON_NDOF_FLY) +DEF_ICON(ICON_NDOF_TRANS) +DEF_ICON(ICON_LAYER_USED) +DEF_ICON(ICON_LAYER_ACTIVE) +DEF_ICON(ICON_BLANK254) +DEF_ICON(ICON_BLANK255) +DEF_ICON(ICON_BLANK256) +DEF_ICON(ICON_BLANK257) +DEF_ICON(ICON_BLANK257b) + + /* available */ +DEF_ICON(ICON_BLANK258) +DEF_ICON(ICON_BLANK259) +DEF_ICON(ICON_BLANK260) +DEF_ICON(ICON_BLANK261) +DEF_ICON(ICON_BLANK262) +DEF_ICON(ICON_BLANK263) +DEF_ICON(ICON_BLANK264) +DEF_ICON(ICON_BLANK265) +DEF_ICON(ICON_BLANK266) +DEF_ICON(ICON_BLANK267) +DEF_ICON(ICON_BLANK268) +DEF_ICON(ICON_BLANK269) +DEF_ICON(ICON_BLANK270) +DEF_ICON(ICON_BLANK271) +DEF_ICON(ICON_BLANK272) +DEF_ICON(ICON_BLANK273) +DEF_ICON(ICON_BLANK274) +DEF_ICON(ICON_BLANK275) +DEF_ICON(ICON_BLANK276) +DEF_ICON(ICON_BLANK277) +DEF_ICON(ICON_BLANK278) +DEF_ICON(ICON_BLANK279) +DEF_ICON(ICON_BLANK280) +DEF_ICON(ICON_BLANK281) +DEF_ICON(ICON_BLANK282) +DEF_ICON(ICON_BLANK282b) + + /* FILE SELECT */ +DEF_ICON(ICON_SORTALPHA) +DEF_ICON(ICON_SORTBYEXT) +DEF_ICON(ICON_SORTTIME) +DEF_ICON(ICON_SORTSIZE) +DEF_ICON(ICON_LONGDISPLAY) +DEF_ICON(ICON_SHORTDISPLAY) +DEF_ICON(ICON_GHOST) +DEF_ICON(ICON_IMGDISPLAY) +DEF_ICON(ICON_BLANK284) +DEF_ICON(ICON_BLANK285) +DEF_ICON(ICON_BOOKMARKS) +DEF_ICON(ICON_FONTPREVIEW) +DEF_ICON(ICON_FILTER) +DEF_ICON(ICON_NEWFOLDER) +DEF_ICON(ICON_BLANK285F) +DEF_ICON(ICON_FILE_PARENT) +DEF_ICON(ICON_FILE_REFRESH) +DEF_ICON(ICON_FILE_FOLDER) +DEF_ICON(ICON_FILE_BLANK) +DEF_ICON(ICON_FILE_BLEND) +DEF_ICON(ICON_FILE_IMAGE) +DEF_ICON(ICON_FILE_MOVIE) +DEF_ICON(ICON_FILE_SCRIPT) +DEF_ICON(ICON_FILE_SOUND) +DEF_ICON(ICON_FILE_FONT) +DEF_ICON(ICON_BLANK291b) + + /* available */ +DEF_ICON(ICON_BLANK292) +DEF_ICON(ICON_BLANK293) +DEF_ICON(ICON_BLANK294) +DEF_ICON(ICON_BLANK295) +DEF_ICON(ICON_BLANK296) +DEF_ICON(ICON_BLANK297) +DEF_ICON(ICON_BLANK298) +DEF_ICON(ICON_BLANK299) +DEF_ICON(ICON_BLANK300) +DEF_ICON(ICON_BLANK301) +DEF_ICON(ICON_BLANK302) +DEF_ICON(ICON_BLANK303) +DEF_ICON(ICON_BLANK304) +DEF_ICON(ICON_BLANK305) +DEF_ICON(ICON_BLANK306) +DEF_ICON(ICON_BLANK307) +DEF_ICON(ICON_BLANK308) +DEF_ICON(ICON_BLANK309) +DEF_ICON(ICON_BLANK310) +DEF_ICON(ICON_BLANK311) +DEF_ICON(ICON_BLANK312) +DEF_ICON(ICON_BLANK313) +DEF_ICON(ICON_BLANK314) +DEF_ICON(ICON_BLANK315) +DEF_ICON(ICON_BLANK316) +DEF_ICON(ICON_DISK_DRIVE) + + /* SHADING / TEXT */ +DEF_ICON(ICON_MATPLANE) +DEF_ICON(ICON_MATSPHERE) +DEF_ICON(ICON_MATCUBE) +DEF_ICON(ICON_MONKEY) +DEF_ICON(ICON_HAIR) +DEF_ICON(ICON_RING) +DEF_ICON(ICON_BLANK317) +DEF_ICON(ICON_BLANK318) +DEF_ICON(ICON_BLANK319) +DEF_ICON(ICON_BLANK320) +DEF_ICON(ICON_BLANK321) +DEF_ICON(ICON_BLANK322) +DEF_ICON(ICON_WORDWRAP_OFF) +DEF_ICON(ICON_WORDWRAP_ON) +DEF_ICON(ICON_SYNTAX_OFF) +DEF_ICON(ICON_SYNTAX_ON) +DEF_ICON(ICON_LINENUMBERS_OFF) +DEF_ICON(ICON_LINENUMBERS_ON) +DEF_ICON(ICON_SCRIPTPLUGINS) // XXX CREATE NEW +DEF_ICON(ICON_BLANK323) +DEF_ICON(ICON_BLANK324) +DEF_ICON(ICON_BLANK325) +DEF_ICON(ICON_BLANK326) +DEF_ICON(ICON_BLANK327) +DEF_ICON(ICON_BLANK328) +DEF_ICON(ICON_BLANK328b) + + /* SEQUENCE / IMAGE EDITOR */ +DEF_ICON(ICON_SEQ_SEQUENCER) +DEF_ICON(ICON_SEQ_PREVIEW) +DEF_ICON(ICON_SEQ_LUMA_WAVEFORM) +DEF_ICON(ICON_SEQ_CHROMA_SCOPE) +DEF_ICON(ICON_SEQ_HISTOGRAM) +DEF_ICON(ICON_BLANK330) +DEF_ICON(ICON_BLANK331) +DEF_ICON(ICON_BLANK332) +DEF_ICON(ICON_BLANK333) +DEF_ICON(ICON_IMAGE_RGB) // XXX CHANGE TO STRAIGHT ALPHA, Z ETC +DEF_ICON(ICON_IMAGE_RGB_ALPHA) +DEF_ICON(ICON_IMAGE_ALPHA) +DEF_ICON(ICON_IMAGE_ZDEPTH) +DEF_ICON(ICON_IMAGEFILE) +DEF_ICON(ICON_BLANK336) +DEF_ICON(ICON_BLANK337) +DEF_ICON(ICON_BLANK338) +DEF_ICON(ICON_BLANK339) +DEF_ICON(ICON_BLANK340) +DEF_ICON(ICON_BLANK341) +DEF_ICON(ICON_BLANK342) +DEF_ICON(ICON_BLANK343) +DEF_ICON(ICON_BLANK344) +DEF_ICON(ICON_BLANK345) +DEF_ICON(ICON_BLANK346) +DEF_ICON(ICON_BLANK346b) + + /* vector icons */ + +DEF_ICON(VICON_VIEW3D) +DEF_ICON(VICON_EDIT) +DEF_ICON(VICON_EDITMODE_DEHLT) +DEF_ICON(VICON_EDITMODE_HLT) +DEF_ICON(VICON_DISCLOSURE_TRI_RIGHT) +DEF_ICON(VICON_DISCLOSURE_TRI_DOWN) +DEF_ICON(VICON_MOVE_UP) +DEF_ICON(VICON_MOVE_DOWN) +DEF_ICON(VICON_X) diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index fad19b6063d..62469686e7f 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -91,11 +91,13 @@ typedef struct uiLayout uiLayout; #define UI_BLOCK_MOVEMOUSE_QUIT 128 #define UI_BLOCK_KEEP_OPEN 256 #define UI_BLOCK_POPUP 512 +#define UI_BLOCK_OUT_1 1024 /* uiPopupBlockHandle->menuretval */ #define UI_RETURN_CANCEL 1 /* cancel all menus cascading */ #define UI_RETURN_OK 2 /* choice made */ #define UI_RETURN_OUT 4 /* left the menu */ +#define UI_RETURN_UPDATE 8 /* update the button that opened */ /* block->flag bits 12-15 are identical to but->flag bits */ @@ -194,6 +196,7 @@ typedef struct uiLayout uiLayout; #define OPTIONN (39<<9) #define SEARCH_MENU (40<<9) #define BUT_EXTRA (41<<9) +#define HSVCIRCLE (42<<9) #define BUTTYPE (63<<9) /* Drawing @@ -399,6 +402,8 @@ uiBut *uiDefMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, char *str, uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, char *str, short x1, short y1, short x2, short y2, char *tip); uiBut *uiDefBlockBut(uiBlock *block, uiBlockCreateFunc func, void *func_arg1, char *str, short x1, short y1, short x2, short y2, char *tip); +uiBut *uiDefBlockButN(uiBlock *block, uiBlockCreateFunc func, void *argN, char *str, short x1, short y1, short x2, short y2, char *tip); + uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int retval, int icon, short x1, short y1, short x2, short y2, char *tip); uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int icon, char *str, short x1, short y1, short x2, short y2, char *tip); @@ -486,7 +491,7 @@ void autocomplete_end(AutoComplete *autocpl, char *autoname); void uiBeginPanels(const struct bContext *C, struct ARegion *ar); void uiEndPanels(const struct bContext *C, struct ARegion *ar); -struct Panel *uiBeginPanel(struct ARegion *ar, uiBlock *block, struct PanelType *pt, int *open); +struct Panel *uiBeginPanel(struct ScrArea *sa, struct ARegion *ar, uiBlock *block, struct PanelType *pt, int *open); void uiEndPanel(uiBlock *block, int width, int height); /* Handlers @@ -534,8 +539,6 @@ void UI_exit(void); uiBut *uiDefMenuButO(uiBlock *block, char *opname, char *name); uiBut *uiDefMenuSep(uiBlock *block); -uiBut *uiDefMenuSub(uiBlock *block, uiBlockCreateFunc func, char *name); -uiBut *uiDefMenuTogR(uiBlock *block, struct PointerRNA *ptr, char *propname, char *propvalue, char *name); /* Layout * @@ -610,6 +613,7 @@ uiLayout *uiTemplateConstraint(uiLayout *layout, struct PointerRNA *ptr); void uiTemplatePreview(uiLayout *layout, struct ID *id); void uiTemplateColorRamp(uiLayout *layout, struct ColorBand *coba, int expand); void uiTemplateCurveMapping(uiLayout *layout, struct CurveMapping *cumap, int type); +void uiTemplateLayers(uiLayout *layout, struct PointerRNA *ptr, char *propname); /* items */ void uiItemO(uiLayout *layout, char *name, int icon, char *opname); diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h index 6fa0eb90c5f..7168e593a8a 100644 --- a/source/blender/editors/include/UI_resources.h +++ b/source/blender/editors/include/UI_resources.h @@ -35,864 +35,16 @@ /* elubie: TODO: move the typedef for icons to UI_interface_icons.h */ /* and add/replace include of UI_resources.h by UI_interface_icons.h */ +#define DEF_ICON(name) name, typedef enum { #define BIFICONID_FIRST (ICON_BLENDER) /* ui */ - ICON_BLENDER, - ICON_QUESTION, - ICON_ERROR, - ICON_BLANK1, // XXX this is used lots, it's not actually 'blank' - ICON_TRIA_RIGHT, - ICON_TRIA_DOWN, - ICON_TRIA_LEFT, - ICON_TRIA_UP, - ICON_ARROW_LEFTRIGHT, - ICON_PLUS, - ICON_DISCLOSURE_TRI_DOWN, - ICON_DISCLOSURE_TRI_RIGHT, - ICON_RADIOBUT_OFF, - ICON_RADIOBUT_ON, - ICON_MENU_PANEL, - ICON_PYTHON, - ICON_BLANK003, - ICON_DOT, - ICON_BLANK004, - ICON_X, - ICON_BLANK005, - ICON_GO_LEFT, - ICON_BLANK006, - ICON_BLANK007, - ICON_BLANK008, - ICON_BLANK008b, - - /* ui */ - ICON_FULLSCREEN, - ICON_SPLITSCREEN, - ICON_RIGHTARROW_THIN, - ICON_BORDERMOVE, - ICON_VIEWZOOM, - ICON_ZOOMIN, - ICON_ZOOMOUT, - ICON_PANEL_CLOSE, - ICON_BLANK009, - ICON_EYEDROPPER, - ICON_BLANK010, - ICON_AUTO, - ICON_CHECKBOX_DEHLT, - ICON_CHECKBOX_HLT, - ICON_UNLOCKED, - ICON_LOCKED, - ICON_PINNED, - ICON_UNPINNED, - ICON_BLANK015, - ICON_RIGHTARROW, - ICON_DOWNARROW_HLT, - ICON_DOTSUP, - ICON_DOTSDOWN, - ICON_LINK, - ICON_INLINK, - ICON_BLANK012b, - - /* various ui */ - ICON_HELP, - ICON_GHOSTDRAW, - ICON_COLOR, - ICON_LINKED, - ICON_UNLINKED, - ICON_HAND, - ICON_ZOOM_ALL, - ICON_ZOOM_SELECTED, - ICON_ZOOM_PREVIOUS, - ICON_ZOOM_IN, - ICON_ZOOM_OUT, - ICON_RENDER_REGION, - ICON_BORDER_RECT, - ICON_BORDER_LASSO, - ICON_FREEZE, - ICON_BLANK031, - ICON_BLANK032, - ICON_BLANK033, - ICON_BLANK034, - ICON_BLANK035, - ICON_BLANK036, - ICON_BLANK037, - ICON_BLANK038, - ICON_BLANK039, - ICON_BLANK040, - ICON_BLANK040b, - - /* BUTTONS */ - ICON_LAMP, - ICON_MATERIAL, - ICON_TEXTURE, - ICON_ANIM, - ICON_WORLD, - ICON_SCENE, - ICON_EDIT, - ICON_GAME, - ICON_RADIO, - ICON_SCRIPT, - ICON_PARTICLES, - ICON_PHYSICS, - ICON_SPEAKER, - ICON_BLANK041, - ICON_BLANK042, - ICON_BLANK043, - ICON_BLANK044, - ICON_BLANK045, - ICON_BLANK046, - ICON_BLANK047, - ICON_BLANK048, - ICON_BLANK049, - ICON_BLANK050, - ICON_BLANK051, - ICON_BLANK052, - ICON_BLANK052b, - - /* EDITORS */ - ICON_VIEW3D, - ICON_IPO, - ICON_OOPS, - ICON_BUTS, - ICON_FILESEL, - ICON_IMAGE_COL, - ICON_INFO, - ICON_SEQUENCE, - ICON_TEXT, - ICON_IMASEL, - ICON_SOUND, - ICON_ACTION, - ICON_NLA, - ICON_SCRIPTWIN, - ICON_TIME, - ICON_NODE, - ICON_BLANK053, - ICON_BLANK054, - ICON_BLANK055, - ICON_BLANK056, - ICON_BLANK057, - ICON_BLANK058, - ICON_BLANK059, - ICON_BLANK060, - ICON_BLANK061, - ICON_BLANK061b, - - /* MODES */ - ICON_OBJECT_DATAMODE, // XXX fix this up - ICON_EDITMODE_HLT, - ICON_FACESEL_HLT, - ICON_VPAINT_HLT, - ICON_TPAINT_HLT, - ICON_WPAINT_HLT, - ICON_SCULPTMODE_HLT, - ICON_POSE_HLT, - ICON_PARTICLEMODE, - ICON_BLANK062, - ICON_BLANK063, - ICON_BLANK064, - ICON_BLANK065, - ICON_BLANK066, - ICON_BLANK067, - ICON_BLANK068, - ICON_BLANK069, - ICON_BLANK070, - ICON_BLANK071, - ICON_BLANK072, - ICON_BLANK073, - ICON_BLANK074, - ICON_BLANK075, - ICON_BLANK076, - ICON_BLANK077, - ICON_BLANK077b, - - /* DATA */ - ICON_SCENE_DATA, - ICON_RENDERLAYERS, - ICON_WORLD_DATA, - ICON_OBJECT_DATA, - ICON_MESH_DATA, - ICON_CURVE_DATA, - ICON_META_DATA, - ICON_LATTICE_DATA, - ICON_LAMP_DATA, - ICON_MATERIAL_DATA, - ICON_TEXTURE_DATA, - ICON_ANIM_DATA, - ICON_CAMERA_DATA, - ICON_PARTICLE_DATA, - ICON_LIBRARY_DATA_DIRECT, - ICON_GROUP, - ICON_ARMATURE_DATA, - ICON_POSE_DATA, - ICON_BONE_DATA, - ICON_CONSTRAINT, - ICON_SHAPEKEY_DATA, - ICON_BLANK079a, - ICON_BLANK079, - ICON_PACKAGE, - ICON_UGLYPACKAGE, - ICON_BLANK079b, - - /* DATA */ - ICON_BRUSH_DATA, - ICON_IMAGE_DATA, - ICON_FILE, - ICON_FCURVE, - ICON_FONT_DATA, - ICON_RENDER_RESULT, - ICON_SURFACE_DATA, - ICON_EMPTY_DATA, - ICON_SETTINGS, - ICON_BLANK080D, - ICON_BLANK080E, - ICON_BLANK080F, - ICON_BLANK080, - ICON_STRANDS, - ICON_LIBRARY_DATA_INDIRECT, - ICON_BLANK082, - ICON_BLANK083, - ICON_BLANK084, - ICON_GROUP_BONE, - ICON_GROUP_VERTEX, - ICON_GROUP_VCOL, - ICON_GROUP_UVS, - ICON_BLANK089, - ICON_BLANK090, - ICON_RNA, - ICON_BLANK090b, - - /* available */ - ICON_BLANK092, - ICON_BLANK093, - ICON_BLANK094, - ICON_BLANK095, - ICON_BLANK096, - ICON_BLANK097, - ICON_BLANK098, - ICON_BLANK099, - ICON_BLANK100, - ICON_BLANK101, - ICON_BLANK102, - ICON_BLANK103, - ICON_BLANK104, - ICON_BLANK105, - ICON_BLANK106, - ICON_BLANK107, - ICON_BLANK108, - ICON_BLANK109, - ICON_BLANK110, - ICON_BLANK111, - ICON_BLANK112, - ICON_BLANK113, - ICON_BLANK114, - ICON_BLANK115, - ICON_BLANK116, - ICON_BLANK116b, - - /* OUTLINER */ - ICON_OUTLINER_OB_EMPTY, - ICON_OUTLINER_OB_MESH, - ICON_OUTLINER_OB_CURVE, - ICON_OUTLINER_OB_LATTICE, - ICON_OUTLINER_OB_META, - ICON_OUTLINER_OB_LAMP, - ICON_OUTLINER_OB_CAMERA, - ICON_OUTLINER_OB_ARMATURE, - ICON_OUTLINER_OB_FONT, - ICON_OUTLINER_OB_SURFACE, - ICON_BLANK119, - ICON_BLANK120, - ICON_BLANK121, - ICON_BLANK122, - ICON_BLANK123, - ICON_BLANK124, - ICON_BLANK125, - ICON_BLANK126, - ICON_BLANK127, - ICON_RESTRICT_VIEW_OFF, - ICON_RESTRICT_VIEW_ON, - ICON_RESTRICT_SELECT_OFF, - ICON_RESTRICT_SELECT_ON, - ICON_RESTRICT_RENDER_OFF, - ICON_RESTRICT_RENDER_ON, - ICON_BLANK127b, - - /* OUTLINER */ - ICON_OUTLINER_DATA_EMPTY, - ICON_OUTLINER_DATA_MESH, - ICON_OUTLINER_DATA_CURVE, - ICON_OUTLINER_DATA_LATTICE, - ICON_OUTLINER_DATA_META, - ICON_OUTLINER_DATA_LAMP, - ICON_OUTLINER_DATA_CAMERA, - ICON_OUTLINER_DATA_ARMATURE, - ICON_OUTLINER_DATA_FONT, - ICON_OUTLINER_DATA_SURFACE, - ICON_OUTLINER_DATA_POSE, - ICON_BLANK129, - ICON_BLANK130, - ICON_BLANK131, - ICON_BLANK132, - ICON_BLANK133, - ICON_BLANK134, - ICON_BLANK135, - ICON_BLANK136, - ICON_BLANK137, - ICON_BLANK138, - ICON_BLANK139, - ICON_BLANK140, - ICON_BLANK141, - ICON_BLANK142, - ICON_BLANK142b, - - /* PRIMITIVES */ - ICON_MESH_PLANE, - ICON_MESH_CUBE, - ICON_MESH_CIRCLE, - ICON_MESH_UVSPHERE, - ICON_MESH_ICOSPHERE, - ICON_MESH_GRID, - ICON_MESH_MONKEY, - ICON_MESH_TUBE, - ICON_MESH_DONUT, - ICON_MESH_CONE, - ICON_BLANK610, - ICON_BLANK611, - ICON_LAMP_POINT, - ICON_LAMP_SUN, - ICON_LAMP_SPOT, - ICON_LAMP_HEMI, - ICON_LAMP_AREA, - ICON_BLANK617, - ICON_BLANK618, - ICON_BLANK619, - ICON_META_PLANE, - ICON_META_CUBE, - ICON_META_BALL, - ICON_META_ELLIPSOID, - ICON_META_TUBE, - ICON_BLANK625, - - /* PRIMITIVES */ - ICON_SURFACE_NCURVE, - ICON_SURFACE_NCIRCLE, - ICON_SURFACE_NSURFACE, - ICON_SURFACE_NTUBE, - ICON_SURFACE_NSPHERE, - ICON_SURFACE_NDONUT, - ICON_BLANK636, - ICON_BLANK637, - ICON_BLANK638, - ICON_CURVE_BEZCURVE, - ICON_CURVE_BEZCIRCLE, - ICON_CURVE_NCURVE, - ICON_CURVE_NCIRCLE, - ICON_CURVE_PATH, - ICON_BLANK644, - ICON_BLANK645, - ICON_BLANK646, - ICON_BLANK647, - ICON_BLANK648, - ICON_BLANK649, - ICON_BLANK650, - ICON_BLANK651, - ICON_BLANK652, - ICON_BLANK653, - ICON_BLANK654, - ICON_BLANK655, - - /* EMPTY */ - ICON_BLANK660, - ICON_BLANK661, - ICON_BLANK662, - ICON_BLANK663, - ICON_BLANK664, - ICON_BLANK665, - ICON_BLANK666, - ICON_BLANK667, - ICON_BLANK668, - ICON_BLANK669, - ICON_BLANK670, - ICON_BLANK671, - ICON_BLANK672, - ICON_BLANK673, - ICON_BLANK674, - ICON_BLANK675, - ICON_BLANK676, - ICON_BLANK677, - ICON_BLANK678, - ICON_BLANK679, - ICON_BLANK680, - ICON_BLANK681, - ICON_BLANK682, - ICON_BLANK683, - ICON_BLANK684, - ICON_BLANK685, - - /* EMPTY */ - ICON_BLANK690, - ICON_BLANK691, - ICON_BLANK692, - ICON_BLANK693, - ICON_BLANK694, - ICON_BLANK695, - ICON_BLANK696, - ICON_BLANK697, - ICON_BLANK698, - ICON_BLANK699, - ICON_BLANK700, - ICON_BLANK701, - ICON_BLANK702, - ICON_BLANK703, - ICON_BLANK704, - ICON_BLANK705, - ICON_BLANK706, - ICON_BLANK707, - ICON_BLANK708, - ICON_BLANK709, - ICON_BLANK710, - ICON_BLANK711, - ICON_BLANK712, - ICON_BLANK713, - ICON_BLANK714, - ICON_BLANK715, - - /* EMPTY */ - ICON_BLANK720, - ICON_BLANK721, - ICON_BLANK722, - ICON_BLANK733, - ICON_BLANK734, - ICON_BLANK735, - ICON_BLANK736, - ICON_BLANK737, - ICON_BLANK738, - ICON_BLANK739, - ICON_BLANK740, - ICON_BLANK741, - ICON_BLANK742, - ICON_BLANK743, - ICON_BLANK744, - ICON_BLANK745, - ICON_BLANK746, - ICON_BLANK747, - ICON_BLANK748, - ICON_BLANK749, - ICON_BLANK750, - ICON_BLANK751, - ICON_BLANK752, - ICON_BLANK753, - ICON_BLANK754, - ICON_BLANK755, - - /* EMPTY */ - ICON_BLANK760, - ICON_BLANK761, - ICON_BLANK762, - ICON_BLANK763, - ICON_BLANK764, - ICON_BLANK765, - ICON_BLANK766, - ICON_BLANK767, - ICON_BLANK768, - ICON_BLANK769, - ICON_BLANK770, - ICON_BLANK771, - ICON_BLANK772, - ICON_BLANK773, - ICON_BLANK774, - ICON_BLANK775, - ICON_BLANK776, - ICON_BLANK777, - ICON_BLANK778, - ICON_BLANK779, - ICON_BLANK780, - ICON_BLANK781, - ICON_BLANK782, - ICON_BLANK783, - ICON_BLANK784, - ICON_BLANK785, - - /* MODIFIERS */ - ICON_MODIFIER, - ICON_MOD_WAVE, - ICON_MOD_BUILD, - ICON_MOD_DECIM, - ICON_MOD_MIRROR, - ICON_MOD_SOFT, - ICON_MOD_SUBSURF, - ICON_HOOK, - ICON_MOD_PHYSICS, - ICON_MOD_PARTICLES, - ICON_MOD_BOOLEAN, - ICON_MOD_EDGESPLIT, - ICON_MOD_ARRAY, - ICON_MOD_UVPROJECT, - ICON_MOD_DISPLACE, - ICON_MOD_CURVE, - ICON_MOD_LATTICE, - ICON_BLANK143, - ICON_MOD_ARMATURE, - ICON_MOD_SHRINKWRAP, - ICON_MOD_CAST, - ICON_MOD_MESHDEFORM, - ICON_MOD_BEVEL, - ICON_MOD_SMOOTH, - ICON_MOD_SIMPLEDEFORM, - ICON_MOD_MASK, - - /* MODIFIERS */ - ICON_MOD_CLOTH, - ICON_MOD_EXPLODE, - ICON_MOD_FLUIDSIM, - ICON_MOD_MULTIRES, - ICON_BLANK157, - ICON_BLANK158, - ICON_BLANK159, - ICON_BLANK160, - ICON_BLANK161, - ICON_BLANK162, - ICON_BLANK163, - ICON_BLANK164, - ICON_BLANK165, - ICON_BLANK166, - ICON_BLANK167, - ICON_BLANK168, - ICON_BLANK169, - ICON_BLANK170, - ICON_BLANK171, - ICON_BLANK172, - ICON_BLANK173, - ICON_BLANK174, - ICON_BLANK175, - ICON_BLANK176, - ICON_BLANK177, - ICON_BLANK177b, - - /* ANIMATION */ - ICON_REC, - ICON_PLAY, - ICON_FF, - ICON_REW, - ICON_PAUSE, - ICON_PREV_KEYFRAME, - ICON_NEXT_KEYFRAME, - ICON_PLAY_AUDIO, - ICON_BLANK178, - ICON_BLANK179, - ICON_BLANK180, - ICON_PMARKER_ACT, - ICON_PMARKER_SEL, - ICON_PMARKER, - ICON_MARKER_HLT, - ICON_MARKER, - ICON_SPACE2, // XXX - ICON_SPACE3, // XXX - ICON_BLANK181, - ICON_KEY_DEHLT, - ICON_KEY_HLT, - ICON_MUTE_IPO_OFF, - ICON_MUTE_IPO_ON, - ICON_BLANK182, - ICON_BLANK183, - ICON_BLANK183b, - - /* available */ - ICON_BLANK184, - ICON_BLANK185, - ICON_BLANK186, - ICON_BLANK187, - ICON_BLANK188, - ICON_BLANK189, - ICON_BLANK190, - ICON_BLANK191, - ICON_BLANK192, - ICON_BLANK193, - ICON_BLANK194, - ICON_BLANK195, - ICON_BLANK196, - ICON_BLANK197, - ICON_BLANK198, - ICON_BLANK199, - ICON_BLANK200, - ICON_BLANK201, - ICON_BLANK202, - ICON_BLANK203, - ICON_BLANK204, - ICON_BLANK205, - ICON_BLANK206, - ICON_BLANK207, - ICON_BLANK208, - ICON_BLANK208b, - - /* EDITING */ - ICON_VERTEXSEL, - ICON_EDGESEL, - ICON_FACESEL, - ICON_LINKEDSEL, - ICON_BLANK210, - ICON_ROTATE, - ICON_CURSOR, - ICON_ROTATECOLLECTION, - ICON_ROTATECENTER, - ICON_ROTACTIVE, - ICON_ALIGN, - ICON_BLANK211, - ICON_SMOOTHCURVE, - ICON_SPHERECURVE, - ICON_ROOTCURVE, - ICON_SHARPCURVE, - ICON_LINCURVE, - ICON_NOCURVE, - ICON_RNDCURVE, - ICON_PROP_OFF, - ICON_PROP_ON, - ICON_PROP_CON, - ICON_BLANK212, - ICON_BLANK213, - ICON_BLANK214, - ICON_BLANK214b, - - /* EDITING */ - ICON_MAN_TRANS, - ICON_MAN_ROT, - ICON_MAN_SCALE, - ICON_MANIPUL, - ICON_BLANK215, - ICON_SNAP_GEAR, - ICON_SNAP_GEO, - ICON_SNAP_NORMAL, - ICON_SNAP_VERTEX, - ICON_SNAP_EDGE, - ICON_SNAP_FACE, - ICON_SNAP_VOLUME, - ICON_STICKY_UVS_LOC, - ICON_STICKY_UVS_DISABLE, - ICON_STICKY_UVS_VERT, - ICON_CLIPUV_DEHLT, - ICON_CLIPUV_HLT, - ICON_BLANK219, - ICON_SNAP_PEEL_OBJECT, - ICON_BLANK221, - ICON_GRID, - ICON_GEARS, - ICON_BLANK224, - ICON_BLANK225, - ICON_BLANK226, - ICON_BLANK226b, - - /* EDITING */ - ICON_PASTEDOWN, - ICON_COPYDOWN, - ICON_PASTEFLIPUP, - ICON_PASTEFLIPDOWN, - ICON_BLANK227, - ICON_BLANK228, - ICON_BLANK229, - ICON_BLANK230, - ICON_BLANK231, - ICON_BLANK232, - ICON_BLANK233, - ICON_BLANK234, - ICON_BLANK235, - ICON_BLANK236, - ICON_BLANK237, - ICON_BLANK238, - ICON_BLANK239, - ICON_BLANK240, - ICON_BLANK241, - ICON_BLANK242, - ICON_BLANK243, - ICON_BLANK244, - ICON_BLANK245, - ICON_BLANK246, - ICON_BLANK247, - ICON_BLANK247b, - - /* 3D VIEW */ - ICON_BBOX, - ICON_WIRE, - ICON_SOLID, - ICON_SMOOTH, - ICON_POTATO, - ICON_BLANK248, - ICON_ORTHO, - ICON_BLANK249, - ICON_CAMERA, - ICON_LOCKVIEW_OFF, - ICON_LOCKVIEW_ON, - ICON_BLANK250, - ICON_AXIS_SIDE, - ICON_AXIS_FRONT, - ICON_AXIS_TOP, - ICON_NDOF_DOM, - ICON_NDOF_TURN, - ICON_NDOF_FLY, - ICON_NDOF_TRANS, - ICON_LAYER_USED, - ICON_LAYER_ACTIVE, - ICON_BLANK254, - ICON_BLANK255, - ICON_BLANK256, - ICON_BLANK257, - ICON_BLANK257b, - - /* available */ - ICON_BLANK258, - ICON_BLANK259, - ICON_BLANK260, - ICON_BLANK261, - ICON_BLANK262, - ICON_BLANK263, - ICON_BLANK264, - ICON_BLANK265, - ICON_BLANK266, - ICON_BLANK267, - ICON_BLANK268, - ICON_BLANK269, - ICON_BLANK270, - ICON_BLANK271, - ICON_BLANK272, - ICON_BLANK273, - ICON_BLANK274, - ICON_BLANK275, - ICON_BLANK276, - ICON_BLANK277, - ICON_BLANK278, - ICON_BLANK279, - ICON_BLANK280, - ICON_BLANK281, - ICON_BLANK282, - ICON_BLANK282b, - - /* FILE SELECT */ - ICON_SORTALPHA, - ICON_SORTBYEXT, - ICON_SORTTIME, - ICON_SORTSIZE, - ICON_LONGDISPLAY, - ICON_SHORTDISPLAY, - ICON_GHOST, - ICON_IMGDISPLAY, - ICON_BLANK284, - ICON_BLANK285, - ICON_BOOKMARKS, - ICON_FONTPREVIEW, - ICON_FILTER, - ICON_NEWFOLDER, - ICON_BLANK285F, - ICON_FILE_PARENT, - ICON_FILE_REFRESH, - ICON_FILE_FOLDER, - ICON_FILE_BLANK, - ICON_FILE_BLEND, - ICON_FILE_IMAGE, - ICON_FILE_MOVIE, - ICON_FILE_SCRIPT, - ICON_FILE_SOUND, - ICON_FILE_FONT, - ICON_BLANK291b, - - /* available */ - ICON_BLANK292, - ICON_BLANK293, - ICON_BLANK294, - ICON_BLANK295, - ICON_BLANK296, - ICON_BLANK297, - ICON_BLANK298, - ICON_BLANK299, - ICON_BLANK300, - ICON_BLANK301, - ICON_BLANK302, - ICON_BLANK303, - ICON_BLANK304, - ICON_BLANK305, - ICON_BLANK306, - ICON_BLANK307, - ICON_BLANK308, - ICON_BLANK309, - ICON_BLANK310, - ICON_BLANK311, - ICON_BLANK312, - ICON_BLANK313, - ICON_BLANK314, - ICON_BLANK315, - ICON_BLANK316, - ICON_DISK_DRIVE, - - /* SHADING / TEXT */ - ICON_MATPLANE, - ICON_MATSPHERE, - ICON_MATCUBE, - ICON_MONKEY, - ICON_HAIR, - ICON_RING, - ICON_BLANK317, - ICON_BLANK318, - ICON_BLANK319, - ICON_BLANK320, - ICON_BLANK321, - ICON_BLANK322, - ICON_WORDWRAP_OFF, - ICON_WORDWRAP_ON, - ICON_SYNTAX_OFF, - ICON_SYNTAX_ON, - ICON_LINENUMBERS_OFF, - ICON_LINENUMBERS_ON, - ICON_SCRIPTPLUGINS, // XXX CREATE NEW - ICON_BLANK323, - ICON_BLANK324, - ICON_BLANK325, - ICON_BLANK326, - ICON_BLANK327, - ICON_BLANK328, - ICON_BLANK328b, - - /* SEQUENCE / IMAGE EDITOR */ - ICON_SEQ_SEQUENCER, - ICON_SEQ_PREVIEW, - ICON_SEQ_LUMA_WAVEFORM, - ICON_SEQ_CHROMA_SCOPE, - ICON_SEQ_HISTOGRAM, - ICON_BLANK330, - ICON_BLANK331, - ICON_BLANK332, - ICON_BLANK333, - ICON_IMAGE_RGB, // XXX CHANGE TO STRAIGHT ALPHA, Z ETC - ICON_IMAGE_RGB_ALPHA, - ICON_IMAGE_ALPHA, - ICON_IMAGE_ZDEPTH, - ICON_IMAGEFILE, - ICON_BLANK336, - ICON_BLANK337, - ICON_BLANK338, - ICON_BLANK339, - ICON_BLANK340, - ICON_BLANK341, - ICON_BLANK342, - ICON_BLANK343, - ICON_BLANK344, - ICON_BLANK345, - ICON_BLANK346, - ICON_BLANK346b, - - /* vector icons */ - - VICON_VIEW3D, - VICON_EDIT, - VICON_EDITMODE_DEHLT, - VICON_EDITMODE_HLT, - VICON_DISCLOSURE_TRI_RIGHT, - VICON_DISCLOSURE_TRI_DOWN, - VICON_MOVE_UP, - VICON_MOVE_DOWN, - VICON_X - -#define BIFICONID_LAST (VICON_X) +#include "UI_icons.h" + BIFICONID_LAST #define BIFNICONIDS (BIFICONID_LAST-BIFICONID_FIRST + 1) } BIFIconID; +#undef DEF_ICON typedef enum { diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index bef01b5a454..5ffc6440dc4 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -398,18 +398,21 @@ void uiMenuPopupBoundsBlock(uiBlock *block, int addval, int mx, int my) static void ui_draw_linkline(uiBut *but, uiLinkLine *line) { - float vec1[2], vec2[2]; + rcti rect; if(line->from==NULL || line->to==NULL) return; - vec1[0]= (line->from->x1+line->from->x2)/2.0; - vec1[1]= (line->from->y1+line->from->y2)/2.0; - vec2[0]= (line->to->x1+line->to->x2)/2.0; - vec2[1]= (line->to->y1+line->to->y2)/2.0; + rect.xmin= (line->from->x1+line->from->x2)/2.0; + rect.ymin= (line->from->y1+line->from->y2)/2.0; + rect.xmax= (line->to->x1+line->to->x2)/2.0; + rect.ymax= (line->to->y1+line->to->y2)/2.0; - if(line->flag & UI_SELECT) glColor3ub(100,100,100); - else glColor3ub(0,0,0); - fdrawline(vec1[0], vec1[1], vec2[0], vec2[1]); + if(line->flag & UI_SELECT) + glColor3ub(100,100,100); + else + glColor3ub(0,0,0); + + ui_draw_link_bezier(&rect); } static void ui_draw_links(uiBlock *block) @@ -432,6 +435,7 @@ static void ui_draw_links(uiBlock *block) /* ************** BLOCK ENDING FUNCTION ************* */ +/* NOTE: if but->poin is allocated memory for every defbut, things fail... */ static int ui_but_equals_old(uiBut *but, uiBut *oldbut) { /* various properties are being compared here, hopfully sufficient @@ -474,6 +478,8 @@ static int ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBut but->selend= oldbut->selend; but->softmin= oldbut->softmin; but->softmax= oldbut->softmax; + but->linkto[0]= oldbut->linkto[0]; + but->linkto[1]= oldbut->linkto[1]; found= 1; oldbut->active= NULL; @@ -732,8 +738,13 @@ static void ui_is_but_sel(uiBut *but) /* XXX 2.50 no links supported yet */ -#if 0 -static uiBut *ui_get_valid_link_button(uiBlock *block, uiBut *but, short *mval) +static int uibut_contains_pt(uiBut *but, short *mval) +{ + return 0; + +} + +uiBut *ui_get_valid_link_button(uiBlock *block, uiBut *but, short *mval) { uiBut *bt; @@ -744,7 +755,7 @@ static uiBut *ui_get_valid_link_button(uiBlock *block, uiBut *but, short *mval) if (bt) { if (but->type==LINK && bt->type==INLINK) { - if( but->link->tocode == (int)bt->min ) { + if( but->link->tocode == (int)bt->hardmin ) { return bt; } } @@ -758,21 +769,6 @@ static uiBut *ui_get_valid_link_button(uiBlock *block, uiBut *but, short *mval) return NULL; } -static int ui_is_a_link(uiBut *from, uiBut *to) -{ - uiLinkLine *line; - uiLink *link; - - link= from->link; - if(link) { - line= link->lines.first; - while(line) { - if(line->from==from && line->to==to) return 1; - line= line->next; - } - } - return 0; -} static uiBut *ui_find_inlink(uiBlock *block, void *poin) { @@ -838,98 +834,6 @@ void uiComposeLinks(uiBlock *block) } } -static void ui_add_link(uiBut *from, uiBut *to) -{ - /* in 'from' we have to add a link to 'to' */ - uiLink *link; - void **oldppoin; - int a; - - if(ui_is_a_link(from, to)) { - printf("already exists\n"); - return; - } - - link= from->link; - - /* are there more pointers allowed? */ - if(link->ppoin) { - oldppoin= *(link->ppoin); - - (*(link->totlink))++; - *(link->ppoin)= MEM_callocN( *(link->totlink)*sizeof(void *), "new link"); - - for(a=0; a< (*(link->totlink))-1; a++) { - (*(link->ppoin))[a]= oldppoin[a]; - } - (*(link->ppoin))[a]= to->poin; - - if(oldppoin) MEM_freeN(oldppoin); - } - else { - *(link->poin)= to->poin; - } - -} - -static int ui_do_but_LINK(uiBlock *block, uiBut *but) -{ - /* - * This button only visualizes, the dobutton mode - * can add a new link, but then the whole system - * should be redrawn/initialized. - * - */ - uiBut *bt=0, *bto=NULL; - short sval[2], mval[2], mvalo[2], first= 1; - - uiGetMouse(curarea->win, sval); - mvalo[0]= sval[0]; - mvalo[1]= sval[1]; - - while (get_mbut() & L_MOUSE) { - uiGetMouse(curarea->win, mval); - - if(mval[0]!=mvalo[0] || mval[1]!=mvalo[1] || first) { - /* clear completely, because of drawbuttons */ - bt= ui_get_valid_link_button(block, but, mval); - if(bt) { - bt->flag |= UI_ACTIVE; - ui_draw_but(ar, bt); - } - if(bto && bto!=bt) { - bto->flag &= ~UI_ACTIVE; - ui_draw_but(ar, bto); - } - bto= bt; - - if (!first) { - glutil_draw_front_xor_line(sval[0], sval[1], mvalo[0], mvalo[1]); - } - glutil_draw_front_xor_line(sval[0], sval[1], mval[0], mval[1]); - - mvalo[0]= mval[0]; - mvalo[1]= mval[1]; - - first= 0; - } - else UI_wait_for_statechange(); - } - - if (!first) { - glutil_draw_front_xor_line(sval[0], sval[1], mvalo[0], mvalo[1]); - } - - if(bt) { - if(but->type==LINK) ui_add_link(but, bt); - else ui_add_link(bt, but); - - scrarea_queue_winredraw(curarea); - } - - return 0; -} -#endif /* ************************************************ */ @@ -1858,18 +1762,24 @@ void ui_check_but(uiBut *but) case ICONTOG: case ICONTOGN: - if(but->flag & UI_SELECT) but->iconadd= 1; - else but->iconadd= 0; + if(!but->rnaprop || (RNA_property_flag(but->rnaprop) & PROP_ICONS_CONSECUTIVE)) { + if(but->flag & UI_SELECT) but->iconadd= 1; + else but->iconadd= 0; + } break; case ICONROW: - value= ui_get_but_val(but); - but->iconadd= (int)value- (int)(but->hardmin); + if(!but->rnaprop || (RNA_property_flag(but->rnaprop) & PROP_ICONS_CONSECUTIVE)) { + value= ui_get_but_val(but); + but->iconadd= (int)value- (int)(but->hardmin); + } break; case ICONTEXTROW: - value= ui_get_but_val(but); - but->iconadd= (int)value- (int)(but->hardmin); + if(!but->rnaprop || (RNA_property_flag(but->rnaprop) & PROP_ICONS_CONSECUTIVE)) { + value= ui_get_but_val(but); + but->iconadd= (int)value- (int)(but->hardmin); + } break; } @@ -2231,7 +2141,7 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, char *str, short } } - if(but->type==HSVCUBE) { /* hsv buttons temp storage */ + if(ELEM(but->type, HSVCUBE, HSVCIRCLE)) { /* hsv buttons temp storage */ float rgb[3]; ui_get_but_vectorf(but, rgb); rgb_to_hsv(rgb[0], rgb[1], rgb[2], but->hsv, but->hsv+1, but->hsv+2); @@ -2266,7 +2176,7 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1, uiBut *but; PropertyRNA *prop; PropertyType proptype; - int freestr= 0; + int freestr= 0, icon= 0; prop= RNA_struct_find_property(ptr, propname); @@ -2278,14 +2188,22 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1, if(type == MENU && proptype == PROP_ENUM) { const EnumPropertyItem *item; DynStr *dynstr; - int i, totitem; + int i, totitem, value; RNA_property_enum_items(ptr, prop, &item, &totitem); + value= RNA_property_enum_get(ptr, prop); dynstr= BLI_dynstr_new(); BLI_dynstr_appendf(dynstr, "%s%%t", RNA_property_ui_name(prop)); - for(i=0; i<totitem; i++) - BLI_dynstr_appendf(dynstr, "|%s %%x%d", item[i].name, item[i].value); + for(i=0; i<totitem; i++) { + if(item[i].icon) + BLI_dynstr_appendf(dynstr, "|%s %%i%d %%x%d", item[i].name, item[i].icon, item[i].value); + else + BLI_dynstr_appendf(dynstr, "|%s %%x%d", item[i].name, item[i].value); + + if(value == item[i].value) + icon= item[i].icon; + } str= BLI_dynstr_get_cstring(dynstr); BLI_dynstr_free(dynstr); @@ -2296,15 +2214,20 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1, int i, totitem; RNA_property_enum_items(ptr, prop, &item, &totitem); - for(i=0; i<totitem; i++) - if(item[i].value == (int)max) + for(i=0; i<totitem; i++) { + if(item[i].value == (int)max) { str= (char*)item[i].name; + icon= item[i].icon; + } + } if(!str) str= (char*)RNA_property_ui_name(prop); } - else + else { str= (char*)RNA_property_ui_name(prop); + icon= RNA_property_ui_icon(prop); + } } if(!tip) { @@ -2383,6 +2306,13 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1, if(type == IDPOIN) uiButSetCompleteFunc(but, ui_rna_ID_autocomplete, but); + + } + + if(icon) { + but->icon= (BIFIconID)icon; + but->flag |= UI_HAS_ICON; + but->flag|= UI_ICON_LEFT; } if (!prop || !RNA_property_editable(&but->rnapoin, prop)) { @@ -2652,8 +2582,10 @@ uiBut *uiDefIconButR(uiBlock *block, int type, int retval, int icon, short x1, s but= ui_def_but_rna(block, type, retval, "", x1, y1, x2, y2, ptr, propname, index, min, max, a1, a2, tip); if(but) { - but->icon= (BIFIconID) icon; - but->flag|= UI_HAS_ICON; + if(icon) { + but->icon= (BIFIconID) icon; + but->flag|= UI_HAS_ICON; + } ui_check_but(but); } @@ -2735,8 +2667,10 @@ uiBut *uiDefIconTextButR(uiBlock *block, int type, int retval, int icon, char *s but= ui_def_but_rna(block, type, retval, str, x1, y1, x2, y2, ptr, propname, index, min, max, a1, a2, tip); if(but) { - but->icon= (BIFIconID) icon; - but->flag|= UI_HAS_ICON; + if(icon) { + but->icon= (BIFIconID) icon; + but->flag|= UI_HAS_ICON; + } but->flag|= UI_ICON_LEFT; ui_check_but(but); } @@ -2778,60 +2712,6 @@ uiBut *uiDefMenuSep(uiBlock *block) return uiDefBut(block, SEPR, 0, "", 0, y, MENU_WIDTH, MENU_SEP_HEIGHT, NULL, 0.0, 0.0, 0, 0, ""); } -uiBut *uiDefMenuSub(uiBlock *block, uiBlockCreateFunc func, char *name) -{ - int y= ui_menu_y(block) - MENU_ITEM_HEIGHT; - return uiDefIconTextBlockBut(block, func, NULL, ICON_BLANK1, name, 0, y, MENU_WIDTH, MENU_ITEM_HEIGHT-1, ""); -} - -uiBut *uiDefMenuTogR(uiBlock *block, PointerRNA *ptr, char *propname, char *propvalue, char *name) -{ - uiBut *but; - PropertyRNA *prop; - PropertyType type; - const EnumPropertyItem *item; - int a, value, totitem, icon= ICON_CHECKBOX_DEHLT; - int y= ui_menu_y(block) - MENU_ITEM_HEIGHT; - - prop= RNA_struct_find_property(ptr, propname); - if(prop) { - type= RNA_property_type(prop); - - if(type == PROP_BOOLEAN) { - if(RNA_property_boolean_get(ptr, prop)) - icon= ICON_CHECKBOX_HLT; - - return uiDefIconTextButR(block, TOG, 0, icon, name, 0, y, MENU_WIDTH, MENU_ITEM_HEIGHT-1, ptr, propname, 0, 0, 0, 0, 0, NULL); - } - else if(type == PROP_ENUM) { - RNA_property_enum_items(ptr, prop, &item, &totitem); - - value= 0; - for(a=0; a<totitem; a++) { - if(propvalue && strcmp(propvalue, item[a].identifier) == 0) { - value= item[a].value; - if(!name) - name= (char*)item[a].name; - - if(RNA_property_enum_get(ptr, prop) == value) - icon= ICON_CHECKBOX_HLT; - break; - } - } - - if(a != totitem) - return uiDefIconTextButR(block, ROW, 0, icon, name, 0, y, MENU_WIDTH, MENU_ITEM_HEIGHT-1, ptr, propname, 0, 0, value, 0, 0, NULL); - } - } - - /* not found */ - uiBlockSetButLock(block, 1, ""); - but= uiDefIconTextBut(block, BUT, 0, ICON_BLANK1, propname, 0, y, MENU_WIDTH, MENU_ITEM_HEIGHT, NULL, 0.0, 0.0, 0, 0, ""); - uiBlockClearButLock(block); - - return but; -} - /* END Button containing both string label and icon */ void uiSetButLink(uiBut *but, void **poin, void ***ppoin, short *tot, int from, int to) @@ -2873,8 +2753,8 @@ void uiBlockFlipOrder(uiBlock *block) uiBut *but, *next; float centy, miny=10000, maxy= -10000; -// if(U.uiflag & USER_PLAINMENUS) -// return; + if(!(U.uiflag & USER_DIRECTIONALORDER)) + return; for(but= block->buttons.first; but; but= but->next) { if(but->flag & UI_BUT_ALIGN) return; @@ -3012,6 +2892,16 @@ uiBut *uiDefBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, char *st return but; } +uiBut *uiDefBlockButN(uiBlock *block, uiBlockCreateFunc func, void *argN, char *str, short x1, short y1, short x2, short y2, char *tip) +{ + uiBut *but= ui_def_but(block, BLOCK, 0, str, x1, y1, x2, y2, NULL, 0.0, 0.0, 0.0, 0.0, tip); + but->block_create_func= func; + but->func_argN= argN; + ui_check_but(but); + return but; +} + + uiBut *uiDefPulldownBut(uiBlock *block, uiBlockCreateFunc func, void *arg, char *str, short x1, short y1, short x2, short y2, char *tip) { uiBut *but= ui_def_but(block, PULLDOWN, 0, str, x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip); @@ -3095,7 +2985,6 @@ uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxle but->flag|= UI_HAS_ICON; but->flag|= UI_ICON_LEFT|UI_TEXT_LEFT; - but->flag|= UI_ICON_SUBMENU; ui_check_but(but); diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index b9e4b18761f..fb5afbf5e36 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -165,6 +165,7 @@ typedef struct uiAfterFunc { bContextStore *context; } uiAfterFunc; +static int ui_mouse_inside_button(ARegion *ar, uiBut *but, int x, int y); static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState state); static int ui_handler_region_menu(bContext *C, wmEvent *event, void *userdata); static int ui_handler_popup(bContext *C, wmEvent *event, void *userdata); @@ -525,6 +526,149 @@ static void ui_apply_but_CHARTAB(bContext *C, uiBut *but, uiHandleButtonData *da } #endif + +static void ui_delete_active_linkline(uiBlock *block) +{ + uiBut *but; + uiLink *link; + uiLinkLine *line, *nline; + int a, b; + + but= block->buttons.first; + while(but) { + if(but->type==LINK && but->link) { + line= but->link->lines.first; + while(line) { + + nline= line->next; + + if(line->flag & UI_SELECT) { + BLI_remlink(&but->link->lines, line); + + link= line->from->link; + + /* are there more pointers allowed? */ + if(link->ppoin) { + + if(*(link->totlink)==1) { + *(link->totlink)= 0; + MEM_freeN(*(link->ppoin)); + *(link->ppoin)= NULL; + } + else { + b= 0; + for(a=0; a< (*(link->totlink)); a++) { + + if( (*(link->ppoin))[a] != line->to->poin ) { + (*(link->ppoin))[b]= (*(link->ppoin))[a]; + b++; + } + } + (*(link->totlink))--; + } + } + else { + *(link->poin)= NULL; + } + + MEM_freeN(line); + } + line= nline; + } + } + but= but->next; + } +} + + +static uiLinkLine *ui_is_a_link(uiBut *from, uiBut *to) +{ + uiLinkLine *line; + uiLink *link; + + link= from->link; + if(link) { + line= link->lines.first; + while(line) { + if(line->from==from && line->to==to) return line; + line= line->next; + } + } + return NULL; +} + +static void ui_add_link(uiBut *from, uiBut *to) +{ + /* in 'from' we have to add a link to 'to' */ + uiLink *link; + uiLinkLine *line; + void **oldppoin; + int a; + + if( (line= ui_is_a_link(from, to)) ) { + line->flag |= UI_SELECT; + ui_delete_active_linkline(from->block); + printf("already exists, means deletion now\n"); + return; + } + + if (from->type==LINK && to->type==INLINK) { + if( from->link->tocode != (int)to->hardmin ) { + printf("cannot link\n"); + return; + } + } + else if(from->type==INLINK && to->type==LINK) { + if( to->link->tocode == (int)from->hardmin ) { + printf("cannot link\n"); + return; + } + } + + link= from->link; + + /* are there more pointers allowed? */ + if(link->ppoin) { + oldppoin= *(link->ppoin); + + (*(link->totlink))++; + *(link->ppoin)= MEM_callocN( *(link->totlink)*sizeof(void *), "new link"); + + for(a=0; a< (*(link->totlink))-1; a++) { + (*(link->ppoin))[a]= oldppoin[a]; + } + (*(link->ppoin))[a]= to->poin; + + if(oldppoin) MEM_freeN(oldppoin); + } + else { + *(link->poin)= to->poin; + } + +} + + +static void ui_apply_but_LINK(bContext *C, uiBut *but, uiHandleButtonData *data) +{ + ARegion *ar= CTX_wm_region(C); + uiBut *bt; + + for(bt= but->block->buttons.first; bt; bt= bt->next) { + if( ui_mouse_inside_button(ar, bt, but->linkto[0]+ar->winrct.xmin, but->linkto[1]+ar->winrct.ymin) ) + break; + } + if(bt && bt!=but) { + + if(but->type==LINK) ui_add_link(but, bt); + else ui_add_link(bt, but); + + ui_apply_but_func(C, but); + data->retval= but->retval; + } + data->applied= 1; +} + + static void ui_apply_button(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, int interactive) { char *editstr; @@ -621,6 +765,7 @@ static void ui_apply_button(bContext *C, uiBlock *block, uiBut *but, uiHandleBut break; case BUT_NORMAL: case HSVCUBE: + case HSVCIRCLE: ui_apply_but_VEC(C, but, data); break; case BUT_COLORBAND: @@ -639,6 +784,7 @@ static void ui_apply_button(bContext *C, uiBlock *block, uiBut *but, uiHandleBut #endif case LINK: case INLINK: + ui_apply_but_LINK(C, but, data); break; default: break; @@ -1263,7 +1409,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle /* exit on LMB only on RELEASE for searchbox, to mimic other popups, and allow multiple menu levels */ if(data->searchbox) - inbox= BLI_in_rcti(&data->searchbox->winrct, event->x, event->y); + inbox= ui_searchbox_inside(data->searchbox, event->x, event->y); if(event->val==KM_PRESS) { mx= event->x; @@ -1287,6 +1433,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle } } else if(inbox) { + printf("release inside \n"); button_activate_state(C, but, BUTTON_STATE_EXIT); retval= WM_UI_HANDLER_BREAK; } @@ -1431,7 +1578,7 @@ static void ui_numedit_begin(uiBut *but, uiHandleButtonData *data) data->coba= (ColorBand*)but->poin; but->editcoba= data->coba; } - else if(ELEM(but->type, BUT_NORMAL, HSVCUBE)) { + else if(ELEM3(but->type, BUT_NORMAL, HSVCUBE, HSVCIRCLE)) { ui_get_but_vectorf(but, data->origvec); VECCOPY(data->vec, data->origvec); but->editvec= data->vec; @@ -1494,7 +1641,7 @@ static void ui_blockopen_begin(bContext *C, uiBut *but, uiHandleButtonData *data } else { func= but->block_create_func; - arg= but->poin; + arg= but->poin?but->poin:but->func_argN; } break; case MENU: @@ -1772,7 +1919,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton click= 1; } else if(event->val==KM_PRESS) { - if(ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->shift) { + if(ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->ctrl) { button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING); retval= WM_UI_HANDLER_BREAK; } @@ -1983,7 +2130,7 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton click= 2; } else if(event->val==KM_PRESS) { - if(ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->shift) { + if(ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->ctrl) { button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING); retval= WM_UI_HANDLER_BREAK; } @@ -2025,7 +2172,7 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton } if(click) { - if (event->ctrl || click==2) { + if (click==2) { /* nudge slider to the left or right */ float f, tempf, softmin, softmax, softrange; int temp; @@ -2078,6 +2225,7 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, wmEvent *event) { + if(data->state == BUTTON_STATE_HIGHLIGHT) { if(ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) { button_activate_state(C, but, BUTTON_STATE_MENU_OPEN); @@ -2098,6 +2246,25 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, wm return WM_UI_HANDLER_BREAK; } } + else if(but->type==COL) { + if( ELEM(event->type, WHEELDOWNMOUSE, WHEELUPMOUSE) && event->alt) { + float col[3]; + + ui_get_but_vectorf(but, col); + rgb_to_hsv(col[0], col[1], col[2], but->hsv, but->hsv+1, but->hsv+2); + + if(event->type==WHEELDOWNMOUSE) + but->hsv[2]= CLAMPIS(but->hsv[2]-0.05f, 0.0f, 1.0f); + else + but->hsv[2]= CLAMPIS(but->hsv[2]+0.05f, 0.0f, 1.0f); + + hsv_to_rgb(but->hsv[0], but->hsv[1], but->hsv[2], data->vec, data->vec+1, data->vec+2); + + button_activate_state(C, but, BUTTON_STATE_EXIT); + ui_apply_button(C, but->block, but, data, 1); + return WM_UI_HANDLER_BREAK; + } + } } return WM_UI_HANDLER_CONTINUE; @@ -2221,8 +2388,11 @@ static int ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx, but->hsv[2]= x; but->hsv[1]= y; } - else + else if(but->a1==3) { but->hsv[0]= x; + } + else + but->hsv[2]= y; ui_set_but_hsv(but); // converts to rgb @@ -2274,6 +2444,79 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu return WM_UI_HANDLER_CONTINUE; } +static int ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, int mx, int my) +{ + rcti rect; + int changed= 1; + + rect.xmin= but->x1; rect.xmax= but->x2; + rect.ymin= but->y1; rect.ymax= but->y2; + + ui_hsvcircle_vals_from_pos(but->hsv, but->hsv+1, &rect, (float)mx, (float)my); + + ui_set_but_hsv(but); // converts to rgb + + // update button values and strings + // XXX ui_update_block_buts_hsv(but->block, but->hsv); + + data->draglastx= mx; + data->draglasty= my; + + return changed; +} + + +static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event) +{ + int mx, my; + + mx= event->x; + my= event->y; + ui_window_to_block(data->region, block, &mx, &my); + + if(data->state == BUTTON_STATE_HIGHLIGHT) { + if(event->type==LEFTMOUSE && event->val==KM_PRESS) { + data->dragstartx= mx; + data->dragstarty= my; + data->draglastx= mx; + data->draglasty= my; + button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); + + /* also do drag the first time */ + if(ui_numedit_but_HSVCIRCLE(but, data, mx, my)) + ui_numedit_apply(C, block, but, data); + + return WM_UI_HANDLER_BREAK; + } + } + else if(data->state == BUTTON_STATE_NUM_EDITING) { + /* XXX hardcoded keymap check.... */ + if(event->type == WHEELDOWNMOUSE) { + but->hsv[2]= CLAMPIS(but->hsv[2]-0.05f, 0.0f, 1.0f); + ui_set_but_hsv(but); // converts to rgb + ui_numedit_apply(C, block, but, data); + } + else if(event->type == WHEELUPMOUSE) { + but->hsv[2]= CLAMPIS(but->hsv[2]+0.05f, 0.0f, 1.0f); + ui_set_but_hsv(but); // converts to rgb + ui_numedit_apply(C, block, but, data); + } + else if(event->type == MOUSEMOVE) { + if(mx!=data->draglastx || my!=data->draglasty) { + if(ui_numedit_but_HSVCIRCLE(but, data, mx, my)) + ui_numedit_apply(C, block, but, data); + } + } + else if(event->type==LEFTMOUSE && event->val!=KM_PRESS) + button_activate_state(C, but, BUTTON_STATE_EXIT); + + return WM_UI_HANDLER_BREAK; + } + + return WM_UI_HANDLER_CONTINUE; +} + + static int verg_colorband(const void *a1, const void *a2) { const CBData *x1=a1, *x2=a2; @@ -2708,6 +2951,38 @@ static int ui_do_but_CHARTAB(bContext *C, uiBlock *block, uiBut *but, uiHandleBu } #endif + +static int ui_do_but_LINK(bContext *C, uiBut *but, uiHandleButtonData *data, wmEvent *event) +{ + ARegion *ar= CTX_wm_region(C); + + but->linkto[0]= event->x-ar->winrct.xmin; + but->linkto[1]= event->y-ar->winrct.ymin; + + if(data->state == BUTTON_STATE_HIGHLIGHT) { + if(event->type == LEFTMOUSE && event->val==KM_PRESS) { + button_activate_state(C, but, BUTTON_STATE_WAIT_RELEASE); + return WM_UI_HANDLER_BREAK; + } + else if(event->type == LEFTMOUSE && but->block->handle) { + button_activate_state(C, but, BUTTON_STATE_EXIT); + return WM_UI_HANDLER_BREAK; + } + } + else if(data->state == BUTTON_STATE_WAIT_RELEASE) { + + if(event->type == LEFTMOUSE && event->val!=KM_PRESS) { + if(!(but->flag & UI_SELECT)) + data->cancel= 1; + button_activate_state(C, but, BUTTON_STATE_EXIT); + return WM_UI_HANDLER_BREAK; + } + } + + return WM_UI_HANDLER_CONTINUE; +} + + static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event) { uiHandleButtonData *data; @@ -2845,18 +3120,19 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event) case HSVCUBE: retval= ui_do_but_HSVCUBE(C, block, but, data, event); break; + case HSVCIRCLE: + retval= ui_do_but_HSVCIRCLE(C, block, but, data, event); + break; #ifdef INTERNATIONAL case CHARTAB: retval= ui_do_but_CHARTAB(C, block, but, data, event); break; #endif - /* XXX 2.50 links not implemented yet */ -#if 0 + case LINK: case INLINK: - retval= retval= ui_do_but_LINK(block, but); + retval= ui_do_but_LINK(C, but, data, event); break; -#endif } return retval; @@ -3112,7 +3388,7 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA but->block->auto_open= 0; button_activate_state(C, but, BUTTON_STATE_HIGHLIGHT); - + if(type == BUTTON_ACTIVATE_OPEN) { button_activate_state(C, but, BUTTON_STATE_MENU_OPEN); @@ -3320,21 +3596,29 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but) else if(data->state == BUTTON_STATE_WAIT_RELEASE) { switch(event->type) { case MOUSEMOVE: - /* deselect the button when moving the mouse away */ - if(ui_mouse_inside_button(ar, but, event->x, event->y)) { - if(!(but->flag & UI_SELECT)) { - but->flag |= UI_SELECT; - data->cancel= 0; - ED_region_tag_redraw(data->region); - } + + if(ELEM(but->type,LINK, INLINK)) { + but->flag |= UI_SELECT; + ui_do_button(C, block, but, event); + ED_region_tag_redraw(data->region); } else { - if(but->flag & UI_SELECT) { - but->flag &= ~UI_SELECT; - data->cancel= 1; - ED_region_tag_redraw(data->region); + /* deselect the button when moving the mouse away */ + if(ui_mouse_inside_button(ar, but, event->x, event->y)) { + if(!(but->flag & UI_SELECT)) { + but->flag |= UI_SELECT; + data->cancel= 0; + ED_region_tag_redraw(data->region); + } } - } + else { + if(but->flag & UI_SELECT) { + but->flag &= ~UI_SELECT; + data->cancel= 1; + ED_region_tag_redraw(data->region); + } + } + } break; default: /* otherwise catch mouse release event */ @@ -3360,7 +3644,8 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but) uiBut *bt= ui_but_find_mouse_over(ar, event->x, event->y); if(bt && bt->active != data) { - data->cancel= 1; + if(but->type != COL) /* exception */ + data->cancel= 1; button_activate_state(C, but, BUTTON_STATE_EXIT); } break; @@ -3389,7 +3674,7 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but) return retval; } -static void ui_handle_button_closed_submenu(bContext *C, wmEvent *event, uiBut *but) +static void ui_handle_button_return_submenu(bContext *C, wmEvent *event, uiBut *but) { uiHandleButtonData *data; uiPopupBlockHandle *menu; @@ -3398,12 +3683,19 @@ static void ui_handle_button_closed_submenu(bContext *C, wmEvent *event, uiBut * menu= data->menu; /* copy over return values from the closing menu */ - if(menu->menuretval == UI_RETURN_OK) { + if(menu->menuretval == UI_RETURN_OK || menu->menuretval == UI_RETURN_UPDATE) { if(but->type == COL) VECCOPY(data->vec, menu->retvec) else if(ELEM3(but->type, MENU, ICONROW, ICONTEXTROW)) data->value= menu->retvalue; } + + if(menu->menuretval == UI_RETURN_UPDATE) { + if(data->interactive) ui_apply_button(C, but->block, but, data, 1); + else ui_check_but(but); + + menu->menuretval= 0; + } /* now change button state or exit, which will close the submenu */ if(ELEM(menu->menuretval, UI_RETURN_OK, UI_RETURN_CANCEL)) { @@ -3522,7 +3814,9 @@ int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle *menu, if(block->miny <= my && block->maxy >= my) inside= 1; - if((but=ui_but_find_activated(ar)) && button_modal_state(but->active->state)) { + /* if there's an active modal button, don't check events or outside, except for search menu */ + but= ui_but_find_activated(ar); + if(but && button_modal_state(but->active->state) && but->type!=SEARCH_MENU) { /* if a button is activated modal, always reset the start mouse * position of the towards mechanism to avoid loosing focus, * and don't handle events */ @@ -3533,125 +3827,130 @@ int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle *menu, if(event->type == MOUSEMOVE) ui_mouse_motion_towards_init(menu, mx, my, 0); - switch(event->type) { - /* closing sublevels of pulldowns */ - case LEFTARROWKEY: - if(event->val==KM_PRESS && (block->flag & UI_BLOCK_LOOP)) - if(BLI_countlist(&block->saferct) > 0) - menu->menuretval= UI_RETURN_OUT; + /* first block own event func */ + if(block->block_event_func && block->block_event_func(C, block, event)); + /* events not for active search menu button */ + else if(but==NULL || but->type!=SEARCH_MENU) { + switch(event->type) { + /* closing sublevels of pulldowns */ + case LEFTARROWKEY: + if(event->val==KM_PRESS && (block->flag & UI_BLOCK_LOOP)) + if(BLI_countlist(&block->saferct) > 0) + menu->menuretval= UI_RETURN_OUT; - retval= WM_UI_HANDLER_BREAK; - break; - - /* opening sublevels of pulldowns */ - case RIGHTARROWKEY: - if(event->val==KM_PRESS && (block->flag & UI_BLOCK_LOOP)) { - but= ui_but_find_activated(ar); - - if(!but) { - /* no item active, we make first active */ - if(block->direction & UI_TOP) but= ui_but_last(block); - else but= ui_but_first(block); - } - - if(but && ELEM(but->type, BLOCK, PULLDOWN)) - ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE_OPEN); - } + retval= WM_UI_HANDLER_BREAK; + break; - retval= WM_UI_HANDLER_BREAK; - break; - - case UPARROWKEY: - case DOWNARROWKEY: - case WHEELUPMOUSE: - case WHEELDOWNMOUSE: - /* arrowkeys: only handle for block_loop blocks */ - if(inside || (block->flag & UI_BLOCK_LOOP)) { - if(event->val==KM_PRESS) { + /* opening sublevels of pulldowns */ + case RIGHTARROWKEY: + if(event->val==KM_PRESS && (block->flag & UI_BLOCK_LOOP)) { but= ui_but_find_activated(ar); - if(but) { - if(ELEM(event->type, DOWNARROWKEY, WHEELDOWNMOUSE)) { - if(block->direction & UI_TOP) but= ui_but_prev(but); - else but= ui_but_next(but); - } - else { - if(block->direction & UI_TOP) but= ui_but_next(but); - else but= ui_but_prev(but); - } - if(but) - ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE); + if(!but) { + /* no item active, we make first active */ + if(block->direction & UI_TOP) but= ui_but_last(block); + else but= ui_but_first(block); } - if(!but) { - if(ELEM(event->type, UPARROWKEY, WHEELUPMOUSE)) { - if(block->direction & UI_TOP) bt= ui_but_first(block); - else bt= ui_but_last(block); - } - else { - if(block->direction & UI_TOP) bt= ui_but_last(block); - else bt= ui_but_first(block); + if(but && ELEM(but->type, BLOCK, PULLDOWN)) + ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE_OPEN); + } + + retval= WM_UI_HANDLER_BREAK; + break; + + case UPARROWKEY: + case DOWNARROWKEY: + case WHEELUPMOUSE: + case WHEELDOWNMOUSE: + /* arrowkeys: only handle for block_loop blocks */ + if(inside || (block->flag & UI_BLOCK_LOOP)) { + if(event->val==KM_PRESS) { + but= ui_but_find_activated(ar); + if(but) { + if(ELEM(event->type, DOWNARROWKEY, WHEELDOWNMOUSE)) { + if(block->direction & UI_TOP) but= ui_but_prev(but); + else but= ui_but_next(but); + } + else { + if(block->direction & UI_TOP) but= ui_but_next(but); + else but= ui_but_prev(but); + } + + if(but) + ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE); } - if(bt) - ui_handle_button_activate(C, ar, bt, BUTTON_ACTIVATE); + if(!but) { + if(ELEM(event->type, UPARROWKEY, WHEELUPMOUSE)) { + if(block->direction & UI_TOP) bt= ui_but_first(block); + else bt= ui_but_last(block); + } + else { + if(block->direction & UI_TOP) bt= ui_but_last(block); + else bt= ui_but_first(block); + } + + if(bt) + ui_handle_button_activate(C, ar, bt, BUTTON_ACTIVATE); + } } } - } - retval= WM_UI_HANDLER_BREAK; - break; + retval= WM_UI_HANDLER_BREAK; + break; - case ONEKEY: case PAD1: - act= 1; - case TWOKEY: case PAD2: - if(act==0) act= 2; - case THREEKEY: case PAD3: - if(act==0) act= 3; - case FOURKEY: case PAD4: - if(act==0) act= 4; - case FIVEKEY: case PAD5: - if(act==0) act= 5; - case SIXKEY: case PAD6: - if(act==0) act= 6; - case SEVENKEY: case PAD7: - if(act==0) act= 7; - case EIGHTKEY: case PAD8: - if(act==0) act= 8; - case NINEKEY: case PAD9: - if(act==0) act= 9; - case ZEROKEY: case PAD0: - if(act==0) act= 10; - - if(block->flag & UI_BLOCK_NUMSELECT) { - if(event->alt) act+= 10; - - count= 0; - for(but= block->buttons.first; but; but= but->next) { - int doit= 0; + case ONEKEY: case PAD1: + act= 1; + case TWOKEY: case PAD2: + if(act==0) act= 2; + case THREEKEY: case PAD3: + if(act==0) act= 3; + case FOURKEY: case PAD4: + if(act==0) act= 4; + case FIVEKEY: case PAD5: + if(act==0) act= 5; + case SIXKEY: case PAD6: + if(act==0) act= 6; + case SEVENKEY: case PAD7: + if(act==0) act= 7; + case EIGHTKEY: case PAD8: + if(act==0) act= 8; + case NINEKEY: case PAD9: + if(act==0) act= 9; + case ZEROKEY: case PAD0: + if(act==0) act= 10; + + if(block->flag & UI_BLOCK_NUMSELECT) { + if(event->alt) act+= 10; - if(but->type!=LABEL && but->type!=SEPR) - count++; + count= 0; + for(but= block->buttons.first; but; but= but->next) { + int doit= 0; + + if(but->type!=LABEL && but->type!=SEPR) + count++; - /* exception for menus like layer buts, with button aligning they're not drawn in order */ - if(but->type==TOGR) { - if(but->bitnr==act-1) - doit= 1; - } - else if(count==act) - doit=1; - - if(doit) { - ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE_APPLY); - break; + /* exception for menus like layer buts, with button aligning they're not drawn in order */ + if(but->type==TOGR) { + if(but->bitnr==act-1) + doit= 1; + } + else if(count==act) + doit=1; + + if(doit) { + ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE_APPLY); + break; + } } } - } - retval= WM_UI_HANDLER_BREAK; - break; + retval= WM_UI_HANDLER_BREAK; + break; + } } - + /* here we check return conditions for menus */ if(block->flag & UI_BLOCK_LOOP) { /* if we click outside the block, verify if we clicked on the @@ -3696,8 +3995,12 @@ int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle *menu, } /* strict check, and include the parent rect */ - if(!menu->dotowards && !saferct) - menu->menuretval= (block->flag & UI_BLOCK_KEEP_OPEN)? UI_RETURN_OK: UI_RETURN_OUT; + if(!menu->dotowards && !saferct) { + if(block->flag & UI_BLOCK_OUT_1) + menu->menuretval= UI_RETURN_OK; + else + menu->menuretval= (block->flag & UI_BLOCK_KEEP_OPEN)? UI_RETURN_OK: UI_RETURN_OUT; + } else if(menu->dotowards && event->type==MOUSEMOVE) retval= WM_UI_HANDLER_BREAK; } @@ -3709,7 +4012,7 @@ int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle *menu, * buttons inside this region. disabled inside check .. not sure * anymore why it was there? but i meant enter enter didn't work * for example when mouse was not over submenu */ - if((/*inside &&*/ !menu->menuretval && retval == WM_UI_HANDLER_CONTINUE) || event->type == TIMER) { + if((/*inside &&*/ (!menu->menuretval || menu->menuretval == UI_RETURN_UPDATE) && retval == WM_UI_HANDLER_CONTINUE) || event->type == TIMER) { but= ui_but_find_activated(ar); if(but) { @@ -3739,7 +4042,7 @@ int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle *menu, return retval; } -static int ui_handle_menu_closed_submenu(bContext *C, wmEvent *event, uiPopupBlockHandle *menu) +static int ui_handle_menu_return_submenu(bContext *C, wmEvent *event, uiPopupBlockHandle *menu) { ARegion *ar; uiBut *but; @@ -3764,10 +4067,15 @@ static int ui_handle_menu_closed_submenu(bContext *C, wmEvent *event, uiPopupBlo menu->butretval= data->retval; } } + else if(submenu->menuretval == UI_RETURN_UPDATE) + menu->menuretval = UI_RETURN_UPDATE; /* now let activated button in this menu exit, which * will actually close the submenu too */ - ui_handle_button_closed_submenu(C, event, but); + ui_handle_button_return_submenu(C, event, but); + + if(submenu->menuretval == UI_RETURN_UPDATE) + submenu->menuretval = 0; } /* for cases where close does not cascade, allow the user to @@ -3801,7 +4109,7 @@ static int ui_handle_menus_recursive(bContext *C, wmEvent *event, uiPopupBlockHa /* now handle events for our own menu */ if(retval == WM_UI_HANDLER_CONTINUE || event->type == TIMER) { if(submenu && submenu->menuretval) - retval= ui_handle_menu_closed_submenu(C, event, menu); + retval= ui_handle_menu_return_submenu(C, event, menu); else retval= ui_handle_menu_event(C, event, menu, (submenu == NULL)); } @@ -3894,7 +4202,7 @@ static int ui_handler_region_menu(bContext *C, wmEvent *event, void *userdata) /* handle events for the activated button */ if(retval == WM_UI_HANDLER_CONTINUE || event->type == TIMER) { if(data->menu->menuretval) - ui_handle_button_closed_submenu(C, event, but); + ui_handle_button_return_submenu(C, event, but); else ui_handle_button_event(C, event, but); } diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 18423434eef..3aed2a7c299 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -181,6 +181,7 @@ struct uiBut { void *search_arg; uiLink *link; + short linkto[2]; char *tip, *lockstr; @@ -254,6 +255,9 @@ struct uiBlock { uiBlockHandleFunc handle_func; void *handle_func_arg; + /* custom extra handling */ + int (*block_event_func)(const struct bContext *C, struct uiBlock *, struct wmEvent *); + /* extra draw function for custom blocks */ void (*drawextra)(const struct bContext *C, void *idv, rcti *rect); @@ -306,6 +310,8 @@ extern void ui_set_but_hsv(uiBut *but); extern void ui_get_but_vectorf(uiBut *but, float *vec); extern void ui_set_but_vectorf(uiBut *but, float *vec); +extern void ui_hsvcircle_vals_from_pos(float *valrad, float *valdist, rcti *rect, float mx, float my); + extern void ui_get_but_string(uiBut *but, char *str, int maxlen); extern int ui_set_but_string(struct bContext *C, uiBut *but, const char *str); extern int ui_get_but_string_max_length(uiBut *but); @@ -357,6 +363,7 @@ void ui_tooltip_free(struct bContext *C, struct ARegion *ar); /* searchbox for string button */ ARegion *ui_searchbox_create(struct bContext *C, struct ARegion *butregion, uiBut *but); +int ui_searchbox_inside(struct ARegion *ar, int x, int y); void ui_searchbox_update(struct bContext *C, struct ARegion *ar, uiBut *but, int reset); void ui_searchbox_event(struct bContext *C, struct ARegion *ar, uiBut *but, struct wmEvent *event); void ui_searchbox_apply(uiBut *but, struct ARegion *ar); @@ -402,6 +409,7 @@ extern int ui_button_is_active(struct ARegion *ar); void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3); void ui_draw_menu_back(struct uiStyle *style, uiBlock *block, rcti *rect); void ui_draw_search_back(struct uiStyle *style, uiBlock *block, rcti *rect); +void ui_draw_link_bezier(rcti *rect); extern void ui_draw_but(const struct bContext *C, ARegion *ar, struct uiStyle *style, uiBut *but, rcti *rect); /* theme color init */ diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 723e48e5970..81c49105870 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -427,19 +427,29 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, char *name, int icon uiBlockSetCurLayout(block, layout); } -static void ui_item_enum_row(uiLayout *layout, uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int x, int y, int w, int h) +static void ui_item_enum_row(uiLayout *layout, uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, char *uiname, int x, int y, int w, int h) { const EnumPropertyItem *item; - int a, totitem, itemw; - const char *propname; + const char *identifier; + char *name; + int a, totitem, itemw, icon, value; - propname= RNA_property_identifier(prop); + identifier= RNA_property_identifier(prop); RNA_property_enum_items(ptr, prop, &item, &totitem); uiBlockSetCurLayout(block, ui_item_local_sublayout(layout, layout, 1)); for(a=0; a<totitem; a++) { - itemw= ui_text_icon_width(block->curlayout, (char*)item[a].name, 0); - uiDefButR(block, ROW, 0, NULL, 0, 0, itemw, h, ptr, propname, -1, 0, item[a].value, -1, -1, NULL); + name= (!uiname || uiname[0])? (char*)item[a].name: ""; + icon= item[a].icon; + value= item[a].value; + itemw= ui_text_icon_width(block->curlayout, name, icon); + + if(icon && strcmp(name, "") != 0) + uiDefIconTextButR(block, ROW, 0, icon, name, 0, 0, itemw, h, ptr, identifier, -1, 0, value, -1, -1, NULL); + else if(icon) + uiDefIconButR(block, ROW, 0, icon, 0, 0, itemw, h, ptr, identifier, -1, 0, value, -1, -1, NULL); + else + uiDefButR(block, ROW, 0, name, 0, 0, itemw, h, ptr, identifier, -1, 0, value, -1, -1, NULL); } uiBlockSetCurLayout(block, layout); } @@ -732,6 +742,8 @@ void uiItemFullR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, Proper /* set name and icon */ if(!name) name= (char*)RNA_property_ui_name(prop); + if(!icon) + icon= RNA_property_ui_icon(prop); if(ELEM5(type, PROP_INT, PROP_FLOAT, PROP_STRING, PROP_ENUM, PROP_POINTER)) name= ui_item_name_add_colon(name, namestr); @@ -764,7 +776,7 @@ void uiItemFullR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, Proper } /* expanded enum */ else if(type == PROP_ENUM && expand) - ui_item_enum_row(layout, block, ptr, prop, 0, 0, w, h); + ui_item_enum_row(layout, block, ptr, prop, name, 0, 0, w, h); /* property with separate label */ else if(type == PROP_ENUM || type == PROP_STRING || type == PROP_POINTER) ui_item_with_label(layout, block, name, icon, ptr, prop, index, 0, 0, w, h); @@ -858,7 +870,7 @@ static void ui_item_menu(uiLayout *layout, char *name, int icon, uiMenuCreateFun uiBlockSetCurLayout(block, layout); if(layout->root->type == UI_LAYOUT_HEADER) - uiBlockSetEmboss(block, UI_EMBOSSP); + uiBlockSetEmboss(block, UI_EMBOSS); if(!name) name= ""; @@ -869,7 +881,7 @@ static void ui_item_menu(uiLayout *layout, char *name, int icon, uiMenuCreateFun h= UI_UNIT_Y; if(layout->root->type == UI_LAYOUT_HEADER) /* ugly .. */ - w -= 3; + w -= 10; if(icon) but= uiDefIconTextMenuBut(block, func, arg, icon, (char*)name, 0, 0, w, h, ""); @@ -1484,6 +1496,7 @@ static void ui_litem_layout_split(uiLayout *litem) { uiLayoutItemSplt *split= (uiLayoutItemSplt*)litem; uiItem *item; + float percentage; int itemh, x, y, w, tot=0, colw=0; x= litem->x; @@ -1495,8 +1508,10 @@ static void ui_litem_layout_split(uiLayout *litem) if(tot == 0) return; + percentage= (split->percentage == 0.0f)? 1.0f/(float)tot: split->percentage; + w= (litem->w - (tot-1)*litem->space); - colw= w*split->percentage; + colw= w*percentage; colw= MAX2(colw, 0); for(item=litem->items.first; item; item=item->next) { @@ -1506,7 +1521,7 @@ static void ui_litem_layout_split(uiLayout *litem) x += colw; if(item->next) { - colw= (w - (w*split->percentage))/(tot-1); + colw= (w - (int)(w*percentage))/(tot-1); colw= MAX2(colw, 0); x += litem->space; @@ -1637,7 +1652,7 @@ uiLayout *uiLayoutSplit(uiLayout *layout, float percentage) split->litem.enabled= 1; split->litem.context= layout->context; split->litem.space= layout->root->style->columnspace; - split->percentage= (percentage == 0.0f)? 0.5f: percentage; + split->percentage= percentage; BLI_addtail(&layout->items, split); uiBlockSetCurLayout(layout->root->block, &split->litem); diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 278f7c026b1..72076175ad5 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -69,6 +69,8 @@ #define PNL_ACTIVE 2 #define PNL_WAS_ACTIVE 4 #define PNL_ANIM_ALIGN 8 +#define PNL_NEW_ADDED 16 +#define PNL_FIRST 32 typedef enum uiHandlePanelState { PANEL_STATE_DRAG, @@ -157,18 +159,20 @@ static void ui_panel_copy_offset(Panel *pa, Panel *papar) pa->ofsy= papar->ofsy + papar->sizey-pa->sizey; } -Panel *uiBeginPanel(ARegion *ar, uiBlock *block, PanelType *pt, int *open) +Panel *uiBeginPanel(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, int *open) { uiStyle *style= U.uistyles.first; Panel *pa, *patab, *palast, *panext; - char *panelname= pt->label; - char *tabname= pt->label; + char *drawname= pt->label; + char *idname= pt->idname; + char *tabname= pt->idname; char *hookname= NULL; int newpanel; + int align= panel_aligned(sa, ar); /* check if Panel exists, then use that one */ for(pa=ar->panels.first; pa; pa=pa->next) - if(strncmp(pa->panelname, panelname, UI_MAX_NAME_STR)==0) + if(strncmp(pa->panelname, idname, UI_MAX_NAME_STR)==0) if(strncmp(pa->tabname, tabname, UI_MAX_NAME_STR)==0) break; @@ -181,13 +185,21 @@ Panel *uiBeginPanel(ARegion *ar, uiBlock *block, PanelType *pt, int *open) /* new panel */ pa= MEM_callocN(sizeof(Panel), "new panel"); pa->type= pt; - BLI_strncpy(pa->panelname, panelname, UI_MAX_NAME_STR); + BLI_strncpy(pa->panelname, idname, UI_MAX_NAME_STR); BLI_strncpy(pa->tabname, tabname, UI_MAX_NAME_STR); + + if(pt->flag & PNL_DEFAULT_CLOSED) { + if(align == BUT_VERTICAL) + pa->flag |= PNL_CLOSEDY; + else + pa->flag |= PNL_CLOSEDX; + } pa->ofsx= 0; pa->ofsy= style->panelouter; pa->sizex= 0; pa->sizey= 0; + pa->runtime_flag |= PNL_NEW_ADDED; BLI_addtail(&ar->panels, pa); @@ -207,6 +219,8 @@ Panel *uiBeginPanel(ARegion *ar, uiBlock *block, PanelType *pt, int *open) } } + BLI_strncpy(pa->drawname, drawname, UI_MAX_NAME_STR); + /* if a new panel is added, we insert it right after the panel * that was last added. this way new panels are inserted in the * right place between versions */ @@ -235,7 +249,6 @@ Panel *uiBeginPanel(ARegion *ar, uiBlock *block, PanelType *pt, int *open) if(pa->flag & PNL_CLOSED) return pa; *open= 1; - pa->drawname[0]= 0; /* otherwise closes panels show wrong title */ return pa; } @@ -244,13 +257,20 @@ void uiEndPanel(uiBlock *block, int width, int height) { Panel *pa= block->panel; - if(pa->sizex != width || pa->sizey != height) { - pa->runtime_flag |= PNL_ANIM_ALIGN; - pa->ofsy += pa->sizey-height; + if(pa->runtime_flag & PNL_NEW_ADDED) { + pa->runtime_flag &= ~PNL_NEW_ADDED; + pa->sizex= width; + pa->sizey= height; } + else if(!(width == 0 || height == 0)) { + if(pa->sizex != width || pa->sizey != height) { + pa->runtime_flag |= PNL_ANIM_ALIGN; + pa->ofsy += pa->sizey-height; + } - pa->sizex= width; - pa->sizey= height; + pa->sizex= width; + pa->sizey= height; + } } #if 0 @@ -509,7 +529,7 @@ static void rectf_scale(rctf *rect, float scale) /* panel integrated in buttonswindow, tool/property lists etc */ void ui_draw_aligned_panel(ARegion *ar, uiStyle *style, uiBlock *block, rcti *rect) { - Panel *panel= block->panel, *prev; + Panel *panel= block->panel; rcti headrect; rctf itemrect; int ofsx; @@ -522,14 +542,7 @@ void ui_draw_aligned_panel(ARegion *ar, uiStyle *style, uiBlock *block, rcti *re headrect.ymin= headrect.ymax; headrect.ymax= headrect.ymin + floor(PNL_HEADER/block->aspect + 0.001f); - /* divider only when there's a previous panel */ - prev= panel->prev; - while(prev) { - if(prev->runtime_flag & PNL_ACTIVE) break; - prev= prev->prev; - } - - if(panel->sortorder != 0) { + if(!(panel->runtime_flag & PNL_FIRST)) { float minx= rect->xmin+5.0f/block->aspect; float maxx= rect->xmax-5.0f/block->aspect; float y= headrect.ymax; @@ -829,7 +842,7 @@ void uiEndPanels(const bContext *C, ARegion *ar) { ScrArea *sa= CTX_wm_area(C); uiBlock *block; - Panel *panot, *panew, *patest, *pa; + Panel *panot, *panew, *patest, *pa, *firstpa; /* offset contents */ for(block= ar->uiblocks.first; block; block= block->next) @@ -869,6 +882,16 @@ void uiEndPanels(const bContext *C, ARegion *ar) uiAlignPanelStep(sa, ar, 1.0, 0); } + /* tag first panel */ + firstpa= NULL; + for(block= ar->uiblocks.first; block; block=block->next) + if(block->active && block->panel) + if(!firstpa || block->panel->sortorder < firstpa->sortorder) + firstpa= block->panel; + + if(firstpa) + firstpa->runtime_flag |= PNL_FIRST; + /* draw panels, selected on top */ for(block= ar->uiblocks.first; block; block=block->next) { if(block->active && block->panel && !(block->panel->flag & PNL_SELECT)) { diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 222c3fe892d..32bcae77e6b 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -520,6 +520,14 @@ static void ui_searchbox_butrect(rcti *rect, uiSearchboxData *data, int itemnr) } +/* x and y in screencoords */ +int ui_searchbox_inside(ARegion *ar, int x, int y) +{ + uiSearchboxData *data= ar->regiondata; + + return(BLI_in_rcti(&data->bbox, x-ar->winrct.xmin, y-ar->winrct.ymin)); +} + /* string validated to be of correct length (but->hardmax) */ void ui_searchbox_apply(uiBut *but, ARegion *ar) { @@ -602,6 +610,8 @@ void ui_searchbox_update(bContext *C, ARegion *ar, uiBut *but, int reset) data->active= a+1; if(cpoin) cpoin[0]= '|'; } + if(data->items.totitem==1) + data->active= 1; } /* validate selected item */ @@ -669,7 +679,7 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) uiSearchboxData *data; float aspect= but->block->aspect; float x1f, x2f, y1f, y2f; - int x1, x2, y1, y2, winx, winy, ofsx, ofsy; + int x1, x2, y1, y2, winx, winy; /* create area region */ ar= ui_add_temporary_region(CTX_wm_screen(C)); @@ -696,61 +706,81 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) data->noback= 1; /* compute position */ - ofsx= (but->block->panel)? but->block->panel->ofsx: 0; - ofsy= (but->block->panel)? but->block->panel->ofsy: 0; - - x1f= but->x1 - 5; /* align text with button */ - x2f= but->x2 + 5; /* symmetrical */ - y2f= but->y1; - y1f= y2f - uiSearchBoxhHeight(); - /* minimal width */ - if(x2f - x1f < 180) x2f= x1f+180; // XXX arbitrary - - /* copy to int, gets projected if possible too */ - x1= x1f; y1= y1f; x2= x2f; y2= y2f; - - if(butregion) { - if(butregion->v2d.cur.xmin != butregion->v2d.cur.xmax) { - UI_view2d_to_region_no_clip(&butregion->v2d, x1f, y1f, &x1, &y1); - UI_view2d_to_region_no_clip(&butregion->v2d, x2f, y2f, &x2, &y2); - } + if(but->block->flag & UI_BLOCK_LOOP) { + /* this case is search menu inside other menu */ + /* we copy region size */ + + ar->winrct= butregion->winrct; - x1 += butregion->winrct.xmin; - x2 += butregion->winrct.xmin; - y1 += butregion->winrct.ymin; - y2 += butregion->winrct.ymin; - } - - wm_window_get_size(CTX_wm_window(C), &winx, &winy); - - if(x2 > winx) { - /* super size */ - if(x2 > winx + x1) { - x2= winx; - x1= 0; + /* widget rect, in region coords */ + data->bbox.xmin= MENU_SHADOW_SIDE; + data->bbox.xmax= (ar->winrct.xmax-ar->winrct.xmin) - MENU_SHADOW_SIDE; + data->bbox.ymin= MENU_SHADOW_BOTTOM; + data->bbox.ymax= (ar->winrct.ymax-ar->winrct.ymin) - MENU_SHADOW_BOTTOM; + + /* check if button is lower half */ + if( but->y2 < (but->block->minx+but->block->maxx)/2 ) { + data->bbox.ymin += (but->y2-but->y1); } else { - x1 -= x2-winx; - x2= winx; + data->bbox.ymax -= (but->y2-but->y1); } } - if(y1 < 0) { - y1 += 36; - y2 += 36; - } - - /* widget rect, in region coords */ - data->bbox.xmin= MENU_SHADOW_SIDE; - data->bbox.xmax= x2-x1 + MENU_SHADOW_SIDE; - data->bbox.ymin= MENU_SHADOW_BOTTOM; - data->bbox.ymax= y2-y1 + MENU_SHADOW_BOTTOM; + else { + x1f= but->x1 - 5; /* align text with button */ + x2f= but->x2 + 5; /* symmetrical */ + y2f= but->y1; + y1f= y2f - uiSearchBoxhHeight(); - /* region bigger for shadow */ - ar->winrct.xmin= x1 - MENU_SHADOW_SIDE; - ar->winrct.xmax= x2 + MENU_SHADOW_SIDE; - ar->winrct.ymin= y1 - MENU_SHADOW_BOTTOM; - ar->winrct.ymax= y2; + /* minimal width */ + if(x2f - x1f < 150) x2f= x1f+150; // XXX arbitrary + + /* copy to int, gets projected if possible too */ + x1= x1f; y1= y1f; x2= x2f; y2= y2f; + + if(butregion) { + if(butregion->v2d.cur.xmin != butregion->v2d.cur.xmax) { + UI_view2d_to_region_no_clip(&butregion->v2d, x1f, y1f, &x1, &y1); + UI_view2d_to_region_no_clip(&butregion->v2d, x2f, y2f, &x2, &y2); + } + + x1 += butregion->winrct.xmin; + x2 += butregion->winrct.xmin; + y1 += butregion->winrct.ymin; + y2 += butregion->winrct.ymin; + } + + wm_window_get_size(CTX_wm_window(C), &winx, &winy); + + if(x2 > winx) { + /* super size */ + if(x2 > winx + x1) { + x2= winx; + x1= 0; + } + else { + x1 -= x2-winx; + x2= winx; + } + } + if(y1 < 0) { + y1 += 36; + y2 += 36; + } + + /* widget rect, in region coords */ + data->bbox.xmin= MENU_SHADOW_SIDE; + data->bbox.xmax= x2-x1 + MENU_SHADOW_SIDE; + data->bbox.ymin= MENU_SHADOW_BOTTOM; + data->bbox.ymax= y2-y1 + MENU_SHADOW_BOTTOM; + + /* region bigger for shadow */ + ar->winrct.xmin= x1 - MENU_SHADOW_SIDE; + ar->winrct.xmax= x2 + MENU_SHADOW_SIDE; + ar->winrct.ymin= y1 - MENU_SHADOW_BOTTOM; + ar->winrct.ymax= y2; + } /* adds subwindow */ ED_region_init(C, ar); @@ -1146,7 +1176,7 @@ uiBlock *ui_block_func_MENU(bContext *C, uiPopupBlockHandle *handle, void *arg_b rows++; /* prevent scaling up of pupmenu */ - aspect= but->aspect; + aspect= but->block->aspect; if(aspect < 1.0f) aspect = 1.0f; @@ -1169,7 +1199,7 @@ uiBlock *ui_block_func_MENU(bContext *C, uiPopupBlockHandle *handle, void *arg_b width = (but->x2 - but->x1); if(width<50) width=50; - + boxh= MENU_BUTTON_HEIGHT; height= rows*boxh; @@ -1363,6 +1393,7 @@ static void update_picker_hex(uiBlock *block, float *rgb) } } +/* also used by small picker, be careful with name checks below... */ void ui_update_block_buts_hsv(uiBlock *block, float *hsv) { uiBut *bt; @@ -1376,7 +1407,7 @@ void ui_update_block_buts_hsv(uiBlock *block, float *hsv) update_picker_hex(block, rgb); for(bt= block->buttons.first; bt; bt= bt->next) { - if(bt->type==HSVCUBE) { + if(ELEM(bt->type, HSVCUBE, HSVCIRCLE)) { VECCOPY(bt->hsv, hsv); ui_set_but_hsv(bt); } @@ -1450,6 +1481,7 @@ static void do_palette_cb(bContext *C, void *bt1, void *col1) { wmWindow *win= CTX_wm_window(C); uiBut *but1= (uiBut *)bt1; + uiPopupBlockHandle *popup= but1->block->handle; float *col= (float *)col1; float *fp, hsv[3]; @@ -1465,6 +1497,18 @@ static void do_palette_cb(bContext *C, void *bt1, void *col1) rgb_to_hsv(col[0], col[1], col[2], hsv, hsv+1, hsv+2); ui_update_block_buts_hsv(but1->block, hsv); update_picker_hex(but1->block, col); + + if(popup) + popup->menuretval= UI_RETURN_UPDATE; +} + +static void do_hsv_cb(bContext *C, void *bt1, void *unused) +{ + uiBut *but1= (uiBut *)bt1; + uiPopupBlockHandle *popup= but1->block->handle; + + if(popup) + popup->menuretval= UI_RETURN_UPDATE; } /* bt1 is num but, hsv1 is pointer to original color in hsv space*/ @@ -1472,6 +1516,7 @@ static void do_palette_cb(bContext *C, void *bt1, void *col1) static void do_palette1_cb(bContext *C, void *bt1, void *hsv1) { uiBut *but1= (uiBut *)bt1; + uiPopupBlockHandle *popup= but1->block->handle; float *hsv= (float *)hsv1; float *fp= NULL; @@ -1484,6 +1529,9 @@ static void do_palette1_cb(bContext *C, void *bt1, void *hsv1) rgb_to_hsv(fp[0], fp[1], fp[2], hsv, hsv+1, hsv+2); } ui_update_block_buts_hsv(but1->block, hsv); + + if(popup) + popup->menuretval= UI_RETURN_UPDATE; } /* bt1 is num but, col1 is pointer to original color */ @@ -1491,6 +1539,7 @@ static void do_palette1_cb(bContext *C, void *bt1, void *hsv1) static void do_palette2_cb(bContext *C, void *bt1, void *col1) { uiBut *but1= (uiBut *)bt1; + uiPopupBlockHandle *popup= but1->block->handle; float *rgb= (float *)col1; float *fp= NULL; @@ -1503,14 +1552,21 @@ static void do_palette2_cb(bContext *C, void *bt1, void *col1) hsv_to_rgb(fp[0], fp[1], fp[2], rgb, rgb+1, rgb+2); } ui_update_block_buts_hsv(but1->block, fp); + + if(popup) + popup->menuretval= UI_RETURN_UPDATE; } static void do_palette_hex_cb(bContext *C, void *bt1, void *hexcl) { uiBut *but1= (uiBut *)bt1; + uiPopupBlockHandle *popup= but1->block->handle; char *hexcol= (char *)hexcl; ui_update_block_buts_hex(but1->block, hexcol); + + if(popup) + popup->menuretval= UI_RETURN_UPDATE; } /* used for both 3d view and image window */ @@ -1593,8 +1649,10 @@ void uiBlockPickerButtons(uiBlock *block, float *col, float *hsv, float *old, ch // the cube intersection bt= uiDefButF(block, HSVCUBE, retval, "", 0,DPICK+BPICK,FPICK,FPICK, col, 0.0, 0.0, 2, 0, ""); + uiButSetFunc(bt, do_hsv_cb, bt, NULL); bt= uiDefButF(block, HSVCUBE, retval, "", 0,0,FPICK,BPICK, col, 0.0, 0.0, 3, 0, ""); + uiButSetFunc(bt, do_hsv_cb, bt, NULL); // palette @@ -1644,22 +1702,103 @@ void uiBlockPickerButtons(uiBlock *block, float *col, float *hsv, float *old, ch uiBlockEndAlign(block); } +/* bt1 is num but, hsv1 is pointer to original color in hsv space*/ +/* callback to handle changes */ +static void do_picker_small_cb(bContext *C, void *bt1, void *hsv1) +{ + uiBut *but1= (uiBut *)bt1; + uiPopupBlockHandle *popup= but1->block->handle; + float *hsv= (float *)hsv1; + float *fp= NULL; + + fp= (float *)but1->poin; + rgb_to_hsv(fp[0], fp[1], fp[2], hsv, hsv+1, hsv+2); + + ui_update_block_buts_hsv(but1->block, hsv); + + if(popup) + popup->menuretval= UI_RETURN_UPDATE; +} + + +/* only the color, a circle, slider */ +void uiBlockPickerSmall(uiBlock *block, float *col, float *hsv, float *old, char *hexcol, char mode, short retval) +{ + uiBut *bt; + + VECCOPY(old, col); // old color stored there, for palette_cb to work + + /* HS circle */ + bt= uiDefButF(block, HSVCIRCLE, retval, "", 0, 0,SPICK,SPICK, col, 0.0, 0.0, 0, 0, ""); + uiButSetFunc(bt, do_picker_small_cb, bt, hsv); + + /* value */ + bt= uiDefButF(block, HSVCUBE, retval, "", SPICK+DPICK,0,14,SPICK, col, 0.0, 0.0, 4, 0, ""); + uiButSetFunc(bt, do_picker_small_cb, bt, hsv); + +} + +static int ui_picker_small_wheel(const bContext *C, uiBlock *block, wmEvent *event) +{ + float add= 0.0f; + + if(event->type==WHEELUPMOUSE) + add= 0.05f; + else if(event->type==WHEELDOWNMOUSE) + add= -0.05f; + + if(add!=0.0f) { + uiBut *but; + + for(but= block->buttons.first; but; but= but->next) { + if(but->type==HSVCUBE && but->active==NULL) { + uiPopupBlockHandle *popup= block->handle; + float col[3]; + + ui_get_but_vectorf(but, col); + + rgb_to_hsv(col[0], col[1], col[2], but->hsv, but->hsv+1, but->hsv+2); + but->hsv[2]= CLAMPIS(but->hsv[2]+add, 0.0f, 1.0f); + hsv_to_rgb(but->hsv[0], but->hsv[1], but->hsv[2], col, col+1, col+2); + + ui_set_but_vectorf(but, col); + + ui_update_block_buts_hsv(block, but->hsv); + if(popup) + popup->menuretval= UI_RETURN_UPDATE; + + return 1; + } + } + } + return 0; +} + uiBlock *ui_block_func_COL(bContext *C, uiPopupBlockHandle *handle, void *arg_but) { + wmWindow *win= CTX_wm_window(C); // XXX temp, needs to become keymap to detect type? uiBut *but= arg_but; uiBlock *block; static float hsvcol[3], oldcol[3]; static char hexcol[128]; block= uiBeginBlock(C, handle->region, "colorpicker", UI_EMBOSS); - block->flag= UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_KEEP_OPEN; VECCOPY(handle->retvec, but->editvec); - uiBlockPickerButtons(block, handle->retvec, hsvcol, oldcol, hexcol, 'p', 0); - + if(win->eventstate->shift) { + uiBlockPickerButtons(block, handle->retvec, hsvcol, oldcol, hexcol, 'p', 0); + block->flag= UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_KEEP_OPEN; + uiBoundsBlock(block, 3); + } + else { + uiBlockPickerSmall(block, handle->retvec, hsvcol, oldcol, hexcol, 'p', 0); + block->flag= UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_RET_1|UI_BLOCK_OUT_1; + uiBoundsBlock(block, 10); + + block->block_event_func= ui_picker_small_wheel; + } /* and lets go */ block->direction= UI_TOP; - uiBoundsBlock(block, 3); return block; } @@ -1809,6 +1948,9 @@ uiBlock *ui_block_func_PUPMENU(bContext *C, uiPopupBlockHandle *handle, void *ar md= decompose_menu_string(info->instr); rows= md->nitems; + if(rows<1) + rows= 1; + columns= 1; /* size and location, title slightly bigger for bold */ diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index 62a4c01bc6c..831a8a5bf6c 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -91,6 +91,7 @@ static uiStyle *ui_style_new(ListBase *styles, const char *name) style->paneltitle.uifont_id= UIFONT_DEFAULT; style->paneltitle.points= 13; + style->paneltitle.kerning= 0.0; style->paneltitle.shadow= 5; style->paneltitle.shadx= 2; style->paneltitle.shady= -2; @@ -99,6 +100,7 @@ static uiStyle *ui_style_new(ListBase *styles, const char *name) style->grouplabel.uifont_id= UIFONT_DEFAULT; style->grouplabel.points= 12; + style->grouplabel.kerning= 0.0; style->grouplabel.shadow= 3; style->grouplabel.shadx= 1; style->grouplabel.shady= -1; @@ -106,6 +108,7 @@ static uiStyle *ui_style_new(ListBase *styles, const char *name) style->widgetlabel.uifont_id= UIFONT_DEFAULT; style->widgetlabel.points= 11; + style->widgetlabel.kerning= 0.0; style->widgetlabel.shadow= 3; style->widgetlabel.shadx= 1; style->widgetlabel.shady= -1; @@ -114,6 +117,7 @@ static uiStyle *ui_style_new(ListBase *styles, const char *name) style->widget.uifont_id= UIFONT_DEFAULT; style->widget.points= 11; + style->widget.kerning= 0.0; style->widget.shadowalpha= 0.25f; style->columnspace= 5; @@ -263,5 +267,6 @@ void uiStyleFontSet(uiFontStyle *fs) BLF_set(font->blf_id); BLF_size(fs->points, U.dpi); + BLF_kerning(fs->kerning); } diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 020d442bfe6..a0ee264cf01 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -78,9 +78,8 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) { TemplateID *template= (TemplateID*)arg_litem; PointerRNA idptr= RNA_property_pointer_get(&template->ptr, template->prop); - ID *idtest, *id= idptr.data; - ListBase *lb= wich_libbase(CTX_data_main(C), template->idtype); - int nr, event= GET_INT_FROM_POINTER(arg_event); + ID *id= idptr.data; + int event= GET_INT_FROM_POINTER(arg_event); if(event == UI_ID_BROWSE && template->browse == 32767) event= UI_ID_ADD_NEW; @@ -88,31 +87,9 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) event= UI_ID_OPEN; switch(event) { - case UI_ID_BROWSE: { - if(template->browse== -2) { - /* XXX implement or find a replacement - * activate_databrowse((ID *)G.buts->lockpoin, GS(id->name), 0, B_MESHBROWSE, &template->browse, do_global_buttons); */ - return; - } - if(template->browse < 0) - return; - - for(idtest=lb->first, nr=1; idtest; idtest=idtest->next, nr++) { - if(nr==template->browse) { - if(id == idtest) - return; - - id= idtest; - RNA_id_pointer_create(id, &idptr); - RNA_property_pointer_set(&template->ptr, template->prop, idptr); - RNA_property_update(C, &template->ptr, template->prop); - /* XXX */ - - break; - } - } + case UI_ID_BROWSE: + printf("warning, id browse shouldnt come here\n"); break; - } case UI_ID_DELETE: memset(&idptr, 0, sizeof(idptr)); RNA_property_pointer_set(&template->ptr, template->prop, idptr); @@ -148,10 +125,79 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) } } +/* ID Search browse menu, assign */ +static void id_search_call_cb(struct bContext *C, void *arg_litem, void *item) +{ + if(item) { + TemplateID *template= (TemplateID*)arg_litem; + PointerRNA idptr= RNA_property_pointer_get(&template->ptr, template->prop); + + RNA_id_pointer_create(item, &idptr); + RNA_property_pointer_set(&template->ptr, template->prop, idptr); + RNA_property_update(C, &template->ptr, template->prop); + } +} + +/* ID Search browse menu, do the search */ +static void id_search_cb(const struct bContext *C, void *arg_litem, char *str, uiSearchItems *items) +{ + TemplateID *template= (TemplateID*)arg_litem; + ListBase *lb= wich_libbase(CTX_data_main(C), template->idtype); + ID *id; + + for(id= lb->first; id; id= id->next) { + + if(BLI_strcasestr(id->name+2, str)) { + if(0==uiSearchItemAdd(items, id->name+2, id)) + break; + } + } +} + +/* ID Search browse menu, open */ +static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_litem) +{ + static char search[256]; + static TemplateID template; + wmEvent event; + wmWindow *win= CTX_wm_window(C); + uiBlock *block; + uiBut *but; + + /* clear initial search string, then all items show */ + search[0]= 0; + /* arg_litem is malloced, can be freed by parent button */ + template= *((TemplateID*)arg_litem); + + block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS); + uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_RET_1); + + /* fake button, it holds space for search items */ + uiDefBut(block, LABEL, 0, "", 10, 15, 150, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL); + + but= uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, 256, 10, 0, 150, 19, ""); + uiButSetSearchFunc(but, id_search_cb, &template, id_search_call_cb); + + uiBoundsBlock(block, 6); + uiBlockSetDirection(block, UI_DOWN); + uiEndBlock(C, block); + + event= *(win->eventstate); /* XXX huh huh? make api call */ + event.type= EVT_BUT_OPEN; + event.val= KM_PRESS; + event.customdata= but; + event.customdatafree= FALSE; + wm_event_add(win, &event); + + return block; +} + +/* ****************** */ + + static void template_header_ID(bContext *C, uiBlock *block, TemplateID *template, StructRNA *type) { uiBut *but; - TemplateID *duptemplate; PointerRNA idptr; ListBase *lb; @@ -165,6 +211,7 @@ static void template_header_ID(bContext *C, uiBlock *block, TemplateID *template uiBlockBeginAlign(block); if(template->flag & UI_ID_BROWSE) { + /* char *extrastr, *str; if((template->flag & UI_ID_ADD_NEW) && (template->flag & UI_ID_OPEN)) @@ -183,6 +230,8 @@ static void template_header_ID(bContext *C, uiBlock *block, TemplateID *template uiButSetNFunc(but, template_id_cb, duptemplate, SET_INT_IN_POINTER(UI_ID_BROWSE)); MEM_freeN(str); + */ + uiDefBlockButN(block, id_search_menu, MEM_dupallocN(template), "", 0, 0, UI_UNIT_X, UI_UNIT_Y, "Browse ID data"); } /* text button with name */ @@ -193,18 +242,31 @@ static void template_header_ID(bContext *C, uiBlock *block, TemplateID *template name[0]= '\0'; but= uiDefButR(block, TEX, 0, name, 0, 0, UI_UNIT_X*6, UI_UNIT_Y, &idptr, "name", -1, 0, 0, -1, -1, NULL); uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_RENAME)); - - /* delete button */ - if(template->flag & UI_ID_DELETE) { - if(template->unlinkop[0]) { - but= uiDefIconButO(block, BUT, template->unlinkop, WM_OP_EXEC_REGION_WIN, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL); - } - else { - but= uiDefIconBut(block, BUT, 0, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); - uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_DELETE)); - } + } + + if(template->flag & UI_ID_ADD_NEW) { + int w= idptr.data?UI_UNIT_X:UI_UNIT_X*6; + + if(template->newop[0]) { + but= uiDefIconTextButO(block, BUT, template->newop, WM_OP_EXEC_REGION_WIN, ICON_ZOOMIN, "Add New", 0, 0, w, UI_UNIT_Y, NULL); + } + else { + but= uiDefIconTextBut(block, BUT, 0, ICON_ZOOMIN, "Add New", 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); + uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ADD_NEW)); } } + + /* delete button */ + if(idptr.data && (template->flag & UI_ID_DELETE)) { + if(template->unlinkop[0]) { + but= uiDefIconButO(block, BUT, template->unlinkop, WM_OP_EXEC_REGION_WIN, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL); + } + else { + but= uiDefIconBut(block, BUT, 0, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); + uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_DELETE)); + } + } + uiBlockEndAlign(block); } @@ -1310,7 +1372,7 @@ void uiTemplatePreview(uiLayout *layout, ID *id) uiBlock *block; Material *ma; - if(!id || !ELEM4(GS(id->name), ID_MA, ID_TE, ID_WO, ID_LA)) { + if(id && !ELEM4(GS(id->name), ID_MA, ID_TE, ID_WO, ID_LA)) { printf("uiTemplatePreview: expected ID of type material, texture, lamp or world.\n"); return; } @@ -1377,3 +1439,54 @@ void uiTemplateCurveMapping(uiLayout *layout, CurveMapping *cumap, int type) } } +/********************* Layer Buttons Template ************************/ + +// TODO: +// - option for showing extra info like whether layer has contents? +// - for now, grouping of layers is determined by dividing up the length of +// the array of layer bitflags + +void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, char *propname) +{ + uiLayout *uRow, *uSplit, *uCol; + PropertyRNA *prop; + int groups, cols, layers; + int group, col, layer, row; + + if (!ptr->data) + return; + + prop= RNA_struct_find_property(ptr, propname); + if (!prop) { + printf("uiTemplateLayer: layers property not found: %s\n", propname); + return; + } + + /* the number of layers determines the way we group them + * - we want 2 rows only (for now) + * - the number of columns (cols) is the total number of buttons per row + * the 'remainder' is added to this, as it will be ok to have first row slightly wider if need be + * - for now, only split into groups if if group will have at least 5 items + */ + layers= RNA_property_array_length(prop); + cols= (layers / 2) + (layers % 2); + groups= ((cols / 2) < 5) ? (1) : (cols / 2); + + /* layers are laid out going across rows, with the columns being divided into groups */ + uSplit= uiLayoutSplit(layout, (1.0f/(float)groups)); + + for (group= 0; group < groups; group++) { + uCol= uiLayoutColumn(uSplit, 1); + + for (row= 0; row < 2; row++) { + uRow= uiLayoutRow(uCol, 1); + layer= groups*cols*row + cols*group; + + /* add layers as toggle buts */ + for (col= 0; (col < cols) && (layer < layers); col++, layer++) { + int icon=0; // XXX - add some way of setting this... + uiItemFullR(uRow, "", icon, ptr, prop, layer, 0, 0, 0, 1); + } + } + } +} diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c index fa7de1151a3..a75a3402774 100644 --- a/source/blender/editors/interface/interface_utils.c +++ b/source/blender/editors/interface/interface_utils.c @@ -38,6 +38,8 @@ #include "DNA_texture_types.h" #include "DNA_windowmanager_types.h" +#include "BLI_blenlib.h" + #include "BKE_colortools.h" #include "BKE_context.h" #include "BKE_idprop.h" @@ -199,10 +201,13 @@ void uiDefAutoButsRNA_single(const bContext *C, uiLayout *layout, PointerRNA *pt RNA_property_collection_end(&iter); } + /***************************** ID Utilities *******************************/ +/* note, C code version, will be replaced with version in interface_templates.c */ typedef struct uiIDPoinParams { uiIDPoinFunc func; + ListBase *lb; ID *id; short id_code; short browsenr; @@ -210,16 +215,12 @@ typedef struct uiIDPoinParams { static void idpoin_cb(bContext *C, void *arg_params, void *arg_event) { - Main *bmain; - ListBase *lb; uiIDPoinParams *params= (uiIDPoinParams*)arg_params; + ListBase *lb= params->lb; uiIDPoinFunc func= params->func; ID *id= params->id, *idtest; int nr, event= GET_INT_FROM_POINTER(arg_event); - bmain= CTX_data_main(C); - lb= wich_libbase(bmain, params->id_code); - if(event == UI_ID_BROWSE && params->browsenr == 32767) event= UI_ID_ADD_NEW; else if(event == UI_ID_BROWSE && params->browsenr == 32766) @@ -286,22 +287,84 @@ static void idpoin_cb(bContext *C, void *arg_params, void *arg_event) func(C, id, event); } +/* ***************************** ID Search browse menu ********************** */ + +static void id_search_call_cb(struct bContext *C, void *arg_params, void *item) +{ + uiIDPoinParams *params= (uiIDPoinParams*)arg_params; + + if(item && params->func) + params->func(C, item, UI_ID_BROWSE); + +} + +static void id_search_cb(const struct bContext *C, void *arg_params, char *str, uiSearchItems *items) +{ + uiIDPoinParams *params= (uiIDPoinParams*)arg_params; + ID *id; + + for(id= params->lb->first; id; id= id->next) { + + if(BLI_strcasestr(id->name+2, str)) { + if(0==uiSearchItemAdd(items, id->name+2, id)) + break; + } + } +} + +static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_params) +{ + static char search[256]; + static uiIDPoinParams params; + wmEvent event; + wmWindow *win= CTX_wm_window(C); + uiBlock *block; + uiBut *but; + + /* clear initial search string, then all items show */ + search[0]= 0; + /* params is malloced, can be freed by parent button */ + params= *((uiIDPoinParams*)arg_params); + + block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS); + uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_RET_1); + + /* fake button, it holds space for search items */ + uiDefBut(block, LABEL, 0, "", 10, 15, 150, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL); + + but= uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, 256, 10, 0, 150, 19, ""); + uiButSetSearchFunc(but, id_search_cb, ¶ms, id_search_call_cb); + + uiBoundsBlock(block, 6); + uiBlockSetDirection(block, UI_DOWN); + uiEndBlock(C, block); + + event= *(win->eventstate); /* XXX huh huh? make api call */ + event.type= EVT_BUT_OPEN; + event.val= KM_PRESS; + event.customdata= but; + event.customdatafree= FALSE; + wm_event_add(win, &event); + + return block; +} + +/* ****************** */ + int uiDefIDPoinButs(uiBlock *block, Main *bmain, ID *parid, ID *id, int id_code, short *pin_p, int x, int y, uiIDPoinFunc func, int events) { - ListBase *lb; uiBut *but; uiIDPoinParams *params, *dup_params; - char *str=NULL, str1[10]; + char str1[10]; int len, add_addbutton=0; /* setup struct that we will pass on with the buttons */ params= MEM_callocN(sizeof(uiIDPoinParams), "uiIDPoinParams"); + params->lb= wich_libbase(bmain, id_code); params->id= id; params->id_code= id_code; params->func= func; - lb= wich_libbase(bmain, id_code); - /* create buttons */ uiBlockBeginAlign(block); @@ -322,45 +385,11 @@ int uiDefIDPoinButs(uiBlock *block, Main *bmain, ID *parid, ID *id, int id_code, /* browse menu */ if(events & UI_ID_BROWSE) { - char *extrastr= NULL; - - if(ELEM4(id_code, ID_MA, ID_TE, ID_BR, ID_PA)) - add_addbutton= 1; - - if(ELEM8(id_code, ID_SCE, ID_SCR, ID_MA, ID_TE, ID_WO, ID_IP, ID_AC, ID_BR) || id_code == ID_PA) - extrastr= "ADD NEW %x 32767"; - else if(id_code==ID_TXT) - extrastr= "OPEN NEW %x 32766 |ADD NEW %x 32767"; - else if(id_code==ID_SO) - extrastr= "OPEN NEW %x 32766"; - - /* XXX should be moved out of this function - uiBlockSetButLock(block, G.scene->id.lib!=0, "Can't edit external libdata"); - if( id_code==ID_SCE || id_code==ID_SCR ) uiBlockClearButLock(block); */ - - /* XXX should be moved out of this function - if(curarea->spacetype==SPACE_BUTS) - uiBlockSetButLock(block, id_code!=ID_SCR && G.obedit!=0 && G.buts->mainb==CONTEXT_EDITING, "Cannot perform in EditMode"); */ - - if(parid) - uiBlockSetButLock(block, parid->lib!=0, "Can't edit external libdata"); - - if(lb) { - if(id_code!=ID_IM || (events & UI_ID_BROWSE_RENDER)) - IDnames_to_pupstring(&str, NULL, extrastr, lb, id, ¶ms->browsenr); - else - IMAnames_to_pupstring(&str, NULL, extrastr, lb, id, ¶ms->browsenr); - } - - dup_params= MEM_dupallocN(params); - but= uiDefButS(block, MENU, 0, str, x, y, DEF_ICON_BUT_WIDTH, DEF_BUT_HEIGHT, &dup_params->browsenr, 0, 0, 0, 0, "Browse existing choices, or add new"); - uiButSetNFunc(but, idpoin_cb, dup_params, SET_INT_IN_POINTER(UI_ID_BROWSE)); + uiDefBlockButN(block, id_search_menu, MEM_dupallocN(params), "", x, y, DEF_ICON_BUT_WIDTH, DEF_BUT_HEIGHT, "Browse ID data"); x+= DEF_ICON_BUT_WIDTH; - - uiBlockClearButLock(block); - - MEM_freeN(str); } + + /* text button with name */ if(id) { diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 03487e2301c..14df9026078 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -40,6 +40,7 @@ #include "BLI_rect.h" #include "BKE_context.h" +#include "BKE_curve.h" #include "BKE_global.h" #include "BKE_utildefines.h" @@ -874,9 +875,9 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB and offset the text label to accomodate it */ if (but->flag & UI_HAS_ICON) { - widget_draw_icon(but, but->icon, 0, rect); + widget_draw_icon(but, but->icon+but->iconadd, 0, rect); - rect->xmin += UI_icon_get_width(but->icon); + rect->xmin += UI_icon_get_width(but->icon+but->iconadd); if(but->editstr || (but->flag & UI_TEXT_LEFT)) rect->xmin += 5; @@ -1024,11 +1025,11 @@ static struct uiWidgetColors wcol_menu_item= { static struct uiWidgetColors wcol_menu_back= { {0, 0, 0, 255}, {25, 25, 25, 230}, - {46, 124, 217, 204}, + {45, 45, 45, 230}, {255, 255, 255, 255}, {255, 255, 255, 255}, - {0, 0, 0, 255}, + {255, 255, 255, 255}, 0, 25, -20 @@ -1087,6 +1088,20 @@ static struct uiWidgetColors wcol_box= { 0, 0 }; +/* free wcol struct to play with */ +static struct uiWidgetColors wcol_tmp= { + {0, 0, 0, 255}, + {128, 128, 128, 255}, + {100, 100, 100, 255}, + {25, 25, 25, 255}, + + {0, 0, 0, 255}, + {255, 255, 255, 255}, + + 0, + 0, 0 +}; + /* called for theme init (new theme) and versions */ void ui_widget_color_init(ThemeUI *tui) @@ -1104,8 +1119,6 @@ void ui_widget_color_init(ThemeUI *tui) tui->wcol_menu_back= wcol_menu_back; tui->wcol_menu_item= wcol_menu_item; tui->wcol_box= wcol_box; - - tui->iconfile[0]= 0; } /* ************ button callbacks, state ***************** */ @@ -1262,6 +1275,109 @@ static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int dir glDisable(GL_BLEND); } + +static void ui_hsv_cursor(float x, float y) +{ + + glPushMatrix(); + glTranslatef(x, y, 0.0f); + + glColor3f(1.0f, 1.0f, 1.0f); + glutil_draw_filled_arc(0.0f, M_PI*2.0, 3.0f, 8); + + glEnable(GL_BLEND); + glEnable(GL_LINE_SMOOTH ); + glColor3f(0.0f, 0.0f, 0.0f); + glutil_draw_lined_arc(0.0f, M_PI*2.0, 3.0f, 12); + glDisable(GL_BLEND); + glDisable(GL_LINE_SMOOTH ); + + glPopMatrix(); + +} + +void ui_hsvcircle_vals_from_pos(float *valrad, float *valdist, rcti *rect, float mx, float my) +{ + /* duplication of code... well, simple is better now */ + float centx= (float)(rect->xmin + rect->xmax)/2; + float centy= (float)(rect->ymin + rect->ymax)/2; + float radius, dist; + + if( rect->xmax-rect->xmin > rect->ymax-rect->ymin ) + radius= (float)(rect->ymax - rect->ymin)/2; + else + radius= (float)(rect->xmax - rect->xmin)/2; + + mx-= centx; + my-= centy; + dist= sqrt( mx*mx + my*my); + if(dist < radius) + *valdist= dist/radius; + else + *valdist= 1.0f; + + *valrad= atan2(mx, my)/(2.0f*M_PI) + 0.5f; +} + +void ui_draw_but_HSVCIRCLE(uiBut *but, rcti *rect) +{ + /* gouraud triangle fan */ + float radstep, ang= 0.0f; + float centx, centy, radius; + float hsv[3], col[3], colcent[3]; + int a, tot= 32; + + radstep= 2.0f*M_PI/(float)tot; + centx= (float)(rect->xmin + rect->xmax)/2; + centy= (float)(rect->ymin + rect->ymax)/2; + + if( rect->xmax-rect->xmin > rect->ymax-rect->ymin ) + radius= (float)(rect->ymax - rect->ymin)/2; + else + radius= (float)(rect->xmax - rect->xmin)/2; + + /* color */ + VECCOPY(hsv, but->hsv); + hsv[0]= hsv[1]= 0.0f; + hsv_to_rgb(hsv[0], hsv[1], hsv[2], colcent, colcent+1, colcent+2); + + glShadeModel(GL_SMOOTH); + + glBegin(GL_TRIANGLE_FAN); + glColor3fv(colcent); + glVertex2f( centx, centy); + + for(a=0; a<=tot; a++, ang+=radstep) { + float si= sin(ang); + float co= cos(ang); + + ui_hsvcircle_vals_from_pos(hsv, hsv+1, rect, centx + co*radius, centy + si*radius); + hsv_to_rgb(hsv[0], hsv[1], hsv[2], col, col+1, col+2); + glColor3fv(col); + glVertex2f( centx + co*radius, centy + si*radius); + } + glEnd(); + + glShadeModel(GL_FLAT); + + /* fully rounded outline */ + glPushMatrix(); + glTranslatef(centx, centy, 0.0f); + glEnable(GL_BLEND); + glEnable(GL_LINE_SMOOTH ); + glColor3f(0.0f, 0.0f, 0.0f); + glutil_draw_lined_arc(0.0f, M_PI*2.0, radius, tot); + glDisable(GL_BLEND); + glDisable(GL_LINE_SMOOTH ); + glPopMatrix(); + + /* cursor */ + ang= 2.0f*M_PI*but->hsv[0] + 0.5f*M_PI; + radius= but->hsv[1]*radius; + ui_hsv_cursor(centx + cos(-ang)*radius, centy + sin(-ang)*radius); + +} + /* ************ custom buttons, old stuff ************** */ /* draws in resolution of 20x4 colors */ @@ -1301,7 +1417,7 @@ static void ui_draw_but_HSVCUBE(uiBut *but, rcti *rect) hsv_to_rgb(h, 1.0, 0.0, &col1[3][0], &col1[3][1], &col1[3][2]); x= v; y= s; } - else { // only hue slider + else if(but->a1==3) { // only hue slider hsv_to_rgb(0.0, 1.0, 1.0, &col1[0][0], &col1[0][1], &col1[0][2]); VECCOPY(col1[1], col1[0]); VECCOPY(col1[2], col1[0]); @@ -1335,7 +1451,7 @@ static void ui_draw_but_HSVCUBE(uiBut *but, rcti *rect) hsv_to_rgb(h, 0.666, dx, &col1[2][0], &col1[2][1], &col1[2][2]); hsv_to_rgb(h, 1.0, dx, &col1[3][0], &col1[3][1], &col1[3][2]); } - else { // only H + else if(but->a1==3) { // only H hsv_to_rgb(dx, 1.0, 1.0, &col1[0][0], &col1[0][1], &col1[0][2]); VECCOPY(col1[1], col1[0]); VECCOPY(col1[2], col1[0]); @@ -1373,13 +1489,42 @@ static void ui_draw_but_HSVCUBE(uiBut *but, rcti *rect) CLAMP(x, rect->xmin+3.0, rect->xmax-3.0); CLAMP(y, rect->ymin+3.0, rect->ymax-3.0); - fdrawXORcirc(x, y, 3.1); + ui_hsv_cursor(x, y); /* outline */ glColor3ub(0, 0, 0); fdrawbox((rect->xmin), (rect->ymin), (rect->xmax), (rect->ymax)); } +/* vertical 'value' slider, using new widget code */ +static void ui_draw_but_HSV_v(uiBut *but, rcti *rect) +{ + uiWidgetBase wtb; + float rad= 0.5f*(rect->xmax - rect->xmin); + float x, y; + + widget_init(&wtb); + + /* fully rounded */ + round_box_edges(&wtb, 15, rect, rad); + + /* setup temp colors */ + wcol_tmp.outline[0]= wcol_tmp.outline[1]= wcol_tmp.outline[2]= 0; + wcol_tmp.inner[0]= wcol_tmp.inner[1]= wcol_tmp.inner[2]= 128; + wcol_tmp.shadetop= 127; + wcol_tmp.shadedown= -128; + wcol_tmp.shaded= 1; + + widgetbase_draw(&wtb, &wcol_tmp); + + /* cursor */ + x= rect->xmin + 0.5f*(rect->xmax-rect->xmin); + y= rect->ymin + but->hsv[2]*(rect->ymax-rect->ymin); + CLAMP(y, rect->ymin+3.0, rect->ymax-3.0); + + ui_hsv_cursor(x, y); + +} /* ************ button callbacks, draw ***************** */ @@ -1406,6 +1551,76 @@ static void widget_numbut(uiWidgetColors *wcol, rcti *rect, int state, int round } + +static int ui_link_bezier_points(rcti *rect, float coord_array[][2], int resol) +{ + float dist, vec[4][2]; + + vec[0][0]= rect->xmin; + vec[0][1]= rect->ymin; + vec[3][0]= rect->xmax; + vec[3][1]= rect->ymax; + + dist= 0.5f*ABS(vec[0][0] - vec[3][0]); + + vec[1][0]= vec[0][0]+dist; + vec[1][1]= vec[0][1]; + + vec[2][0]= vec[3][0]-dist; + vec[2][1]= vec[3][1]; + + forward_diff_bezier(vec[0][0], vec[1][0], vec[2][0], vec[3][0], coord_array[0], resol, 2); + forward_diff_bezier(vec[0][1], vec[1][1], vec[2][1], vec[3][1], coord_array[0]+1, resol, 2); + + return 1; +} + +#define LINK_RESOL 24 +void ui_draw_link_bezier(rcti *rect) +{ + float coord_array[LINK_RESOL+1][2]; + + if(ui_link_bezier_points(rect, coord_array, LINK_RESOL)) { + float dist; + int i; + + /* we can reuse the dist variable here to increment the GL curve eval amount*/ + dist = 1.0f/(float)LINK_RESOL; + + glEnable(GL_BLEND); + glEnable(GL_LINE_SMOOTH); + + glBegin(GL_LINE_STRIP); + for(i=0; i<=LINK_RESOL; i++) { + glVertex2fv(coord_array[i]); + } + glEnd(); + + glDisable(GL_BLEND); + glDisable(GL_LINE_SMOOTH); + + } +} + + +static void widget_link(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign) +{ + + if(but->flag & UI_SELECT) { + rcti rectlink; + + UI_ThemeColor(TH_TEXT_HI); + + rectlink.xmin= (rect->xmin+rect->xmax)/2; + rectlink.ymin= (rect->ymin+rect->ymax)/2; + rectlink.xmax= but->linkto[0]; + rectlink.ymax= but->linkto[1]; + + ui_draw_link_bezier(&rectlink); + } +} + + static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign) { uiWidgetBase wtb, wtb1; @@ -1661,7 +1876,9 @@ static void widget_disabled(rcti *rect) /* can't use theme TH_BACK or TH_PANEL... undefined */ glGetFloatv(GL_COLOR_CLEAR_VALUE, col); glColor4f(col[0], col[1], col[2], 0.5f); - glRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax); + /* need -1 and +1 to make it work right for aligned buttons, + * but problem may be somewhere else? */ + glRectf(rect->xmin-1, rect->ymin, rect->xmax, rect->ymax+1); glDisable(GL_BLEND); } @@ -1865,31 +2082,43 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct fstyle= &style->widgetlabel; } break; + case SEPR: break; + case BUT: wt= widget_type(UI_WTYPE_EXEC); break; case NUM: wt= widget_type(UI_WTYPE_NUMBER); break; + case NUMSLI: case HSVSLI: wt= widget_type(UI_WTYPE_SLIDER); break; + case ROW: wt= widget_type(UI_WTYPE_RADIO); break; + case TEX: + wt= widget_type(UI_WTYPE_NAME); + break; + case SEARCH_MENU: wt= widget_type(UI_WTYPE_NAME); + if(but->block->flag & UI_BLOCK_LOOP) + wt->wcol_theme= &btheme->tui.wcol_menu_back; break; + case TOGBUT: case TOG: case TOGN: case TOG3: wt= widget_type(UI_WTYPE_TOGGLE); break; + case OPTION: case OPTIONN: if (!(but->flag & UI_HAS_ICON)) { @@ -1899,6 +2128,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct else wt= widget_type(UI_WTYPE_TOGGLE); break; + case MENU: case BLOCK: case ICONTEXTROW: @@ -1920,21 +2150,37 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct case ROUNDBOX: wt= widget_type(UI_WTYPE_BOX); break; + + case LINK: + case INLINK: + wt= widget_type(UI_WTYPE_ICON); + wt->custom= widget_link; + + break; case BUT_EXTRA: widget_draw_extra_mask(C, but, widget_type(UI_WTYPE_BOX), rect); break; - // XXX four old button types case HSVCUBE: - ui_draw_but_HSVCUBE(but, rect); + if(but->a1==4) // vertical V slider, uses new widget draw now + ui_draw_but_HSV_v(but, rect); + else // other HSV pickers... + ui_draw_but_HSVCUBE(but, rect); + break; + + case HSVCIRCLE: + ui_draw_but_HSVCIRCLE(but, rect); break; + case BUT_COLORBAND: ui_draw_but_COLORBAND(but, &tui->wcol_regular, rect); break; + case BUT_NORMAL: ui_draw_but_NORMAL(but, &tui->wcol_regular, rect); break; + case BUT_CURVE: ui_draw_but_CURVE(ar, but, &tui->wcol_regular, rect); break; diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index f0032809631..af68c5e6b25 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -75,7 +75,7 @@ static int theme_regionid= RGN_TYPE_WINDOW; void ui_resources_init(void) { - UI_icons_init(BIFICONID_LAST+1); + UI_icons_init(BIFICONID_LAST); } void ui_resources_free(void) @@ -156,6 +156,9 @@ char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid) case SPACE_NODE: ts= &btheme->tnode; break; + case SPACE_LOGIC: + ts= &btheme->tlogic; + break; default: ts= &btheme->tv3d; break; @@ -398,6 +401,7 @@ static void ui_theme_init_new(bTheme *btheme) ui_theme_init_new_do(&btheme->toops); ui_theme_init_new_do(&btheme->ttime); ui_theme_init_new_do(&btheme->tnode); + ui_theme_init_new_do(&btheme->tlogic); } @@ -597,6 +601,10 @@ void ui_theme_init_userdef(void) SETCOL(btheme->tnode.syntaxv, 142, 138, 145, 255); /* generator */ SETCOL(btheme->tnode.syntaxc, 120, 145, 120, 255); /* group */ + /* space logic */ + btheme->tlogic= btheme->tv3d; + SETCOL(btheme->tlogic.back, 100, 100, 100, 255); + } @@ -1222,6 +1230,13 @@ void init_userdef_do_versions(void) if(btheme->tui.wcol_num.outline[3]==0) ui_widget_color_init(&btheme->tui); + + /* Logic editor theme, check for alpha==0 is safe, then color was never set */ + if(btheme->tlogic.syntaxn[3]==0) { + /* re-uses syntax color storage */ + btheme->tlogic= btheme->tv3d; + SETCOL(btheme->tlogic.back, 100, 100, 100, 255); + } } } diff --git a/source/blender/editors/mesh/editmesh.c b/source/blender/editors/mesh/editmesh.c index 40373c9f327..dd003d103d5 100644 --- a/source/blender/editors/mesh/editmesh.c +++ b/source/blender/editors/mesh/editmesh.c @@ -1434,10 +1434,10 @@ void remake_editMesh(Scene *scene, Object *ob) /* *************** Operator: separate parts *************/ static EnumPropertyItem prop_separate_types[] = { - {0, "SELECTED", "Selection", ""}, - {1, "MATERIAL", "By Material", ""}, - {2, "LOOSE", "By loose parts", ""}, - {0, NULL, NULL, NULL} + {0, "SELECTED", 0, "Selection", ""}, + {1, "MATERIAL", 0, "By Material", ""}, + {2, "LOOSE", 0, "By loose parts", ""}, + {0, NULL, 0, NULL, NULL} }; /* return 1: success */ diff --git a/source/blender/editors/mesh/editmesh_lib.c b/source/blender/editors/mesh/editmesh_lib.c index bfa381550df..e1b63022dd4 100644 --- a/source/blender/editors/mesh/editmesh_lib.c +++ b/source/blender/editors/mesh/editmesh_lib.c @@ -51,11 +51,13 @@ editmesh_lib: generic (no UI, no menus) operations/evaluators for editmesh data #include "BLI_editVert.h" #include "BKE_customdata.h" +#include "BKE_context.h" #include "BKE_global.h" #include "BKE_mesh.h" #include "BKE_utildefines.h" #include "ED_mesh.h" +#include "ED_screen.h" #include "ED_view3d.h" #include "mesh_intern.h" @@ -2278,3 +2280,10 @@ void EM_free_uv_vert_map(UvVertMap *vmap) } } +/* poll call for mesh operators requiring a view3d context */ +int EM_view3d_poll(bContext *C) +{ + if(ED_operator_editmesh(C) && ED_operator_view3d_active(C)) + return 1; + return 0; +} diff --git a/source/blender/editors/mesh/editmesh_loop.c b/source/blender/editors/mesh/editmesh_loop.c index d0f7517df78..afbf43c4d85 100644 --- a/source/blender/editors/mesh/editmesh_loop.c +++ b/source/blender/editors/mesh/editmesh_loop.c @@ -458,10 +458,10 @@ typedef struct CutCurve { #define KNIFE_MULTICUT 3 static EnumPropertyItem knife_items[]= { - {KNIFE_EXACT, "EXACT", "Exact", ""}, - {KNIFE_MIDPOINT, "MIDPOINTS", "Midpoints", ""}, - {KNIFE_MULTICUT, "MULTICUT", "Multicut", ""}, - {0, NULL, NULL} + {KNIFE_EXACT, "EXACT", 0, "Exact", ""}, + {KNIFE_MIDPOINT, "MIDPOINTS", 0, "Midpoints", ""}, + {KNIFE_MULTICUT, "MULTICUT", 0, "Multicut", ""}, + {0, NULL, 0, NULL, NULL} }; /* seg_intersect() Determines if and where a mouse trail intersects an EditEdge */ diff --git a/source/blender/editors/mesh/editmesh_mods.c b/source/blender/editors/mesh/editmesh_mods.c index faa3176c958..a1f8b3251c8 100644 --- a/source/blender/editors/mesh/editmesh_mods.c +++ b/source/blender/editors/mesh/editmesh_mods.c @@ -655,13 +655,13 @@ FACES GROUP */ static EnumPropertyItem prop_simface_types[] = { - {1, "MATERIAL", "Material", ""}, - {2, "IMAGE", "Image", ""}, - {3, "AREA", "Area", ""}, - {4, "PERIMETER", "Perimeter", ""}, - {5, "NORMAL", "Normal", ""}, - {6, "COPLANAR", "Co-planar", ""}, - {0, NULL, NULL, NULL} + {1, "MATERIAL", 0, "Material", ""}, + {2, "IMAGE", 0, "Image", ""}, + {3, "AREA", 0, "Area", ""}, + {4, "PERIMETER", 0, "Perimeter", ""}, + {5, "NORMAL", 0, "Normal", ""}, + {6, "COPLANAR", 0, "Co-planar", ""}, + {0, NULL, 0, NULL, NULL} }; @@ -849,14 +849,14 @@ EDGE GROUP */ static EnumPropertyItem prop_simedge_types[] = { - {1, "LENGTH", "Length", ""}, - {2, "DIR", "Direction", ""}, - {3, "FACE", "Amount of Vertices in Face", ""}, - {4, "FACE_ANGLE", "Face Angles", ""}, - {5, "CREASE", "Crease", ""}, - {6, "SEAM", "Seam", ""}, - {7, "SHARP", "Sharpness", ""}, - {0, NULL, NULL, NULL} + {1, "LENGTH", 0, "Length", ""}, + {2, "DIR", 0, "Direction", ""}, + {3, "FACE", 0, "Amount of Vertices in Face", ""}, + {4, "FACE_ANGLE", 0, "Face Angles", ""}, + {5, "CREASE", 0, "Crease", ""}, + {6, "SEAM", 0, "Seam", ""}, + {7, "SHARP", 0, "Sharpness", ""}, + {0, NULL, 0, NULL, NULL} }; static int similar_edge_select__internal(Scene *scene, EditMesh *em, int mode) @@ -1105,10 +1105,10 @@ VERT GROUP mode 3: same vertex groups */ static EnumPropertyItem prop_simvertex_types[] = { - {0, "NORMAL", "Normal", ""}, - {1, "FACE", "Amount of Vertices in Face", ""}, - {2, "VGROUP", "Vertex Groups", ""}, - {0, NULL, NULL, NULL} + {0, "NORMAL", 0, "Normal", ""}, + {1, "FACE", 0, "Amount of Vertices in Face", ""}, + {2, "VGROUP", 0, "Vertex Groups", ""}, + {0, NULL, 0, NULL, NULL} }; @@ -3537,10 +3537,10 @@ static void mesh_selection_type(Scene *scene, EditMesh *em, int val) } static EnumPropertyItem prop_mesh_edit_types[] = { - {1, "VERT", "Vertices", ""}, - {2, "EDGE", "Edges", ""}, - {3, "FACE", "Faces", ""}, - {0, NULL, NULL, NULL} + {1, "VERT", 0, "Vertices", ""}, + {2, "EDGE", 0, "Edges", ""}, + {3, "FACE", 0, "Faces", ""}, + {0, NULL, 0, NULL, NULL} }; static int mesh_selection_type_exec(bContext *C, wmOperator *op) diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 4fc16297db8..b26fded4fb6 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -966,7 +966,7 @@ void MESH_OT_spin(wmOperatorType *ot) /* api callbacks */ ot->invoke= spin_mesh_invoke; ot->exec= spin_mesh_exec; - ot->poll= ED_operator_editmesh; + ot->poll= EM_view3d_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1073,7 +1073,7 @@ void MESH_OT_screw(wmOperatorType *ot) /* api callbacks */ ot->invoke= screw_mesh_invoke; ot->exec= screw_mesh_exec; - ot->poll= ED_operator_editmesh; + ot->poll= EM_view3d_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1273,14 +1273,14 @@ void delete_mesh(Object *obedit, EditMesh *em, wmOperator *op, int event) /* Note, these values must match delete_mesh() event values */ static EnumPropertyItem prop_mesh_delete_types[] = { - {10,"VERT", "Vertices", ""}, - {1, "EDGE", "Edges", ""}, - {2, "FACE", "Faces", ""}, - {3, "ALL", "All", ""}, - {4, "EDGE_FACE","Edges & Faces", ""}, - {5, "ONLY_FACE","Only Faces", ""}, - {6, "EDGE_LOOP","Edge Loop", ""}, - {0, NULL, NULL, NULL} + {10,"VERT", 0, "Vertices", ""}, + {1, "EDGE", 0, "Edges", ""}, + {2, "FACE", 0, "Faces", ""}, + {3, "ALL", 0, "All", ""}, + {4, "EDGE_FACE",0, "Edges & Faces", ""}, + {5, "ONLY_FACE",0, "Only Faces", ""}, + {6, "EDGE_LOOP",0, "Edge Loop", ""}, + {0, NULL, 0, NULL, NULL} }; static int delete_mesh_exec(bContext *C, wmOperator *op) @@ -4656,7 +4656,7 @@ void mesh_set_face_flags(EditMesh *em, short mode) { EditFace *efa; MTFace *tface; - short m_tex=0, m_tiles=0, m_shared=0, + short m_tex=0, m_shared=0, m_light=0, m_invis=0, m_collision=0, m_twoside=0, m_obcolor=0, m_halo=0, m_billboard=0, m_shadow=0, m_text=0, @@ -4669,7 +4669,6 @@ void mesh_set_face_flags(EditMesh *em, short mode) // } add_numbut(0, TOG|SHO, "Texture", 0, 0, &m_tex, NULL); - add_numbut(1, TOG|SHO, "Tiles", 0, 0, &m_tiles, NULL); add_numbut(2, TOG|SHO, "Light", 0, 0, &m_light, NULL); add_numbut(3, TOG|SHO, "Invisible", 0, 0, &m_invis, NULL); add_numbut(4, TOG|SHO, "Collision", 0, 0, &m_collision, NULL); @@ -4691,7 +4690,6 @@ void mesh_set_face_flags(EditMesh *em, short mode) m_billboard = 0; if (m_tex) flag |= TF_TEX; - if (m_tiles) flag |= TF_TILES; if (m_shared) flag |= TF_SHAREDCOL; if (m_light) flag |= TF_LIGHT; if (m_invis) flag |= TF_INVISIBLE; @@ -4997,7 +4995,7 @@ void MESH_OT_rip(wmOperatorType *ot) /* api callbacks */ ot->invoke= mesh_rip_invoke; - ot->poll= ED_operator_editmesh; // XXX + v3d! + ot->poll= EM_view3d_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -6646,11 +6644,11 @@ static int subdivs_exec(bContext *C, wmOperator *op) void MESH_OT_subdivs(wmOperatorType *ot) { static EnumPropertyItem type_items[]= { - {0, "SIMPLE", "Simple", ""}, - {1, "MULTI", "Multi", ""}, - {2, "FRACTAL", "Fractal", ""}, - {3, "SMOOTH", "Smooth", ""}, - {0, NULL, NULL}}; + {0, "SIMPLE", 0, "Simple", ""}, + {1, "MULTI", 0, "Multi", ""}, + {2, "FRACTAL", 0, "Fractal", ""}, + {3, "SMOOTH", 0, "Smooth", ""}, + {0, NULL, 0, NULL, NULL}}; /* identifiers */ ot->name= "subdivs"; diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h index f7d2fcfc1f2..83a4211dda1 100644 --- a/source/blender/editors/mesh/mesh_intern.h +++ b/source/blender/editors/mesh/mesh_intern.h @@ -135,6 +135,7 @@ extern int convex(float *v1, float *v2, float *v3, float *v4); extern struct EditFace *EM_face_from_faces(EditMesh *em, struct EditFace *efa1, struct EditFace *efa2, int i1, int i2, int i3, int i4); +extern int EM_view3d_poll(struct bContext *C); /* ******************* editmesh_loop.c */ diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 4cf98f2c904..74a1fc12631 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -244,17 +244,17 @@ void ED_object_base_init_from_view(bContext *C, Base *base) /* ******************* add object operator ****************** */ static EnumPropertyItem prop_object_types[] = { - {OB_EMPTY, "EMPTY", "Empty", ""}, - {OB_MESH, "MESH", "Mesh", ""}, - {OB_CURVE, "CURVE", "Curve", ""}, - {OB_SURF, "SURFACE", "Surface", ""}, - {OB_FONT, "TEXT", "Text", ""}, - {OB_MBALL, "META", "Meta", ""}, - {OB_LAMP, "LAMP", "Lamp", ""}, - {OB_CAMERA, "CAMERA", "Camera", ""}, - {OB_ARMATURE, "ARMATURE", "Armature", ""}, - {OB_LATTICE, "LATTICE", "Lattice", ""}, - {0, NULL, NULL, NULL} + {OB_EMPTY, "EMPTY", 0, "Empty", ""}, + {OB_MESH, "MESH", 0, "Mesh", ""}, + {OB_CURVE, "CURVE", 0, "Curve", ""}, + {OB_SURF, "SURFACE", 0, "Surface", ""}, + {OB_FONT, "TEXT", 0, "Text", ""}, + {OB_MBALL, "META", 0, "Meta", ""}, + {OB_LAMP, "LAMP", 0, "Lamp", ""}, + {OB_CAMERA, "CAMERA", 0, "Camera", ""}, + {OB_ARMATURE, "ARMATURE", 0, "Armature", ""}, + {OB_LATTICE, "LATTICE", 0, "Lattice", ""}, + {0, NULL, 0, NULL, NULL} }; @@ -321,16 +321,16 @@ void OBJECT_OT_object_add(wmOperatorType *ot) /* ****** work both in and outside editmode ****** */ static EnumPropertyItem prop_mesh_types[] = { - {0, "PLANE", "Plane", ""}, - {1, "CUBE", "Cube", ""}, - {2, "CIRCLE", "Circle", ""}, - {3, "UVSPHERE", "UVsphere", ""}, - {4, "ICOSPHERE", "Icosphere", ""}, - {5, "CYLINDER", "Cylinder", ""}, - {6, "CONE", "Cone", ""}, - {7, "GRID", "Grid", ""}, - {8, "MONKEY", "Monkey", ""}, - {0, NULL, NULL, NULL} + {0, "PLANE", 0, "Plane", ""}, + {1, "CUBE", 0, "Cube", ""}, + {2, "CIRCLE", 0, "Circle", ""}, + {3, "UVSPHERE", 0, "UVsphere", ""}, + {4, "ICOSPHERE", 0, "Icosphere", ""}, + {5, "CYLINDER", 0, "Cylinder", ""}, + {6, "CONE", 0, "Cone", ""}, + {7, "GRID", 0, "Grid", ""}, + {8, "MONKEY", 0, "Monkey", ""}, + {0, NULL, 0, NULL, NULL} }; static int object_add_mesh_exec(bContext *C, wmOperator *op) @@ -405,12 +405,12 @@ void OBJECT_OT_mesh_add(wmOperatorType *ot) } static EnumPropertyItem prop_curve_types[] = { - {CU_BEZIER|CU_2D|CU_PRIM_CURVE, "BEZIER_CURVE", "Bezier Curve", ""}, - {CU_BEZIER|CU_2D|CU_PRIM_CIRCLE, "BEZIER_CIRCLE", "Bezier Circle", ""}, - {CU_NURBS|CU_2D|CU_PRIM_CURVE, "NURBS_CURVE", "NURBS Curve", ""}, - {CU_NURBS|CU_2D|CU_PRIM_CIRCLE, "NURBS_CIRCLE", "NURBS Circle", ""}, - {CU_NURBS|CU_2D|CU_PRIM_PATH, "PATH", "Path", ""}, - {0, NULL, NULL, NULL} + {CU_BEZIER|CU_2D|CU_PRIM_CURVE, "BEZIER_CURVE", 0, "Bezier Curve", ""}, + {CU_BEZIER|CU_2D|CU_PRIM_CIRCLE, "BEZIER_CIRCLE", 0, "Bezier Circle", ""}, + {CU_NURBS|CU_2D|CU_PRIM_CURVE, "NURBS_CURVE", 0, "NURBS Curve", ""}, + {CU_NURBS|CU_2D|CU_PRIM_CIRCLE, "NURBS_CIRCLE", 0, "NURBS Circle", ""}, + {CU_NURBS|CU_2D|CU_PRIM_PATH, "PATH", 0, "Path", ""}, + {0, NULL, 0, NULL, NULL} }; static int object_add_curve_exec(bContext *C, wmOperator *op) @@ -479,13 +479,13 @@ void OBJECT_OT_curve_add(wmOperatorType *ot) } static EnumPropertyItem prop_surface_types[]= { - {CU_PRIM_CURVE|CU_NURBS, "NURBS_CURVE", "NURBS Curve", ""}, - {CU_PRIM_CIRCLE|CU_NURBS, "NURBS_CIRCLE", "NURBS Circle", ""}, - {CU_PRIM_PATCH|CU_NURBS, "NURBS_SURFACE", "NURBS Surface", ""}, - {CU_PRIM_TUBE|CU_NURBS, "NURBS_TUBE", "NURBS Tube", ""}, - {CU_PRIM_SPHERE|CU_NURBS, "NURBS_SPHERE", "NURBS Sphere", ""}, - {CU_PRIM_DONUT|CU_NURBS, "NURBS_DONUT", "NURBS Donut", ""}, - {0, NULL, NULL, NULL} + {CU_PRIM_CURVE|CU_NURBS, "NURBS_CURVE", 0, "NURBS Curve", ""}, + {CU_PRIM_CIRCLE|CU_NURBS, "NURBS_CIRCLE", 0, "NURBS Circle", ""}, + {CU_PRIM_PATCH|CU_NURBS, "NURBS_SURFACE", 0, "NURBS Surface", ""}, + {CU_PRIM_TUBE|CU_NURBS, "NURBS_TUBE", 0, "NURBS Tube", ""}, + {CU_PRIM_SPHERE|CU_NURBS, "NURBS_SPHERE", 0, "NURBS Sphere", ""}, + {CU_PRIM_DONUT|CU_NURBS, "NURBS_DONUT", 0, "NURBS Donut", ""}, + {0, NULL, 0, NULL, NULL} }; static int object_add_surface_exec(bContext *C, wmOperator *op) @@ -1366,10 +1366,10 @@ void add_hook_menu(Scene *scene, View3D *v3d) /* ******************** clear parent operator ******************* */ static EnumPropertyItem prop_clear_parent_types[] = { - {0, "CLEAR", "Clear Parent", ""}, - {1, "CLEAR_KEEP_TRANSFORM", "Clear and Keep Transformation (Clear Track)", ""}, - {2, "CLEAR_INVERSE", "Clear Parent Inverse", ""}, - {0, NULL, NULL, NULL} + {0, "CLEAR", 0, "Clear Parent", ""}, + {1, "CLEAR_KEEP_TRANSFORM", 0, "Clear and Keep Transformation (Clear Track)", ""}, + {2, "CLEAR_INVERSE", 0, "Clear Parent Inverse", ""}, + {0, NULL, 0, NULL, NULL} }; /* note, poll should check for editable scene */ @@ -1422,9 +1422,9 @@ void OBJECT_OT_parent_clear(wmOperatorType *ot) static EnumPropertyItem prop_clear_track_types[] = { - {0, "CLEAR", "Clear Track", ""}, - {1, "CLEAR_KEEP_TRANSFORM", "Clear and Keep Transformation (Clear Track)", ""}, - {0, NULL, NULL, NULL} + {0, "CLEAR", 0, "Clear Track", ""}, + {1, "CLEAR_KEEP_TRANSFORM", 0, "Clear and Keep Transformation (Clear Track)", ""}, + {0, NULL, 0, NULL, NULL} }; /* note, poll should check for editable scene */ @@ -1471,9 +1471,9 @@ void OBJECT_OT_track_clear(wmOperatorType *ot) /* *****************Selection Operators******************* */ static EnumPropertyItem prop_select_types[] = { - {0, "EXCLUSIVE", "Exclusive", ""}, - {1, "EXTEND", "Extend", ""}, - {0, NULL, NULL, NULL} + {0, "EXCLUSIVE", 0, "Exclusive", ""}, + {1, "EXTEND", 0, "Extend", ""}, + {0, NULL, 0, NULL, NULL} }; /* ****** Select by Type ****** */ @@ -1526,13 +1526,13 @@ void OBJECT_OT_select_by_type(wmOperatorType *ot) /* ****** selection by links *******/ static EnumPropertyItem prop_select_linked_types[] = { - {1, "IPO", "Object IPO", ""}, // XXX depreceated animation system stuff... - {2, "OBDATA", "Ob Data", ""}, - {3, "MATERIAL", "Material", ""}, - {4, "TEXTURE", "Texture", ""}, - {5, "DUPGROUP", "Dupligroup", ""}, - {6, "PARTICLE", "Particle System", ""}, - {0, NULL, NULL, NULL} + {1, "IPO", 0, "Object IPO", ""}, // XXX depreceated animation system stuff... + {2, "OBDATA", 0, "Ob Data", ""}, + {3, "MATERIAL", 0, "Material", ""}, + {4, "TEXTURE", 0, "Texture", ""}, + {5, "DUPGROUP", 0, "Dupligroup", ""}, + {6, "PARTICLE", 0, "Particle System", ""}, + {0, NULL, 0, NULL, NULL} }; static int object_select_linked_exec(bContext *C, wmOperator *op) @@ -2085,9 +2085,9 @@ void OBJECT_OT_restrictview_clear(wmOperatorType *ot) } static EnumPropertyItem prop_set_restrictview_types[] = { - {0, "SELECTED", "Selected", ""}, - {1, "UNSELECTED", "Unselected ", ""}, - {0, NULL, NULL, NULL} + {0, "SELECTED", 0, "Selected", ""}, + {1, "UNSELECTED", 0, "Unselected ", ""}, + {0, NULL, 0, NULL, NULL} }; static int object_restrictview_set_exec(bContext *C, wmOperator *op) @@ -2462,16 +2462,16 @@ void make_proxy(Scene *scene) #define PAR_TRIA 8 static EnumPropertyItem prop_make_parent_types[] = { - {PAR_OBJECT, "OBJECT", "Object", ""}, - {PAR_ARMATURE, "ARMATURE", "Armature Deform", ""}, - {PAR_BONE, "BONE", "Bone", ""}, - {PAR_CURVE, "CURVE", "Curve Deform", ""}, - {PAR_FOLLOW, "FOLLOW", "Follow Path", ""}, - {PAR_PATH_CONST, "PATH_CONST", "Path Constraint", ""}, - {PAR_LATTICE, "LATTICE", "Lattice Deform", ""}, - {PAR_VERTEX, "VERTEX", "Vertex", ""}, - {PAR_TRIA, "TRIA", "Triangle", ""}, - {0, NULL, NULL, NULL} + {PAR_OBJECT, "OBJECT", 0, "Object", ""}, + {PAR_ARMATURE, "ARMATURE", 0, "Armature Deform", ""}, + {PAR_BONE, "BONE", 0, "Bone", ""}, + {PAR_CURVE, "CURVE", 0, "Curve Deform", ""}, + {PAR_FOLLOW, "FOLLOW", 0, "Follow Path", ""}, + {PAR_PATH_CONST, "PATH_CONST", 0, "Path Constraint", ""}, + {PAR_LATTICE, "LATTICE", 0, "Lattice Deform", ""}, + {PAR_VERTEX, "VERTEX", 0, "Vertex", ""}, + {PAR_TRIA, "TRIA", 0, "Triangle", ""}, + {0, NULL, 0, NULL, NULL} }; static int test_parent_loop(Object *par, Object *ob) @@ -2655,10 +2655,10 @@ void OBJECT_OT_parent_set(wmOperatorType *ot) /* *** make track ***** */ static EnumPropertyItem prop_make_track_types[] = { - {1, "TRACKTO", "TrackTo Constraint", ""}, - {2, "LOCKTRACK", "LockTrack Constraint", ""}, - {3, "OLDTRACK", "Old Track", ""}, - {0, NULL, NULL, NULL} + {1, "TRACKTO", 0, "TrackTo Constraint", ""}, + {2, "LOCKTRACK", 0, "LockTrack Constraint", ""}, + {3, "OLDTRACK", 0, "Old Track", ""}, + {0, NULL, 0, NULL, NULL} }; static int track_set_exec(bContext *C, wmOperator *op) @@ -2831,10 +2831,10 @@ void OBJECT_OT_dupli_set_real(wmOperatorType *ot) /* ******************* Set Object Center ********************** */ static EnumPropertyItem prop_set_center_types[] = { - {0, "CENTER", "ObData to Center", "Move object data around Object center"}, - {1, "CENTERNEW", "Center New", "Move Object center to center of object data"}, - {2, "CENTERCURSOR", "Center Cursor", "Move Object Center to position of the 3d cursor"}, - {0, NULL, NULL, NULL} + {0, "CENTER", 0, "ObData to Center", "Move object data around Object center"}, + {1, "CENTERNEW", 0, "Center New", "Move Object center to center of object data"}, + {2, "CENTERCURSOR", 0, "Center Cursor", "Move Object Center to position of the 3d cursor"}, + {0, NULL, 0, NULL, NULL} }; /* 0 == do center, 1 == center new, 2 == center cursor */ diff --git a/source/blender/editors/physics/editparticle.c b/source/blender/editors/physics/editparticle.c index 0947f540fc6..a9fc65bdc37 100644 --- a/source/blender/editors/physics/editparticle.c +++ b/source/blender/editors/physics/editparticle.c @@ -2347,8 +2347,8 @@ void PARTICLE_OT_brush_radial_control(wmOperatorType *ot) enum { DEL_PARTICLE, DEL_KEY }; static EnumPropertyItem delete_type_items[]= { - {DEL_PARTICLE, "PARTICLE", "Particle", ""}, - {DEL_KEY, "KEY", "Key", ""}, + {DEL_PARTICLE, "PARTICLE", 0, "Particle", ""}, + {DEL_KEY, "KEY", 0, "Key", ""}, {0, NULL, NULL}}; static void set_delete_particle(PEData *data, int pa_index) @@ -2563,15 +2563,15 @@ void PARTICLE_OT_mirror(wmOperatorType *ot) /*********************** set brush operator **********************/ static EnumPropertyItem brush_type_items[]= { - {PE_BRUSH_NONE, "NONE", "None", ""}, - {PE_BRUSH_COMB, "COMB", "Comb", ""}, - {PE_BRUSH_SMOOTH, "SMOOTH", "Smooth", ""}, - {PE_BRUSH_WEIGHT, "WEIGHT", "Weight", ""}, - {PE_BRUSH_ADD, "ADD", "Add", ""}, - {PE_BRUSH_LENGTH, "LENGTH", "Length", ""}, - {PE_BRUSH_PUFF, "PUFF", "Puff", ""}, - {PE_BRUSH_CUT, "CUT", "Cut", ""}, - {0, NULL, NULL, NULL} + {PE_BRUSH_NONE, "NONE", 0, "None", ""}, + {PE_BRUSH_COMB, "COMB", 0, "Comb", ""}, + {PE_BRUSH_SMOOTH, "SMOOTH", 0, "Smooth", ""}, + {PE_BRUSH_WEIGHT, "WEIGHT", 0, "Weight", ""}, + {PE_BRUSH_ADD, "ADD", 0, "Add", ""}, + {PE_BRUSH_LENGTH, "LENGTH", 0, "Length", ""}, + {PE_BRUSH_PUFF, "PUFF", 0, "Puff", ""}, + {PE_BRUSH_CUT, "CUT", 0, "Cut", ""}, + {0, NULL, 0, NULL, NULL} }; static int set_brush_exec(bContext *C, wmOperator *op) diff --git a/source/blender/editors/preview/previewrender.c b/source/blender/editors/preview/previewrender.c index 3ed4fa6bd0f..1ce20fcb0af 100644 --- a/source/blender/editors/preview/previewrender.c +++ b/source/blender/editors/preview/previewrender.c @@ -633,41 +633,41 @@ void BIF_previewrender_buts(Scene *scene, SpaceButs *sbuts) /* uses ROUNDBOX button in block to get the rect */ void ED_preview_draw(const bContext *C, void *idp, rcti *rect) { - ScrArea *sa= CTX_wm_area(C); - SpaceButs *sbuts= sa->spacedata.first; - RenderResult rres; - int newx= rect->xmax-rect->xmin, newy= rect->ymax-rect->ymin; - int ok= 0; - char name[32]; - - sprintf(name, "Preview %p", sa); - BLI_lock_malloc_thread(); - RE_GetResultImage(RE_GetRender(name), &rres); - - if(rres.rectf) { - - if( ABS(rres.rectx-newx)<2 && ABS(rres.recty-newy)<2 ) { - /* correct size, then black outline matches */ - rect->xmax= rect->xmin + rres.rectx; - rect->ymax= rect->ymin + rres.recty; + if(idp) { + ScrArea *sa= CTX_wm_area(C); + SpaceButs *sbuts= sa->spacedata.first; + RenderResult rres; + int newx= rect->xmax-rect->xmin, newy= rect->ymax-rect->ymin; + int ok= 0; + char name[32]; - glaDrawPixelsSafe(rect->xmin, rect->ymin, rres.rectx, rres.recty, rres.rectx, GL_RGBA, GL_FLOAT, rres.rectf); - ok= 1; + sprintf(name, "Preview %p", sa); + BLI_lock_malloc_thread(); + RE_GetResultImage(RE_GetRender(name), &rres); + + if(rres.rectf) { + + if( ABS(rres.rectx-newx)<2 && ABS(rres.recty-newy)<2 ) { + /* correct size, then black outline matches */ + rect->xmax= rect->xmin + rres.rectx; + rect->ymax= rect->ymin + rres.recty; + + glaDrawPixelsSafe(rect->xmin, rect->ymin, rres.rectx, rres.recty, rres.rectx, GL_RGBA, GL_FLOAT, rres.rectf); + ok= 1; + } } - } - BLI_unlock_malloc_thread(); + BLI_unlock_malloc_thread(); - /* check for spacetype... */ - if(sbuts->spacetype==SPACE_BUTS && sbuts->preview) { - sbuts->preview= 0; - ok= 0; - } - - if(ok==0) { - printf("added shader job\n"); - ED_preview_shader_job(C, sa, idp, newx, newy); - } - + /* check for spacetype... */ + if(sbuts->spacetype==SPACE_BUTS && sbuts->preview) { + sbuts->preview= 0; + ok= 0; + } + + if(ok==0) { + ED_preview_shader_job(C, sa, idp, newx, newy); + } + } } /* *************************** Preview for 3d window *********************** */ diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 81b63b694ba..07d8fb370e6 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -1048,6 +1048,7 @@ static char *windowtype_pup(void) "|Outliner %x3" //232 "|Buttons Window %x4" //251 "|Node Editor %x16" + "|Logic Editor %x17" "|%l" //254 "|File Browser %x5" //290 @@ -1106,6 +1107,7 @@ int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco) void ED_region_panels(const bContext *C, ARegion *ar, int vertical, char *context) { + ScrArea *sa= CTX_wm_area(C); uiStyle *style= U.uistyles.first; uiBlock *block; PanelType *pt; @@ -1143,7 +1145,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, char *contex /* draw panel */ if(pt->draw && (!pt->poll || pt->poll(C, pt))) { block= uiBeginBlock(C, ar, pt->idname, UI_EMBOSS); - panel= uiBeginPanel(ar, block, pt, &open); + panel= uiBeginPanel(sa, ar, block, pt, &open); if(vertical) y -= header; @@ -1161,7 +1163,6 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, char *contex } if(open) { - panel->type= pt; panel->layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, style->panelspace, 0, w-2*style->panelspace, em, style); @@ -1173,8 +1174,10 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, char *contex yco -= 2*style->panelspace; uiEndPanel(block, w, -yco); } - else + else { yco= 0; + uiEndPanel(block, w, 0); + } uiEndBlock(C, block); diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 8e72ebae3c0..14121ccdc4d 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -185,6 +185,11 @@ int ED_operator_nla_active(bContext *C) return ed_spacetype_test(C, SPACE_NLA); } +int ED_operator_logic_active(bContext *C) +{ + return ed_spacetype_test(C, SPACE_LOGIC); +} + int ED_operator_object_active(bContext *C) { return NULL != CTX_data_active_object(C); @@ -1198,9 +1203,9 @@ static int area_split_modal(bContext *C, wmOperator *op, wmEvent *event) } static EnumPropertyItem prop_direction_items[] = { - {'h', "HORIZONTAL", "Horizontal", ""}, - {'v', "VERTICAL", "Vertical", ""}, - {0, NULL, NULL, NULL}}; + {'h', "HORIZONTAL", 0, "Horizontal", ""}, + {'v', "VERTICAL", 0, "Vertical", ""}, + {0, NULL, 0, NULL, NULL}}; void SCREEN_OT_area_split(wmOperatorType *ot) { diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 1effd8fd377..a163ef5f8e2 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -4517,6 +4517,9 @@ static int paint_init(bContext *C, wmOperator *op) pop->ps.ar= CTX_wm_region(C); /* intialize brush */ + if(!settings->imapaint.brush) + return 0; + pop->s.brush = settings->imapaint.brush; pop->s.tool = settings->imapaint.tool; if(pop->mode == PAINT_MODE_3D && (pop->s.tool == PAINT_TOOL_CLONE)) @@ -4536,6 +4539,10 @@ static int paint_init(bContext *C, wmOperator *op) if (!pop->s.ob || !(pop->s.ob->lay & pop->ps.v3d->lay)) return 0; pop->s.me = get_mesh(pop->s.ob); if (!pop->s.me) return 0; + + /* Dont allow brush size below 2 */ + if (pop->ps.brush && pop->ps.brush->size<=1) + pop->ps.brush->size = 2; } else { pop->s.image = pop->s.sima->image; @@ -4548,10 +4555,6 @@ static int paint_init(bContext *C, wmOperator *op) return 0; } - - /* Dont allow brush size below 2 */ - if (pop->ps.brush->size<=1) - pop->ps.brush->size = 2; } /* note, if we have no UVs on the derived mesh, then we must return here */ diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index dc954ff5f26..7703dc0c303 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -234,6 +234,9 @@ static char brush_size(Sculpt *sd) special multiplier found experimentally to scale the strength factor. */ static float brush_strength(Sculpt *sd, StrokeCache *cache) { + /* Primary strength input; square it to make lower values more sensitive */ + float alpha = sd->brush->alpha * sd->brush->alpha; + float dir= sd->brush->flag & BRUSH_DIR_IN ? -1 : 1; float pressure= 1; float flip= cache->flip ? -1:1; @@ -244,18 +247,17 @@ static float brush_strength(Sculpt *sd, StrokeCache *cache) switch(sd->brush->sculpt_tool){ case SCULPT_TOOL_DRAW: - case SCULPT_TOOL_LAYER: - return sd->brush->alpha / 50.0f * dir * pressure * flip * anchored; /*XXX: not sure why? multiplied by G.vd->grid */; + case SCULPT_TOOL_INFLATE: + return alpha * dir * pressure * flip; /*XXX: not sure why? was multiplied by G.vd->grid */; + case SCULPT_TOOL_FLATTEN: case SCULPT_TOOL_SMOOTH: - return sd->brush->alpha / .5 * pressure * anchored; + return alpha * 4 * pressure; case SCULPT_TOOL_PINCH: - return sd->brush->alpha / 10.0f * dir * pressure * flip * anchored; + return alpha / 2 * dir * pressure * flip; case SCULPT_TOOL_GRAB: return 1; - case SCULPT_TOOL_INFLATE: - return sd->brush->alpha / 50.0f * dir * pressure * flip * anchored; - case SCULPT_TOOL_FLATTEN: - return sd->brush->alpha / 5.0f * pressure * anchored; + case SCULPT_TOOL_LAYER: + return sd->brush->alpha / 50.0f * dir * pressure * flip * anchored; /*XXX: not sure why? multiplied by G.vd->grid */; default: return 0; } @@ -354,10 +356,10 @@ static void do_draw_brush(Sculpt *sd, SculptSession *ss, const ListBase* active_ while(node){ float *co= ss->mvert[node->Index].co; - - const float val[3]= {co[0]+area_normal[0]*node->Fade*ss->cache->scale[0], - co[1]+area_normal[1]*node->Fade*ss->cache->scale[1], - co[2]+area_normal[2]*node->Fade*ss->cache->scale[2]}; + + const float val[3]= {co[0]+area_normal[0]*ss->cache->radius*node->Fade*ss->cache->scale[0], + co[1]+area_normal[1]*ss->cache->radius*node->Fade*ss->cache->scale[1], + co[2]+area_normal[2]*ss->cache->radius*node->Fade*ss->cache->scale[2]}; sculpt_clip(ss->cache, co, val); @@ -412,18 +414,21 @@ static void neighbor_average(SculptSession *ss, float avg[3], const int vert) static void do_smooth_brush(SculptSession *ss, const ListBase* active_verts) { ActiveData *node= active_verts->first; - - while(node){ - float *co= ss->mvert[node->Index].co; - float avg[3], val[3]; - - neighbor_average(ss, avg, node->Index); - val[0] = co[0]+(avg[0]-co[0])*node->Fade; - val[1] = co[1]+(avg[1]-co[1])*node->Fade; - val[2] = co[2]+(avg[2]-co[2])*node->Fade; - - sculpt_clip(ss->cache, co, val); - node= node->next; + int i; + + for(i = 0; i < 2; ++i) { + while(node){ + float *co= ss->mvert[node->Index].co; + float avg[3], val[3]; + + neighbor_average(ss, avg, node->Index); + val[0] = co[0]+(avg[0]-co[0])*node->Fade; + val[1] = co[1]+(avg[1]-co[1])*node->Fade; + val[2] = co[2]+(avg[2]-co[2])*node->Fade; + + sculpt_clip(ss->cache, co, val); + node= node->next; + } } } @@ -467,33 +472,33 @@ static void do_layer_brush(Sculpt *sd, SculptSession *ss, const ListBase *active { float area_normal[3]; ActiveData *node= active_verts->first; - const float bstr= brush_strength(sd, ss->cache); + float lim= brush_strength(sd, ss->cache); + + if(sd->brush->flag & BRUSH_DIR_IN) + lim = -lim; calc_area_normal(sd, area_normal, active_verts); while(node){ float *disp= &ss->cache->layer_disps[node->Index]; - if((bstr > 0 && *disp < bstr) || - (bstr < 0 && *disp > bstr)) { + if((lim > 0 && *disp < lim) || + (lim < 0 && *disp > lim)) { float *co= ss->mvert[node->Index].co; + float val[3]; *disp+= node->Fade; - if(bstr < 0) { - if(*disp < bstr) - *disp = bstr; - } else { - if(*disp > bstr) - *disp = bstr; - } + if(lim < 0 && *disp < lim) + *disp = lim; + else if(lim > 0 && *disp > lim) + *disp = lim; - { - const float val[3]= {ss->cache->mesh_store[node->Index][0]+area_normal[0] * *disp*ss->cache->scale[0], - ss->cache->mesh_store[node->Index][1]+area_normal[1] * *disp*ss->cache->scale[1], - ss->cache->mesh_store[node->Index][2]+area_normal[2] * *disp*ss->cache->scale[2]}; - sculpt_clip(ss->cache, co, val); - } + val[0] = ss->cache->mesh_store[node->Index][0]+area_normal[0] * *disp*ss->cache->scale[0]; + val[1] = ss->cache->mesh_store[node->Index][1]+area_normal[1] * *disp*ss->cache->scale[1]; + val[2] = ss->cache->mesh_store[node->Index][2]+area_normal[2] * *disp*ss->cache->scale[2]; + //VecMulf(val, ss->cache->radius); + sculpt_clip(ss->cache, co, val); } node= node->next; @@ -512,7 +517,7 @@ static void do_inflate_brush(SculptSession *ss, const ListBase *active_verts) add[0]= no[0]/ 32767.0f; add[1]= no[1]/ 32767.0f; add[2]= no[2]/ 32767.0f; - VecMulf(add, node->Fade); + VecMulf(add, node->Fade * ss->cache->radius); add[0]*= ss->cache->scale[0]; add[1]*= ss->cache->scale[1]; add[2]*= ss->cache->scale[2]; @@ -1245,10 +1250,10 @@ static int sculpt_brush_curve_preset_exec(bContext *C, wmOperator *op) static void SCULPT_OT_brush_curve_preset(wmOperatorType *ot) { static EnumPropertyItem prop_mode_items[] = { - {BRUSH_PRESET_SHARP, "SHARP", "Sharp Curve", ""}, - {BRUSH_PRESET_SMOOTH, "SMOOTH", "Smooth Curve", ""}, - {BRUSH_PRESET_MAX, "MAX", "Max Curve", ""}, - {0, NULL, NULL, NULL}}; + {BRUSH_PRESET_SHARP, "SHARP", 0, "Sharp Curve", ""}, + {BRUSH_PRESET_SMOOTH, "SMOOTH", 0, "Smooth Curve", ""}, + {BRUSH_PRESET_MAX, "MAX", 0, "Max Curve", ""}, + {0, NULL, 0, NULL, NULL}}; ot->name= "Preset"; ot->idname= "SCULPT_OT_brush_curve_preset"; diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index af074ca348d..a0f1adbd97e 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -369,10 +369,10 @@ void ACT_OT_keyframes_paste (wmOperatorType *ot) /* defines for insert keyframes tool */ EnumPropertyItem prop_actkeys_insertkey_types[] = { - {1, "ALL", "All Channels", ""}, - {2, "SEL", "Only Selected Channels", ""}, - {3, "GROUP", "In Active Group", ""}, // xxx not in all cases - {0, NULL, NULL, NULL} + {1, "ALL", 0, "All Channels", ""}, + {2, "SEL", 0, "Only Selected Channels", ""}, + {3, "GROUP", 0, "In Active Group", ""}, // xxx not in all cases + {0, NULL, 0, NULL, NULL} }; /* this function is responsible for snapping keyframes to frame-times */ @@ -799,9 +799,9 @@ void ACT_OT_keyframes_sample (wmOperatorType *ot) /* defines for set extrapolation-type for selected keyframes tool */ EnumPropertyItem prop_actkeys_expo_types[] = { - {FCURVE_EXTRAPOLATE_CONSTANT, "CONSTANT", "Constant Extrapolation", ""}, - {FCURVE_EXTRAPOLATE_LINEAR, "LINEAR", "Linear Extrapolation", ""}, - {0, NULL, NULL, NULL} + {FCURVE_EXTRAPOLATE_CONSTANT, "CONSTANT", 0, "Constant Extrapolation", ""}, + {FCURVE_EXTRAPOLATE_LINEAR, "LINEAR", 0, "Linear Extrapolation", ""}, + {0, NULL, 0, NULL, NULL} }; /* this function is responsible for setting extrapolation mode for keyframes */ @@ -1089,11 +1089,11 @@ void ACT_OT_keyframes_cfrasnap (wmOperatorType *ot) /* defines for snap keyframes tool */ EnumPropertyItem prop_actkeys_snap_types[] = { - {ACTKEYS_SNAP_CFRA, "CFRA", "Current frame", ""}, - {ACTKEYS_SNAP_NEAREST_FRAME, "NEAREST_FRAME", "Nearest Frame", ""}, // XXX as single entry? - {ACTKEYS_SNAP_NEAREST_SECOND, "NEAREST_SECOND", "Nearest Second", ""}, // XXX as single entry? - {ACTKEYS_SNAP_NEAREST_MARKER, "NEAREST_MARKER", "Nearest Marker", ""}, - {0, NULL, NULL, NULL} + {ACTKEYS_SNAP_CFRA, "CFRA", 0, "Current frame", ""}, + {ACTKEYS_SNAP_NEAREST_FRAME, "NEAREST_FRAME", 0, "Nearest Frame", ""}, // XXX as single entry? + {ACTKEYS_SNAP_NEAREST_SECOND, "NEAREST_SECOND", 0, "Nearest Second", ""}, // XXX as single entry? + {ACTKEYS_SNAP_NEAREST_MARKER, "NEAREST_MARKER", 0, "Nearest Marker", ""}, + {0, NULL, 0, NULL, NULL} }; /* this function is responsible for snapping keyframes to frame-times */ @@ -1188,11 +1188,11 @@ void ACT_OT_keyframes_snap (wmOperatorType *ot) /* defines for mirror keyframes tool */ EnumPropertyItem prop_actkeys_mirror_types[] = { - {ACTKEYS_MIRROR_CFRA, "CFRA", "Current frame", ""}, - {ACTKEYS_MIRROR_YAXIS, "YAXIS", "Vertical Axis", ""}, - {ACTKEYS_MIRROR_XAXIS, "XAXIS", "Horizontal Axis", ""}, - {ACTKEYS_MIRROR_MARKER, "MARKER", "First Selected Marker", ""}, - {0, NULL, NULL, NULL} + {ACTKEYS_MIRROR_CFRA, "CFRA", 0, "Current frame", ""}, + {ACTKEYS_MIRROR_YAXIS, "YAXIS", 0, "Vertical Axis", ""}, + {ACTKEYS_MIRROR_XAXIS, "XAXIS", 0, "Horizontal Axis", ""}, + {ACTKEYS_MIRROR_MARKER, "MARKER", 0, "First Selected Marker", ""}, + {0, NULL, 0, NULL, NULL} }; /* this function is responsible for mirroring keyframes */ diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index 826728e83f9..6bfdf77e2e7 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -374,11 +374,11 @@ void ACT_OT_keyframes_select_border(wmOperatorType *ot) /* defines for column-select mode */ static EnumPropertyItem prop_column_select_types[] = { - {ACTKEYS_COLUMNSEL_KEYS, "KEYS", "On Selected Keyframes", ""}, - {ACTKEYS_COLUMNSEL_CFRA, "CFRA", "On Current Frame", ""}, - {ACTKEYS_COLUMNSEL_MARKERS_COLUMN, "MARKERS_COLUMN", "On Selected Markers", ""}, - {ACTKEYS_COLUMNSEL_MARKERS_BETWEEN, "MARKERS_BETWEEN", "Between Min/Max Selected Markers", ""}, - {0, NULL, NULL, NULL} + {ACTKEYS_COLUMNSEL_KEYS, "KEYS", 0, "On Selected Keyframes", ""}, + {ACTKEYS_COLUMNSEL_CFRA, "CFRA", 0, "On Current Frame", ""}, + {ACTKEYS_COLUMNSEL_MARKERS_COLUMN, "MARKERS_COLUMN", 0, "On Selected Markers", ""}, + {ACTKEYS_COLUMNSEL_MARKERS_BETWEEN, "MARKERS_BETWEEN", 0, "Between Min/Max Selected Markers", ""}, + {0, NULL, 0, NULL, NULL} }; /* ------------------- */ @@ -584,11 +584,11 @@ void ACT_OT_keyframes_select_column (wmOperatorType *ot) /* defines for left-right select tool */ static EnumPropertyItem prop_actkeys_leftright_select_types[] = { - {ACTKEYS_LRSEL_TEST, "CHECK", "Check if Select Left or Right", ""}, - {ACTKEYS_LRSEL_NONE, "OFF", "Don't select", ""}, - {ACTKEYS_LRSEL_LEFT, "LEFT", "Before current frame", ""}, - {ACTKEYS_LRSEL_RIGHT, "RIGHT", "After current frame", ""}, - {0, NULL, NULL, NULL} + {ACTKEYS_LRSEL_TEST, "CHECK", 0, "Check if Select Left or Right", ""}, + {ACTKEYS_LRSEL_NONE, "OFF", 0, "Don't select", ""}, + {ACTKEYS_LRSEL_LEFT, "LEFT", 0, "Before current frame", ""}, + {ACTKEYS_LRSEL_RIGHT, "RIGHT", 0, "After current frame", ""}, + {0, NULL, 0, NULL, NULL} }; /* sensitivity factor for frame-selections */ diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c index 9a4d1f329e8..4f9c1f4b7a7 100644 --- a/source/blender/editors/space_api/spacetypes.c +++ b/source/blender/editors/space_api/spacetypes.c @@ -73,6 +73,7 @@ void ED_spacetypes_init(void) ED_spacetype_script(); ED_spacetype_text(); ED_spacetype_sequencer(); + ED_spacetype_logic(); // ... /* register operator types for screen and all spaces */ diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 255bee1bf5a..fc280d9b551 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -54,6 +54,7 @@ #include "RNA_access.h" +#include "ED_armature.h" #include "ED_screen.h" #include "UI_interface.h" @@ -249,16 +250,29 @@ static int buttons_context_path_bone(ButsContextPath *path) { bArmature *arm; Bone *bone; + EditBone *edbo; /* if we have an armature, get the active bone */ if(buttons_context_path_data(path, OB_ARMATURE)) { arm= path->ptr[path->len-1].data; - bone= find_active_bone(arm->bonebase.first); - if(bone) { - RNA_pointer_create(&arm->id, &RNA_Bone, bone, &path->ptr[path->len]); - path->len++; - return 1; + if(arm->edbo) { + for(edbo=arm->edbo->first; edbo; edbo=edbo->next) { + if(edbo->flag & BONE_ACTIVE) { + RNA_pointer_create(&arm->id, &RNA_EditBone, edbo, &path->ptr[path->len]); + path->len++; + return 1; + } + } + } + else { + bone= find_active_bone(arm->bonebase.first); + + if(bone) { + RNA_pointer_create(&arm->id, &RNA_Bone, bone, &path->ptr[path->len]); + path->len++; + return 1; + } } } @@ -569,13 +583,23 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r set_pointer_type(path, result, &RNA_Bone); return 1; } + else if(CTX_data_equals(member, "edit_bone")) { + set_pointer_type(path, result, &RNA_EditBone); + return 1; + } else if(CTX_data_equals(member, "particle_system")) { set_pointer_type(path, result, &RNA_ParticleSystem); return 1; } else if(CTX_data_equals(member, "cloth")) { - set_pointer_type(path, result, &RNA_ClothModifier); - return 1; + PointerRNA *ptr= get_pointer_type(path, &RNA_Object); + + if(ptr && ptr->data) { + Object *ob= ptr->data; + ModifierData *md= modifiers_findByType(ob, eModifierType_Cloth); + CTX_data_pointer_set(result, &ob->id, &RNA_ClothModifier, md); + return 1; + } } else if(CTX_data_equals(member, "soft_body")) { PointerRNA *ptr= get_pointer_type(path, &RNA_Object); diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index a3d0b50b9a6..49397ed0edd 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -1001,9 +1001,9 @@ void GRAPHEDIT_OT_keyframes_sample (wmOperatorType *ot) /* defines for set extrapolation-type for selected keyframes tool */ EnumPropertyItem prop_graphkeys_expo_types[] = { - {FCURVE_EXTRAPOLATE_CONSTANT, "CONSTANT", "Constant Extrapolation", ""}, - {FCURVE_EXTRAPOLATE_LINEAR, "LINEAR", "Linear Extrapolation", ""}, - {0, NULL, NULL, NULL} + {FCURVE_EXTRAPOLATE_CONSTANT, "CONSTANT", 0, "Constant Extrapolation", ""}, + {FCURVE_EXTRAPOLATE_LINEAR, "LINEAR", 0, "Linear Extrapolation", ""}, + {0, NULL, 0, NULL, NULL} }; /* this function is responsible for setting extrapolation mode for keyframes */ @@ -1371,12 +1371,12 @@ void GRAPHEDIT_OT_keyframes_cfrasnap (wmOperatorType *ot) /* defines for snap keyframes tool */ EnumPropertyItem prop_graphkeys_snap_types[] = { - {GRAPHKEYS_SNAP_CFRA, "CFRA", "Current frame", ""}, - {GRAPHKEYS_SNAP_NEAREST_FRAME, "NEAREST_FRAME", "Nearest Frame", ""}, // XXX as single entry? - {GRAPHKEYS_SNAP_NEAREST_SECOND, "NEAREST_SECOND", "Nearest Second", ""}, // XXX as single entry? - {GRAPHKEYS_SNAP_NEAREST_MARKER, "NEAREST_MARKER", "Nearest Marker", ""}, - {GRAPHKEYS_SNAP_HORIZONTAL, "HORIZONTAL", "Flatten Handles", ""}, - {0, NULL, NULL, NULL} + {GRAPHKEYS_SNAP_CFRA, "CFRA", 0, "Current frame", ""}, + {GRAPHKEYS_SNAP_NEAREST_FRAME, "NEAREST_FRAME", 0, "Nearest Frame", ""}, // XXX as single entry? + {GRAPHKEYS_SNAP_NEAREST_SECOND, "NEAREST_SECOND", 0, "Nearest Second", ""}, // XXX as single entry? + {GRAPHKEYS_SNAP_NEAREST_MARKER, "NEAREST_MARKER", 0, "Nearest Marker", ""}, + {GRAPHKEYS_SNAP_HORIZONTAL, "HORIZONTAL", 0, "Flatten Handles", ""}, + {0, NULL, 0, NULL, NULL} }; /* this function is responsible for snapping keyframes to frame-times */ @@ -1466,11 +1466,11 @@ void GRAPHEDIT_OT_keyframes_snap (wmOperatorType *ot) /* defines for mirror keyframes tool */ EnumPropertyItem prop_graphkeys_mirror_types[] = { - {GRAPHKEYS_MIRROR_CFRA, "CFRA", "Current frame", ""}, - {GRAPHKEYS_MIRROR_YAXIS, "YAXIS", "Vertical Axis", ""}, - {GRAPHKEYS_MIRROR_XAXIS, "XAXIS", "Horizontal Axis", ""}, - {GRAPHKEYS_MIRROR_MARKER, "MARKER", "First Selected Marker", ""}, - {0, NULL, NULL, NULL} + {GRAPHKEYS_MIRROR_CFRA, "CFRA", 0, "Current frame", ""}, + {GRAPHKEYS_MIRROR_YAXIS, "YAXIS", 0, "Vertical Axis", ""}, + {GRAPHKEYS_MIRROR_XAXIS, "XAXIS", 0, "Horizontal Axis", ""}, + {GRAPHKEYS_MIRROR_MARKER, "MARKER", 0, "First Selected Marker", ""}, + {0, NULL, 0, NULL, NULL} }; /* this function is responsible for mirroring keyframes */ diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index 21320b60ead..a222109b0fe 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -340,11 +340,11 @@ void GRAPHEDIT_OT_keyframes_select_border(wmOperatorType *ot) /* defines for column-select mode */ static EnumPropertyItem prop_column_select_types[] = { - {GRAPHKEYS_COLUMNSEL_KEYS, "KEYS", "On Selected Keyframes", ""}, - {GRAPHKEYS_COLUMNSEL_CFRA, "CFRA", "On Current Frame", ""}, - {GRAPHKEYS_COLUMNSEL_MARKERS_COLUMN, "MARKERS_COLUMN", "On Selected Markers", ""}, - {GRAPHKEYS_COLUMNSEL_MARKERS_BETWEEN, "MARKERS_BETWEEN", "Between Min/Max Selected Markers", ""}, - {0, NULL, NULL, NULL} + {GRAPHKEYS_COLUMNSEL_KEYS, "KEYS", 0, "On Selected Keyframes", ""}, + {GRAPHKEYS_COLUMNSEL_CFRA, "CFRA", 0, "On Current Frame", ""}, + {GRAPHKEYS_COLUMNSEL_MARKERS_COLUMN, "MARKERS_COLUMN", 0, "On Selected Markers", ""}, + {GRAPHKEYS_COLUMNSEL_MARKERS_BETWEEN, "MARKERS_BETWEEN", 0, "Between Min/Max Selected Markers", ""}, + {0, NULL, 0, NULL, NULL} }; /* ------------------- */ @@ -526,11 +526,11 @@ void GRAPHEDIT_OT_keyframes_columnselect (wmOperatorType *ot) /* defines for left-right select tool */ static EnumPropertyItem prop_graphkeys_leftright_select_types[] = { - {GRAPHKEYS_LRSEL_TEST, "CHECK", "Check if Select Left or Right", ""}, - {GRAPHKEYS_LRSEL_NONE, "OFF", "Don't select", ""}, - {GRAPHKEYS_LRSEL_LEFT, "LEFT", "Before current frame", ""}, - {GRAPHKEYS_LRSEL_RIGHT, "RIGHT", "After current frame", ""}, - {0, NULL, NULL, NULL} + {GRAPHKEYS_LRSEL_TEST, "CHECK", 0, "Check if Select Left or Right", ""}, + {GRAPHKEYS_LRSEL_NONE, "OFF", 0, "Don't select", ""}, + {GRAPHKEYS_LRSEL_LEFT, "LEFT", 0, "Before current frame", ""}, + {GRAPHKEYS_LRSEL_RIGHT, "RIGHT", 0, "After current frame", ""}, + {0, NULL, 0, NULL, NULL} }; /* ------------------- */ diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 35004a4bdef..b5df0257e71 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -383,41 +383,6 @@ static void image_editcursor_buts(const bContext *C, View2D *v2d, uiBlock *block } } -static void image_panel_game_properties(const bContext *C, Panel *pa) -{ - SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C); - ImBuf *ibuf= BKE_image_get_ibuf(sima->image, &sima->iuser); - uiBlock *block; - - block= uiLayoutFreeBlock(pa->layout); - uiBlockSetHandleFunc(block, do_image_panel_events, NULL); - - if (ibuf) { - char str[128]; - - image_info(sima->image, ibuf, str); - uiDefBut(block, LABEL, B_NOP, str, 10,180,300,19, 0, 0, 0, 0, 0, ""); - - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, IMA_TWINANIM, B_TWINANIM, "Anim", 10,150,140,19, &sima->image->tpageflag, 0, 0, 0, 0, "Toggles use of animated texture"); - uiDefButS(block, NUM, B_TWINANIM, "Start:", 10,130,140,19, &sima->image->twsta, 0.0, 128.0, 0, 0, "Displays the start frame of an animated texture"); - uiDefButS(block, NUM, B_TWINANIM, "End:", 10,110,140,19, &sima->image->twend, 0.0, 128.0, 0, 0, "Displays the end frame of an animated texture"); - uiDefButS(block, NUM, B_NOP, "Speed", 10,90,140,19, &sima->image->animspeed, 1.0, 100.0, 0, 0, "Displays Speed of the animation in frames per second"); - uiBlockEndAlign(block); - - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, IMA_TILES, B_SIMAGETILE, "Tiles", 160,150,140,19, &sima->image->tpageflag, 0, 0, 0, 0, "Toggles use of tilemode for faces (Shift LMB to pick the tile for selected faces)"); - uiDefButS(block, NUM, B_REDR, "X:", 160,130,70,19, &sima->image->xrep, 1.0, 16.0, 0, 0, "Sets the degree of repetition in the X direction"); - uiDefButS(block, NUM, B_REDR, "Y:", 230,130,70,19, &sima->image->yrep, 1.0, 16.0, 0, 0, "Sets the degree of repetition in the Y direction"); - uiBlockBeginAlign(block); - - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, IMA_CLAMP_U, B_REDR, "ClampX", 160,100,70,19, &sima->image->tpageflag, 0, 0, 0, 0, "Disable texture repeating horizontaly"); - uiDefButBitS(block, TOG, IMA_CLAMP_V, B_REDR, "ClampY", 230,100,70,19, &sima->image->tpageflag, 0, 0, 0, 0, "Disable texture repeating vertically"); - uiBlockEndAlign(block); - } -} - static void image_panel_view_properties(const bContext *C, Panel *pa) { SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C); @@ -1412,12 +1377,6 @@ void image_buttons_register(ARegionType *art) pt->draw= image_panel_properties; BLI_addtail(&art->paneltypes, pt); - pt= MEM_callocN(sizeof(PanelType), "spacetype image panel game properties"); - strcpy(pt->idname, "IMAGE_PT_game_properties"); - strcpy(pt->label, "Game Properties"); - pt->draw= image_panel_game_properties; - BLI_addtail(&art->paneltypes, pt); - pt= MEM_callocN(sizeof(PanelType), "spacetype image view properties"); strcpy(pt->idname, "IMAGE_PT_view_properties"); strcpy(pt->label, "View Properties"); diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 378d91c8e32..537996601b8 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -132,10 +132,10 @@ static int space_image_file_exists_poll(bContext *C) int space_image_main_area_poll(bContext *C) { SpaceLink *slink= CTX_wm_space_data(C); - ARegion *ar= CTX_wm_region(C); + // XXX ARegion *ar= CTX_wm_region(C); if(slink && (slink->spacetype == SPACE_IMAGE)) - return (ar && ar->type->regionid == RGN_TYPE_WINDOW); + return 1; // XXX (ar && ar->type->regionid == RGN_TYPE_WINDOW); return 0; } @@ -1412,9 +1412,9 @@ void IMAGE_OT_sample(wmOperatorType *ot) void IMAGE_OT_curves_point_set(wmOperatorType *ot) { static EnumPropertyItem point_items[]= { - {0, "BLACK_POINT", "Black Point", ""}, - {1, "WHITE_POINT", "White Point", ""}, - {0, NULL, NULL, NULL}}; + {0, "BLACK_POINT", 0, "Black Point", ""}, + {1, "WHITE_POINT", 0, "White Point", ""}, + {0, NULL, 0, NULL, NULL}}; /* identifiers */ ot->name= "Set Curves Point"; diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index c82018a3aac..e12f3bfe357 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -270,13 +270,6 @@ static void image_refresh(const bContext *C, ScrArea *sa) if(sima->flag & SI_EDITTILE); else sima->curtile= tf->tile; - - if(ima) { - if(tf->mode & TF_TILES) - ima->tpageflag |= IMA_TILES; - else - ima->tpageflag &= ~IMA_TILES; - } } } @@ -286,8 +279,6 @@ static void image_refresh(const bContext *C, ScrArea *sa) static void image_listener(ScrArea *sa, wmNotifier *wmn) { - SpaceImage *sima= sa->spacedata.first; - /* context changes */ switch(wmn->category) { case NC_SCENE: @@ -301,8 +292,7 @@ static void image_listener(ScrArea *sa, wmNotifier *wmn) } break; case NC_IMAGE: - if(!wmn->reference || wmn->reference == sima->image) - ED_area_tag_redraw(sa); + ED_area_tag_redraw(sa); break; } } @@ -508,11 +498,17 @@ static void image_buttons_area_listener(ARegion *ar, wmNotifier *wmn) /* add handlers, stuff you only do once or on area/region changes */ static void image_header_area_init(wmWindowManager *wm, ARegion *ar) { +#if 0 UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); +#else + ED_region_header_init(ar); +#endif } static void image_header_area_draw(const bContext *C, ARegion *ar) { + ED_region_header(C, ar); +#if 0 float col[3]; /* clear */ @@ -531,6 +527,7 @@ static void image_header_area_draw(const bContext *C, ARegion *ar) /* restore view matrix? */ UI_view2d_view_restore(C); +#endif } /**************************** spacetype *****************************/ @@ -616,10 +613,12 @@ void ED_space_image_set(bContext *C, SpaceImage *sima, Scene *scene, Object *obe if(sima->image && sima->image->id.us==0) sima->image->id.us= 1; - if(obedit) - WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit); + if(C) { + if(obedit) + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, obedit); - ED_area_tag_redraw(CTX_wm_area(C)); + ED_area_tag_redraw(CTX_wm_area(C)); + } } ImBuf *ED_space_image_buffer(SpaceImage *sima) diff --git a/source/blender/editors/space_logic/Makefile b/source/blender/editors/space_logic/Makefile new file mode 100644 index 00000000000..e07a5bbf4a9 --- /dev/null +++ b/source/blender/editors/space_logic/Makefile @@ -0,0 +1,54 @@ +# +# $Id: Makefile 14 2002-10-13 15:57:19Z hans $ +# +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# The Original Code is Copyright (C) 2007 Blender Foundation +# All rights reserved. +# +# The Original Code is: all of this file. +# +# Contributor(s): none yet. +# +# ***** END GPL LICENSE BLOCK ***** +# +# Makes module object directory and bounces make to subdirectories. + +LIBNAME = ed_logic +DIR = $(OCGDIR)/blender/$(LIBNAME) + +include nan_compile.mk + +CFLAGS += $(LEVEL_1_C_WARNINGS) + +CPPFLAGS += -I$(NAN_GLEW)/include +CPPFLAGS += -I$(OPENGL_HEADERS) + +# not very neat.... +CPPFLAGS += -I../../windowmanager +CPPFLAGS += -I../../blenloader +CPPFLAGS += -I../../blenkernel +CPPFLAGS += -I../../blenlib +CPPFLAGS += -I../../makesdna +CPPFLAGS += -I../../makesrna +CPPFLAGS += -I../../imbuf +CPPFLAGS += -I../../python +CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include + +# own include + +CPPFLAGS += -I../include diff --git a/source/blender/editors/space_logic/SConscript b/source/blender/editors/space_logic/SConscript new file mode 100644 index 00000000000..46a9858a836 --- /dev/null +++ b/source/blender/editors/space_logic/SConscript @@ -0,0 +1,18 @@ +#!/usr/bin/python +Import ('env') + +sources = env.Glob('*.c') + +incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf' +incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include' +incs += ' ../../makesrna' + +defs = [] + +if env['WITH_BF_GAMEENGINE']: + defs.append('GAMEBLENDER=1') + + if env['WITH_BF_SOLID']: + defs.append('USE_SUMO_SOLID') + +env.BlenderLib ( 'bf_editors_space_game', sources, Split(incs), defs, libtype=['core'], priority=[120] ) diff --git a/source/blender/editors/space_logic/logic_buttons.c b/source/blender/editors/space_logic/logic_buttons.c new file mode 100644 index 00000000000..240ddfc2614 --- /dev/null +++ b/source/blender/editors/space_logic/logic_buttons.c @@ -0,0 +1,147 @@ +/** + * $Id: image_buttons.c 20913 2009-06-16 01:22:56Z blendix $ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2009 by Blender Foundation + * All rights reserved. + * + * ***** END GPL LICENSE BLOCK ***** + */ + + +#include <string.h> +#include <stdio.h> + +#include "DNA_object_types.h" +#include "DNA_node_types.h" +#include "DNA_space_types.h" +#include "DNA_scene_types.h" +#include "DNA_screen_types.h" +#include "DNA_userdef_types.h" + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" +#include "BLI_arithb.h" + +#include "BKE_context.h" +#include "BKE_global.h" +#include "BKE_library.h" +#include "BKE_main.h" +#include "BKE_mesh.h" +#include "BKE_node.h" +#include "BKE_screen.h" +#include "BKE_utildefines.h" + +#include "ED_space_api.h" +#include "ED_screen.h" +#include "ED_util.h" + +#include "BIF_gl.h" +#include "BIF_glutil.h" + +#include "RNA_access.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "UI_interface.h" +#include "UI_resources.h" +#include "UI_view2d.h" + +#include "logic_intern.h" + +static void do_logic_panel_events(bContext *C, void *arg, int event) +{ + + switch(event) { + + } +} + + +/* *** */ + +static void logic_panel_properties(const bContext *C, Panel *pa) +{ +// SpaceLogic *slogic= (SpaceLogic*)CTX_wm_space_data(C); + uiBlock *block; + + block= uiLayoutFreeBlock(pa->layout); + uiBlockSetHandleFunc(block, do_logic_panel_events, NULL); + +} + +static void logic_panel_view_properties(const bContext *C, Panel *pa) +{ + // SpaceLogic *slogic= (SpaceLogic*)CTX_wm_space_data(C); + uiBlock *block; + + block= uiLayoutFreeBlock(pa->layout); + uiBlockSetHandleFunc(block, do_logic_panel_events, NULL); + +} + + +void logic_buttons_register(ARegionType *art) +{ + PanelType *pt; + + pt= MEM_callocN(sizeof(PanelType), "spacetype logic panel properties"); + strcpy(pt->idname, "LOGIC_PT_properties"); + strcpy(pt->label, "Logic Properties"); + pt->draw= logic_panel_properties; + BLI_addtail(&art->paneltypes, pt); + + pt= MEM_callocN(sizeof(PanelType), "spacetype logic view properties"); + strcpy(pt->idname, "LOGIC_PT_view_properties"); + strcpy(pt->label, "View Properties"); + pt->draw= logic_panel_view_properties; + BLI_addtail(&art->paneltypes, pt); + +} + +static int logic_properties(bContext *C, wmOperator *op) +{ + ScrArea *sa= CTX_wm_area(C); + ARegion *ar= logic_has_buttons_region(sa); + + if(ar) { + ar->flag ^= RGN_FLAG_HIDDEN; + ar->v2d.flag &= ~V2D_IS_INITIALISED; /* XXX should become hide/unhide api? */ + + ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa); + ED_area_tag_redraw(sa); + } + return OPERATOR_FINISHED; +} + +void LOGIC_OT_properties(wmOperatorType *ot) +{ + ot->name= "Properties"; + ot->idname= "LOGIC_OT_properties"; + + ot->exec= logic_properties; + ot->poll= ED_operator_logic_active; + + /* flags */ + ot->flag= 0; +} + + + diff --git a/source/blender/editors/space_logic/logic_header.c b/source/blender/editors/space_logic/logic_header.c new file mode 100644 index 00000000000..d0e905728be --- /dev/null +++ b/source/blender/editors/space_logic/logic_header.c @@ -0,0 +1,126 @@ +/** + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2009 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include <string.h> +#include <stdio.h> + +#include "DNA_space_types.h" +#include "DNA_scene_types.h" +#include "DNA_screen_types.h" +#include "DNA_windowmanager_types.h" + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" + +#include "BKE_context.h" +#include "BKE_screen.h" +#include "BKE_main.h" + +#include "ED_screen.h" +#include "ED_types.h" +#include "ED_util.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "BIF_gl.h" +#include "BIF_glutil.h" + +#include "UI_interface.h" +#include "UI_resources.h" +#include "UI_view2d.h" + +#include "logic_intern.h" + +/* ************************ header area region *********************** */ + + +static void do_logic_buttons(bContext *C, void *arg, int event) +{ +// SpaceLogic *slogic= (SpaceLogic*)CTX_wm_space_data(C); +} + +static uiBlock *logic_addmenu(bContext *C, ARegion *ar, void *arg_unused) +{ +// SpaceLogic *slogic= (SpaceLogic*)CTX_wm_space_data(C); + uiBlock *block; + short yco= 0, menuwidth=120; + + block= uiBeginBlock(C, ar, "logic_addmenu", UI_EMBOSSP); +// uiBlockSetButmFunc(block, do_logic_addmenu, NULL); + + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Nothing yet", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); + + uiTextBoundsBlock(block, 50); + uiBlockSetDirection(block, UI_TOP); + uiEndBlock(C, block); + + return block; +} + +void logic_header_buttons(const bContext *C, ARegion *ar) +{ + ScrArea *sa= CTX_wm_area(C); +// SpaceLogic *slogic= (SpaceLogic*)CTX_wm_space_data(C); + uiBlock *block; + short xco, yco= 3; + + block= uiBeginBlock(C, ar, "header logic", UI_EMBOSS); + uiBlockSetHandleFunc(block, do_logic_buttons, NULL); + + xco= ED_area_header_standardbuttons(C, block, yco); + + if((sa->flag & HEADER_NO_PULLDOWN)==0) { + int xmax; + + xmax= GetButStringLength("View"); + uiDefPulldownBut(block, logic_addmenu, NULL, + "View", xco, yco, xmax-3, 20, ""); + xco+= xmax; + + xmax= GetButStringLength("Select"); + uiDefPulldownBut(block, logic_addmenu, NULL, + "Select", xco, yco, xmax-3, 20, ""); + xco+= xmax; + + xmax= GetButStringLength("Add"); + uiDefPulldownBut(block, logic_addmenu, NULL, + "Add", xco, yco, xmax-3, 20, ""); + xco+= xmax; + } + + uiBlockSetEmboss(block, UI_EMBOSS); + + UI_view2d_totRect_set(&ar->v2d, xco+XIC+100, (int)(ar->v2d.tot.ymax-ar->v2d.tot.ymin)); + + uiEndBlock(C, block); + uiDrawBlock(C, block); +} + + diff --git a/source/blender/editors/space_logic/logic_intern.h b/source/blender/editors/space_logic/logic_intern.h new file mode 100644 index 00000000000..ac5d11a3ee1 --- /dev/null +++ b/source/blender/editors/space_logic/logic_intern.h @@ -0,0 +1,58 @@ +/** + * $Id: + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2009 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef ED_LOGIC_INTERN_H +#define ED_LOGIC_INTERN_H + +/* internal exports only */ +struct bContext; +struct ARegion; +struct ARegionType; +struct ScrArea; +struct SpaceLogic; +struct Object; +struct wmOperatorType; +struct Scene; + +/* space_logic.c */ +struct ARegion *logic_has_buttons_region(struct ScrArea *sa); + +/* logic_header.c */ +void logic_header_buttons(const struct bContext *C, struct ARegion *ar); + +/* logic_ops.c */ + +/* logic_buttons.c */ +void logic_buttons_register(struct ARegionType *art); +void LOGIC_OT_properties(struct wmOperatorType *ot); + +/* logic_window.c */ +void logic_buttons(struct bContext *C, struct ARegion *ar); + +#endif /* ED_LOGIC_INTERN_H */ + diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c new file mode 100644 index 00000000000..b328ed74e08 --- /dev/null +++ b/source/blender/editors/space_logic/logic_window.c @@ -0,0 +1,3351 @@ +/** + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2009 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include <string.h> +#include <stdio.h> + +#include "DNA_actuator_types.h" +#include "DNA_controller_types.h" +#include "DNA_object_types.h" +#include "DNA_property_types.h" +#include "DNA_space_types.h" +#include "DNA_scene_types.h" +#include "DNA_screen_types.h" +#include "DNA_sensor_types.h" +#include "DNA_sound_types.h" +#include "DNA_windowmanager_types.h" + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" + +#include "BKE_context.h" +#include "BKE_global.h" +#include "BKE_library.h" +#include "BKE_main.h" +#include "BKE_property.h" +#include "BKE_screen.h" +#include "BKE_sca.h" +#include "BKE_utildefines.h" + +#include "ED_screen.h" +#include "ED_types.h" +#include "ED_util.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "BIF_gl.h" +#include "BIF_glutil.h" + +#include "UI_interface.h" +#include "UI_resources.h" +#include "UI_view2d.h" + +/* XXX BAD BAD */ +#include "../interface/interface_intern.h" + +#include "logic_intern.h" + + + +/* XXX */ +static int pupmenu() {return 1;} +/* XXX */ + +#define MAX_RENDER_PASS 100 +#define B_REDR 1 +#define B_IDNAME 2 + +#define B_ADD_PROP 2701 +#define B_CHANGE_PROP 2702 + +#define B_ADD_SENS 2703 +#define B_CHANGE_SENS 2704 +#define B_DEL_SENS 2705 + +#define B_ADD_CONT 2706 +#define B_CHANGE_CONT 2707 +#define B_DEL_CONT 2708 + +#define B_ADD_ACT 2709 +#define B_CHANGE_ACT 2710 +#define B_DEL_ACT 2711 + +#define B_SOUNDACT_BROWSE 2712 + +#define B_SETSECTOR 2713 +#define B_SETPROP 2714 +#define B_SETACTOR 2715 +#define B_SETMAINACTOR 2716 +#define B_SETDYNA 2717 +#define B_SET_STATE_BIT 2718 +#define B_INIT_STATE_BIT 2719 + +/* proto */ +static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisflag); + +static int vergname(const void *v1, const void *v2) +{ + char **x1, **x2; + + x1= (char **)v1; + x2= (char **)v2; + + return strcmp(*x1, *x2); +} + +void make_unique_prop_names(bContext *C, char *str) +{ + Object *ob; + bProperty *prop; + bSensor *sens; + bController *cont; + bActuator *act; + ID **idar; + short a, obcount, propcount=0, nr; + char **names; + + /* this function is called by a Button, and gives the current + * stringpointer as an argument, this is the one that can change + */ + + idar= get_selected_and_linked_obs(C, &obcount, BUTS_SENS_SEL|BUTS_SENS_ACT|BUTS_ACT_SEL|BUTS_ACT_ACT|BUTS_CONT_SEL|BUTS_CONT_ACT); + + /* for each object, make properties and sca names unique */ + + /* count total names */ + for(a=0; a<obcount; a++) { + ob= (Object *)idar[a]; + propcount+= BLI_countlist(&ob->prop); + propcount+= BLI_countlist(&ob->sensors); + propcount+= BLI_countlist(&ob->controllers); + propcount+= BLI_countlist(&ob->actuators); + } + if(propcount==0) { + if(idar) MEM_freeN(idar); + return; + } + + /* make names array for sorting */ + names= MEM_callocN(propcount*sizeof(void *), "names"); + + /* count total names */ + nr= 0; + for(a=0; a<obcount; a++) { + ob= (Object *)idar[a]; + prop= ob->prop.first; + while(prop) { + names[nr++]= prop->name; + prop= prop->next; + } + sens= ob->sensors.first; + while(sens) { + names[nr++]= sens->name; + sens= sens->next; + } + cont= ob->controllers.first; + while(cont) { + names[nr++]= cont->name; + cont= cont->next; + } + act= ob->actuators.first; + while(act) { + names[nr++]= act->name; + act= act->next; + } + } + + qsort(names, propcount, sizeof(void *), vergname); + + /* now we check for double names, and change them */ + + for(nr=0; nr<propcount; nr++) { + if(names[nr]!=str && strcmp( names[nr], str )==0 ) { + BLI_newname(str, +1); + } + } + + MEM_freeN(idar); + MEM_freeN(names); +} + +static void make_unique_prop_names_cb(bContext *C, void *strv, void *redraw_view3d_flagv) +{ + char *str= strv; +// int redraw_view3d_flag= GET_INT_FROM_POINTER(redraw_view3d_flagv); + + make_unique_prop_names(C, str); +} + + +static void sca_move_sensor(bContext *C, void *datav, void *data2_unused) +{ + Scene *scene= CTX_data_scene(C); + bSensor *sens_to_delete= datav; + int val; + Base *base; + bSensor *sens, *tmp; + + val= pupmenu("Move up%x1|Move down %x2"); + + if(val>0) { + /* now find out which object has this ... */ + base= FIRSTBASE; + while(base) { + + sens= base->object->sensors.first; + while(sens) { + if(sens == sens_to_delete) break; + sens= sens->next; + } + + if(sens) { + if( val==1 && sens->prev) { + for (tmp=sens->prev; tmp; tmp=tmp->prev) { + if (tmp->flag & SENS_VISIBLE) + break; + } + if (tmp) { + BLI_remlink(&base->object->sensors, sens); + BLI_insertlinkbefore(&base->object->sensors, tmp, sens); + } + } + else if( val==2 && sens->next) { + for (tmp=sens->next; tmp; tmp=tmp->next) { + if (tmp->flag & SENS_VISIBLE) + break; + } + if (tmp) { + BLI_remlink(&base->object->sensors, sens); + BLI_insertlink(&base->object->sensors, tmp, sens); + } + } + ED_undo_push(C, "Move sensor"); + break; + } + + base= base->next; + } + } +} + +static void sca_move_controller(bContext *C, void *datav, void *data2_unused) +{ + Scene *scene= CTX_data_scene(C); + bController *controller_to_del= datav; + int val; + Base *base; + bController *cont, *tmp; + + val= pupmenu("Move up%x1|Move down %x2"); + + if(val>0) { + /* now find out which object has this ... */ + base= FIRSTBASE; + while(base) { + + cont= base->object->controllers.first; + while(cont) { + if(cont == controller_to_del) break; + cont= cont->next; + } + + if(cont) { + if( val==1 && cont->prev) { + /* locate the controller that has the same state mask but is earlier in the list */ + tmp = cont->prev; + while(tmp) { + if(tmp->state_mask & cont->state_mask) + break; + tmp = tmp->prev; + } + if (tmp) { + BLI_remlink(&base->object->controllers, cont); + BLI_insertlinkbefore(&base->object->controllers, tmp, cont); + } + } + else if( val==2 && cont->next) { + tmp = cont->next; + while(tmp) { + if(tmp->state_mask & cont->state_mask) + break; + tmp = tmp->next; + } + BLI_remlink(&base->object->controllers, cont); + BLI_insertlink(&base->object->controllers, tmp, cont); + } + ED_undo_push(C, "Move controller"); + break; + } + + base= base->next; + } + } +} + +static void sca_move_actuator(bContext *C, void *datav, void *data2_unused) +{ + Scene *scene= CTX_data_scene(C); + bActuator *actuator_to_move= datav; + int val; + Base *base; + bActuator *act, *tmp; + + val= pupmenu("Move up%x1|Move down %x2"); + + if(val>0) { + /* now find out which object has this ... */ + base= FIRSTBASE; + while(base) { + + act= base->object->actuators.first; + while(act) { + if(act == actuator_to_move) break; + act= act->next; + } + + if(act) { + if( val==1 && act->prev) { + /* locate the first visible actuators before this one */ + for (tmp = act->prev; tmp; tmp=tmp->prev) { + if (tmp->flag & ACT_VISIBLE) + break; + } + if (tmp) { + BLI_remlink(&base->object->actuators, act); + BLI_insertlinkbefore(&base->object->actuators, tmp, act); + } + } + else if( val==2 && act->next) { + for (tmp=act->next; tmp; tmp=tmp->next) { + if (tmp->flag & ACT_VISIBLE) + break; + } + if (tmp) { + BLI_remlink(&base->object->actuators, act); + BLI_insertlink(&base->object->actuators, tmp, act); + } + } + ED_undo_push(C, "Move actuator"); + break; + } + + base= base->next; + } + } +} + +void do_logic_buts(bContext *C, void *arg, int event) +{ + bProperty *prop; + bSensor *sens; + bController *cont; + bActuator *act; + Object *ob; + int didit, bit; + + ob= CTX_data_active_object(C); + if(ob==NULL) return; + + switch(event) { + + case B_SETPROP: + /* check for inconsistant types */ + ob->gameflag &= ~(OB_SECTOR|OB_MAINACTOR|OB_DYNAMIC|OB_ACTOR); + break; + + case B_SETACTOR: + case B_SETDYNA: + case B_SETMAINACTOR: + ob->gameflag &= ~(OB_SECTOR|OB_PROP); + break; + + + case B_ADD_PROP: + prop= new_property(PROP_FLOAT); + make_unique_prop_names(C, prop->name); + BLI_addtail(&ob->prop, prop); + ED_undo_push(C, "Add property"); + break; + + case B_CHANGE_PROP: + prop= ob->prop.first; + while(prop) { + if(prop->type!=prop->otype) { + init_property(prop); + } + prop= prop->next; + } + break; + + case B_ADD_SENS: + for(ob=G.main->object.first; ob; ob=ob->id.next) { + if(ob->scaflag & OB_ADDSENS) { + ob->scaflag &= ~OB_ADDSENS; + sens= new_sensor(SENS_ALWAYS); + BLI_addtail(&(ob->sensors), sens); + make_unique_prop_names(C, sens->name); + ob->scaflag |= OB_SHOWSENS; + } + } + + ED_undo_push(C, "Add sensor"); + break; + + case B_CHANGE_SENS: + for(ob=G.main->object.first; ob; ob=ob->id.next) { + sens= ob->sensors.first; + while(sens) { + if(sens->type != sens->otype) { + init_sensor(sens); + sens->otype= sens->type; + break; + } + sens= sens->next; + } + } + break; + + case B_DEL_SENS: + for(ob=G.main->object.first; ob; ob=ob->id.next) { + sens= ob->sensors.first; + while(sens) { + if(sens->flag & SENS_DEL) { + BLI_remlink(&(ob->sensors), sens); + free_sensor(sens); + break; + } + sens= sens->next; + } + } + ED_undo_push(C, "Delete sensor"); + break; + + case B_ADD_CONT: + for(ob=G.main->object.first; ob; ob=ob->id.next) { + if(ob->scaflag & OB_ADDCONT) { + ob->scaflag &= ~OB_ADDCONT; + cont= new_controller(CONT_LOGIC_AND); + make_unique_prop_names(C, cont->name); + ob->scaflag |= OB_SHOWCONT; + BLI_addtail(&(ob->controllers), cont); + /* set the controller state mask from the current object state. + A controller is always in a single state, so select the lowest bit set + from the object state */ + for (bit=0; bit<32; bit++) { + if (ob->state & (1<<bit)) + break; + } + cont->state_mask = (1<<bit); + if (cont->state_mask == 0) { + /* shouldn't happen, object state is never 0 */ + cont->state_mask = 1; + } + } + } + ED_undo_push(C, "Add controller"); + break; + + case B_SET_STATE_BIT: + for(ob=G.main->object.first; ob; ob=ob->id.next) { + if(ob->scaflag & OB_SETSTBIT) { + ob->scaflag &= ~OB_SETSTBIT; + ob->state = 0x3FFFFFFF; + } + } + break; + + case B_INIT_STATE_BIT: + for(ob=G.main->object.first; ob; ob=ob->id.next) { + if(ob->scaflag & OB_INITSTBIT) { + ob->scaflag &= ~OB_INITSTBIT; + ob->state = ob->init_state; + if (!ob->state) + ob->state = 1; + } + } + break; + + case B_CHANGE_CONT: + for(ob=G.main->object.first; ob; ob=ob->id.next) { + cont= ob->controllers.first; + while(cont) { + if(cont->type != cont->otype) { + init_controller(cont); + cont->otype= cont->type; + break; + } + cont= cont->next; + } + } + break; + + + case B_DEL_CONT: + for(ob=G.main->object.first; ob; ob=ob->id.next) { + cont= ob->controllers.first; + while(cont) { + if(cont->flag & CONT_DEL) { + BLI_remlink(&(ob->controllers), cont); + unlink_controller(cont); + free_controller(cont); + break; + } + cont= cont->next; + } + } + ED_undo_push(C, "Delete controller"); + break; + + case B_ADD_ACT: + for(ob=G.main->object.first; ob; ob=ob->id.next) { + if(ob->scaflag & OB_ADDACT) { + ob->scaflag &= ~OB_ADDACT; + act= new_actuator(ACT_OBJECT); + make_unique_prop_names(C, act->name); + BLI_addtail(&(ob->actuators), act); + ob->scaflag |= OB_SHOWACT; + } + } + ED_undo_push(C, "Add actuator"); + break; + + case B_CHANGE_ACT: + for(ob=G.main->object.first; ob; ob=ob->id.next) { + act= ob->actuators.first; + while(act) { + if(act->type != act->otype) { + init_actuator(act); + act->otype= act->type; + break; + } + act= act->next; + } + } + break; + + case B_DEL_ACT: + for(ob=G.main->object.first; ob; ob=ob->id.next) { + act= ob->actuators.first; + while(act) { + if(act->flag & ACT_DEL) { + BLI_remlink(&(ob->actuators), act); + unlink_actuator(act); + free_actuator(act); + break; + } + act= act->next; + } + } + ED_undo_push(C, "Delete actuator"); + break; + + case B_SOUNDACT_BROWSE: + /* since we don't know which... */ + didit= 0; + for(ob=G.main->object.first; ob; ob=ob->id.next) { + act= ob->actuators.first; + while(act) + { + if(act->type==ACT_SOUND) + { + bSoundActuator *sa= act->data; + if(sa->sndnr) + { + bSound *sound= G.main->sound.first; + int nr= 1; + + if(sa->sndnr == -2) { +// XXX activate_databrowse((ID *)G.main->sound.first, ID_SO, 0, B_SOUNDACT_BROWSE, +// &sa->sndnr, do_logic_buts); + break; + } + + while(sound) + { + if(nr==sa->sndnr) + break; + nr++; + sound= sound->id.next; + } + + if(sa->sound) + sa->sound->id.us--; + + sa->sound= sound; + + if(sound) + sound->id.us++; + + sa->sndnr= 0; + didit= 1; + } + } + act= act->next; + } + if(didit) + break; + } + + break; + } +} + + +static char *sensor_name(int type) +{ + switch (type) { + case SENS_ALWAYS: + return "Always"; + case SENS_TOUCH: + return "Touch"; + case SENS_NEAR: + return "Near"; + case SENS_KEYBOARD: + return "Keyboard"; + case SENS_PROPERTY: + return "Property"; + case SENS_ACTUATOR: + return "Actuator"; + case SENS_DELAY: + return "Delay"; + case SENS_MOUSE: + return "Mouse"; + case SENS_COLLISION: + return "Collision"; + case SENS_RADAR: + return "Radar"; + case SENS_RANDOM: + return "Random"; + case SENS_RAY: + return "Ray"; + case SENS_MESSAGE: + return "Message"; + case SENS_JOYSTICK: + return "Joystick"; + } + return "unknown"; +} + +static char *sensor_pup(void) +{ + /* the number needs to match defines in game.h */ + return "Sensors %t|Always %x0|Delay %x13|Keyboard %x3|Mouse %x5|" + "Touch %x1|Collision %x6|Near %x2|Radar %x7|" + "Property %x4|Random %x8|Ray %x9|Message %x10|Joystick %x11|Actuator %x12"; +} + +static char *controller_name(int type) +{ + switch (type) { + case CONT_LOGIC_AND: + return "AND"; + case CONT_LOGIC_OR: + return "OR"; + case CONT_LOGIC_NAND: + return "NAND"; + case CONT_LOGIC_NOR: + return "NOR"; + case CONT_LOGIC_XOR: + return "XOR"; + case CONT_LOGIC_XNOR: + return "XNOR"; + case CONT_EXPRESSION: + return "Expression"; + case CONT_PYTHON: + return "Python"; + } + return "unknown"; +} + +static char *controller_pup(void) +{ + return "Controllers %t|AND %x0|OR %x1|XOR %x6|NAND %x4|NOR %x5|XNOR %x7|Expression %x2|Python %x3"; +} + +static char *actuator_name(int type) +{ + switch (type) { + case ACT_SHAPEACTION: + return "Shape Action"; + case ACT_ACTION: + return "Action"; + case ACT_OBJECT: + return "Motion"; + case ACT_IPO: + return "Ipo"; + case ACT_LAMP: + return "Lamp"; + case ACT_CAMERA: + return "Camera"; + case ACT_MATERIAL: + return "Material"; + case ACT_SOUND: + return "Sound"; + case ACT_CD: + return "CD"; + case ACT_PROPERTY: + return "Property"; + case ACT_EDIT_OBJECT: + return "Edit Object"; + case ACT_CONSTRAINT: + return "Constraint"; + case ACT_SCENE: + return "Scene"; + case ACT_GROUP: + return "Group"; + case ACT_RANDOM: + return "Random"; + case ACT_MESSAGE: + return "Message"; + case ACT_GAME: + return "Game"; + case ACT_VISIBILITY: + return "Visibility"; + case ACT_2DFILTER: + return "2D Filter"; + case ACT_PARENT: + return "Parent"; + case ACT_STATE: + return "State"; + } + return "unknown"; +} + + + + +static char *actuator_pup(Object *owner) +{ + switch (owner->type) + { + case OB_ARMATURE: + return "Actuators %t|Action %x15|Motion %x0|Constraint %x9|Ipo %x1" + "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10" + "|Scene %x11|Random %x13|Message %x14|CD %x16|Game %x17" + "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22"; + break; + + case OB_MESH: + return "Actuators %t|Shape Action %x21|Motion %x0|Constraint %x9|Ipo %x1" + "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10" + "|Scene %x11|Random %x13|Message %x14|CD %x16|Game %x17" + "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22"; + break; + + default: + return "Actuators %t|Motion %x0|Constraint %x9|Ipo %x1" + "|Camera %x3|Sound %x5|Property %x6|Edit Object %x10" + "|Scene %x11|Random %x13|Message %x14|CD %x16|Game %x17" + "|Visibility %x18|2D Filter %x19|Parent %x20|State %x22"; + } +} + + + +static void set_sca_ob(Object *ob) +{ + bController *cont; + bActuator *act; + + cont= ob->controllers.first; + while(cont) { + cont->mynew= (bController *)ob; + cont= cont->next; + } + act= ob->actuators.first; + while(act) { + act->mynew= (bActuator *)ob; + act= act->next; + } +} + +static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisflag) +{ + Base *base; + Scene *scene= CTX_data_scene(C); + Object *ob, *obt, *obact= CTX_data_active_object(C); + ID **idar; + bSensor *sens; + bController *cont; + unsigned int lay; + int a, nr, doit; + + /* we need a sorted object list */ + /* set scavisflags flags in Objects to indicate these should be evaluated */ + /* also hide ob pointers in ->new entries of controllerss/actuators */ + + *count= 0; + + if(scene==NULL) return NULL; + + ob= G.main->object.first; + while(ob) { + ob->scavisflag= 0; + set_sca_ob(ob); + ob= ob->id.next; + } + + /* XXX here it checked 3d lay */ + lay= scene->lay; + + base= FIRSTBASE; + while(base) { + if(base->lay & lay) { + if(base->flag & SELECT) { + if(scavisflag & BUTS_SENS_SEL) base->object->scavisflag |= OB_VIS_SENS; + if(scavisflag & BUTS_CONT_SEL) base->object->scavisflag |= OB_VIS_CONT; + if(scavisflag & BUTS_ACT_SEL) base->object->scavisflag |= OB_VIS_ACT; + } + } + base= base->next; + } + + if(obact) { + if(scavisflag & BUTS_SENS_ACT) obact->scavisflag |= OB_VIS_SENS; + if(scavisflag & BUTS_CONT_ACT) obact->scavisflag |= OB_VIS_CONT; + if(scavisflag & BUTS_ACT_ACT) obact->scavisflag |= OB_VIS_ACT; + } + + /* BUTS_XXX_STATE are similar to BUTS_XXX_LINK for selecting the object */ + if(scavisflag & (BUTS_SENS_LINK|BUTS_CONT_LINK|BUTS_ACT_LINK|BUTS_SENS_STATE|BUTS_ACT_STATE)) { + doit= 1; + while(doit) { + doit= 0; + + ob= G.main->object.first; + while(ob) { + + /* 1st case: select sensor when controller selected */ + if((scavisflag & (BUTS_SENS_LINK|BUTS_SENS_STATE)) && (ob->scavisflag & OB_VIS_SENS)==0) { + sens= ob->sensors.first; + while(sens) { + for(a=0; a<sens->totlinks; a++) { + if(sens->links[a]) { + obt= (Object *)sens->links[a]->mynew; + if(obt && (obt->scavisflag & OB_VIS_CONT)) { + doit= 1; + ob->scavisflag |= OB_VIS_SENS; + break; + } + } + } + if(doit) break; + sens= sens->next; + } + } + + /* 2nd case: select cont when act selected */ + if((scavisflag & BUTS_CONT_LINK) && (ob->scavisflag & OB_VIS_CONT)==0) { + cont= ob->controllers.first; + while(cont) { + for(a=0; a<cont->totlinks; a++) { + if(cont->links[a]) { + obt= (Object *)cont->links[a]->mynew; + if(obt && (obt->scavisflag & OB_VIS_ACT)) { + doit= 1; + ob->scavisflag |= OB_VIS_CONT; + break; + } + } + } + if(doit) break; + cont= cont->next; + } + } + + /* 3rd case: select controller when sensor selected */ + if((scavisflag & BUTS_CONT_LINK) && (ob->scavisflag & OB_VIS_SENS)) { + sens= ob->sensors.first; + while(sens) { + for(a=0; a<sens->totlinks; a++) { + if(sens->links[a]) { + obt= (Object *)sens->links[a]->mynew; + if(obt && (obt->scavisflag & OB_VIS_CONT)==0) { + doit= 1; + obt->scavisflag |= OB_VIS_CONT; + } + } + } + sens= sens->next; + } + } + + /* 4th case: select actuator when controller selected */ + if( (scavisflag & (BUTS_ACT_LINK|BUTS_ACT_STATE)) && (ob->scavisflag & OB_VIS_CONT)) { + cont= ob->controllers.first; + while(cont) { + for(a=0; a<cont->totlinks; a++) { + if(cont->links[a]) { + obt= (Object *)cont->links[a]->mynew; + if(obt && (obt->scavisflag & OB_VIS_ACT)==0) { + doit= 1; + obt->scavisflag |= OB_VIS_ACT; + } + } + } + cont= cont->next; + } + + } + ob= ob->id.next; + } + } + } + + /* now we count */ + ob= G.main->object.first; + while(ob) { + if( ob->scavisflag ) (*count)++; + ob= ob->id.next; + } + + if(*count==0) return NULL; + if(*count>24) *count= 24; /* temporal */ + + idar= MEM_callocN( (*count)*sizeof(void *), "idar"); + + ob= G.main->object.first; + nr= 0; + while(ob) { + if( ob->scavisflag ) { + idar[nr]= (ID *)ob; + nr++; + } + if(nr>=24) break; + ob= ob->id.next; + } + + /* just to be sure... these were set in set_sca_done_ob() */ + clear_sca_new_poins(); + + return idar; +} + + +static int get_col_sensor(int type) +{ + /* XXX themecolors not here */ + + switch(type) { + case SENS_ALWAYS: return TH_PANEL; + case SENS_DELAY: return TH_PANEL; + case SENS_TOUCH: return TH_PANEL; + case SENS_COLLISION: return TH_PANEL; + case SENS_NEAR: return TH_PANEL; + case SENS_KEYBOARD: return TH_PANEL; + case SENS_PROPERTY: return TH_PANEL; + case SENS_ACTUATOR: return TH_PANEL; + case SENS_MOUSE: return TH_PANEL; + case SENS_RADAR: return TH_PANEL; + case SENS_RANDOM: return TH_PANEL; + case SENS_RAY: return TH_PANEL; + case SENS_MESSAGE: return TH_PANEL; + case SENS_JOYSTICK: return TH_PANEL; + default: return TH_PANEL; + } +} +static void set_col_sensor(int type, int medium) +{ + int col= get_col_sensor(type); + UI_ThemeColorShade(col, medium?30:0); +} + + +static void verify_logicbutton_func(bContext *C, void *data1, void *data2) +{ + bSensor *sens= (bSensor*)data1; + + if(sens->level && sens->tap) { + if(data2 == &(sens->level)) + sens->tap= 0; + else + sens->level= 0; + } +} + + +/** + * Draws a toggle for pulse mode, a frequency field and a toggle to invert + * the value of this sensor. Operates on the shared data block of sensors. + */ +static void draw_default_sensor_header(bSensor *sens, + uiBlock *block, + short x, + short y, + short w) +{ + uiBut *but; + + /* Pulsing and frequency */ + uiDefIconButBitS(block, TOG, SENS_PULSE_REPEAT, 1, ICON_DOTSUP, + (short)(x + 10 + 0. * (w-20)), (short)(y - 21), (short)(0.1 * (w-20)), 19, + &sens->pulse, 0.0, 0.0, 0, 0, + "Activate TRUE level triggering (pulse mode)"); + + uiDefIconButBitS(block, TOG, SENS_NEG_PULSE_MODE, 1, ICON_DOTSDOWN, + (short)(x + 10 + 0.1 * (w-20)), (short)(y - 21), (short)(0.1 * (w-20)), 19, + &sens->pulse, 0.0, 0.0, 0, 0, + "Activate FALSE level triggering (pulse mode)"); + uiDefButS(block, NUM, 1, "f:", + (short)(x + 10 + 0.2 * (w-20)), (short)(y - 21), (short)(0.275 * (w-20)), 19, + &sens->freq, 0.0, 10000.0, 0, 0, + "Delay between repeated pulses (in logic tics, 0 = no delay)"); + + /* value or shift? */ + but= uiDefButS(block, TOG, 1, "Level", + (short)(x + 10 + 0.5 * (w-20)), (short)(y - 21), (short)(0.20 * (w-20)), 19, + &sens->level, 0.0, 0.0, 0, 0, + "Level detector, trigger controllers of new states (only applicable upon logic state transition)"); + uiButSetFunc(but, verify_logicbutton_func, sens, &(sens->level)); + but= uiDefButS(block, TOG, 1, "Tap", + (short)(x + 10 + 0.702 * (w-20)), (short)(y - 21), (short)(0.12 * (w-20)), 19, + &sens->tap, 0.0, 0.0, 0, 0, + "Trigger controllers only for an instant, even while the sensor remains true"); + uiButSetFunc(but, verify_logicbutton_func, sens, &(sens->tap)); + + uiDefButS(block, TOG, 1, "Inv", + (short)(x + 10 + 0.85 * (w-20)), (short)(y - 21), (short)(0.15 * (w-20)), 19, + &sens->invert, 0.0, 0.0, 0, 0, + "Invert the level (output) of this sensor"); +} + +static short draw_sensorbuttons(bSensor *sens, uiBlock *block, short xco, short yco, short width,char* objectname) +{ + bNearSensor *ns = NULL; + bTouchSensor *ts = NULL; + bKeyboardSensor *ks = NULL; + bPropertySensor *ps = NULL; + bMouseSensor *ms = NULL; + bCollisionSensor *cs = NULL; + bRadarSensor *rs = NULL; + bRandomSensor *randomSensor = NULL; + bRaySensor *raySens = NULL; + bMessageSensor *mes = NULL; + bJoystickSensor *joy = NULL; + bActuatorSensor *as = NULL; + bDelaySensor *ds = NULL; + short ysize; + char *str; + + /* yco is at the top of the rect, draw downwards */ + + set_col_sensor(sens->type, 0); + + switch (sens->type) + { + case SENS_ALWAYS: + { + ysize= 24; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + draw_default_sensor_header(sens, block, xco, yco, width); + + yco-= ysize; + + break; + } + case SENS_TOUCH: + { + ysize= 48; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + draw_default_sensor_header(sens, block, xco, yco, width); + + ts= sens->data; + + /* uiDefBut(block, TEX, 1, "Property:", xco,yco-22,width, 19, &ts->name, 0, 31, 0, 0, "Only look for Objects with this property"); */ + uiDefIDPoinBut(block, test_matpoin_but, ID_MA, 1, "MA:",(short)(xco + 10),(short)(yco-44), (short)(width - 20), 19, &ts->ma, "Only look for floors with this Material"); + ///* uiDefButF(block, NUM, 1, "Margin:", xco+width/2,yco-44,width/2, 19, &ts->dist, 0.0, 10.0, 100, 0, "Extra margin (distance) for larger sensitivity"); + yco-= ysize; + break; + } + case SENS_COLLISION: + { + ysize= 48; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + draw_default_sensor_header(sens, block, xco, yco, width); + cs= sens->data; + + /* The collision sensor will become a generic collision (i.e. it */ + /* absorb the old touch sensor). */ + + uiDefButBitS(block, TOG, SENS_COLLISION_PULSE, B_REDR, "Pulse",(short)(xco + 10),(short)(yco - 44), + (short)(0.20 * (width-20)), 19, &cs->mode, 0.0, 0.0, 0, 0, + "Changes to the set of colliding objects generated pulses"); + + uiDefButBitS(block, TOG, SENS_COLLISION_MATERIAL, B_REDR, "M/P",(short)(xco + 10 + (0.20 * (width-20))),(short)(yco - 44), + (short)(0.20 * (width-20)), 19, &cs->mode, 0.0, 0.0, 0, 0, + "Toggle collision on material or property"); + + if (cs->mode & SENS_COLLISION_MATERIAL) { + uiDefBut(block, TEX, 1, "Material:", (short)(xco + 10 + 0.40 * (width-20)), + (short)(yco-44), (short)(0.6*(width-20)), 19, &cs->materialName, 0, 31, 0, 0, + "Only look for Objects with this material"); + } else { + uiDefBut(block, TEX, 1, "Property:", (short)(xco + 10 + 0.40 * (width-20)), (short)(yco-44), + (short)(0.6*(width-20)), 19, &cs->name, 0, 31, 0, 0, + "Only look for Objects with this property"); + } + + /* uiDefButS(block, NUM, 1, "Damp:", xco+10+width-90,yco-24, 70, 19, &cs->damp, 0, 250, 0, 0, "For 'damp' time don't detect another collision"); */ + + yco-= ysize; + break; + } + case SENS_NEAR: + { + ysize= 72; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + draw_default_sensor_header(sens, block, xco, yco, width); + ns= sens->data; + + uiDefBut(block, TEX, 1, "Property:",(short)(10+xco),(short)(yco-44), (short)(width-20), 19, + &ns->name, 0, 31, 0, 0, "Only look for Objects with this property"); + uiDefButF(block, NUM, 1, "Dist",(short)(10+xco),(short)(yco-68),(short)((width-22)/2), 19, + &ns->dist, 0.0, 1000.0, 1000, 0, "Trigger distance"); + uiDefButF(block, NUM, 1, "Reset",(short)(10+xco+(width-22)/2), (short)(yco-68), (short)((width-22)/2), 19, + &ns->resetdist, 0.0, 1000.0, 1000, 0, "Reset distance"); + yco-= ysize; + break; + } + case SENS_RADAR: + { + ysize= 72; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + draw_default_sensor_header(sens, block, xco, yco, width); + + rs= sens->data; + + uiDefBut(block, TEX, 1, "Prop:", + (short)(10+xco),(short)(yco-44), (short)(0.7 * (width-20)), 19, + &rs->name, 0, 31, 0, 0, + "Only look for Objects with this property"); + + str = "Type %t|+X axis %x0|+Y axis %x1|+Z axis %x2|-X axis %x3|-Y axis %x4|-Z axis %x5"; + uiDefButS(block, MENU, B_REDR, str, + (short)(10+xco+0.7 * (width-20)), (short)(yco-44), (short)(0.3 * (width-22)), 19, + &rs->axis, 2.0, 31, 0, 0, + "Specify along which axis the radar cone is cast"); + + uiDefButF(block, NUM, 1, "Ang:", + (short)(10+xco), (short)(yco-68), (short)((width-20)/2), 19, + &rs->angle, 0.0, 179.9, 10, 0, + "Opening angle of the radar cone"); + uiDefButF(block, NUM, 1, "Dist:", + (short)(xco+10 + (width-20)/2), (short)(yco-68), (short)((width-20)/2), 19, + &rs->range, 0.01, 10000.0, 100, 0, + "Depth of the radar cone"); + yco-= ysize; + break; + } + case SENS_KEYBOARD: + { + ks= sens->data; + + /* 5 lines: 120 height */ + ysize= (ks->type&1) ? 96:120; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + /* header line */ + draw_default_sensor_header(sens, block, xco, yco, width); + + /* part of line 1 */ + uiDefBut(block, LABEL, 0, "Key", xco, yco-44, 40, 19, NULL, 0, 0, 0, 0, ""); + uiDefButBitS(block, TOG, 1, B_REDR, "All keys", xco+40+(width/2), yco-44, (width/2)-50, 19, + &ks->type, 0, 0, 0, 0, ""); + + + if ((ks->type&1)==0) { /* is All Keys option off? */ + /* line 2: hotkey and allkeys toggle */ + uiDefKeyevtButS(block, 0, "", xco+40, yco-44, (width)/2, 19, &ks->key, "Key code"); + + /* line 3: two key modifyers (qual1, qual2) */ + uiDefBut(block, LABEL, 0, "Hold", xco, yco-68, 40, 19, NULL, 0, 0, 0, 0, ""); + uiDefKeyevtButS(block, 0, "", xco+40, yco-68, (width-50)/2, 19, &ks->qual, "Modifier key code"); + uiDefKeyevtButS(block, 0, "", xco+40+(width-50)/2, yco-68, (width-50)/2, 19, &ks->qual2, "Second Modifier key code"); + } + + /* line 4: toggle property for string logging mode */ + uiDefBut(block, TEX, 1, "LogToggle: ", + xco+10, yco-((ks->type&1) ? 68:92), (width-20), 19, + ks->toggleName, 0, 31, 0, 0, + "Property that indicates whether to log " + "keystrokes as a string"); + + /* line 5: target property for string logging mode */ + uiDefBut(block, TEX, 1, "Target: ", + xco+10, yco-((ks->type&1) ? 92:116), (width-20), 19, + ks->targetName, 0, 31, 0, 0, + "Property that receives the keystrokes in case " + "a string is logged"); + + yco-= ysize; + break; + } + case SENS_PROPERTY: + { + ysize= 96; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, + (float)xco+width, (float)yco, 1); + + draw_default_sensor_header(sens, block, xco, yco, width); + ps= sens->data; + + str= "Type %t|Equal %x0|Not Equal %x1|Interval %x2|Changed %x3"; + /* str= "Type %t|Equal %x0|Not Equal %x1"; */ + uiDefButI(block, MENU, B_REDR, str, xco+30,yco-44,width-60, 19, + &ps->type, 0, 31, 0, 0, "Type"); + + if (ps->type != SENS_PROP_EXPRESSION) + { + uiDefBut(block, TEX, 1, "Prop: ", xco+30,yco-68,width-60, 19, + ps->name, 0, 31, 0, 0, "Property name"); + } + + if(ps->type == SENS_PROP_INTERVAL) + { + uiDefBut(block, TEX, 1, "Min: ", xco,yco-92,width/2, 19, + ps->value, 0, 31, 0, 0, "check for min value"); + uiDefBut(block, TEX, 1, "Max: ", xco+width/2,yco-92,width/2, 19, + ps->maxvalue, 0, 31, 0, 0, "check for max value"); + } + else if(ps->type == SENS_PROP_CHANGED); + else + { + uiDefBut(block, TEX, 1, "Value: ", xco+30,yco-92,width-60, 19, + ps->value, 0, 31, 0, 0, "check for value"); + } + + yco-= ysize; + break; + } + case SENS_ACTUATOR: + { + ysize= 48; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, + (float)xco+width, (float)yco, 1); + + draw_default_sensor_header(sens, block, xco, yco, width); + as= sens->data; + + uiDefBut(block, TEX, 1, "Act: ", xco+30,yco-44,width-60, 19, + as->name, 0, 31, 0, 0, "Actuator name, actuator active state modifications will be detected"); + yco-= ysize; + break; + } + case SENS_DELAY: + { + ysize= 48; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, + (float)xco+width, (float)yco, 1); + + draw_default_sensor_header(sens, block, xco, yco, width); + ds = sens->data; + + uiDefButS(block, NUM, 0, "Delay",(short)(10+xco),(short)(yco-44),(short)((width-22)*0.4+10), 19, + &ds->delay, 0.0, 5000.0, 0, 0, "Delay in number of logic tics before the positive trigger (default 60 per second)"); + uiDefButS(block, NUM, 0, "Dur",(short)(10+xco+(width-22)*0.4+10),(short)(yco-44),(short)((width-22)*0.4-10), 19, + &ds->duration, 0.0, 5000.0, 0, 0, "If >0, delay in number of logic tics before the negative trigger following the positive trigger"); + uiDefButBitS(block, TOG, SENS_DELAY_REPEAT, 0, "REP",(short)(xco + 10 + (width-22)*0.8),(short)(yco - 44), + (short)(0.20 * (width-22)), 19, &ds->flag, 0.0, 0.0, 0, 0, + "Toggle repeat option. If selected, the sensor restarts after Delay+Dur logic tics"); + yco-= ysize; + break; + } + case SENS_MOUSE: + { + ms= sens->data; + /* Two lines: 48 pixels high. */ + ysize = 48; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + /* line 1: header */ + draw_default_sensor_header(sens, block, xco, yco, width); + + /* Line 2: type selection. The number are a bit mangled to get + * proper compatibility with older .blend files. */ + str= "Type %t|Left button %x1|Middle button %x2|" + "Right button %x4|Wheel Up %x5|Wheel Down %x6|Movement %x8|Mouse over %x16|Mouse over any%x32"; + uiDefButS(block, MENU, B_REDR, str, xco+10, yco-44, width-20, 19, + &ms->type, 0, 31, 0, 0, + "Specify the type of event this mouse sensor should trigger on"); + + yco-= ysize; + break; + } + case SENS_RANDOM: + { + ysize = 48; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + draw_default_sensor_header(sens, block, xco, yco, width); + randomSensor = sens->data; + /* some files were wrongly written, avoid crash now */ + if (randomSensor) + { + uiDefButI(block, NUM, 1, "Seed: ", xco+10,yco-44,(width-20), 19, + &randomSensor->seed, 0, 1000, 0, 0, + "Initial seed of the generator. (Choose 0 for not random)"); + } + yco-= ysize; + break; + } + case SENS_RAY: + { + ysize = 72; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + draw_default_sensor_header(sens, block, xco, yco, width); + raySens = sens->data; + + /* 1. property or material */ + uiDefButBitS(block, TOG, SENS_COLLISION_MATERIAL, B_REDR, "M/P", + xco + 10,yco - 44, 0.20 * (width-20), 19, + &raySens->mode, 0.0, 0.0, 0, 0, + "Toggle collision on material or property"); + + if (raySens->mode & SENS_COLLISION_MATERIAL) + { + uiDefBut(block, TEX, 1, "Material:", xco + 10 + 0.20 * (width-20), yco-44, 0.8*(width-20), 19, + &raySens->matname, 0, 31, 0, 0, + "Only look for Objects with this material"); + } + else + { + uiDefBut(block, TEX, 1, "Property:", xco + 10 + 0.20 * (width-20), yco-44, 0.8*(width-20), 19, + &raySens->propname, 0, 31, 0, 0, + "Only look for Objects with this property"); + } + + /* X-Ray option */ + uiDefButBitS(block, TOG, SENS_RAY_XRAY, 1, "X", + xco + 10,yco - 68, 0.10 * (width-20), 19, + &raySens->mode, 0.0, 0.0, 0, 0, + "Toggle X-Ray option (see through objects that don't have the property)"); + /* 2. sensing range */ + uiDefButF(block, NUM, 1, "Range", xco+10 + 0.10 * (width-20), yco-68, 0.5 * (width-20), 19, + &raySens->range, 0.01, 10000.0, 100, 0, + "Sense objects no farther than this distance"); + + /* 3. axis choice */ + str = "Type %t|+ X axis %x1|+ Y axis %x0|+ Z axis %x2|- X axis %x3|- Y axis %x4|- Z axis %x5"; + uiDefButI(block, MENU, B_REDR, str, xco+10 + 0.6 * (width-20), yco-68, 0.4 * (width-20), 19, + &raySens->axisflag, 2.0, 31, 0, 0, + "Specify along which axis the ray is cast"); + + yco-= ysize; + break; + } + case SENS_MESSAGE: + { + mes = sens->data; + ysize = 2 * 24; /* total number of lines * 24 pixels/line */ + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, + (float)xco+width, (float)yco, 1); + + /* line 1: header line */ + draw_default_sensor_header(sens, block, xco, yco, width); + + /* line 2: Subject filter */ + uiDefBut(block, TEX, 1, "Subject: ", + (xco+10), (yco-44), (width-20), 19, + mes->subject, 0, 31, 0, 0, + "Optional subject filter: only accept messages with this subject" + ", or empty for all"); + + yco -= ysize; + break; + } + case SENS_JOYSTICK: + { + + ysize = 72; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + /* line 1: header */ + draw_default_sensor_header(sens, block, xco, yco, width); + + joy= sens->data; + + uiDefButC(block, NUM, 1, "Index:", xco+10, yco-44, 0.33 * (width-20), 19, + &joy->joyindex, 0, SENS_JOY_MAXINDEX-1, 100, 0, + "Specify which joystick to use"); + + str= "Type %t|Button %x0|Axis %x1|Single Axis %x3|Hat%x2"; + uiDefButC(block, MENU, B_REDR, str, xco+87, yco-44, 0.26 * (width-20), 19, + &joy->type, 0, 31, 0, 0, + "The type of event this joystick sensor is triggered on"); + + if (joy->type != SENS_JOY_AXIS_SINGLE) { + if (joy->flag & SENS_JOY_ANY_EVENT) { + switch (joy->type) { + case SENS_JOY_AXIS: + str = "All Axis Events"; + break; + case SENS_JOY_BUTTON: + str = "All Button Events"; + break; + default: + str = "All Hat Events"; + break; + } + } else { + str = "All"; + } + + uiDefButBitS(block, TOG, SENS_JOY_ANY_EVENT, B_REDR, str, + xco+10 + 0.475 * (width-20), yco-68, ((joy->flag & SENS_JOY_ANY_EVENT) ? 0.525 : 0.12) * (width-20), 19, + &joy->flag, 0, 0, 0, 0, + "Triggered by all events on this joysticks current type (axis/button/hat)"); + } + if(joy->type == SENS_JOY_BUTTON) + { + if ((joy->flag & SENS_JOY_ANY_EVENT)==0) { + uiDefButI(block, NUM, 1, "Number:", xco+10 + 0.6 * (width-20), yco-68, 0.4 * (width-20), 19, + &joy->button, 0, 18, 100, 0, + "Specify which button to use"); + } + } + else if(joy->type == SENS_JOY_AXIS) + { + uiDefButS(block, NUM, 1, "Number:", xco+10, yco-68, 0.46 * (width-20), 19, + &joy->axis, 1, 8.0, 100, 0, + "Specify which axis pair to use, 1 is useually the main direction input"); + + uiDefButI(block, NUM, 1, "Threshold:", xco+10 + 0.6 * (width-20),yco-44, 0.4 * (width-20), 19, + &joy->precision, 0, 32768.0, 100, 0, + "Specify the precision of the axis"); + + if ((joy->flag & SENS_JOY_ANY_EVENT)==0) { + str = "Type %t|Up Axis %x1 |Down Axis %x3|Left Axis %x2|Right Axis %x0"; + uiDefButI(block, MENU, B_REDR, str, xco+10 + 0.6 * (width-20), yco-68, 0.4 * (width-20), 19, + &joy->axisf, 2.0, 31, 0, 0, + "The direction of the axis, use 'All Events' to recieve events on any direction"); + } + } + else if (joy->type == SENS_JOY_HAT) + { + uiDefButI(block, NUM, 1, "Number:", xco+10, yco-68, 0.46 * (width-20), 19, + &joy->hat, 1, 4.0, 100, 0, + "Specify which hat to use"); + + if ((joy->flag & SENS_JOY_ANY_EVENT)==0) { + str = "Direction%t|Up%x1|Down%x4|Left%x8|Right%x2|%l|Up/Right%x3|Down/Left%x12|Up/Left%x9|Down/Right%x6"; + uiDefButI(block, MENU, 0, str, xco+10 + 0.6 * (width-20), yco-68, 0.4 * (width-20), 19, + &joy->hatf, 2.0, 31, 0, 0, + "The direction of the hat, use 'All Events' to recieve events on any direction"); + } + } + else { /* (joy->type == SENS_JOY_AXIS_SINGLE)*/ + uiDefButS(block, NUM, 1, "Number:", xco+10, yco-68, 0.46 * (width-20), 19, + &joy->axis_single, 1, 16.0, 100, 0, + "Specify a single axis (verticle/horizontal/other) to detect"); + + uiDefButI(block, NUM, 1, "Threshold:", xco+10 + 0.6 * (width-20),yco-44, 0.4 * (width-20), 19, + &joy->precision, 0, 32768.0, 100, 0, + "Specify the precision of the axis"); + } + yco-= ysize; + break; + } + } + + return yco-4; +} + + + +static short draw_controllerbuttons(bController *cont, uiBlock *block, short xco, short yco, short width) +{ + bExpressionCont *ec; + bPythonCont *pc; + short ysize; + + switch (cont->type) { + case CONT_EXPRESSION: + ysize= 28; + + UI_ThemeColor(TH_PANEL); + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + /* uiDefBut(block, LABEL, 1, "Not yet...", xco,yco-24,80, 19, NULL, 0, 0, 0, 0, ""); */ + ec= cont->data; + /* uiDefBut(block, BUT, 1, "Variables", xco,yco-24,80, 19, NULL, 0, 0, 0, 0, "Available variables for expression"); */ + uiDefBut(block, TEX, 1, "Exp:", xco + 10 , yco-21, width-20, 19, + ec->str, 0, 127, 0, 0, + "Expression"); + + yco-= ysize; + break; + case CONT_PYTHON: + ysize= 28; + + if(cont->data==NULL) init_controller(cont); + pc= cont->data; + + UI_ThemeColor(TH_PANEL); + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + + uiBlockBeginAlign(block); + uiDefButI(block, MENU, B_REDR, "Execution Method%t|Script%x0|Module%x1", xco+4,yco-23, 66, 19, &pc->mode, 0, 0, 0, 0, "Python script type (textblock or module - faster)"); + if(pc->mode==0) + uiDefIDPoinBut(block, test_scriptpoin_but, ID_SCRIPT, 1, "", xco+70,yco-23,width-74, 19, &pc->text, "Blender textblock to run as a script"); + else { + uiDefBut(block, TEX, 1, "", xco+70,yco-23,(width-70)-25, 19, pc->module, 0, 63, 0, 0, "Module name and function to run e.g. \"someModule.main\". Internal texts and external python files can be used"); + uiDefButBitI(block, TOG, CONT_PY_DEBUG, B_REDR, "D", (xco+width)-25, yco-23, 19, 19, &pc->flag, 0, 0, 0, 0, "Continuously reload the module from disk for editing external modules without restarting"); + } + uiBlockEndAlign(block); + + yco-= ysize; + break; + + default: + ysize= 4; + + UI_ThemeColor(TH_PANEL); + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + yco-= ysize; + } + + return yco; +} + +static int get_col_actuator(int type) +{ + switch(type) { + case ACT_ACTION: return TH_PANEL; + case ACT_SHAPEACTION: return TH_PANEL; + case ACT_OBJECT: return TH_PANEL; + case ACT_IPO: return TH_PANEL; + case ACT_PROPERTY: return TH_PANEL; + case ACT_SOUND: return TH_PANEL; + case ACT_CD: return TH_PANEL; + case ACT_CAMERA: return TH_PANEL; + case ACT_EDIT_OBJECT: return TH_PANEL; + case ACT_GROUP: return TH_PANEL; + case ACT_RANDOM: return TH_PANEL; + case ACT_SCENE: return TH_PANEL; + case ACT_MESSAGE: return TH_PANEL; + case ACT_GAME: return TH_PANEL; + case ACT_VISIBILITY: return TH_PANEL; + case ACT_CONSTRAINT: return TH_PANEL; + case ACT_STATE: return TH_PANEL; + default: return TH_PANEL; + } +} +static void set_col_actuator(int item, int medium) +{ + int col= get_col_actuator(item); + UI_ThemeColorShade(col, medium?30:10); + +} + +static void change_object_actuator(bContext *C, void *act, void *arg) +{ + bObjectActuator *oa = act; + + if (oa->type != oa->otype) { + switch (oa->type) { + case ACT_OBJECT_NORMAL: + memset(oa, 0, sizeof(bObjectActuator)); + oa->flag = ACT_FORCE_LOCAL|ACT_TORQUE_LOCAL|ACT_DLOC_LOCAL|ACT_DROT_LOCAL; + oa->type = ACT_OBJECT_NORMAL; + break; + + case ACT_OBJECT_SERVO: + memset(oa, 0, sizeof(bObjectActuator)); + oa->flag = ACT_LIN_VEL_LOCAL; + oa->type = ACT_OBJECT_SERVO; + oa->forcerot[0] = 30.0f; + oa->forcerot[1] = 0.5f; + oa->forcerot[2] = 0.0f; + break; + } + } +} + +static void change_ipo_actuator(bContext *C, void *arg1_but, void *arg2_ia) +{ + bIpoActuator *ia = arg2_ia; + uiBut *but = arg1_but; + + if (but->retval & ACT_IPOFORCE) + ia->flag &= ~ACT_IPOADD; + else if (but->retval & ACT_IPOADD) + ia->flag &= ~ACT_IPOFORCE; + but->retval = B_REDR; +} + +void update_object_actuator_PID(bContext *C, void *act, void *arg) +{ + bObjectActuator *oa = act; + oa->forcerot[0] = 60.0f*oa->forcerot[1]; +} + +char *get_state_name(Object *ob, short bit) +{ + bController *cont; + unsigned int mask; + + mask = (1<<bit); + cont = ob->controllers.first; + while (cont) { + if (cont->state_mask & mask) { + return cont->name; + } + cont = cont->next; + } + return (char*)""; +} + +static void check_state_mask(bContext *C, void *arg1_but, void *arg2_mask) +{ + int shift= 0; // XXX + unsigned int *cont_mask = arg2_mask; + uiBut *but = arg1_but; + + if (*cont_mask == 0 || !(shift)) + *cont_mask = (1<<but->retval); + but->retval = B_REDR; +} + +static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, short xco, short yco, short width) +{ + bSoundActuator *sa = NULL; + bCDActuator *cda = NULL; + bObjectActuator *oa = NULL; + bIpoActuator *ia = NULL; + bPropertyActuator *pa = NULL; + bCameraActuator *ca = NULL; + bEditObjectActuator *eoa = NULL; + bConstraintActuator *coa = NULL; + bSceneActuator *sca = NULL; + bGroupActuator *ga = NULL; + bRandomActuator *randAct = NULL; + bMessageActuator *ma = NULL; + bActionActuator *aa = NULL; + bGameActuator *gma = NULL; + bVisibilityActuator *visAct = NULL; + bTwoDFilterActuator *tdfa = NULL; + bParentActuator *parAct = NULL; + bStateActuator *staAct = NULL; + + float *fp; + short ysize = 0, wval; + char *str; + int myline, stbit; + uiBut *but; + + + /* yco is at the top of the rect, draw downwards */ + set_col_actuator(act->type, 0); + + switch (act->type) + { + case ACT_OBJECT: + { + oa = act->data; + wval = (width-100)/3; + if (oa->type == ACT_OBJECT_NORMAL) + { + if ( ob->gameflag & OB_DYNAMIC ) + { + ysize= 175; + } + else + { + ysize= 72; + } + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + uiBlockBeginAlign(block); + uiDefBut(block, LABEL, 0, "Loc", xco, yco-45, 45, 19, NULL, 0, 0, 0, 0, "Sets the location"); + uiDefButF(block, NUM, 0, "", xco+45, yco-45, wval, 19, oa->dloc, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+wval, yco-45, wval, 19, oa->dloc+1, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-45, wval, 19, oa->dloc+2, -10000.0, 10000.0, 10, 0, ""); + uiBlockEndAlign(block); + + uiDefBut(block, LABEL, 0, "Rot", xco, yco-64, 45, 19, NULL, 0, 0, 0, 0, "Sets the rotation"); + uiBlockBeginAlign(block); + uiDefButF(block, NUM, 0, "", xco+45, yco-64, wval, 19, oa->drot, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+wval, yco-64, wval, 19, oa->drot+1, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-64, wval, 19, oa->drot+2, -10000.0, 10000.0, 10, 0, ""); + uiBlockEndAlign(block); + + uiDefButBitS(block, TOG, ACT_DLOC_LOCAL, 0, "L", xco+45+3*wval, yco-45, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); + uiDefButBitS(block, TOG, ACT_DROT_LOCAL, 0, "L", xco+45+3*wval, yco-64, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); + + if ( ob->gameflag & OB_DYNAMIC ) + { + uiDefBut(block, LABEL, 0, "Force", xco, yco-87, 55, 19, NULL, 0, 0, 0, 0, "Sets the force"); + uiBlockBeginAlign(block); + uiDefButF(block, NUM, 0, "", xco+45, yco-87, wval, 19, oa->forceloc, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+wval, yco-87, wval, 19, oa->forceloc+1, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-87, wval, 19, oa->forceloc+2, -10000.0, 10000.0, 10, 0, ""); + uiBlockEndAlign(block); + + uiDefBut(block, LABEL, 0, "Torque", xco, yco-106, 55, 19, NULL, 0, 0, 0, 0, "Sets the torque"); + uiBlockBeginAlign(block); + uiDefButF(block, NUM, 0, "", xco+45, yco-106, wval, 19, oa->forcerot, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+wval, yco-106, wval, 19, oa->forcerot+1, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-106, wval, 19, oa->forcerot+2, -10000.0, 10000.0, 10, 0, ""); + uiBlockEndAlign(block); + } + + if ( ob->gameflag & OB_DYNAMIC ) + { + uiDefBut(block, LABEL, 0, "LinV", xco, yco-129, 45, 19, NULL, 0, 0, 0, 0, "Sets the linear velocity"); + uiBlockBeginAlign(block); + uiDefButF(block, NUM, 0, "", xco+45, yco-129, wval, 19, oa->linearvelocity, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+wval, yco-129, wval, 19, oa->linearvelocity+1, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-129, wval, 19, oa->linearvelocity+2, -10000.0, 10000.0, 10, 0, ""); + uiBlockEndAlign(block); + + uiDefBut(block, LABEL, 0, "AngV", xco, yco-148, 45, 19, NULL, 0, 0, 0, 0, "Sets the angular velocity"); + uiBlockBeginAlign(block); + uiDefButF(block, NUM, 0, "", xco+45, yco-148, wval, 19, oa->angularvelocity, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+wval, yco-148, wval, 19, oa->angularvelocity+1, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-148, wval, 19, oa->angularvelocity+2, -10000.0, 10000.0, 10, 0, ""); + uiBlockEndAlign(block); + + uiDefBut(block, LABEL, 0, "Damp", xco, yco-171, 45, 19, NULL, 0, 0, 0, 0, "Number of frames to reach the target velocity"); + uiDefButS(block, NUM, 0, "", xco+45, yco-171, wval, 19, &oa->damping, 0.0, 1000.0, 100, 0, ""); + + uiDefButBitS(block, TOG, ACT_FORCE_LOCAL, 0, "L", xco+45+3*wval, yco-87, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); + uiDefButBitS(block, TOG, ACT_TORQUE_LOCAL, 0, "L", xco+45+3*wval, yco-106, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); + uiDefButBitS(block, TOG, ACT_LIN_VEL_LOCAL, 0, "L", xco+45+3*wval, yco-129, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); + uiDefButBitS(block, TOG, ACT_ANG_VEL_LOCAL, 0, "L", xco+45+3*wval, yco-148, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); + + uiDefButBitS(block, TOG, ACT_ADD_LIN_VEL, 0, "add",xco+45+3*wval+15, yco-129, 35, 19, &oa->flag, 0.0, 0.0, 0, 0, "Toggles between ADD and SET linV"); + } + } else if (oa->type == ACT_OBJECT_SERVO) + { + ysize= 195; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + uiDefBut(block, LABEL, 0, "Ref", xco, yco-45, 45, 19, NULL, 0, 0, 0, 0, ""); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+45, yco-45, wval*3, 19, &(oa->reference), "Reference object for velocity calculation, leave empty for world reference"); + uiDefBut(block, LABEL, 0, "linV", xco, yco-68, 45, 19, NULL, 0, 0, 0, 0, "Sets the target relative linear velocity, it will be achieved by automatic application of force. Null velocity is a valid target"); + uiBlockBeginAlign(block); + uiDefButF(block, NUM, 0, "", xco+45, yco-68, wval, 19, oa->linearvelocity, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+wval, yco-68, wval, 19, oa->linearvelocity+1, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-68, wval, 19, oa->linearvelocity+2, -10000.0, 10000.0, 10, 0, ""); + uiBlockEndAlign(block); + uiDefButBitS(block, TOG, ACT_LIN_VEL_LOCAL, 0, "L", xco+45+3*wval, yco-68, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Velocity is defined in local coordinates"); + + uiDefBut(block, LABEL, 0, "Limit", xco, yco-91, 45, 19, NULL, 0, 0, 0, 0, "Select if the force needs to be limited along certain axis (local or global depending on LinV Local flag)"); + uiBlockBeginAlign(block); + uiDefButBitS(block, TOG, ACT_SERVO_LIMIT_X, B_REDR, "X", xco+45, yco-91, wval, 19, &oa->flag, 0.0, 0.0, 0, 0, "Set limit to force along the X axis"); + uiDefButBitS(block, TOG, ACT_SERVO_LIMIT_Y, B_REDR, "Y", xco+45+wval, yco-91, wval, 19, &oa->flag, 0.0, 0.0, 0, 0, "Set limit to force along the Y axis"); + uiDefButBitS(block, TOG, ACT_SERVO_LIMIT_Z, B_REDR, "Z", xco+45+2*wval, yco-91, wval, 19, &oa->flag, 0.0, 0.0, 0, 0, "Set limit to force along the Z axis"); + uiBlockEndAlign(block); + uiDefBut(block, LABEL, 0, "Max", xco, yco-110, 45, 19, NULL, 0, 0, 0, 0, "Set the upper limit for force"); + uiDefBut(block, LABEL, 0, "Min", xco, yco-129, 45, 19, NULL, 0, 0, 0, 0, "Set the lower limit for force"); + if (oa->flag & ACT_SERVO_LIMIT_X) { + uiDefButF(block, NUM, 0, "", xco+45, yco-110, wval, 19, oa->dloc, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45, yco-129, wval, 19, oa->drot, -10000.0, 10000.0, 10, 0, ""); + } + if (oa->flag & ACT_SERVO_LIMIT_Y) { + uiDefButF(block, NUM, 0, "", xco+45+wval, yco-110, wval, 19, oa->dloc+1, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+wval, yco-129, wval, 19, oa->drot+1, -10000.0, 10000.0, 10, 0, ""); + } + if (oa->flag & ACT_SERVO_LIMIT_Z) { + uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-110, wval, 19, oa->dloc+2, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-129, wval, 19, oa->drot+2, -10000.0, 10000.0, 10, 0, ""); + } + uiDefBut(block, LABEL, 0, "Servo", xco, yco-152, 45, 19, NULL, 0, 0, 0, 0, "Coefficients of the PID servo controller"); + uiDefButF(block, NUMSLI, B_REDR, "P: ", xco+45, yco-152, wval*3, 19, oa->forcerot, 0.00, 200.0, 100, 0, "Proportional coefficient, typical value is 60x Integral coefficient"); + uiDefBut(block, LABEL, 0, "Slow", xco, yco-171, 45, 19, NULL, 0, 0, 0, 0, "Low value of I coefficient correspond to slow response"); + but = uiDefButF(block, NUMSLI, B_REDR, " I : ", xco+45, yco-171, wval*3, 19, oa->forcerot+1, 0.0, 3.0, 1, 0, "Integral coefficient, low value (0.01) for slow response, high value (0.5) for fast response"); + uiButSetFunc(but, update_object_actuator_PID, oa, NULL); + uiDefBut(block, LABEL, 0, "Fast", xco+45+3*wval, yco-171, 45, 19, NULL, 0, 0, 0, 0, "High value of I coefficient correspond to fast response"); + uiDefButF(block, NUMSLI, B_REDR, "D: ", xco+45, yco-190, wval*3, 19, oa->forcerot+2, -100.0, 100.0, 100, 0, "Derivate coefficient, not required, high values can cause instability"); + } + str= "Motion Type %t|Simple motion %x0|Servo Control %x1"; + but = uiDefButS(block, MENU, B_REDR, str, xco+40, yco-23, (width-80), 19, &oa->type, 0.0, 0.0, 0, 0, ""); + oa->otype = oa->type; + uiButSetFunc(but, change_object_actuator, oa, NULL); + yco-= ysize; + break; + } + case ACT_ACTION: + case ACT_SHAPEACTION: + { + /* DrawAct */ +#ifdef __NLA_ACTION_BY_MOTION_ACTUATOR + ysize = 112; +#else + ysize= 92; +#endif + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + aa = act->data; + wval = (width-60)/3; + + // str= "Action types %t|Play %x0|Ping Pong %x1|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x6"; +#ifdef __NLA_ACTION_BY_MOTION_ACTUATOR + str= "Action types %t|Play %x0|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x6|Displacement %x7"; +#else + str= "Action types %t|Play %x0|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x6"; +#endif + uiDefButS(block, MENU, B_REDR, str, xco+10, yco-24, width/3, 19, &aa->type, 0.0, 0.0, 0.0, 0.0, "Action playback type"); + uiDefIDPoinBut(block, test_actionpoin_but, ID_AC, 1, "AC: ", xco+10+ (width/3), yco-24, ((width/3)*2) - (20 + 60), 19, &aa->act, "Action name"); + + uiDefButBitS(block, TOGN, 1, 0, "Continue", xco+((width/3)*2)+20, yco-24, 60, 19, + &aa->end_reset, 0.0, 0.0, 0, 0, "Restore last frame when switching on/off, otherwise play from the start each time"); + + + if(aa->type == ACT_ACTION_FROM_PROP) + { + uiDefBut(block, TEX, 0, "Prop: ",xco+10, yco-44, width-20, 19, aa->name, 0.0, 31.0, 0, 0, "Use this property to define the Action position"); + } + else + { + uiDefButI(block, NUM, 0, "Sta: ",xco+10, yco-44, (width-20)/2, 19, &aa->sta, 1.0, MAXFRAMEF, 0, 0, "Start frame"); + uiDefButI(block, NUM, 0, "End: ",xco+10+(width-20)/2, yco-44, (width-20)/2, 19, &aa->end, 1.0, MAXFRAMEF, 0, 0, "End frame"); + } + + uiDefButS(block, NUM, 0, "Blendin: ", xco+10, yco-64, (width-20)/2, 19, &aa->blendin, 0.0, 32767, 0.0, 0.0, "Number of frames of motion blending"); + uiDefButS(block, NUM, 0, "Priority: ", xco+10+(width-20)/2, yco-64, (width-20)/2, 19, &aa->priority, 0.0, 100.0, 0.0, 0.0, "Execution priority - lower numbers will override actions with higher numbers, With 2 or more actions at once, the overriding channels must be lower in the stack"); + + uiDefBut(block, TEX, 0, "FrameProp: ",xco+10, yco-84, width-20, 19, aa->frameProp, 0.0, 31.0, 0, 0, "Assign the action's current frame number to this property"); + + +#ifdef __NLA_ACTION_BY_MOTION_ACTUATOR + if(aa->type == ACT_ACTION_MOTION) + { + uiDefButF(block, NUM, 0, "Cycle: ",xco+30, yco-84, (width-60)/2, 19, &aa->stridelength, 0.0, 2500.0, 0, 0, "Distance covered by a single cycle of the action"); + } +#endif + + + + yco-=ysize; + break; + } + case ACT_IPO: + { + ia= act->data; + + ysize= 72; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + str = "Ipo types %t|Play %x0|Ping Pong %x1|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x6"; + + uiDefButS(block, MENU, B_REDR, str, xco+10, yco-24, (width-20)/2, 19, &ia->type, 0, 0, 0, 0, ""); + + but = uiDefButBitS(block, TOG, ACT_IPOFORCE, ACT_IPOFORCE, + "Force", xco+10+(width-20)/2, yco-24, (width-20)/4-10, 19, + &ia->flag, 0, 0, 0, 0, + "Apply Ipo as a global or local force depending on the local option (dynamic objects only)"); + uiButSetFunc(but, change_ipo_actuator, but, ia); + + but = uiDefButBitS(block, TOG, ACT_IPOADD, ACT_IPOADD, + "Add", xco+3*(width-20)/4, yco-24, (width-20)/4-10, 19, + &ia->flag, 0, 0, 0, 0, + "Ipo is added to the current loc/rot/scale in global or local coordinate according to Local flag"); + uiButSetFunc(but, change_ipo_actuator, but, ia); + + /* Only show the do-force-local toggle if force is requested */ + if (ia->flag & (ACT_IPOFORCE|ACT_IPOADD)) { + uiDefButBitS(block, TOG, ACT_IPOLOCAL, 0, + "L", xco+width-30, yco-24, 20, 19, + &ia->flag, 0, 0, 0, 0, + "Let the ipo acts in local coordinates, used in Force and Add mode"); + } + + if(ia->type==ACT_IPO_FROM_PROP) { + uiDefBut(block, TEX, 0, + "Prop: ", xco+10, yco-44, width-80, 19, + ia->name, 0.0, 31.0, 0, 0, + "Use this property to define the Ipo position"); + } + else { + uiDefButI(block, NUM, 0, + "Sta", xco+10, yco-44, (width-80)/2, 19, + &ia->sta, 1.0, MAXFRAMEF, 0, 0, + "Start frame"); + uiDefButI(block, NUM, 0, + "End", xco+10+(width-80)/2, yco-44, (width-80)/2, 19, + &ia->end, 1.0, MAXFRAMEF, 0, 0, + "End frame"); + } + uiDefButBitS(block, TOG, ACT_IPOCHILD, B_REDR, + "Child", xco+10+(width-80), yco-44, 60, 19, + &ia->flag, 0, 0, 0, 0, + "Update IPO on all children Objects as well"); + uiDefBut(block, TEX, 0, + "FrameProp: ", xco+10, yco-64, width-20, 19, + ia->frameProp, 0.0, 31.0, 0, 0, + "Assign the action's current frame number to this property"); + + yco-= ysize; + break; + } + case ACT_PROPERTY: + { + ysize= 68; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + pa= act->data; + + str= "Type%t|Assign%x0|Add %x1|Copy %x2|Toggle (bool/int/float/timer)%x3"; + uiDefButI(block, MENU, B_REDR, str, xco+30,yco-24,width-60, 19, &pa->type, 0, 31, 0, 0, "Type"); + + uiDefBut(block, TEX, 1, "Prop: ", xco+30,yco-44,width-60, 19, pa->name, 0, 31, 0, 0, "Property name"); + + + if(pa->type==ACT_PROP_TOGGLE) { + /* no ui */ + ysize -= 22; + } + else if(pa->type==ACT_PROP_COPY) { + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+10, yco-64, (width-20)/2, 19, &(pa->ob), "Copy from this Object"); + uiDefBut(block, TEX, 1, "Prop: ", xco+10+(width-20)/2, yco-64, (width-20)/2, 19, pa->value, 0, 31, 0, 0, "Copy this property"); + } + else { + uiDefBut(block, TEX, 1, "Value: ", xco+30,yco-64,width-60, 19, pa->value, 0, 31, 0, 0, "change with this value, use \"\" around strings"); + } + yco-= ysize; + + break; + } + case ACT_SOUND: + { + ysize = 70; + + sa = act->data; + sa->sndnr = 0; + + wval = (width-20)/2; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + if(G.main->sound.first) { + IDnames_to_pupstring(&str, "Sound files", NULL, &(G.main->sound), (ID *)sa->sound, &(sa->sndnr)); + /* reset this value, it is for handling the event */ + sa->sndnr = 0; + uiDefButS(block, MENU, B_SOUNDACT_BROWSE, str, xco+10,yco-22,20,19, &(sa->sndnr), 0, 0, 0, 0, ""); + + if(sa->sound) { + char dummy_str[] = "Sound mode %t|Play Stop %x0|Play End %x1|Loop Stop %x2|Loop End %x3|Loop Ping Pong Stop %x5|Loop Ping Pong %x4"; + uiDefBut(block, TEX, B_IDNAME, "SO:",xco+30,yco-22,width-40,19, sa->sound->id.name+2, 0.0, 21.0, 0, 0, ""); + uiDefButS(block, MENU, 1, dummy_str,xco+10,yco-44,width-20, 19, &sa->type, 0.0, 0.0, 0, 0, ""); + uiDefButF(block, NUM, 0, "Volume:", xco+10,yco-66,wval, 19, &sa->sound->volume, 0.0, 1.0, 0, 0, "Sets the volume of this sound"); + uiDefButF(block, NUM, 0, "Pitch:",xco+wval+10,yco-66,wval, 19, &sa->sound->pitch,-12.0, 12.0, 0, 0, "Sets the pitch of this sound"); + } + MEM_freeN(str); + } + else { + uiDefBut(block, LABEL, 0, "Use Sound window (F10) to load samples", xco, yco-24, width, 19, NULL, 0, 0, 0, 0, ""); + } + + yco-= ysize; + + break; + } + case ACT_CD: + { + char cd_type_str[] = "Sound mode %t|Play all tracks %x0|Play one track %x1|" + "Volume %x3|Stop %x4|Pause %x5|Resume %x6"; + cda = act->data; + + if (cda) { + if (cda->track == 0) { + cda->track = 1; + cda->volume = 1; + cda->type = ACT_CD_PLAY_ALL; + } + + if (cda->type == ACT_CD_PLAY_TRACK || cda->type == ACT_CD_LOOP_TRACK) { + ysize = 48; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + uiDefButS(block, NUM, 0, "Track:", xco+10,yco-44,width-20, 19, &cda->track, 1, 99, 0, 0, "Select the track to be played"); + } + else if (cda->type == ACT_CD_VOLUME) { + ysize = 48; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + uiDefButF(block, NUM, 0, "Volume:", xco+10,yco-44,width-20, 19, &cda->volume, 0, 1, 0, 0, "Set the volume for CD playback"); + } + else { + ysize = 28; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + } + uiDefButS(block, MENU, B_REDR, cd_type_str,xco+10,yco-22,width-20, 19, &cda->type, 0.0, 0.0, 0, 0, ""); + } + yco-= ysize; + break; + } + case ACT_CAMERA: + + ysize= 48; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + ca= act->data; + + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+10, yco-24, (width-20)/2, 19, &(ca->ob), "Look at this Object"); + uiDefButF(block, NUM, 0, "Height:", xco+10+(width-20)/2, yco-24, (width-20)/2, 19, &ca->height, 0.0, 20.0, 0, 0, ""); + + uiDefButF(block, NUM, 0, "Min:", xco+10, yco-44, (width-60)/2, 19, &ca->min, 0.0, 20.0, 0, 0, ""); + + if(ca->axis==0) ca->axis= 'x'; + uiDefButS(block, ROW, 0, "X", xco+10+(width-60)/2, yco-44, 20, 19, &ca->axis, 4.0, (float)'x', 0, 0, "Camera tries to get behind the X axis"); + uiDefButS(block, ROW, 0, "Y", xco+30+(width-60)/2, yco-44, 20, 19, &ca->axis, 4.0, (float)'y', 0, 0, "Camera tries to get behind the Y axis"); + + uiDefButF(block, NUM, 0, "Max:", xco+20+(width)/2, yco-44, (width-60)/2, 19, &ca->max, 0.0, 20.0, 0, 0, ""); + + yco-= ysize; + + break; + + case ACT_EDIT_OBJECT: + + eoa= act->data; + + if(eoa->type==ACT_EDOB_ADD_OBJECT) { + int wval; /* just a temp width */ + ysize = 92; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+10, yco-44, (width-20)/2, 19, &(eoa->ob), "Add this Object and all its children (cant be on an visible layer)"); + uiDefButI(block, NUM, 0, "Time:", xco+10+(width-20)/2, yco-44, (width-20)/2, 19, &eoa->time, 0.0, 2000.0, 0, 0, "Duration the new Object lives"); + + wval= (width-60)/3; + uiDefBut(block, LABEL, 0, "linV", xco, yco-68, 45, 19, + NULL, 0, 0, 0, 0, + "Velocity upon creation"); + uiDefButF(block, NUM, 0, "", xco+45, yco-68, wval, 19, + eoa->linVelocity, -100.0, 100.0, 10, 0, + "Velocity upon creation, x component"); + uiDefButF(block, NUM, 0, "", xco+45+wval, yco-68, wval, 19, + eoa->linVelocity+1, -100.0, 100.0, 10, 0, + "Velocity upon creation, y component"); + uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-68, wval, 19, + eoa->linVelocity+2, -100.0, 100.0, 10, 0, + "Velocity upon creation, z component"); + uiDefButBitS(block, TOG, ACT_EDOB_LOCAL_LINV, 0, "L", xco+45+3*wval, yco-68, 15, 19, + &eoa->localflag, 0.0, 0.0, 0, 0, + "Apply the transformation locally"); + + + uiDefBut(block, LABEL, 0, "AngV", xco, yco-90, 45, 19, + NULL, 0, 0, 0, 0, + "Angular velocity upon creation"); + uiDefButF(block, NUM, 0, "", xco+45, yco-90, wval, 19, + eoa->angVelocity, -10000.0, 10000.0, 10, 0, + "Angular velocity upon creation, x component"); + uiDefButF(block, NUM, 0, "", xco+45+wval, yco-90, wval, 19, + eoa->angVelocity+1, -10000.0, 10000.0, 10, 0, + "Angular velocity upon creation, y component"); + uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-90, wval, 19, + eoa->angVelocity+2, -10000.0, 10000.0, 10, 0, + "Angular velocity upon creation, z component"); + uiDefButBitS(block, TOG, ACT_EDOB_LOCAL_ANGV, 0, "L", xco+45+3*wval, yco-90, 15, 19, + &eoa->localflag, 0.0, 0.0, 0, 0, + "Apply the rotation locally"); + + + } + else if(eoa->type==ACT_EDOB_END_OBJECT) { + ysize= 28; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + } + else if(eoa->type==ACT_EDOB_REPLACE_MESH) { + ysize= 48; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + uiDefIDPoinBut(block, test_meshpoin_but, ID_ME, 1, "ME:", xco+40, yco-44, (width-80), 19, &(eoa->me), "replace the existing mesh with this one"); + } + else if(eoa->type==ACT_EDOB_TRACK_TO) { + ysize= 48; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+10, yco-44, (width-20)/2, 19, &(eoa->ob), "Track to this Object"); + uiDefButI(block, NUM, 0, "Time:", xco+10+(width-20)/2, yco-44, (width-20)/2-40, 19, &eoa->time, 0.0, 2000.0, 0, 0, "Duration the tracking takes"); + uiDefButS(block, TOG, 0, "3D", xco+width-50, yco-44, 40, 19, &eoa->flag, 0.0, 0.0, 0, 0, "Enable 3D tracking"); + } + else if(eoa->type==ACT_EDOB_DYNAMICS) { + ysize= 69; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + str= "Dynamic Operation %t|Restore Dynamics %x0|Suspend Dynamics %x1|Enable Rigid Body %x2|Disable Rigid Body %x3|Set Mass %x4"; + uiDefButS(block, MENU, B_REDR, str, xco+40, yco-44, (width-80), 19, &(eoa->dyn_operation), 0.0, 0.0, 0, 0, ""); + if(eoa->dyn_operation==4) { + uiDefButF(block, NUM, 0, "", xco+40, yco-63, width-80, 19, + &eoa->mass, 0.0, 10000.0, 10, 0, + "Mass for object"); + } + } + str= "Edit Object %t|Add Object %x0|End Object %x1|Replace Mesh %x2|Track to %x3|Dynamics %x4"; + uiDefButS(block, MENU, B_REDR, str, xco+40, yco-24, (width-80), 19, &eoa->type, 0.0, 0.0, 0, 0, ""); + + yco-= ysize; + + break; + + case ACT_CONSTRAINT: + coa= act->data; + + if (coa->type == ACT_CONST_TYPE_LOC) { + ysize= 69; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + /* str= "Limit %t|None %x0|Loc X %x1|Loc Y %x2|Loc Z %x4|Rot X %x8|Rot Y %x16|Rot Z %x32"; */ + /* coa->flag &= ~(63); */ + str= "Limit %t|None %x0|Loc X %x1|Loc Y %x2|Loc Z %x4"; + coa->flag &= 7; + coa->time = 0; + uiDefButS(block, MENU, 1, str, xco+10, yco-65, 70, 19, &coa->flag, 0.0, 0.0, 0, 0, ""); + + uiDefButS(block, NUM, 0, "damp", xco+10, yco-45, 70, 19, &coa->damp, 0.0, 100.0, 0, 0, "Damping factor: time constant (in frame) of low pass filter"); + uiDefBut(block, LABEL, 0, "Min", xco+80, yco-45, (width-90)/2, 19, NULL, 0.0, 0.0, 0, 0, ""); + uiDefBut(block, LABEL, 0, "Max", xco+80+(width-90)/2, yco-45, (width-90)/2, 19, NULL, 0.0, 0.0, 0, 0, ""); + + if(coa->flag & ACT_CONST_LOCX) fp= coa->minloc; + else if(coa->flag & ACT_CONST_LOCY) fp= coa->minloc+1; + else if(coa->flag & ACT_CONST_LOCZ) fp= coa->minloc+2; + else if(coa->flag & ACT_CONST_ROTX) fp= coa->minrot; + else if(coa->flag & ACT_CONST_ROTY) fp= coa->minrot+1; + else fp= coa->minrot+2; + + uiDefButF(block, NUM, 0, "", xco+80, yco-65, (width-90)/2, 19, fp, -2000.0, 2000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+80+(width-90)/2, yco-65, (width-90)/2, 19, fp+3, -2000.0, 2000.0, 10, 0, ""); + } else if (coa->type == ACT_CONST_TYPE_DIST) { + ysize= 106; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + str= "Direction %t|None %x0|X axis %x1|Y axis %x2|Z axis %x4|-X axis %x8|-Y axis %x16|-Z axis %x32"; + uiDefButS(block, MENU, B_REDR, str, xco+10, yco-65, 70, 19, &coa->mode, 0.0, 0.0, 0, 0, "Set the direction of the ray"); + + uiDefButS(block, NUM, 0, "damp", xco+10, yco-45, 70, 19, &coa->damp, 0.0, 100.0, 0, 0, "Damping factor: time constant (in frame) of low pass filter"); + uiDefBut(block, LABEL, 0, "Range", xco+80, yco-45, (width-115)/2, 19, NULL, 0.0, 0.0, 0, 0, "Set the maximum length of ray"); + uiDefButBitS(block, TOG, ACT_CONST_DISTANCE, B_REDR, "Dist", xco+80+(width-115)/2, yco-45, (width-115)/2, 19, &coa->flag, 0.0, 0.0, 0, 0, "Force distance of object to point of impact of ray"); + uiDefButBitS(block, TOG, ACT_CONST_LOCAL, 0, "L", xco+80+(width-115), yco-45, 25, 19, + &coa->flag, 0.0, 0.0, 0, 0, "Set ray along object's axis or global axis"); + + if(coa->mode & (ACT_CONST_DIRPX|ACT_CONST_DIRNX)) fp= coa->minloc; + else if(coa->mode & (ACT_CONST_DIRPY|ACT_CONST_DIRNY)) fp= coa->minloc+1; + else fp= coa->minloc+2; + + uiDefButF(block, NUM, 0, "", xco+80, yco-65, (width-115)/2, 19, fp+3, 0.0, 2000.0, 10, 0, "Maximum length of ray"); + if (coa->flag & ACT_CONST_DISTANCE) + uiDefButF(block, NUM, 0, "", xco+80+(width-115)/2, yco-65, (width-115)/2, 19, fp, -2000.0, 2000.0, 10, 0, "Keep this distance to target"); + uiDefButBitS(block, TOG, ACT_CONST_NORMAL, 0, "N", xco+80+(width-115), yco-65, 25, 19, + &coa->flag, 0.0, 0.0, 0, 0, "Set object axis along (local axis) or parallel (global axis) to the normal at hit position"); + uiDefButBitS(block, TOG, ACT_CONST_MATERIAL, B_REDR, "M/P", xco+10, yco-84, 40, 19, + &coa->flag, 0.0, 0.0, 0, 0, "Detect material instead of property"); + if (coa->flag & ACT_CONST_MATERIAL) + { + uiDefBut(block, TEX, 1, "Material:", xco + 50, yco-84, (width-60), 19, + coa->matprop, 0, 31, 0, 0, + "Ray detects only Objects with this material"); + } + else + { + uiDefBut(block, TEX, 1, "Property:", xco + 50, yco-84, (width-60), 19, + coa->matprop, 0, 31, 0, 0, + "Ray detect only Objects with this property"); + } + uiDefButBitS(block, TOG, ACT_CONST_PERMANENT, 0, "PER", xco+10, yco-103, 40, 19, + &coa->flag, 0.0, 0.0, 0, 0, "Persistent actuator: stays active even if ray does not reach target"); + uiDefButS(block, NUM, 0, "time", xco+50, yco-103, (width-60)/2, 19, &(coa->time), 0.0, 1000.0, 0, 0, "Maximum activation time in frame, 0 for unlimited"); + uiDefButS(block, NUM, 0, "rotDamp", xco+50+(width-60)/2, yco-103, (width-60)/2, 19, &(coa->rotdamp), 0.0, 100.0, 0, 0, "Use a different damping for orientation"); + } else if (coa->type == ACT_CONST_TYPE_ORI) { + ysize= 87; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + str= "Direction %t|None %x0|X axis %x1|Y axis %x2|Z axis %x4"; + uiDefButS(block, MENU, B_REDR, str, xco+10, yco-65, 70, 19, &coa->mode, 0.0, 0.0, 0, 0, "Select the axis to be aligned along the reference direction"); + + uiDefButS(block, NUM, 0, "damp", xco+10, yco-45, 70, 19, &coa->damp, 0.0, 100.0, 0, 0, "Damping factor: time constant (in frame) of low pass filter"); + uiDefBut(block, LABEL, 0, "X", xco+80, yco-45, (width-115)/3, 19, NULL, 0.0, 0.0, 0, 0, ""); + uiDefBut(block, LABEL, 0, "Y", xco+80+(width-115)/3, yco-45, (width-115)/3, 19, NULL, 0.0, 0.0, 0, 0, ""); + uiDefBut(block, LABEL, 0, "Z", xco+80+2*(width-115)/3, yco-45, (width-115)/3, 19, NULL, 0.0, 0.0, 0, 0, ""); + + uiDefButF(block, NUM, 0, "", xco+80, yco-65, (width-115)/3, 19, &coa->maxrot[0], -2000.0, 2000.0, 10, 0, "X component of reference direction"); + uiDefButF(block, NUM, 0, "", xco+80+(width-115)/3, yco-65, (width-115)/3, 19, &coa->maxrot[1], -2000.0, 2000.0, 10, 0, "Y component of reference direction"); + uiDefButF(block, NUM, 0, "", xco+80+2*(width-115)/3, yco-65, (width-115)/3, 19, &coa->maxrot[2], -2000.0, 2000.0, 10, 0, "Z component of reference direction"); + + uiDefButS(block, NUM, 0, "time", xco+10, yco-84, 70, 19, &(coa->time), 0.0, 1000.0, 0, 0, "Maximum activation time in frame, 0 for unlimited"); + uiDefButF(block, NUM, 0, "min", xco+80, yco-84, (width-115)/2, 19, &(coa->minloc[0]), 0.0, 180.0, 10, 1, "Minimum angle (in degree) to maintain with target direction. No correction is done if angle with target direction is between min and max"); + uiDefButF(block, NUM, 0, "max", xco+80+(width-115)/2, yco-84, (width-115)/2, 19, &(coa->maxloc[0]), 0.0, 180.0, 10, 1, "Maximum angle (in degree) allowed with target direction. No correction is done if angle with target direction is between min and max"); + } else if (coa->type == ACT_CONST_TYPE_FH) { + ysize= 106; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + str= "Direction %t|None %x0|X axis %x1|Y axis %x2|Z axis %x4|-X axis %x8|-Y axis %x16|-Z axis %x32"; + uiDefButS(block, MENU, B_REDR, str, xco+10, yco-65, 70, 19, &coa->mode, 0.0, 0.0, 0, 0, "Set the direction of the ray (in world coordinate)"); + + if(coa->mode & (ACT_CONST_DIRPX|ACT_CONST_DIRNX)) fp= coa->minloc; + else if(coa->mode & (ACT_CONST_DIRPY|ACT_CONST_DIRNY)) fp= coa->minloc+1; + else fp= coa->minloc+2; + + uiDefButF(block, NUM, 0, "damp", xco+10, yco-45, (width-70)/2, 19, &coa->maxrot[0], 0.0, 1.0, 1, 0, "Damping factor of the Fh spring force"); + uiDefButF(block, NUM, 0, "dist", xco+10+(width-70)/2, yco-45, (width-70)/2, 19, fp, 0.010, 2000.0, 10, 0, "Height of the Fh area"); + uiDefButBitS(block, TOG, ACT_CONST_DOROTFH, 0, "Rot Fh", xco+10+(width-70), yco-45, 50, 19, &coa->flag, 0.0, 0.0, 0, 0, "Keep object axis parallel to normal"); + + uiDefButF(block, NUMSLI, 0, "Fh ", xco+80, yco-65, (width-115), 19, fp+3, 0.0, 1.0, 0, 0, "Spring force within the Fh area"); + uiDefButBitS(block, TOG, ACT_CONST_NORMAL, 0, "N", xco+80+(width-115), yco-65, 25, 19, + &coa->flag, 0.0, 0.0, 0, 0, "Add a horizontal spring force on slopes"); + uiDefButBitS(block, TOG, ACT_CONST_MATERIAL, B_REDR, "M/P", xco+10, yco-84, 40, 19, + &coa->flag, 0.0, 0.0, 0, 0, "Detect material instead of property"); + if (coa->flag & ACT_CONST_MATERIAL) + { + uiDefBut(block, TEX, 1, "Material:", xco + 50, yco-84, (width-60), 19, + coa->matprop, 0, 31, 0, 0, + "Ray detects only Objects with this material"); + } + else + { + uiDefBut(block, TEX, 1, "Property:", xco + 50, yco-84, (width-60), 19, + coa->matprop, 0, 31, 0, 0, + "Ray detect only Objects with this property"); + } + uiDefButBitS(block, TOG, ACT_CONST_PERMANENT, 0, "PER", xco+10, yco-103, 40, 19, + &coa->flag, 0.0, 0.0, 0, 0, "Persistent actuator: stays active even if ray does not reach target"); + uiDefButS(block, NUM, 0, "time", xco+50, yco-103, 90, 19, &(coa->time), 0.0, 1000.0, 0, 0, "Maximum activation time in frame, 0 for unlimited"); + uiDefButF(block, NUM, 0, "rotDamp", xco+140, yco-103, (width-150), 19, &coa->maxrot[1], 0.0, 1.0, 1, 0, "Use a different damping for rotation"); + } + str= "Constraint Type %t|Location %x0|Distance %x1|Orientation %x2|Force field %x3"; + but = uiDefButS(block, MENU, B_REDR, str, xco+40, yco-23, (width-80), 19, &coa->type, 0.0, 0.0, 0, 0, ""); + yco-= ysize; + break; + + case ACT_SCENE: + sca= act->data; + + if(sca->type==ACT_SCENE_RESTART) { + ysize= 28; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + } + else if(sca->type==ACT_SCENE_CAMERA) { + + ysize= 48; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+40, yco-44, (width-80), 19, &(sca->camera), "Set this Camera. Leave empty to refer to self object"); + } + else if(sca->type==ACT_SCENE_SET) { + + ysize= 48; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Set this Scene"); + } + else if(sca->type==ACT_SCENE_ADD_FRONT) { + + ysize= 48; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Add an Overlay Scene"); + } + else if(sca->type==ACT_SCENE_ADD_BACK) { + + ysize= 48; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Add a Background Scene"); + } + else if(sca->type==ACT_SCENE_REMOVE) { + + ysize= 48; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Remove a Scene"); + } + else if(sca->type==ACT_SCENE_SUSPEND) { + + ysize= 48; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Pause a Scene"); + } + else if(sca->type==ACT_SCENE_RESUME) { + + ysize= 48; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Unpause a Scene"); + } + + str= "Scene %t|Restart %x0|Set Scene %x1|Set Camera %x2|Add OverlayScene %x3|Add BackgroundScene %x4|Remove Scene %x5|Suspend Scene %x6|Resume Scene %x7"; + uiDefButS(block, MENU, B_REDR, str, xco+40, yco-24, (width-80), 19, &sca->type, 0.0, 0.0, 0, 0, ""); + + yco-= ysize; + break; + case ACT_GAME: + { + gma = act->data; + if (gma->type == ACT_GAME_LOAD) + { + //ysize = 68; + ysize = 48; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + uiDefBut(block, TEX, 1, "File: ", xco+10, yco-44,width-20,19, &(gma->filename), 0, 63, 0, 0, "Load this blend file, use the \"//\" prefix for a path relative to the current blend file"); +// uiDefBut(block, TEX, 1, "Anim: ", xco+10, yco-64,width-20,19, &(gma->loadaniname), 0, 63, 0, 0, "Use this loadinganimation"); + } +/* else if (gma->type == ACT_GAME_START) + { + ysize = 68; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + uiDefBut(block, TEX, 1, "File: ", xco+10, yco-44,width-20,19, &(gma->filename), 0, 63, 0, 0, "Load this file"); + uiDefBut(block, TEX, 1, "Anim: ", xco+10, yco-64,width-20,19, &(gma->loadaniname), 0, 63, 0, 0, "Use this loadinganimation"); + } +*/ else if (ELEM4(gma->type, ACT_GAME_RESTART, ACT_GAME_QUIT, ACT_GAME_SAVECFG, ACT_GAME_LOADCFG)) + { + ysize = 28; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + } + + //str = "Scene %t|Load game%x0|Start loaded game%x1|Restart this game%x2|Quit this game %x3"; + str = "Scene %t|Start new game%x0|Restart this game%x2|Quit this game %x3|Save GameLogic.globalDict %x4|Load GameLogic.globalDict %x5"; + uiDefButS(block, MENU, B_REDR, str, xco+40, yco-24, (width-80), 19, &gma->type, 0.0, 0.0, 0, 0, ""); + + yco -= ysize; + break; + } + case ACT_GROUP: + ga= act->data; + + ysize= 52; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + str= "GroupKey types %t|Set Key %x6|Play %x0|Ping Pong %x1|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x5"; + + uiDefButS(block, MENU, 1, str, xco+20, yco-24, width-40, 19, &ga->type, 0, 0, 0, 0, ""); + if(ga->type==ACT_GROUP_SET) { + uiDefBut(block, TEX, 0, "Key: ", xco+20, yco-44, (width-10)/2, 19, ga->name, 0.0, 31.0, 0, 0, "This name defines groupkey to be set"); + uiDefButI(block, NUM, 0, "Frame:", xco+20+(width-10)/2, yco-44, (width-70)/2, 19, &ga->sta, 0.0, 2500.0, 0, 0, "Set this frame"); + } + else if(ga->type==ACT_GROUP_FROM_PROP) { + uiDefBut(block, TEX, 0, "Prop: ", xco+20, yco-44, width-40, 19, ga->name, 0.0, 31.0, 0, 0, "Use this property to define the Group position"); + } + else { + uiDefButI(block, NUM, 0, "State", xco+20, yco-44, (width-40)/2, 19, &ga->sta, 0.0, 2500.0, 0, 0, "Start frame"); + uiDefButI(block, NUM, 0, "End", xco+20+(width-40)/2, yco-44, (width-40)/2, 19, &ga->end, 0.0, 2500.0, 0, 0, "End frame"); + } + yco-= ysize; + break; + + case ACT_VISIBILITY: + ysize = 24; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, + (float)yco-ysize, (float)xco+width, (float)yco, 1); + + visAct = act->data; + + uiBlockBeginAlign(block); + uiDefButBitI(block, TOGN, ACT_VISIBILITY_INVISIBLE, B_REDR, + "Visible", + xco + 10, yco - 20, (width - 20)/3, 19, &visAct->flag, + 0.0, 0.0, 0, 0, + "Set the objects visible. Initialized from the objects render restriction toggle (access in the outliner)"); + uiDefButBitI(block, TOG, ACT_VISIBILITY_OCCLUSION, B_REDR, + "Occlusion", + xco + 10 + ((width - 20)/3), yco - 20, (width - 20)/3, 19, &visAct->flag, + 0.0, 0.0, 0, 0, + "Set the object to occlude objects behind it. Initialized from the object type in physics button"); + uiBlockEndAlign(block); + + uiDefButBitI(block, TOG, ACT_VISIBILITY_RECURSIVE, 0, + "Children", + xco + 10 + (((width - 20)/3)*2)+10, yco - 20, ((width - 20)/3)-10, 19, &visAct->flag, + 0.0, 0.0, 0, 0, + "Sets all the children of this object to the same visibility/occlusion recursively"); + + yco-= ysize; + + break; + + case ACT_STATE: + ysize = 34; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, + (float)yco-ysize, (float)xco+width, (float)yco, 1); + + staAct = act->data; + + str= "Operation %t|Cpy %x0|Add %x1|Sub %x2|Inv %x3"; + + uiDefButI(block, MENU, B_REDR, str, + xco + 10, yco - 24, 65, 19, &staAct->type, + 0.0, 0.0, 0, 0, + "Select the bit operation on object state mask"); + + for (wval=0; wval<15; wval+=5) { + uiBlockBeginAlign(block); + for (stbit=0; stbit<5; stbit++) { + but = uiDefButBitI(block, TOG, 1<<(stbit+wval), stbit+wval, "", (short)(xco+85+12*stbit+13*wval), yco-17, 12, 12, (int *)&(staAct->mask), 0, 0, 0, 0, get_state_name(ob, (short)(stbit+wval))); + uiButSetFunc(but, check_state_mask, but, &(staAct->mask)); + } + for (stbit=0; stbit<5; stbit++) { + but = uiDefButBitI(block, TOG, 1<<(stbit+wval+15), stbit+wval+15, "", (short)(xco+85+12*stbit+13*wval), yco-29, 12, 12, (int *)&(staAct->mask), 0, 0, 0, 0, get_state_name(ob, (short)(stbit+wval+15))); + uiButSetFunc(but, check_state_mask, but, &(staAct->mask)); + } + } + uiBlockEndAlign(block); + + yco-= ysize; + + break; + + case ACT_RANDOM: + ysize = 69; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, + (float)yco-ysize, (float)xco+width, (float)yco, 1); + + randAct = act->data; + + /* 1. seed */ + uiDefButI(block, NUM, 1, "Seed: ", (xco+10),yco-24, 0.4 *(width-20), 19, + &randAct->seed, 0, 1000, 0, 0, + "Initial seed of the random generator. Use Python for more freedom. " + " (Choose 0 for not random)"); + + /* 2. distribution type */ + /* One pick per distribution. These numbers MUST match the #defines */ + /* in game.h !!! */ + str= "Distribution %t|Bool Constant %x0|Bool Uniform %x1" + "|Bool Bernoulli %x2|Int Constant %x3|Int Uniform %x4" + "|Int Poisson %x5|Float Constant %x6|Float Uniform %x7" + "|Float Normal %x8|Float Neg. Exp. %x9"; + uiDefButI(block, MENU, B_REDR, str, (xco+10) + 0.4 * (width-20), yco-24, 0.6 * (width-20), 19, + &randAct->distribution, 0.0, 0.0, 0, 0, + "Choose the type of distribution"); + + /* 3. property */ + uiDefBut(block, TEX, 1, "Property:", (xco+10), yco-44, (width-20), 19, + &randAct->propname, 0, 31, 0, 0, + "Assign the random value to this property"); + + /*4. and 5. arguments for the distribution*/ + switch (randAct->distribution) { + case ACT_RANDOM_BOOL_CONST: + uiDefButBitI(block, TOG, 1, 1, "Always true", (xco+10), yco-64, (width-20), 19, + &randAct->int_arg_1, 2.0, 1, 0, 0, + "Always false or always true"); + break; + case ACT_RANDOM_BOOL_UNIFORM: + uiDefBut(block, LABEL, 0, " Do a 50-50 pick", (xco+10), yco-64, (width-20), 19, + NULL, 0, 0, 0, 0, + "Choose between true and false, 50% chance each"); + break; + case ACT_RANDOM_BOOL_BERNOUILLI: + uiDefButF(block, NUM, 1, "Chance", (xco+10), yco-64, (width-20), 19, + &randAct->float_arg_1, 0.0, 1.0, 0, 0, + "Pick a number between 0 and 1. Success if you stay " + "below this value"); + break; + case ACT_RANDOM_INT_CONST: + uiDefButI(block, NUM, 1, "Value: ", (xco+10), yco-64, (width-20), 19, + &randAct->int_arg_1, -1000, 1000, 0, 0, + "Always return this number"); + break; + case ACT_RANDOM_INT_UNIFORM: + uiDefButI(block, NUM, 1, "Min: ", (xco+10), yco-64, (width-20)/2, 19, + &randAct->int_arg_1, -1000, 1000, 0, 0, + "Choose a number from a range. " + "Lower boundary of the range"); + uiDefButI(block, NUM, 1, "Max: ", (xco+10) + (width-20)/2, yco-64, (width-20)/2, 19, + &randAct->int_arg_2, -1000, 1000, 0, 0, + "Choose a number from a range. " + "Upper boundary of the range"); + break; + case ACT_RANDOM_INT_POISSON: + uiDefButF(block, NUM, 1, "Mean: ", (xco+10), yco-64, (width-20), 19, + &randAct->float_arg_1, 0.01, 100.0, 0, 0, + "Expected mean value of the distribution"); + break; + case ACT_RANDOM_FLOAT_CONST: + uiDefButF(block, NUM, 1, "Value: ", (xco+10), yco-64, (width-20), 19, + &randAct->float_arg_1, 0.0, 1.0, 0, 0, + "Always return this number"); + break; + case ACT_RANDOM_FLOAT_UNIFORM: + uiDefButF(block, NUM, 1, "Min: ", (xco+10), yco-64, (width-20)/2, 19, + &randAct->float_arg_1, -10000.0, 10000.0, 0, 0, + "Choose a number from a range" + "Lower boundary of the range"); + uiDefButF(block, NUM, 1, "Max: ", (xco+10) + (width-20)/2, yco-64, (width-20)/2, 19, + &randAct->float_arg_2, -10000.0, 10000.0, 0, 0, + "Choose a number from a range" + "Upper boundary of the range"); + break; + case ACT_RANDOM_FLOAT_NORMAL: + uiDefButF(block, NUM, 1, "Mean: ", (xco+10), yco-64, (width-20)/2, 19, + &randAct->float_arg_1, -10000.0, 10000.0, 0, 0, + "A normal distribution. Mean of the distribution"); + uiDefButF(block, NUM, 1, "SD: ", (xco+10) + (width-20)/2, yco-64, (width-20)/2, 19, + &randAct->float_arg_2, 0.0, 10000.0, 0, 0, + "A normal distribution. Standard deviation of the " + "distribution"); + break; + case ACT_RANDOM_FLOAT_NEGATIVE_EXPONENTIAL: + uiDefButF(block, NUM, 1, "Half-life time: ", (xco+10), yco-64, (width-20), 19, + &randAct->float_arg_1, 0.001, 10000.0, 0, 0, + "Negative exponential dropoff"); + break; + default: + ; /* don't know what this distro is... can be useful for testing */ + /* though :) */ + } + + yco-= ysize; + break; + case ACT_MESSAGE: + ma = act->data; + + ysize = 4 + (3 * 24); /* footer + number of lines * 24 pixels/line */ + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, + (float)xco+width, (float)yco, 1); + + myline=1; + + /* line 1: To */ + uiDefBut(block, TEX, 1, "To: ", + (xco+10), (yco-(myline++*24)), (width-20), 19, + &ma->toPropName, 0, 31, 0, 0, + "Optional send message to objects with this name only, or empty to broadcast"); + + /* line 2: Message Subject */ + uiDefBut(block, TEX, 1, "Subject: ", + (xco+10), (yco-(myline++*24)), (width-20), 19, + &ma->subject, 0, 31, 0, 0, + "Optional message subject. This is what can be filtered on"); + + /* line 3: Text/Property */ + uiDefButBitS(block, TOG, 1, B_REDR, "T/P", + (xco+10),(yco-(myline*24)), (0.20 * (width-20)), 19, + &ma->bodyType, 0.0, 0.0, 0, 0, + "Toggle message type: either Text or a PropertyName"); + + if (ma->bodyType == ACT_MESG_MESG) + { + /* line 3: Message Body */ + uiDefBut(block, TEX, 1, "Body: ", + (xco+10+(0.20*(width-20))),(yco-(myline++*24)),(0.8*(width-20)),19, + &ma->body, 0, 31, 0, 0, + "Optional message body Text"); + } else + { + /* line 3: Property body (set by property) */ + uiDefBut(block, TEX, 1, "Propname: ", + (xco+10+(0.20*(width-20))),(yco-(myline++*24)),(0.8*(width-20)),19, + &ma->body, 0, 31, 0, 0, + "The message body will be set by the Property Value"); + } + + yco -= ysize; + break; + case ACT_2DFILTER: + tdfa = act->data; + + ysize = 50; + if(tdfa->type == ACT_2DFILTER_CUSTOMFILTER) + { + ysize +=20; + } + glRects( xco, yco-ysize, xco+width, yco ); + uiEmboss( (float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1 ); + + switch(tdfa->type) + { + case ACT_2DFILTER_MOTIONBLUR: + if(!tdfa->flag) + { + uiDefButS(block, TOG, B_REDR, "D", xco+30,yco-44,19, 19, &tdfa->flag, 0.0, 0.0, 0.0, 0.0, "Disable Motion Blur"); + uiDefButF(block, NUM, B_REDR, "Value:", xco+52,yco-44,width-82,19,&tdfa->float_arg,0.0,1.0,0.0,0.0,"Set motion blur value"); + } + else + { + uiDefButS(block, TOG, B_REDR, "Disabled", xco+30,yco-44,width-60, 19, &tdfa->flag, 0.0, 0.0, 0.0, 0.0, "Enable Motion Blur"); + } + break; + case ACT_2DFILTER_BLUR: + case ACT_2DFILTER_SHARPEN: + case ACT_2DFILTER_DILATION: + case ACT_2DFILTER_EROSION: + case ACT_2DFILTER_LAPLACIAN: + case ACT_2DFILTER_SOBEL: + case ACT_2DFILTER_PREWITT: + case ACT_2DFILTER_GRAYSCALE: + case ACT_2DFILTER_SEPIA: + case ACT_2DFILTER_INVERT: + case ACT_2DFILTER_NOFILTER: + case ACT_2DFILTER_DISABLED: + case ACT_2DFILTER_ENABLED: + uiDefButI(block, NUM, B_REDR, "Pass Number:", xco+30,yco-44,width-60,19,&tdfa->int_arg,0.0,MAX_RENDER_PASS-1,0.0,0.0,"Set motion blur value"); + break; + case ACT_2DFILTER_CUSTOMFILTER: + uiDefButI(block, NUM, B_REDR, "Pass Number:", xco+30,yco-44,width-60,19,&tdfa->int_arg,0.0,MAX_RENDER_PASS-1,0.0,0.0,"Set motion blur value"); + uiDefIDPoinBut(block, test_scriptpoin_but, ID_SCRIPT, 1, "Script: ", xco+30,yco-64,width-60, 19, &tdfa->text, ""); + break; + } + + str= "2D Filter %t|Motion Blur %x1|Blur %x2|Sharpen %x3|Dilation %x4|Erosion %x5|" + "Laplacian %x6|Sobel %x7|Prewitt %x8|Gray Scale %x9|Sepia %x10|Invert %x11|Custom Filter %x12|" + "Enable Filter %x-2|Disable Filter %x-1|Remove Filter %x0|"; + uiDefButS(block, MENU, B_REDR, str, xco+30,yco-24,width-60, 19, &tdfa->type, 0.0, 0.0, 0.0, 0.0, "2D filter type"); + + yco -= ysize; + break; + case ACT_PARENT: + parAct = act->data; + + if(parAct->type==ACT_PARENT_SET) { + + ysize= 48; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+95, yco-24, (width-100), 19, &(parAct->ob), "Set this object as parent"); + uiBlockBeginAlign(block); + uiDefButBitS(block, TOGN, ACT_PARENT_COMPOUND, B_REDR, + "Compound", + xco + 5, yco - 44, (width - 10)/2, 19, &parAct->flag, + 0.0, 0.0, 0, 0, + "Add this object shape to the parent shape (only if the parent shape is already compound)"); + uiDefButBitS(block, TOGN, ACT_PARENT_GHOST, B_REDR, + "Ghost", + xco + 5 + ((width - 10)/2), yco - 44, (width - 10)/2, 19, &parAct->flag, + 0.0, 0.0, 0, 0, + "Make this object ghost while parented (only if not compound)"); + uiBlockEndAlign(block); + } + else if(parAct->type==ACT_PARENT_REMOVE) { + + ysize= 28; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + } + + str= "Parent %t|Set Parent %x0|Remove Parent %x1"; + uiDefButI(block, MENU, B_REDR, str, xco+5, yco-24, parAct->type==1?(width-80):90, 19, &parAct->type, 0.0, 0.0, 0, 0, ""); + + yco-= ysize; + break; + default: + ysize= 4; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + yco-= ysize; + break; + } + + uiBlockSetEmboss(block, UI_EMBOSS); + + return yco-4; +} + +static void do_sensor_menu(bContext *C, void *arg, int event) +{ + SpaceLogic *slogic= (SpaceLogic *)CTX_wm_space_data(C); + ID **idar; + Object *ob; + bSensor *sens; + short count, a; + + idar= get_selected_and_linked_obs(C, &count, slogic->scaflag); + + for(a=0; a<count; a++) { + ob= (Object *)idar[a]; + if(event==0 || event==2) ob->scaflag |= OB_SHOWSENS; + else if(event==1) ob->scaflag &= ~OB_SHOWSENS; + } + + for(a=0; a<count; a++) { + ob= (Object *)idar[a]; + sens= ob->sensors.first; + while(sens) { + if(event==2) sens->flag |= SENS_SHOW; + else if(event==3) sens->flag &= ~SENS_SHOW; + sens= sens->next; + } + } + + if(idar) MEM_freeN(idar); +} + +static uiBlock *sensor_menu(bContext *C, ARegion *ar, void *arg_unused) +{ + uiBlock *block; + int yco=0; + + block= uiBeginBlock(C, ar, "filemenu", UI_EMBOSSP); + uiBlockSetButmFunc(block, do_sensor_menu, NULL); + + uiDefBut(block, BUTM, 1, "Show Objects", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, ""); + uiDefBut(block, BUTM, 1, "Hide Objects", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, ""); + uiDefBut(block, SEPR, 0, "", 0, (short)(yco-=6), 160, 6, NULL, 0.0, 0.0, 0, 0, ""); + uiDefBut(block, BUTM, 1, "Show Sensors", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 2, ""); + uiDefBut(block, BUTM, 1, "Hide Sensors", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 3, ""); + + uiBlockSetDirection(block, UI_TOP); + uiEndBlock(C, block); + + return block; +} + +static void do_controller_menu(bContext *C, void *arg, int event) +{ + SpaceLogic *slogic= (SpaceLogic *)CTX_wm_space_data(C); + ID **idar; + Object *ob; + bController *cont; + short count, a; + + idar= get_selected_and_linked_obs(C, &count, slogic->scaflag); + + for(a=0; a<count; a++) { + ob= (Object *)idar[a]; + if(event==0 || event==2) ob->scaflag |= OB_SHOWCONT; + else if(event==1) ob->scaflag &= ~OB_SHOWCONT; + } + + for(a=0; a<count; a++) { + ob= (Object *)idar[a]; + cont= ob->controllers.first; + while(cont) { + if(event==2) cont->flag |= CONT_SHOW; + else if(event==3) cont->flag &= ~CONT_SHOW; + cont= cont->next; + } + } + + if(idar) MEM_freeN(idar); +} + +static uiBlock *controller_menu(bContext *C, ARegion *ar, void *arg_unused) +{ + uiBlock *block; + int yco=0; + + block= uiBeginBlock(C, ar, "filemenu", UI_EMBOSSP); + uiBlockSetButmFunc(block, do_controller_menu, NULL); + + uiDefBut(block, BUTM, 1, "Show Objects", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, ""); + uiDefBut(block, BUTM, 1, "Hide Objects", 0,(short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, ""); + uiDefBut(block, SEPR, 0, "", 0, (short)(yco-=6), 160, 6, NULL, 0.0, 0.0, 0, 0, ""); + uiDefBut(block, BUTM, 1, "Show Controllers", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 2, 2, ""); + uiDefBut(block, BUTM, 1, "Hide Controllers", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 3, 3, ""); + + uiBlockSetDirection(block, UI_TOP); + uiEndBlock(C, block); + + return block; +} + +static void do_actuator_menu(bContext *C, void *arg, int event) +{ + SpaceLogic *slogic= (SpaceLogic *)CTX_wm_space_data(C); + ID **idar; + Object *ob; + bActuator *act; + short count, a; + + idar= get_selected_and_linked_obs(C, &count, slogic->scaflag); + + for(a=0; a<count; a++) { + ob= (Object *)idar[a]; + if(event==0 || event==2) ob->scaflag |= OB_SHOWACT; + else if(event==1) ob->scaflag &= ~OB_SHOWACT; + } + + for(a=0; a<count; a++) { + ob= (Object *)idar[a]; + act= ob->actuators.first; + while(act) { + if(event==2) act->flag |= ACT_SHOW; + else if(event==3) act->flag &= ~ACT_SHOW; + act= act->next; + } + } + + if(idar) MEM_freeN(idar); +} + +static uiBlock *actuator_menu(bContext *C, ARegion *ar, void *arg_unused) +{ + uiBlock *block; + int xco=0; + + block= uiBeginBlock(C, ar, "filemenu", UI_EMBOSSP); + uiBlockSetButmFunc(block, do_actuator_menu, NULL); + + uiDefBut(block, BUTM, 1, "Show Objects", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, ""); + uiDefBut(block, BUTM, 1, "Hide Objects", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, ""); + uiDefBut(block, SEPR, 0, "", 0, (short)(xco-=6), 160, 6, NULL, 0.0, 0.0, 0, 0, ""); + uiDefBut(block, BUTM, 1, "Show Actuators", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 2, ""); + uiDefBut(block, BUTM, 1, "Hide Actuators", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 3, ""); + + uiBlockSetDirection(block, UI_TOP); + uiEndBlock(C, block); + + return block; +} + + + +static void check_controller_state_mask(bContext *C, void *arg1_but, void *arg2_mask) +{ + unsigned int *cont_mask = arg2_mask; + uiBut *but = arg1_but; + + /* a controller is always in a single state */ + *cont_mask = (1<<but->retval); + but->retval = B_REDR; +} + +static int first_bit(unsigned int mask) +{ + int bit; + + for (bit=0; bit<32; bit++) { + if (mask & (1<<bit)) + return bit; + } + return -1; +} + +static uiBlock *controller_state_mask_menu(bContext *C, ARegion *ar, void *arg_cont) +{ + uiBlock *block; + uiBut *but; + bController *cont = arg_cont; + + short yco = 12, xco = 0, stbit, offset; + + block= uiBeginBlock(C, ar, "Controller state mask", UI_EMBOSS); + + /* use this for a fake extra empy space around the buttons */ + uiDefBut(block, LABEL, 0, "", -5, -5, 200, 34, NULL, 0, 0, 0, 0, ""); + + for (offset=0; offset<15; offset+=5) { + uiBlockBeginAlign(block); + for (stbit=0; stbit<5; stbit++) { + but = uiDefButBitI(block, TOG, (1<<(stbit+offset)), (stbit+offset), "", (short)(xco+12*stbit+13*offset), yco, 12, 12, (int *)&(cont->state_mask), 0, 0, 0, 0, ""); + uiButSetFunc(but, check_controller_state_mask, but, &(cont->state_mask)); + } + for (stbit=0; stbit<5; stbit++) { + but = uiDefButBitI(block, TOG, (1<<(stbit+offset+15)), (stbit+offset+15), "", (short)(xco+12*stbit+13*offset), yco-12, 12, 12, (int *)&(cont->state_mask), 0, 0, 0, 0, ""); + uiButSetFunc(but, check_controller_state_mask, but, &(cont->state_mask)); + } + } + uiBlockEndAlign(block); + + uiBlockSetDirection(block, UI_TOP); + uiEndBlock(C, block); + + return block; +} + +static void do_object_state_menu(bContext *C, void *arg, int event) +{ + Object *ob = arg; + + switch (event) { + case 0: + ob->state = 0x3FFFFFFF; + break; + case 1: + ob->state = ob->init_state; + if (!ob->state) + ob->state = 1; + break; + case 2: + ob->init_state = ob->state; + break; + } +} + +static uiBlock *object_state_mask_menu(bContext *C, ARegion *ar, void *arg_obj) +{ + uiBlock *block; + short xco = 0; + + block= uiBeginBlock(C, ar, "obstatemenu", UI_EMBOSSP); + uiBlockSetButmFunc(block, do_object_state_menu, arg_obj); + + uiDefBut(block, BUTM, 1, "Set all bits", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, ""); + uiDefBut(block, BUTM, 1, "Recall init state", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, ""); + uiDefBut(block, SEPR, 0, "", 0, (short)(xco-=6), 160, 6, NULL, 0.0, 0.0, 0, 0, ""); + uiDefBut(block, BUTM, 1, "Store init state", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 2, ""); + + uiBlockSetDirection(block, UI_TOP); + uiEndBlock(C, block); + + return block; +} + +static int is_sensor_linked(uiBlock *block, bSensor *sens) +{ + bController *cont; + int i, count; + + for (count=0, i=0; i<sens->totlinks; i++) { + cont = sens->links[i]; + if (uiFindInlink(block, cont) != NULL) + return 1; + } + return 0; +} + +/* never used, see CVS 1.134 for the code */ +/* static FreeCamera *new_freecamera(void) */ + +/* never used, see CVS 1.120 for the code */ +/* static uiBlock *freecamera_menu(void) */ + + +void logic_buttons(bContext *C, ARegion *ar) +{ + SpaceLogic *slogic= (SpaceLogic *)CTX_wm_space_data(C); + Object *ob= CTX_data_active_object(C); + ID **idar; + bSensor *sens; + bController *cont; + bActuator *act; + uiBlock *block; + uiBut *but; + int a, iact, stbit, offset; + short xco, yco, count, width, ycoo; + char name[32]; + /* pin is a bool used for actuator and sensor drawing with states + * pin so changing states dosnt hide the logic brick */ + char pin; + + if(ob==NULL) return; +// uiSetButLock(object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); + + sprintf(name, "buttonswin %p", ar); + block= uiBeginBlock(C, ar, name, UI_EMBOSS); + uiBlockSetHandleFunc(block, do_logic_buts, NULL); + + idar= get_selected_and_linked_obs(C, &count, slogic->scaflag); + + /* clean ACT_LINKED and ACT_VISIBLE of all potentially visible actuators so that + we can determine which is actually linked/visible */ + for(a=0; a<count; a++) { + ob= (Object *)idar[a]; + act= ob->actuators.first; + while(act) { + act->flag &= ~(ACT_LINKED|ACT_VISIBLE); + act = act->next; + } + /* same for sensors */ + sens= ob->sensors.first; + while(sens) { + sens->flag &= ~(SENS_VISIBLE); + sens = sens->next; + } + } + + /* start with the controller because we need to know which one is visible */ + /* ******************************* */ + xco= 500; yco= 170; width= 300; + + uiDefPulldownBut(block, controller_menu, NULL, "Controllers", xco-10, yco+35, 100, 19, ""); + + uiBlockBeginAlign(block); + uiDefButBitS(block, TOG, BUTS_CONT_SEL, B_REDR, "Sel", xco+110, yco+35, (width-100)/3, 19, &slogic->scaflag, 0, 0, 0, 0, "Show all selected Objects"); + uiDefButBitS(block, TOG, BUTS_CONT_ACT, B_REDR, "Act", xco+110+(width-100)/3, yco+35, (width-100)/3, 19, &slogic->scaflag, 0, 0, 0, 0, "Show active Object"); + uiDefButBitS(block, TOG, BUTS_CONT_LINK, B_REDR, "Link", xco+110+2*(width-100)/3, yco+35, (width-100)/3, 19, &slogic->scaflag, 0, 0, 0, 0, "Show linked Objects to Sensor/Actuator"); + uiBlockEndAlign(block); + + ob= CTX_data_active_object(C); + + for(a=0; a<count; a++) { + unsigned int controller_state_mask = 0; /* store a bitmask for states that are used */ + + ob= (Object *)idar[a]; +// uiClearButLock(); +// uiSetButLock(object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); + if( (ob->scavisflag & OB_VIS_CONT) == 0) continue; + + /* presume it is only objects for now */ + uiBlockBeginAlign(block); +// if(ob->controllers.first) uiSetCurFont(block, UI_HELVB); + uiDefButBitS(block, TOG, OB_SHOWCONT, B_REDR, ob->id.name+2,(short)(xco-10), yco, (short)(width-30), 19, &ob->scaflag, 0, 0, 0, 0, "Active Object name"); +// if(ob->controllers.first) uiSetCurFont(block, UI_HELV); + uiDefButBitS(block, TOG, OB_ADDCONT, B_ADD_CONT, "Add",(short)(xco+width-40), yco, 50, 19, &ob->scaflag, 0, 0, 0, 0, "Add a new Controller"); + uiBlockEndAlign(block); + yco-=20; + + /* mark all actuators linked to these controllers */ + /* note that some of these actuators could be from objects that are not in the display list. + It's ok because those actuators will not be displayed here */ + cont= ob->controllers.first; + while(cont) { + for (iact=0; iact<cont->totlinks; iact++) { + act = cont->links[iact]; + if (act) + act->flag |= ACT_LINKED; + } + controller_state_mask |= cont->state_mask; + cont = cont->next; + } + + if(ob->scaflag & OB_SHOWCONT) { + + /* first show the state */ + uiDefBlockBut(block, object_state_mask_menu, ob, "State", (short)(xco-10), (short)(yco-10), 36, 19, "Object state menu: store and retrieve initial state"); + + if (!ob->state) + ob->state = 1; + for (offset=0; offset<15; offset+=5) { + uiBlockBeginAlign(block); + for (stbit=0; stbit<5; stbit++) { + but = uiDefButBitI(block, controller_state_mask&(1<<(stbit+offset)) ? BUT_TOGDUAL:TOG, 1<<(stbit+offset), stbit+offset, "", (short)(xco+31+12*stbit+13*offset), yco, 12, 12, (int *)&(ob->state), 0, 0, 0, 0, get_state_name(ob, (short)(stbit+offset))); + uiButSetFunc(but, check_state_mask, but, &(ob->state)); + } + for (stbit=0; stbit<5; stbit++) { + but = uiDefButBitI(block, controller_state_mask&(1<<(stbit+offset+15)) ? BUT_TOGDUAL:TOG, 1<<(stbit+offset+15), stbit+offset+15, "", (short)(xco+31+12*stbit+13*offset), yco-12, 12, 12, (int *)&(ob->state), 0, 0, 0, 0, get_state_name(ob, (short)(stbit+offset+15))); + uiButSetFunc(but, check_state_mask, but, &(ob->state)); + } + } + uiBlockBeginAlign(block); + uiDefButBitS(block, TOG, OB_SETSTBIT, B_SET_STATE_BIT, "All",(short)(xco+226), yco-10, 22, 19, &ob->scaflag, 0, 0, 0, 0, "Set all state bits"); + uiDefButBitS(block, TOG, OB_INITSTBIT, B_INIT_STATE_BIT, "Ini",(short)(xco+248), yco-10, 22, 19, &ob->scaflag, 0, 0, 0, 0, "Set the initial state"); + uiDefButBitS(block, TOG, OB_DEBUGSTATE, 0, "D",(short)(xco+270), yco-10, 15, 19, &ob->scaflag, 0, 0, 0, 0, "Print state debug info"); + uiBlockEndAlign(block); + + yco-=35; + + /* display only the controllers that match the current state */ + offset = 0; + for (stbit=0; stbit<32; stbit++) { + if (!(ob->state & (1<<stbit))) + continue; + /* add a separation between controllers of different states */ + if (offset) { + offset = 0; + yco -= 6; + } + cont= ob->controllers.first; + while(cont) { + if (cont->state_mask & (1<<stbit)) { + /* this controller is visible, mark all its actuator */ + for (iact=0; iact<cont->totlinks; iact++) { + act = cont->links[iact]; + if (act) + act->flag |= ACT_VISIBLE; + } + uiDefIconButBitS(block, TOG, CONT_DEL, B_DEL_CONT, ICON_X, xco, yco, 22, 19, &cont->flag, 0, 0, 0, 0, "Delete Controller"); + uiDefIconButBitS(block, ICONTOG, CONT_SHOW, B_REDR, ICON_RIGHTARROW, (short)(xco+width-22), yco, 22, 19, &cont->flag, 0, 0, 0, 0, "Controller settings"); + uiDefIconButBitS(block, TOG, CONT_PRIO, B_REDR, ICON_BOOKMARKS, (short)(xco+width-66), yco, 22, 19, &cont->flag, 0, 0, 0, 0, "Mark controller for execution before all non-marked controllers (good for startup scripts)"); + + sprintf(name, "%d", first_bit(cont->state_mask)+1); + uiDefBlockBut(block, controller_state_mask_menu, cont, name, (short)(xco+width-44), yco, 22, 19, "Set controller state index (from 1 to 30)"); + + if(cont->flag & CONT_SHOW) { + cont->otype= cont->type; + uiDefButS(block, MENU, B_CHANGE_CONT, controller_pup(),(short)(xco+22), yco, 70, 19, &cont->type, 0, 0, 0, 0, "Controller type"); + but= uiDefBut(block, TEX, 1, "", (short)(xco+92), yco, (short)(width-158), 19, cont->name, 0, 31, 0, 0, "Controller name"); + uiButSetFunc(but, make_unique_prop_names_cb, cont->name, (void*) 0); + + ycoo= yco; + yco= draw_controllerbuttons(cont, block, xco, yco, width); + if(yco-6 < ycoo) ycoo= (yco+ycoo-20)/2; + } + else { + cpack(0x999999); + glRecti(xco+22, yco, xco+width-22,yco+19); + but= uiDefBut(block, LABEL, 0, controller_name(cont->type), (short)(xco+22), yco, 70, 19, cont, 0, 0, 0, 0, "Controller type"); + uiButSetFunc(but, sca_move_controller, cont, NULL); + but= uiDefBut(block, LABEL, 0, cont->name,(short)(xco+92), yco,(short)(width-158), 19, cont, 0, 0, 0, 0, "Controller name"); + uiButSetFunc(but, sca_move_controller, cont, NULL); + ycoo= yco; + } + + but= uiDefIconBut(block, LINK, 0, ICON_LINK, (short)(xco+width), ycoo, 19, 19, NULL, 0, 0, 0, 0, ""); + uiSetButLink(but, NULL, (void ***)&(cont->links), &cont->totlinks, LINK_CONTROLLER, LINK_ACTUATOR); + + uiDefIconBut(block, INLINK, 0, ICON_INLINK,(short)(xco-19), ycoo, 19, 19, cont, LINK_CONTROLLER, 0, 0, 0, ""); + /* offset is >0 if at least one controller was displayed */ + offset++; + yco-=20; + } + cont= cont->next; + } + + } + yco-= 6; + } + } + + /* ******************************* */ + xco= 10; yco= 170; width= 400; + + uiDefPulldownBut(block, sensor_menu, NULL, "Sensors", xco-10, yco+35, 70, 19, ""); + + uiBlockBeginAlign(block); + uiDefButBitS(block, TOG, BUTS_SENS_SEL, B_REDR, "Sel", xco+80, yco+35, (width-70)/4, 19, &slogic->scaflag, 0, 0, 0, 0, "Show all selected Objects"); + uiDefButBitS(block, TOG, BUTS_SENS_ACT, B_REDR, "Act", xco+80+(width-70)/4, yco+35, (width-70)/4, 19, &slogic->scaflag, 0, 0, 0, 0, "Show active Object"); + uiDefButBitS(block, TOG, BUTS_SENS_LINK, B_REDR, "Link", xco+80+2*(width-70)/4, yco+35, (width-70)/4, 19, &slogic->scaflag, 0, 0, 0, 0, "Show linked Objects to Controller"); + uiDefButBitS(block, TOG, BUTS_SENS_STATE, B_REDR, "State", xco+80+3*(width-70)/4, yco+35, (width-70)/4, 19, &slogic->scaflag, 0, 0, 0, 0, "Show only sensors connected to active states"); + uiBlockEndAlign(block); + + for(a=0; a<count; a++) { + ob= (Object *)idar[a]; +// uiClearButLock(); +// uiSetButLock(object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); + + if( (ob->scavisflag & OB_VIS_SENS) == 0) continue; + + /* presume it is only objects for now */ + uiBlockBeginAlign(block); +// if(ob->sensors.first) uiSetCurFont(block, UI_HELVB); + uiDefButBitS(block, TOG, OB_SHOWSENS, B_REDR, ob->id.name+2,(short)(xco-10), yco, (short)(width-30), 19, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide sensors"); +// if(ob->sensors.first) uiSetCurFont(block, UI_HELV); + uiDefButBitS(block, TOG, OB_ADDSENS, B_ADD_SENS, "Add",(short)(xco+width-40), yco, 50, 19, &ob->scaflag, 0, 0, 0, 0, "Add a new Sensor"); + uiBlockEndAlign(block); + yco-=20; + + if(ob->scaflag & OB_SHOWSENS) { + + sens= ob->sensors.first; + while(sens) { + if (!(slogic->scaflag & BUTS_SENS_STATE) || + (sens->totlinks == 0) || /* always display sensor without links so that is can be edited */ + (sens->flag & SENS_PIN && slogic->scaflag & BUTS_SENS_STATE) || /* states can hide some sensors, pinned sensors ignore the visible state */ + (is_sensor_linked(block, sens)) + ) { + /* should we draw the pin? - for now always draw when there is a state */ + pin = (slogic->scaflag & BUTS_SENS_STATE && (sens->flag & SENS_SHOW || sens->flag & SENS_PIN)) ? 1:0 ; + + sens->flag |= SENS_VISIBLE; + uiDefIconButBitS(block, TOG, SENS_DEL, B_DEL_SENS, ICON_X, xco, yco, 22, 19, &sens->flag, 0, 0, 0, 0, "Delete Sensor"); + if (pin) + uiDefIconButBitS(block, ICONTOG, SENS_PIN, B_REDR, ICON_PINNED, (short)(xco+width-44), yco, 22, 19, &sens->flag, 0, 0, 0, 0, "Display when not linked to a visible states controller"); + + uiDefIconButBitS(block, ICONTOG, SENS_SHOW, B_REDR, ICON_RIGHTARROW, (short)(xco+width-22), yco, 22, 19, &sens->flag, 0, 0, 0, 0, "Sensor settings"); + + ycoo= yco; + if(sens->flag & SENS_SHOW) + { + uiDefButS(block, MENU, B_CHANGE_SENS, sensor_pup(), (short)(xco+22), yco, 80, 19, &sens->type, 0, 0, 0, 0, "Sensor type"); + but= uiDefBut(block, TEX, 1, "", (short)(xco+102), yco, (short)(width-(pin?146:124)), 19, sens->name, 0, 31, 0, 0, "Sensor name"); + uiButSetFunc(but, make_unique_prop_names_cb, sens->name, (void*) 0); + + sens->otype= sens->type; + yco= draw_sensorbuttons(sens, block, xco, yco, width,ob->id.name); + if(yco-6 < ycoo) ycoo= (yco+ycoo-20)/2; + } + else { + set_col_sensor(sens->type, 1); + glRecti(xco+22, yco, xco+width-22,yco+19); + but= uiDefBut(block, LABEL, 0, sensor_name(sens->type), (short)(xco+22), yco, 80, 19, sens, 0, 0, 0, 0, ""); + uiButSetFunc(but, sca_move_sensor, sens, NULL); + but= uiDefBut(block, LABEL, 0, sens->name, (short)(xco+102), yco, (short)(width-(pin?146:124)), 19, sens, 0, 31, 0, 0, ""); + uiButSetFunc(but, sca_move_sensor, sens, NULL); + } + + but= uiDefIconBut(block, LINK, 0, ICON_LINK, (short)(xco+width), ycoo, 19, 19, NULL, 0, 0, 0, 0, ""); + uiSetButLink(but, NULL, (void ***)&(sens->links), &sens->totlinks, LINK_SENSOR, LINK_CONTROLLER); + + yco-=20; + } + sens= sens->next; + } + yco-= 6; + } + } + + /* ******************************* */ + xco= 900; yco= 170; width= 400; + + uiDefPulldownBut(block, actuator_menu, NULL, "Actuators", xco-10, yco+35, 90, 19, ""); + + uiBlockBeginAlign(block); + uiDefButBitS(block, TOG, BUTS_ACT_SEL, B_REDR, "Sel", xco+110, yco+35, (width-100)/4, 19, &slogic->scaflag, 0, 0, 0, 0, "Show all selected Objects"); + uiDefButBitS(block, TOG, BUTS_ACT_ACT, B_REDR, "Act", xco+110+(width-100)/4, yco+35, (width-100)/4, 19, &slogic->scaflag, 0, 0, 0, 0, "Show active Object"); + uiDefButBitS(block, TOG, BUTS_ACT_LINK, B_REDR, "Link", xco+110+2*(width-100)/4, yco+35, (width-100)/4, 19, &slogic->scaflag, 0, 0, 0, 0, "Show linked Objects to Controller"); + uiDefButBitS(block, TOG, BUTS_ACT_STATE, B_REDR, "State", xco+110+3*(width-100)/4, yco+35, (width-100)/4, 19, &slogic->scaflag, 0, 0, 0, 0, "Show only actuators connected to active states"); + uiBlockEndAlign(block); + for(a=0; a<count; a++) { + ob= (Object *)idar[a]; +// uiClearButLock(); +// uiSetButLock(object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); + if( (ob->scavisflag & OB_VIS_ACT) == 0) continue; + + /* presume it is only objects for now */ + uiBlockBeginAlign(block); +// if(ob->actuators.first) uiSetCurFont(block, UI_HELVB); + uiDefButBitS(block, TOG, OB_SHOWACT, B_REDR, ob->id.name+2,(short)(xco-10), yco,(short)(width-30), 19, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide actuators"); +// if(ob->actuators.first) uiSetCurFont(block, UI_HELV); + uiDefButBitS(block, TOG, OB_ADDACT, B_ADD_ACT, "Add",(short)(xco+width-40), yco, 50, 19, &ob->scaflag, 0, 0, 0, 0, "Add a new Actuator"); + uiBlockEndAlign(block); + yco-=20; + + if(ob->scaflag & OB_SHOWACT) { + + act= ob->actuators.first; + while(act) { + if (!(slogic->scaflag & BUTS_ACT_STATE) || + !(act->flag & ACT_LINKED) || /* always display actuators without links so that is can be edited */ + (act->flag & ACT_VISIBLE) || /* this actuator has visible connection, display it */ + (act->flag & ACT_PIN && slogic->scaflag & BUTS_ACT_STATE)) { + + pin = (slogic->scaflag & BUTS_ACT_STATE && (act->flag & SENS_SHOW || act->flag & SENS_PIN)) ? 1:0 ; + + act->flag |= ACT_VISIBLE; /* mark the actuator as visible to help implementing the up/down action */ + uiDefIconButBitS(block, TOG, ACT_DEL, B_DEL_ACT, ICON_X, xco, yco, 22, 19, &act->flag, 0, 0, 0, 0, "Delete Actuator"); + if (pin) + uiDefIconButBitS(block, ICONTOG, ACT_PIN, B_REDR, ICON_PINNED, (short)(xco+width-44), yco, 22, 19, &act->flag, 0, 0, 0, 0, "Display when not linked to a visible states controller"); + uiDefIconButBitS(block, ICONTOG, ACT_SHOW, B_REDR, ICON_RIGHTARROW, (short)(xco+width-22), yco, 22, 19, &act->flag, 0, 0, 0, 0, "Display the actuator"); + + if(act->flag & ACT_SHOW) { + act->otype= act->type; + uiDefButS(block, MENU, B_CHANGE_ACT, actuator_pup(ob), (short)(xco+22), yco, 90, 19, &act->type, 0, 0, 0, 0, "Actuator type"); + but= uiDefBut(block, TEX, 1, "", (short)(xco+112), yco, (short)(width-(pin?156:134)), 19, act->name, 0, 31, 0, 0, "Actuator name"); + uiButSetFunc(but, make_unique_prop_names_cb, act->name, (void*) 0); + + ycoo= yco; + yco= draw_actuatorbuttons(ob, act, block, xco, yco, width); + if(yco-6 < ycoo) ycoo= (yco+ycoo-20)/2; + } + else { + set_col_actuator(act->type, 1); + glRecti((short)(xco+22), yco, (short)(xco+width-22),(short)(yco+19)); + but= uiDefBut(block, LABEL, 0, actuator_name(act->type), (short)(xco+22), yco, 90, 19, act, 0, 0, 0, 0, "Actuator type"); + uiButSetFunc(but, sca_move_actuator, act, NULL); + but= uiDefBut(block, LABEL, 0, act->name, (short)(xco+112), yco, (short)(width-(pin?156:134)), 19, act, 0, 0, 0, 0, "Actuator name"); + uiButSetFunc(but, sca_move_actuator, act, NULL); + ycoo= yco; + } + + uiDefIconBut(block, INLINK, 0, ICON_INLINK,(short)(xco-19), ycoo, 19, 19, act, LINK_ACTUATOR, 0, 0, 0, ""); + + yco-=20; + } + act= act->next; + } + yco-= 6; + } + } + + uiComposeLinks(block); + + uiEndBlock(C, block); + uiDrawBlock(C, block); + + if(idar) MEM_freeN(idar); +} + + + + + + diff --git a/source/blender/editors/space_logic/space_logic.c b/source/blender/editors/space_logic/space_logic.c new file mode 100644 index 00000000000..a593cfd1e7f --- /dev/null +++ b/source/blender/editors/space_logic/space_logic.c @@ -0,0 +1,369 @@ +/** + * $Id: + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2009 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include <string.h> +#include <stdio.h> + +#include "DNA_image_types.h" +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" +#include "DNA_object_types.h" +#include "DNA_space_types.h" +#include "DNA_scene_types.h" +#include "DNA_screen_types.h" + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" +#include "BLI_arithb.h" + +#include "BKE_context.h" +#include "BKE_screen.h" +#include "BKE_utildefines.h" + +#include "ED_space_api.h" +#include "ED_screen.h" + +#include "BIF_gl.h" +#include "BIF_glutil.h" + +#include "RNA_access.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "UI_interface.h" +#include "UI_resources.h" +#include "UI_view2d.h" + +#include "logic_intern.h" + +/* ******************** manage regions ********************* */ + +ARegion *logic_has_buttons_region(ScrArea *sa) +{ + ARegion *ar, *arnew; + + for(ar= sa->regionbase.first; ar; ar= ar->next) + if(ar->regiontype==RGN_TYPE_UI) + return ar; + + /* add subdiv level; after header */ + for(ar= sa->regionbase.first; ar; ar= ar->next) + if(ar->regiontype==RGN_TYPE_HEADER) + break; + + /* is error! */ + if(ar==NULL) return NULL; + + arnew= MEM_callocN(sizeof(ARegion), "buttons for image"); + + BLI_insertlinkafter(&sa->regionbase, ar, arnew); + arnew->regiontype= RGN_TYPE_UI; + arnew->alignment= RGN_ALIGN_LEFT; + + arnew->flag = RGN_FLAG_HIDDEN; + + return arnew; +} + +/* ******************** default callbacks for image space ***************** */ + +static SpaceLink *logic_new(const bContext *C) +{ + ARegion *ar; + SpaceLogic *slogic; + + slogic= MEM_callocN(sizeof(SpaceLogic), "initlogic"); + slogic->spacetype= SPACE_LOGIC; + + /* header */ + ar= MEM_callocN(sizeof(ARegion), "header for logic"); + + BLI_addtail(&slogic->regionbase, ar); + ar->regiontype= RGN_TYPE_HEADER; + ar->alignment= RGN_ALIGN_BOTTOM; + + /* buttons/list view */ + ar= MEM_callocN(sizeof(ARegion), "buttons for logic"); + + BLI_addtail(&slogic->regionbase, ar); + ar->regiontype= RGN_TYPE_UI; + ar->alignment= RGN_ALIGN_LEFT; + + /* main area */ + ar= MEM_callocN(sizeof(ARegion), "main area for logic"); + + BLI_addtail(&slogic->regionbase, ar); + ar->regiontype= RGN_TYPE_WINDOW; + + ar->v2d.tot.xmin= 0.0f; + ar->v2d.tot.ymin= 0.0f; + ar->v2d.tot.xmax= 1280; + ar->v2d.tot.ymax= 240.0f; + + ar->v2d.cur.xmin= 0.0f; + ar->v2d.cur.ymin= 0.0f; + ar->v2d.cur.xmax= 1280.0f; + ar->v2d.cur.ymax= 240.0f; + + ar->v2d.min[0]= 1.0f; + ar->v2d.min[1]= 1.0f; + + ar->v2d.max[0]= 32000.0f; + ar->v2d.max[1]= 32000.0f; + + ar->v2d.minzoom= 0.5f; + ar->v2d.maxzoom= 1.21f; + + ar->v2d.scroll= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM); + ar->v2d.keepzoom= V2D_KEEPZOOM|V2D_KEEPASPECT; + ar->v2d.keeptot= 0; + + + return (SpaceLink *)slogic; +} + +/* not spacelink itself */ +static void logic_free(SpaceLink *sl) +{ +// Spacelogic *slogic= (SpaceLogic*) sl; + +// if(slogic->gpd) +// XXX free_gpencil_data(slogic->gpd); + +} + + +/* spacetype; init callback */ +static void logic_init(struct wmWindowManager *wm, ScrArea *sa) +{ + +} + +static SpaceLink *logic_duplicate(SpaceLink *sl) +{ + SpaceLogic *slogicn= MEM_dupallocN(sl); + + return (SpaceLink *)slogicn; +} + +void logic_operatortypes(void) +{ + WM_operatortype_append(LOGIC_OT_properties); + +} + +void logic_keymap(struct wmWindowManager *wm) +{ + ListBase *keymap= WM_keymap_listbase(wm, "Logic Generic", SPACE_LOGIC, 0); + + WM_keymap_add_item(keymap, "LOGIC_OT_properties", NKEY, KM_PRESS, 0, 0); +} + +static void logic_refresh(const bContext *C, ScrArea *sa) +{ +// SpaceLogic *slogic= (SpaceImage*)CTX_wm_space_data(C); +// Object *obedit= CTX_data_edit_object(C); + +} + +static void logic_listener(ARegion *ar, wmNotifier *wmn) +{ + /* context changes */ + switch(wmn->category) { + case NC_SCENE: + switch(wmn->data) { + case ND_FRAME: + ED_region_tag_redraw(ar); + break; + + case ND_OB_ACTIVE: + ED_region_tag_redraw(ar); + break; + } + break; + case NC_OBJECT: + break; + } +} + +static int logic_context(const bContext *C, const char *member, bContextDataResult *result) +{ +// SpaceLogic *slogic= (SpaceLogic*)CTX_wm_space_data(C); + + + return 0; +} + +/************************** main region ***************************/ + + +/* add handlers, stuff you only do once or on area/region changes */ +static void logic_main_area_init(wmWindowManager *wm, ARegion *ar) +{ + ListBase *keymap; + + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); + + /* own keymaps */ + keymap= WM_keymap_listbase(wm, "Logic Generic", SPACE_LOGIC, 0); + WM_event_add_keymap_handler(&ar->handlers, keymap); +} + +static void logic_main_area_draw(const bContext *C, ARegion *ar) +{ + /* draw entirely, view changes should be handled here */ +// SpaceLogic *slogic= (SpaceLogic*)CTX_wm_space_data(C); + View2D *v2d= &ar->v2d; + View2DScrollers *scrollers; + float col[3]; + + /* clear and setup matrix */ + UI_GetThemeColor3fv(TH_BACK, col); + glClearColor(col[0], col[1], col[2], 0.0); + glClear(GL_COLOR_BUFFER_BIT); + + UI_view2d_view_ortho(C, v2d); + + logic_buttons((bContext *)C, ar); + + /* reset view matrix */ + UI_view2d_view_restore(C); + + /* scrollers */ + scrollers= UI_view2d_scrollers_calc(C, v2d, 10, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + UI_view2d_scrollers_draw(C, v2d, scrollers); + UI_view2d_scrollers_free(scrollers); + +} + + +/* *********************** buttons region ************************ */ + +/* add handlers, stuff you only do once or on area/region changes */ +static void logic_buttons_area_init(wmWindowManager *wm, ARegion *ar) +{ + ListBase *keymap; + + ED_region_panels_init(wm, ar); + + keymap= WM_keymap_listbase(wm, "Logic Generic", SPACE_LOGIC, 0); + WM_event_add_keymap_handler(&ar->handlers, keymap); +} + +static void logic_buttons_area_draw(const bContext *C, ARegion *ar) +{ + ED_region_panels(C, ar, 1, NULL); +} + +/************************* header region **************************/ + +/* add handlers, stuff you only do once or on area/region changes */ +static void logic_header_area_init(wmWindowManager *wm, ARegion *ar) +{ + ED_region_header_init(ar); +} + +static void logic_header_area_draw(const bContext *C, ARegion *ar) +{ + float col[3]; + + /* clear */ + if(ED_screen_area_active(C)) + UI_GetThemeColor3fv(TH_HEADER, col); + else + UI_GetThemeColor3fv(TH_HEADERDESEL, col); + + glClearColor(col[0], col[1], col[2], 0.0); + glClear(GL_COLOR_BUFFER_BIT); + + /* set view2d view matrix for scrolling (without scrollers) */ + UI_view2d_view_ortho(C, &ar->v2d); + + logic_header_buttons(C, ar); + + /* restore view matrix? */ + UI_view2d_view_restore(C); +} + +/**************************** spacetype *****************************/ + +/* only called once, from space/spacetypes.c */ +void ED_spacetype_logic(void) +{ + SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype logic"); + ARegionType *art; + + st->spaceid= SPACE_LOGIC; + + st->new= logic_new; + st->free= logic_free; + st->init= logic_init; + st->duplicate= logic_duplicate; + st->operatortypes= logic_operatortypes; + st->keymap= logic_keymap; + st->refresh= logic_refresh; + st->context= logic_context; + + /* regions: main window */ + art= MEM_callocN(sizeof(ARegionType), "spacetype logic region"); + art->regionid = RGN_TYPE_WINDOW; + art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES|ED_KEYMAP_VIEW2D; + art->init= logic_main_area_init; + art->draw= logic_main_area_draw; + art->listener= logic_listener; + + BLI_addhead(&st->regiontypes, art); + + /* regions: listview/buttons */ + art= MEM_callocN(sizeof(ARegionType), "spacetype logic region"); + art->regionid = RGN_TYPE_UI; + art->minsizex= 220; // XXX + art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES; + art->listener= logic_listener; + art->init= logic_buttons_area_init; + art->draw= logic_buttons_area_draw; + BLI_addhead(&st->regiontypes, art); + + logic_buttons_register(art); + + /* regions: header */ + art= MEM_callocN(sizeof(ARegionType), "spacetype logic region"); + art->regionid = RGN_TYPE_HEADER; + art->minsizey= HEADERY; + art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES; + art->init= logic_header_area_init; + art->draw= logic_header_area_draw; + + BLI_addhead(&st->regiontypes, art); + + BKE_spacetype_register(st); +} + + diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c index 3c37793e8d6..6746c21ebcf 100644 --- a/source/blender/editors/space_node/node_select.c +++ b/source/blender/editors/space_node/node_select.c @@ -177,8 +177,8 @@ static int node_extend_select_invoke(bContext *C, wmOperator *op, wmEvent *event /* operators */ static EnumPropertyItem prop_select_items[] = { - {NODE_SELECT_MOUSE, "NORMAL", "Normal Select", "Select using the mouse"}, - {0, NULL, NULL, NULL}}; + {NODE_SELECT_MOUSE, "NORMAL", 0, "Normal Select", "Select using the mouse"}, + {0, NULL, 0, NULL, NULL}}; void NODE_OT_select_extend(wmOperatorType *ot) { @@ -225,9 +225,9 @@ void NODE_OT_select(wmOperatorType *ot) /* ****** Border Select ****** */ static EnumPropertyItem prop_select_types[] = { - {NODE_EXCLUSIVE, "EXCLUSIVE", "Exclusive", ""}, /* right mouse */ - {NODE_EXTEND, "EXTEND", "Extend", ""}, /* left mouse */ - {0, NULL, NULL, NULL} + {NODE_EXCLUSIVE, "EXCLUSIVE", 0, "Exclusive", ""}, /* right mouse */ + {NODE_EXTEND, "EXTEND", 0, "Extend", ""}, /* left mouse */ + {0, NULL, 0, NULL, NULL} }; static int node_borderselect_exec(bContext *C, wmOperator *op) diff --git a/source/blender/editors/space_script/script_edit.c b/source/blender/editors/space_script/script_edit.c index 797302a8652..88b8dccc6c9 100644 --- a/source/blender/editors/space_script/script_edit.c +++ b/source/blender/editors/space_script/script_edit.c @@ -62,15 +62,17 @@ static int run_pyfile_exec(bContext *C, wmOperator *op) { ARegion *ar= CTX_wm_region(C); + char filename[512]; RNA_string_get(op->ptr, "filename", filename); #ifndef DISABLE_PYTHON - BPY_run_python_script(C, filename, NULL); + if(BPY_run_python_script(C, filename, NULL, op->reports)) { + ED_region_tag_redraw(ar); + return OPERATOR_FINISHED; + } #endif - ED_region_tag_redraw(ar); - - return OPERATOR_FINISHED; + return OPERATOR_CANCELLED; /* FAIL */ } void SCRIPT_OT_python_file_run(wmOperatorType *ot) diff --git a/source/blender/editors/space_script/space_script.c b/source/blender/editors/space_script/space_script.c index 4c17ed16475..99233cc5020 100644 --- a/source/blender/editors/space_script/space_script.c +++ b/source/blender/editors/space_script/space_script.c @@ -175,29 +175,12 @@ static void script_main_area_draw(const bContext *C, ARegion *ar) /* add handlers, stuff you only do once or on area/region changes */ static void script_header_area_init(wmWindowManager *wm, ARegion *ar) { - UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); + ED_region_header_init(ar); } static void script_header_area_draw(const bContext *C, ARegion *ar) { - float col[3]; - - /* clear */ - if(ED_screen_area_active(C)) - UI_GetThemeColor3fv(TH_HEADER, col); - else - UI_GetThemeColor3fv(TH_HEADERDESEL, col); - - glClearColor(col[0], col[1], col[2], 0.0); - glClear(GL_COLOR_BUFFER_BIT); - - /* set view2d view matrix for scrolling (without scrollers) */ - UI_view2d_view_ortho(C, &ar->v2d); - - script_header_buttons(C, ar); - - /* restore view matrix? */ - UI_view2d_view_restore(C); + ED_region_header(C, ar); } static void script_main_area_listener(ARegion *ar, wmNotifier *wmn) diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index bd31d8d86ff..3b90039335e 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -741,7 +741,8 @@ static void draw_image_seq(Scene *scene, ARegion *ar, SpaceSeq *sseq) static int recursive= 0; float zoom; float zoomx, zoomy; - int render_size = 0; + float render_size = 0.0; + float proxy_size = 100.0; glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); @@ -749,6 +750,8 @@ static void draw_image_seq(Scene *scene, ARegion *ar, SpaceSeq *sseq) render_size = sseq->render_size; if (render_size == 0) { render_size = scene->r.size; + } else { + proxy_size = render_size; } if (render_size < 0) { return; @@ -767,13 +770,13 @@ static void draw_image_seq(Scene *scene, ARegion *ar, SpaceSeq *sseq) else { recursive= 1; if (special_seq_update) { - ibuf= give_ibuf_seq_direct(scene, rectx, recty, (scene->r.cfra), render_size, special_seq_update); + ibuf= give_ibuf_seq_direct(scene, rectx, recty, (scene->r.cfra), proxy_size, special_seq_update); } else if (!U.prefetchframes) { // XXX || (G.f & G_PLAYANIM) == 0) { - ibuf= (ImBuf *)give_ibuf_seq(scene, rectx, recty, (scene->r.cfra), sseq->chanshown, render_size); + ibuf= (ImBuf *)give_ibuf_seq(scene, rectx, recty, (scene->r.cfra), sseq->chanshown, proxy_size); } else { - ibuf= (ImBuf *)give_ibuf_seq_threaded(scene, rectx, recty, (scene->r.cfra), sseq->chanshown, render_size); + ibuf= (ImBuf *)give_ibuf_seq_threaded(scene, rectx, recty, (scene->r.cfra), sseq->chanshown, proxy_size); } recursive= 0; @@ -790,8 +793,8 @@ static void draw_image_seq(Scene *scene, ARegion *ar, SpaceSeq *sseq) if(ibuf->rect==NULL && ibuf->rect_float == NULL) return; - - switch(sseq->mainb != SEQ_DRAW_SEQUENCE) { + + switch(sseq->mainb) { case SEQ_DRAW_IMG_IMBUF: if (sseq->zebra != 0) { ibuf = make_zebra_view_from_ibuf(ibuf, sseq->zebra); @@ -824,7 +827,7 @@ static void draw_image_seq(Scene *scene, ARegion *ar, SpaceSeq *sseq) zoom= SEQ_ZOOM_FAC(sseq->zoom); if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) { - zoom /= render_size / 100.0; + zoom /= proxy_size / 100.0; zoomx = zoom * ((float)scene->r.xasp / (float)scene->r.yasp); zoomy = zoom; } else { @@ -960,8 +963,11 @@ void drawprefetchseqspace(Scene *scene, ARegion *ar, SpaceSeq *sseq) { int rectx, recty; int render_size = sseq->render_size; + int proxy_size = 100.0; if (render_size == 0) { render_size = scene->r.size; + } else { + proxy_size = render_size; } if (render_size < 0) { return; @@ -973,7 +979,7 @@ void drawprefetchseqspace(Scene *scene, ARegion *ar, SpaceSeq *sseq) if(sseq->mainb != SEQ_DRAW_SEQUENCE) { give_ibuf_prefetch_request( rectx, recty, (scene->r.cfra), sseq->chanshown, - render_size); + proxy_size); } } diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 20ad1b61981..7cd81faede1 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -105,35 +105,35 @@ static int okee() {return 0;} /* XXX */ /* RNA Enums, used in multiple files */ EnumPropertyItem sequencer_prop_effect_types[] = { - {SEQ_CROSS, "CROSS", "Crossfade", "Crossfade effect strip type"}, - {SEQ_ADD, "ADD", "Add", "Add effect strip type"}, - {SEQ_SUB, "SUBTRACT", "Subtract", "Subtract effect strip type"}, - {SEQ_ALPHAOVER, "ALPHA_OVER", "Alpha Over", "Alpha Over effect strip type"}, - {SEQ_ALPHAUNDER, "ALPHA_UNDER", "Alpha Under", "Alpha Under effect strip type"}, - {SEQ_GAMCROSS, "GAMMA_CROSS", "Gamma Cross", "Gamma Cross effect strip type"}, - {SEQ_MUL, "MULTIPLY", "Multiply", "Multiply effect strip type"}, - {SEQ_OVERDROP, "OVER_DROP", "Alpha Over Drop", "Alpha Over Drop effect strip type"}, - {SEQ_PLUGIN, "PLUGIN", "Plugin", "Plugin effect strip type"}, - {SEQ_WIPE, "WIPE", "Wipe", "Wipe effect strip type"}, - {SEQ_GLOW, "GLOW", "Glow", "Glow effect strip type"}, - {SEQ_TRANSFORM, "TRANSFORM", "Transform", "Transform effect strip type"}, - {SEQ_COLOR, "COLOR", "Color", "Color effect strip type"}, - {SEQ_SPEED, "SPEED", "Speed", "Color effect strip type"}, - {0, NULL, NULL, NULL} + {SEQ_CROSS, "CROSS", 0, "Crossfade", "Crossfade effect strip type"}, + {SEQ_ADD, "ADD", 0, "Add", "Add effect strip type"}, + {SEQ_SUB, "SUBTRACT", 0, "Subtract", "Subtract effect strip type"}, + {SEQ_ALPHAOVER, "ALPHA_OVER", 0, "Alpha Over", "Alpha Over effect strip type"}, + {SEQ_ALPHAUNDER, "ALPHA_UNDER", 0, "Alpha Under", "Alpha Under effect strip type"}, + {SEQ_GAMCROSS, "GAMMA_CROSS", 0, "Gamma Cross", "Gamma Cross effect strip type"}, + {SEQ_MUL, "MULTIPLY", 0, "Multiply", "Multiply effect strip type"}, + {SEQ_OVERDROP, "OVER_DROP", 0, "Alpha Over Drop", "Alpha Over Drop effect strip type"}, + {SEQ_PLUGIN, "PLUGIN", 0, "Plugin", "Plugin effect strip type"}, + {SEQ_WIPE, "WIPE", 0, "Wipe", "Wipe effect strip type"}, + {SEQ_GLOW, "GLOW", 0, "Glow", "Glow effect strip type"}, + {SEQ_TRANSFORM, "TRANSFORM", 0, "Transform", "Transform effect strip type"}, + {SEQ_COLOR, "COLOR", 0, "Color", "Color effect strip type"}, + {SEQ_SPEED, "SPEED", 0, "Speed", "Color effect strip type"}, + {0, NULL, 0, NULL, NULL} }; /* mute operator */ EnumPropertyItem sequencer_prop_operate_types[] = { /* better name? */ - {SEQ_SELECTED, "SELECTED", "Selected", ""}, - {SEQ_UNSELECTED, "UNSELECTED", "Unselected ", ""}, - {0, NULL, NULL, NULL} + {SEQ_SELECTED, "SELECTED", 0, "Selected", ""}, + {SEQ_UNSELECTED, "UNSELECTED", 0, "Unselected ", ""}, + {0, NULL, 0, NULL, NULL} }; EnumPropertyItem prop_side_types[] = { - {SEQ_SIDE_LEFT, "LEFT", "Left", ""}, - {SEQ_SIDE_RIGHT, "RIGHT", "Right", ""}, - {SEQ_SIDE_BOTH, "BOTH", "Both", ""}, - {0, NULL, NULL, NULL} + {SEQ_SIDE_LEFT, "LEFT", 0, "Left", ""}, + {SEQ_SIDE_RIGHT, "RIGHT", 0, "Right", ""}, + {SEQ_SIDE_BOTH, "BOTH", 0, "Both", ""}, + {0, NULL, 0, NULL, NULL} }; typedef struct TransSeq { @@ -1726,9 +1726,9 @@ void SEQUENCER_OT_refresh_all(struct wmOperatorType *ot) /* cut operator */ static EnumPropertyItem prop_cut_types[] = { - {SEQ_CUT_SOFT, "SOFT", "Soft", ""}, - {SEQ_CUT_HARD, "HARD", "Hard", ""}, - {0, NULL, NULL, NULL} + {SEQ_CUT_SOFT, "SOFT", 0, "Soft", ""}, + {SEQ_CUT_HARD, "HARD", 0, "Hard", ""}, + {0, NULL, 0, NULL, NULL} }; static int sequencer_cut_exec(bContext *C, wmOperator *op) diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index 384ad3e919c..d3c3b78cc50 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -415,8 +415,6 @@ void ED_spacetype_text(void) art->init= text_header_area_init; art->draw= text_header_area_draw; - - text_header_register(art); BLI_addhead(&st->regiontypes, art); diff --git a/source/blender/editors/space_text/text_header.c b/source/blender/editors/space_text/text_header.c index fe00b86e19f..1b8149cb5a2 100644 --- a/source/blender/editors/space_text/text_header.c +++ b/source/blender/editors/space_text/text_header.c @@ -155,101 +155,6 @@ static uiBlock *text_plugin_scriptsmenu(bContext *C, void *args_unused) } #endif -static void text_editmenu_viewmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemEnumO(layout, "Top of File", 0, "TEXT_OT_move", "type", FILE_TOP); - uiItemEnumO(layout, "Bottom of File", 0, "TEXT_OT_move", "type", FILE_BOTTOM); -} - -static void text_editmenu_selectmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "TEXT_OT_select_all"); - uiItemO(layout, NULL, 0, "TEXT_OT_select_line"); -} - -static void text_editmenu_markermenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemO(layout, NULL, 0, "TEXT_OT_markers_clear"); - uiItemO(layout, NULL, 0, "TEXT_OT_next_marker"); - uiItemO(layout, NULL, 0, "TEXT_OT_previous_marker"); -} - -static void text_formatmenu(const bContext *C, Menu *menu) -{ - uiLayout *layout= menu->layout; - - uiItemO(layout, NULL, 0, "TEXT_OT_indent"); - uiItemO(layout, NULL, 0, "TEXT_OT_unindent"); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "TEXT_OT_comment"); - uiItemO(layout, NULL, 0, "TEXT_OT_uncomment"); - - uiItemS(layout); - - uiItemMenuEnumO(layout, NULL, 0, "TEXT_OT_convert_whitespace", "type"); -} - -static void text_editmenu_to3dmenu(bContext *C, uiLayout *layout, void *arg_unused) -{ - uiItemBooleanO(layout, "One Object", 0, "TEXT_OT_to_3d_object", "split_lines", 0); - uiItemBooleanO(layout, "One Object Per Line", 0, "TEXT_OT_to_3d_object", "split_lines", 1); -} - -static int text_menu_edit_poll(bContext *C) -{ - return (CTX_data_edit_text(C) != NULL); -} - -static void text_editmenu(const bContext *C, Menu *menu) -{ - uiLayout *layout= menu->layout; - - uiItemO(layout, NULL, 0, "ED_OT_undo"); - uiItemO(layout, NULL, 0, "ED_OT_redo"); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "TEXT_OT_cut"); - uiItemO(layout, NULL, 0, "TEXT_OT_copy"); - uiItemO(layout, NULL, 0, "TEXT_OT_paste"); - - uiItemS(layout); - - uiItemMenuF(layout, "View", 0, text_editmenu_viewmenu); - uiItemMenuF(layout, "Select", 0, text_editmenu_selectmenu); - uiItemMenuF(layout, "Markers", 0, text_editmenu_markermenu); - - uiItemS(layout); - - uiItemO(layout, NULL, 0, "TEXT_OT_jump"); - uiItemO(layout, NULL, 0, "TEXT_OT_properties"); - - uiItemS(layout); - - uiItemMenuF(layout, "Text to 3D Object", 0, text_editmenu_to3dmenu); -} - -/********************** header buttons ***********************/ - -void text_header_register(ARegionType *art) -{ - MenuType *mt; - - mt= MEM_callocN(sizeof(MenuType), "spacetype text menu edit"); - strcpy(mt->idname, "TEXT_MT_edit"); - strcpy(mt->label, "Edit"); - mt->draw= text_editmenu; - BLI_addhead(&art->menutypes, mt); - - mt= MEM_callocN(sizeof(MenuType), "spacetype text menu format"); - strcpy(mt->idname, "TEXT_MT_format"); - strcpy(mt->label, "Format"); - mt->draw= text_formatmenu; - BLI_addhead(&art->menutypes, mt); -} - /************************** properties ******************************/ ARegion *text_has_properties_region(ScrArea *sa) diff --git a/source/blender/editors/space_text/text_intern.h b/source/blender/editors/space_text/text_intern.h index 259811aee0f..31d29ac7f17 100644 --- a/source/blender/editors/space_text/text_intern.h +++ b/source/blender/editors/space_text/text_intern.h @@ -41,9 +41,6 @@ struct TextLine; struct wmOperatorType; struct wmWindowManager; -/* text_header.c */ -void text_header_register(struct ARegionType *art); - /* text_draw.c */ void draw_text_main(struct SpaceText *st, struct ARegion *ar); diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 065b4ffcc48..95970798e53 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -521,10 +521,13 @@ static int run_script_exec(bContext *C, wmOperator *op) #else Text *text= CTX_data_edit_text(C); - if (BPY_run_python_script( C, NULL, text )) + if (BPY_run_python_script(C, NULL, text, op->reports)) return OPERATOR_FINISHED; - BKE_report(op->reports, RPT_ERROR, "Python script fail, look in the console for now..."); + /* Dont report error messages while live editing */ + if(!CTX_wm_space_text(C)->live_edit) + BKE_report(op->reports, RPT_ERROR, "Python script fail, look in the console for now..."); + return OPERATOR_CANCELLED; #endif } @@ -699,6 +702,10 @@ static int paste_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_TEXT|ND_CURSOR, text); WM_event_add_notifier(C, NC_TEXT|NA_EDITED, text); + /* run the script while editing, evil but useful */ + if(CTX_wm_space_text(C)->live_edit) + run_script_exec(C, op); + return OPERATOR_FINISHED; } @@ -765,6 +772,10 @@ static int cut_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_TEXT|ND_CURSOR, text); WM_event_add_notifier(C, NC_TEXT|NA_EDITED, text); + /* run the script while editing, evil but useful */ + if(CTX_wm_space_text(C)->live_edit) + run_script_exec(C, op); + return OPERATOR_FINISHED; } @@ -961,9 +972,9 @@ void TEXT_OT_uncomment(wmOperatorType *ot) enum { TO_SPACES, TO_TABS }; static EnumPropertyItem whitespace_type_items[]= { - {TO_SPACES, "SPACES", "To Spaces", NULL}, - {TO_TABS, "TABS", "To Tabs", NULL}, - {0, NULL, NULL, NULL}}; + {TO_SPACES, "SPACES", 0, "To Spaces", NULL}, + {TO_TABS, "TABS", 0, "To Tabs", NULL}, + {0, NULL, 0, NULL, NULL}}; static int convert_whitespace_exec(bContext *C, wmOperator *op) { @@ -1259,19 +1270,19 @@ void TEXT_OT_markers_clear(wmOperatorType *ot) /************************ move operator ************************/ static EnumPropertyItem move_type_items[]= { - {LINE_BEGIN, "LINE_BEGIN", "Line Begin", ""}, - {LINE_END, "LINE_END", "Line End", ""}, - {FILE_TOP, "FILE_TOP", "File Top", ""}, - {FILE_BOTTOM, "FILE_BOTTOM", "File Bottom", ""}, - {PREV_CHAR, "PREVIOUS_CHARACTER", "Previous Character", ""}, - {NEXT_CHAR, "NEXT_CHARACTER", "Next Character", ""}, - {PREV_WORD, "PREVIOUS_WORD", "Previous Word", ""}, - {NEXT_WORD, "NEXT_WORD", "Next Word", ""}, - {PREV_LINE, "PREVIOUS_LINE", "Previous Line", ""}, - {NEXT_LINE, "NEXT_LINE", "Next Line", ""}, - {PREV_PAGE, "PREVIOUS_PAGE", "Previous Page", ""}, - {NEXT_PAGE, "NEXT_PAGE", "Next Page", ""}, - {0, NULL, NULL, NULL}}; + {LINE_BEGIN, "LINE_BEGIN", 0, "Line Begin", ""}, + {LINE_END, "LINE_END", 0, "Line End", ""}, + {FILE_TOP, "FILE_TOP", 0, "File Top", ""}, + {FILE_BOTTOM, "FILE_BOTTOM", 0, "File Bottom", ""}, + {PREV_CHAR, "PREVIOUS_CHARACTER", 0, "Previous Character", ""}, + {NEXT_CHAR, "NEXT_CHARACTER", 0, "Next Character", ""}, + {PREV_WORD, "PREVIOUS_WORD", 0, "Previous Word", ""}, + {NEXT_WORD, "NEXT_WORD", 0, "Next Word", ""}, + {PREV_LINE, "PREVIOUS_LINE", 0, "Previous Line", ""}, + {NEXT_LINE, "NEXT_LINE", 0, "Next Line", ""}, + {PREV_PAGE, "PREVIOUS_PAGE", 0, "Previous Page", ""}, + {NEXT_PAGE, "NEXT_PAGE", 0, "Next Page", ""}, + {0, NULL, 0, NULL, NULL}}; static void wrap_move_bol(SpaceText *st, ARegion *ar, short sel) { @@ -1602,11 +1613,11 @@ void TEXT_OT_jump(wmOperatorType *ot) /******************* delete operator **********************/ static EnumPropertyItem delete_type_items[]= { - {DEL_NEXT_CHAR, "NEXT_CHARACTER", "Next Character", ""}, - {DEL_PREV_CHAR, "PREVIOUS_CHARACTER", "Previous Character", ""}, - {DEL_NEXT_WORD, "NEXT_WORD", "Next Word", ""}, - {DEL_PREV_WORD, "PREVIOUS_WORD", "Previous Word", ""}, - {0, NULL, NULL, NULL}}; + {DEL_NEXT_CHAR, "NEXT_CHARACTER", 0, "Next Character", ""}, + {DEL_PREV_CHAR, "PREVIOUS_CHARACTER", 0, "Previous Character", ""}, + {DEL_NEXT_WORD, "NEXT_WORD", 0, "Next Word", ""}, + {DEL_PREV_WORD, "PREVIOUS_WORD", 0, "Previous Word", ""}, + {0, NULL, 0, NULL, NULL}}; static int delete_exec(bContext *C, wmOperator *op) { @@ -1627,6 +1638,10 @@ static int delete_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_TEXT|ND_CURSOR, text); WM_event_add_notifier(C, NC_TEXT|NA_EDITED, text); + /* run the script while editing, evil but useful */ + if(CTX_wm_space_text(C)->live_edit) + run_script_exec(C, op); + return OPERATOR_FINISHED; } @@ -2224,7 +2239,7 @@ static int insert_exec(bContext *C, wmOperator *op) static int insert_invoke(bContext *C, wmOperator *op, wmEvent *event) { char str[2]; - + int ret; /* XXX old code from winqreadtextspace, is it still needed somewhere? */ /* smartass code to prevent the CTRL/ALT events below from not working! */ /*if(qual & (LR_ALTKEY|LR_CTRLKEY)) @@ -2235,8 +2250,13 @@ static int insert_invoke(bContext *C, wmOperator *op, wmEvent *event) str[1]= '\0'; RNA_string_set(op->ptr, "text", str); - - return insert_exec(C, op); + ret = insert_exec(C, op); + + /* run the script while editing, evil but useful */ + if(ret==OPERATOR_FINISHED && CTX_wm_space_text(C)->live_edit) + run_script_exec(C, op); + + return ret; } void TEXT_OT_insert(wmOperatorType *ot) @@ -2449,11 +2469,11 @@ void TEXT_OT_replace_set_selected(wmOperatorType *ot) enum { RESOLVE_IGNORE, RESOLVE_RELOAD, RESOLVE_SAVE, RESOLVE_MAKE_INTERNAL }; static EnumPropertyItem resolution_items[]= { - {RESOLVE_IGNORE, "IGNORE", "Ignore", ""}, - {RESOLVE_RELOAD, "RELOAD", "Reload", ""}, - {RESOLVE_SAVE, "SAVE", "Save", ""}, - {RESOLVE_MAKE_INTERNAL, "MAKE_INTERNAL", "Make Internal", ""}, - {0, NULL, NULL, NULL}}; + {RESOLVE_IGNORE, "IGNORE", 0, "Ignore", ""}, + {RESOLVE_RELOAD, "RELOAD", 0, "Reload", ""}, + {RESOLVE_SAVE, "SAVE", 0, "Save", ""}, + {RESOLVE_MAKE_INTERNAL, "MAKE_INTERNAL", 0, "Make Internal", ""}, + {0, NULL, 0, NULL, NULL}}; /* returns 0 if file on disk is the same or Text is in memory only returns 1 if file has been modified on disk since last local edit diff --git a/source/blender/editors/space_view3d/SConscript b/source/blender/editors/space_view3d/SConscript index b771095c781..7d51d237ef0 100644 --- a/source/blender/editors/space_view3d/SConscript +++ b/source/blender/editors/space_view3d/SConscript @@ -2,10 +2,14 @@ Import ('env') sources = env.Glob('*.c') +defs = [] incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf' incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include' incs += ' ../../render/extern/include #/intern/guardedalloc' incs += ' ../../gpu ../../makesrna ../../blenfont' -env.BlenderLib ( 'bf_editors_space_view3d', sources, Split(incs), [], libtype=['core'], priority=[40] ) +if env['WITH_BF_GAMEENGINE']: + defs.append('GAMEBLENDER=1') + +env.BlenderLib ( 'bf_editors_space_view3d', sources, Split(incs), defines = defs, libtype=['core'], priority=[40] ) diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index d7cb08db414..3146b8b45ae 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -1157,11 +1157,13 @@ static void view3d_panel_brush(const bContext *C, Panel *pa) cy-= 20; uiBlockEndAlign(block); - rect.xmin= cx; rect.xmax= cx + w; - rect.ymin= cy - 200; rect.ymax= cy; - uiBlockBeginAlign(block); - curvemap_buttons(block, br->curve, (char)0, B_NOP, 0, &rect); - uiBlockEndAlign(block); + if(br->curve) { + rect.xmin= cx; rect.xmax= cx + w; + rect.ymin= cy - 200; rect.ymax= cy; + uiBlockBeginAlign(block); + curvemap_buttons(block, br->curve, (char)0, B_NOP, 0, &rect); + uiBlockEndAlign(block); + } } static void sculptmode_draw_interface_tools(Scene *scene, uiBlock *block, unsigned short cx, unsigned short cy) diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index b4b35be3ef3..79173d3fec7 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -1320,14 +1320,14 @@ void VIEW3D_OT_zoom_border(wmOperatorType *ot) /* ********************* Changing view operator ****************** */ static EnumPropertyItem prop_view_items[] = { - {V3D_VIEW_FRONT, "FRONT", "Front", "View From the Front"}, - {V3D_VIEW_BACK, "BACK", "Back", "View From the Back"}, - {V3D_VIEW_LEFT, "LEFT", "Left", "View From the Left"}, - {V3D_VIEW_RIGHT, "RIGHT", "Right", "View From the Right"}, - {V3D_VIEW_TOP, "TOP", "Top", "View From the Top"}, - {V3D_VIEW_BOTTOM, "BOTTOM", "Bottom", "View From the Bottom"}, - {V3D_VIEW_CAMERA, "CAMERA", "Camera", "View From the active amera"}, - {0, NULL, NULL, NULL}}; + {V3D_VIEW_FRONT, "FRONT", 0, "Front", "View From the Front"}, + {V3D_VIEW_BACK, "BACK", 0, "Back", "View From the Back"}, + {V3D_VIEW_LEFT, "LEFT", 0, "Left", "View From the Left"}, + {V3D_VIEW_RIGHT, "RIGHT", 0, "Right", "View From the Right"}, + {V3D_VIEW_TOP, "TOP", 0, "Top", "View From the Top"}, + {V3D_VIEW_BOTTOM, "BOTTOM", 0, "Bottom", "View From the Bottom"}, + {V3D_VIEW_CAMERA, "CAMERA", 0, "Camera", "View From the active amera"}, + {0, NULL, 0, NULL, NULL}}; static void axis_set_view(bContext *C, float q1, float q2, float q3, float q4, short view, int perspo) { @@ -1479,11 +1479,11 @@ void VIEW3D_OT_viewnumpad(wmOperatorType *ot) } static EnumPropertyItem prop_view_orbit_items[] = { - {V3D_VIEW_STEPLEFT, "ORBITLEFT", "Orbit Left", "Orbit the view around to the Left"}, - {V3D_VIEW_STEPRIGHT, "ORBITRIGHT", "Orbit Right", "Orbit the view around to the Right"}, - {V3D_VIEW_STEPUP, "ORBITUP", "Orbit Up", "Orbit the view Up"}, - {V3D_VIEW_STEPDOWN, "ORBITDOWN", "Orbit Down", "Orbit the view Down"}, - {0, NULL, NULL, NULL}}; + {V3D_VIEW_STEPLEFT, "ORBITLEFT", 0, "Orbit Left", "Orbit the view around to the Left"}, + {V3D_VIEW_STEPRIGHT, "ORBITRIGHT", 0, "Orbit Right", "Orbit the view around to the Right"}, + {V3D_VIEW_STEPUP, "ORBITUP", 0, "Orbit Up", "Orbit the view Up"}, + {V3D_VIEW_STEPDOWN, "ORBITDOWN", 0, "Orbit Down", "Orbit the view Down"}, + {0, NULL, 0, NULL, NULL}}; static int vieworbit_exec(bContext *C, wmOperator *op) { @@ -1547,11 +1547,11 @@ void VIEW3D_OT_view_orbit(wmOperatorType *ot) } static EnumPropertyItem prop_view_pan_items[] = { - {V3D_VIEW_PANLEFT, "PANLEFT", "Pan Left", "Pan the view to the Left"}, - {V3D_VIEW_PANRIGHT, "PANRIGHT", "Pan Right", "Pan the view to the Right"}, - {V3D_VIEW_PANUP, "PANUP", "Pan Up", "Pan the view Up"}, - {V3D_VIEW_PANDOWN, "PANDOWN", "Pan Down", "Pan the view Down"}, - {0, NULL, NULL, NULL}}; + {V3D_VIEW_PANLEFT, "PANLEFT", 0, "Pan Left", "Pan the view to the Left"}, + {V3D_VIEW_PANRIGHT, "PANRIGHT", 0, "Pan Right", "Pan the view to the Right"}, + {V3D_VIEW_PANUP, "PANUP", 0, "Pan Up", "Pan the view Up"}, + {V3D_VIEW_PANDOWN, "PANDOWN", 0, "Pan Down", "Pan the view Down"}, + {0, NULL, 0, NULL, NULL}}; static int viewpan_exec(bContext *C, wmOperator *op) { diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index ab705cb32fb..6dbd99c67be 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -120,6 +120,8 @@ void VIEW3D_OT_select_lasso(struct wmOperatorType *ot); void VIEW3D_OT_smoothview(struct wmOperatorType *ot); void VIEW3D_OT_setcameratoview(struct wmOperatorType *ot); void VIEW3D_OT_localview(struct wmOperatorType *ot); +void VIEW3D_OT_game_start(struct wmOperatorType *ot); + int boundbox_clip(RegionView3D *rv3d, float obmat[][4], struct BoundBox *bb); diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 0ed43bead17..6cb1051ce4a 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -85,6 +85,7 @@ void view3d_operatortypes(void) WM_operatortype_append(VIEW3D_OT_drawtype); WM_operatortype_append(VIEW3D_OT_editmesh_face_toolbox); WM_operatortype_append(VIEW3D_OT_localview); + WM_operatortype_append(VIEW3D_OT_game_start); WM_operatortype_append(VIEW3D_OT_layers); WM_operatortype_append(VIEW3D_OT_properties); @@ -173,6 +174,8 @@ void view3d_keymap(wmWindowManager *wm) WM_keymap_add_item(keymap, "VIEW3D_OT_localview", PADSLASHKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "VIEW3D_OT_game_start", PKEY, KM_PRESS, 0, 0); + /* layers, shift + alt are properties set in invoke() */ RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", ONEKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 1); RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", TWOKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 2); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 9c4f0b576da..e0e8ac7c7a7 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -715,9 +715,9 @@ void view3d_lasso_select(bContext *C, ViewContext *vc, short mcords[][2], short } static EnumPropertyItem lasso_select_types[] = { - {0, "SELECT", "Select", ""}, - {1, "DESELECT", "Deselect", ""}, - {0, NULL, NULL, NULL} + {0, "SELECT", 0, "Select", ""}, + {1, "DESELECT", 0, "Deselect", ""}, + {0, NULL, 0, NULL, NULL} }; @@ -1526,9 +1526,9 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op) /* *****************Selection Operators******************* */ static EnumPropertyItem prop_select_types[] = { - {0, "EXCLUSIVE", "Exclusive", ""}, - {1, "EXTEND", "Extend", ""}, - {0, NULL, NULL, NULL} + {0, "EXCLUSIVE", 0, "Exclusive", ""}, + {1, "EXTEND", 0, "Extend", ""}, + {0, NULL, 0, NULL, NULL} }; /* ****** Border Select ****** */ diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index e1a6f32aa41..2db5f2c97fd 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -1382,6 +1382,82 @@ void VIEW3D_OT_localview(wmOperatorType *ot) ot->poll= ED_operator_view3d_active; } +static ListBase queue_back; +static void SaveState(bContext *C) +{ + wmWindow *win= CTX_wm_window(C); + + glPushAttrib(GL_ALL_ATTRIB_BITS); + + GPU_state_init(); + + if(G.f & G_TEXTUREPAINT) + GPU_paint_set_mipmap(1); + + queue_back= win->queue; + + win->queue.first= win->queue.last= NULL; + + //XXX waitcursor(1); +} + +static void RestoreState(bContext *C) +{ + wmWindow *win= CTX_wm_window(C); + + if(G.f & G_TEXTUREPAINT) + GPU_paint_set_mipmap(0); + + //XXX curarea->win_swap = 0; + //XXX curarea->head_swap=0; + //XXX allqueue(REDRAWVIEW3D, 1); + //XXX allqueue(REDRAWBUTSALL, 0); + //XXX reset_slowparents(); + //XXX waitcursor(0); + //XXX G.qual= 0; + + win->queue= queue_back; + + glPopAttrib(); +} + +/* maybe we need this defined somewhere else */ +extern void StartKetsjiShell(struct bContext *C,int always_use_expand_framing); + + +static int game_engine_exec(bContext *C, wmOperator *unused) +{ + Scene *startscene = CTX_data_scene(C); + +#if GAMEBLENDER == 1 + SaveState(C); + StartKetsjiShell(C, 1); + RestoreState(C); + + //XXX restore_all_scene_cfra(scene_cfra_store); + set_scene_bg(startscene); + //XXX scene_update_for_newframe(G.scene, G.scene->lay); + +#else + printf("GameEngine Disabled\n"); +#endif + ED_area_tag_redraw(CTX_wm_area(C)); + return OPERATOR_FINISHED; +} + +void VIEW3D_OT_game_start(wmOperatorType *ot) +{ + + /* identifiers */ + ot->name= "Start Game Engine"; + ot->idname= "VIEW3D_OT_game_start"; + + /* api callbacks */ + ot->exec= game_engine_exec; + + ot->poll= ED_operator_view3d_active; +} + /* ************************************** */ void view3d_align_axis_to_vector(View3D *v3d, RegionView3D *rv3d, int axisidx, float vec[3]) diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index f7ddd18452e..de731ad7d95 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -56,29 +56,29 @@ static float VecOne[3] = {1, 1, 1}; /* need constants for this */ EnumPropertyItem proportional_mode_types[] = { - {0, "OFF", "Off", ""}, - {1, "ON", "On", ""}, - {2, "CONNECTED", "Connected", ""}, - {0, NULL, NULL, NULL} + {0, "OFF", 0, "Off", ""}, + {1, "ON", 0, "On", ""}, + {2, "CONNECTED", 0, "Connected", ""}, + {0, NULL, 0, NULL, NULL} }; EnumPropertyItem snap_mode_types[] = { - {SCE_SNAP_TARGET_CLOSEST, "CLOSEST", "Closest", ""}, - {SCE_SNAP_TARGET_CENTER, "CENTER", "Center", ""}, - {SCE_SNAP_TARGET_MEDIAN, "MEDIAN", "Median", ""}, - {SCE_SNAP_TARGET_ACTIVE, "ACTIVE", "Active", ""}, - {0, NULL, NULL, NULL} + {SCE_SNAP_TARGET_CLOSEST, "CLOSEST", 0, "Closest", ""}, + {SCE_SNAP_TARGET_CENTER, "CENTER", 0, "Center", ""}, + {SCE_SNAP_TARGET_MEDIAN, "MEDIAN", 0, "Median", ""}, + {SCE_SNAP_TARGET_ACTIVE, "ACTIVE", 0, "Active", ""}, + {0, NULL, 0, NULL, NULL} }; EnumPropertyItem proportional_falloff_types[] = { - {PROP_SMOOTH, "SMOOTH", "Smooth", ""}, - {PROP_SPHERE, "SPHERE", "Sphere", ""}, - {PROP_ROOT, "ROOT", "Root", ""}, - {PROP_SHARP, "SHARP", "Sharp", ""}, - {PROP_LIN, "LINEAR", "Linear", ""}, - {PROP_CONST, "CONSTANT", "Constant", ""}, - {PROP_RANDOM, "RANDOM", "Random", ""}, - {0, NULL, NULL, NULL} + {PROP_SMOOTH, "SMOOTH", 0, "Smooth", ""}, + {PROP_SPHERE, "SPHERE", 0, "Sphere", ""}, + {PROP_ROOT, "ROOT", 0, "Root", ""}, + {PROP_SHARP, "SHARP", 0, "Sharp", ""}, + {PROP_LIN, "LINEAR", 0, "Linear", ""}, + {PROP_CONST, "CONSTANT", 0, "Constant", ""}, + {PROP_RANDOM, "RANDOM", 0, "Random", ""}, + {0, NULL, 0, NULL, NULL} }; char OP_TRANSLATION[] = "TFM_OT_translation"; @@ -133,12 +133,12 @@ static int select_orientation_invoke(bContext *C, wmOperator *op, wmEvent *event void TFM_OT_select_orientation(struct wmOperatorType *ot) { static EnumPropertyItem orientation_items[]= { - {V3D_MANIP_GLOBAL, "GLOBAL", "Global", ""}, - {V3D_MANIP_NORMAL, "NORMAL", "Normal", ""}, - {V3D_MANIP_LOCAL, "LOCAL", "Local", ""}, - {V3D_MANIP_VIEW, "VIEW", "View", ""}, - {V3D_MANIP_CUSTOM, "CUSTOM", "Custom", ""}, - {0, NULL, NULL, NULL}}; + {V3D_MANIP_GLOBAL, "GLOBAL", 0, "Global", ""}, + {V3D_MANIP_NORMAL, "NORMAL", 0, "Normal", ""}, + {V3D_MANIP_LOCAL, "LOCAL", 0, "Local", ""}, + {V3D_MANIP_VIEW, "VIEW", 0, "View", ""}, + {V3D_MANIP_CUSTOM, "CUSTOM", 0, "Custom", ""}, + {0, NULL, 0, NULL, NULL}}; /* identifiers */ ot->name = "Select Orientation"; @@ -484,33 +484,33 @@ void TFM_OT_tosphere(struct wmOperatorType *ot) void TFM_OT_transform(struct wmOperatorType *ot) { static EnumPropertyItem transform_mode_types[] = { - {TFM_INIT, "INIT", "Init", ""}, - {TFM_DUMMY, "DUMMY", "Dummy", ""}, - {TFM_TRANSLATION, "TRANSLATION", "Translation", ""}, - {TFM_ROTATION, "ROTATION", "Rotation", ""}, - {TFM_RESIZE, "RESIZE", "Resize", ""}, - {TFM_TOSPHERE, "TOSPHERE", "Tosphere", ""}, - {TFM_SHEAR, "SHEAR", "Shear", ""}, - {TFM_WARP, "WARP", "Warp", ""}, - {TFM_SHRINKFATTEN, "SHRINKFATTEN", "Shrinkfatten", ""}, - {TFM_TILT, "TILT", "Tilt", ""}, - {TFM_TRACKBALL, "TRACKBALL", "Trackball", ""}, - {TFM_PUSHPULL, "PUSHPULL", "Pushpull", ""}, - {TFM_CREASE, "CREASE", "Crease", ""}, - {TFM_MIRROR, "MIRROR", "Mirror", ""}, - {TFM_BONESIZE, "BONESIZE", "Bonesize", ""}, - {TFM_BONE_ENVELOPE, "BONE_ENVELOPE", "Bone_Envelope", ""}, - {TFM_CURVE_SHRINKFATTEN, "CURVE_SHRINKFATTEN", "Curve_Shrinkfatten", ""}, - {TFM_BONE_ROLL, "BONE_ROLL", "Bone_Roll", ""}, - {TFM_TIME_TRANSLATE, "TIME_TRANSLATE", "Time_Translate", ""}, - {TFM_TIME_SLIDE, "TIME_SLIDE", "Time_Slide", ""}, - {TFM_TIME_SCALE, "TIME_SCALE", "Time_Scale", ""}, - {TFM_TIME_EXTEND, "TIME_EXTEND", "Time_Extend", ""}, - {TFM_BAKE_TIME, "BAKE_TIME", "Bake_Time", ""}, - {TFM_BEVEL, "BEVEL", "Bevel", ""}, - {TFM_BWEIGHT, "BWEIGHT", "Bweight", ""}, - {TFM_ALIGN, "ALIGN", "Align", ""}, - {0, NULL, NULL, NULL} + {TFM_INIT, "INIT", 0, "Init", ""}, + {TFM_DUMMY, "DUMMY", 0, "Dummy", ""}, + {TFM_TRANSLATION, "TRANSLATION", 0, "Translation", ""}, + {TFM_ROTATION, "ROTATION", 0, "Rotation", ""}, + {TFM_RESIZE, "RESIZE", 0, "Resize", ""}, + {TFM_TOSPHERE, "TOSPHERE", 0, "Tosphere", ""}, + {TFM_SHEAR, "SHEAR", 0, "Shear", ""}, + {TFM_WARP, "WARP", 0, "Warp", ""}, + {TFM_SHRINKFATTEN, "SHRINKFATTEN", 0, "Shrinkfatten", ""}, + {TFM_TILT, "TILT", 0, "Tilt", ""}, + {TFM_TRACKBALL, "TRACKBALL", 0, "Trackball", ""}, + {TFM_PUSHPULL, "PUSHPULL", 0, "Pushpull", ""}, + {TFM_CREASE, "CREASE", 0, "Crease", ""}, + {TFM_MIRROR, "MIRROR", 0, "Mirror", ""}, + {TFM_BONESIZE, "BONESIZE", 0, "Bonesize", ""}, + {TFM_BONE_ENVELOPE, "BONE_ENVELOPE", 0, "Bone_Envelope", ""}, + {TFM_CURVE_SHRINKFATTEN, "CURVE_SHRINKFATTEN", 0, "Curve_Shrinkfatten", ""}, + {TFM_BONE_ROLL, "BONE_ROLL", 0, "Bone_Roll", ""}, + {TFM_TIME_TRANSLATE, "TIME_TRANSLATE", 0, "Time_Translate", ""}, + {TFM_TIME_SLIDE, "TIME_SLIDE", 0, "Time_Slide", ""}, + {TFM_TIME_SCALE, "TIME_SCALE", 0, "Time_Scale", ""}, + {TFM_TIME_EXTEND, "TIME_EXTEND", 0, "Time_Extend", ""}, + {TFM_BAKE_TIME, "BAKE_TIME", 0, "Bake_Time", ""}, + {TFM_BEVEL, "BEVEL", 0, "Bevel", ""}, + {TFM_BWEIGHT, "BWEIGHT", 0, "Bweight", ""}, + {TFM_ALIGN, "ALIGN", 0, "Align", ""}, + {0, NULL, 0, NULL, NULL} }; /* identifiers */ diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 0b82efda7ab..7dca4d34c48 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -126,9 +126,6 @@ void ED_uvedit_assign_image(Scene *scene, Object *obedit, Image *ima, Image *pre tf->tpage= ima; tf->mode |= TF_TEX; - if(ima->tpageflag & IMA_TILES) tf->mode |= TF_TILES; - else tf->mode &= ~TF_TILES; - if(ima->id.us==0) id_us_plus(&ima->id); else id_lib_extern(&ima->id); } @@ -150,7 +147,7 @@ void ED_uvedit_assign_image(Scene *scene, Object *obedit, Image *ima, Image *pre /* dotile - 1, set the tile flag (from the space image) * 2, set the tile index for the faces. */ -void ED_uvedit_set_tile(bContext *C, Scene *scene, Object *obedit, Image *ima, int curtile, int dotile) +void ED_uvedit_set_tile(bContext *C, Scene *scene, Object *obedit, Image *ima, int curtile) { EditMesh *em; EditFace *efa; @@ -169,17 +166,8 @@ void ED_uvedit_set_tile(bContext *C, Scene *scene, Object *obedit, Image *ima, i for(efa= em->faces.first; efa; efa= efa->next) { tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); - if(efa->h==0 && efa->f & SELECT) { - if(dotile==1) { - /* set tile flag */ - if(ima->tpageflag & IMA_TILES) - tf->mode |= TF_TILES; - else - tf->mode &= ~TF_TILES; - } - else if(dotile==2) - tf->tile= curtile; /* set tile index */ - } + if(efa->h==0 && efa->f & SELECT) + tf->tile= curtile; /* set tile index */ } DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); @@ -963,9 +951,9 @@ static int mirror_exec(bContext *C, wmOperator *op) void UV_OT_mirror(wmOperatorType *ot) { static EnumPropertyItem axis_items[] = { - {'x', "MIRROR_X", "Mirror X", "Mirror UVs over X axis."}, - {'y', "MIRROR_Y", "Mirror Y", "Mirror UVs over Y axis."}, - {0, NULL, NULL, NULL}}; + {'x', "MIRROR_X", 0, "Mirror X", "Mirror UVs over X axis."}, + {'y', "MIRROR_Y", 0, "Mirror Y", "Mirror UVs over Y axis."}, + {0, NULL, 0, NULL, NULL}}; /* identifiers */ ot->name= "Mirror"; @@ -1068,10 +1056,10 @@ static int align_exec(bContext *C, wmOperator *op) void UV_OT_align(wmOperatorType *ot) { static EnumPropertyItem axis_items[] = { - {'a', "ALIGN_AUTO", "Align Auto", "Automatically choose the axis on which there is most alignment already."}, - {'x', "ALIGN_X", "Align X", "Align UVs on X axis."}, - {'y', "ALIGN_Y", "Align Y", "Align UVs on Y axis."}, - {0, NULL, NULL, NULL}}; + {'a', "ALIGN_AUTO", 0, "Align Auto", "Automatically choose the axis on which there is most alignment already."}, + {'x', "ALIGN_X", 0, "Align X", "Align UVs on X axis."}, + {'y', "ALIGN_Y", 0, "Align Y", "Align UVs on Y axis."}, + {0, NULL, 0, NULL, NULL}}; /* identifiers */ ot->name= "Align"; @@ -2326,9 +2314,9 @@ static int snap_cursor_exec(bContext *C, wmOperator *op) void UV_OT_snap_cursor(wmOperatorType *ot) { static EnumPropertyItem target_items[] = { - {0, "PIXELS", "Pixels", ""}, - {1, "SELECTION", "Selection", ""}, - {0, NULL, NULL, NULL}}; + {0, "PIXELS", 0, "Pixels", ""}, + {1, "SELECTION", 0, "Selection", ""}, + {0, NULL, 0, NULL, NULL}}; /* identifiers */ ot->name= "Snap Cursor"; @@ -2561,10 +2549,10 @@ static int snap_selection_exec(bContext *C, wmOperator *op) void UV_OT_snap_selection(wmOperatorType *ot) { static EnumPropertyItem target_items[] = { - {0, "PIXELS", "Pixels", ""}, - {1, "CURSOR", "Cursor", ""}, - {2, "ADJACENT_UNSELECTED", "Adjacent Unselected", ""}, - {0, NULL, NULL, NULL}}; + {0, "PIXELS", 0, "Pixels", ""}, + {1, "CURSOR", 0, "Cursor", ""}, + {2, "ADJACENT_UNSELECTED", 0, "Adjacent Unselected", ""}, + {0, NULL, 0, NULL, NULL}}; /* identifiers */ ot->name= "Snap Selection"; @@ -3005,7 +2993,7 @@ static int set_tile_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; RNA_int_get_array(op->ptr, "tile", tile); - ED_uvedit_set_tile(C, CTX_data_scene(C), CTX_data_edit_object(C), ima, tile[0] + ima->xrep*tile[1], 1); + ED_uvedit_set_tile(C, CTX_data_scene(C), CTX_data_edit_object(C), ima, tile[0] + ima->xrep*tile[1]); ED_area_tag_redraw(CTX_wm_area(C)); diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 27d0c68ec36..95467d13e8d 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -639,15 +639,15 @@ static void uv_map_transform(bContext *C, wmOperator *op, float center[3], float static void uv_transform_properties(wmOperatorType *ot, int radius) { static EnumPropertyItem direction_items[]= { - {VIEW_ON_EQUATOR, "VIEW_ON_EQUATOR", "View on Equator", "3D view is on the equator."}, - {VIEW_ON_POLES, "VIEW_ON_POLES", "View on Poles", "3D view is on the poles."}, - {ALIGN_TO_OBJECT, "ALIGN_TO_OBJECT", "Align to Object", "Align according to object transform."}, - {0, NULL, NULL, NULL} + {VIEW_ON_EQUATOR, "VIEW_ON_EQUATOR", 0, "View on Equator", "3D view is on the equator."}, + {VIEW_ON_POLES, "VIEW_ON_POLES", 0, "View on Poles", "3D view is on the poles."}, + {ALIGN_TO_OBJECT, "ALIGN_TO_OBJECT", 0, "Align to Object", "Align according to object transform."}, + {0, NULL, 0, NULL, NULL} }; static EnumPropertyItem align_items[]= { - {POLAR_ZX, "POLAR_ZX", "Polar ZX", "Polar 0 is X."}, - {POLAR_ZY, "POLAR_ZY", "Polar ZY", "Polar 0 is Y."}, - {0, NULL, NULL, NULL} + {POLAR_ZX, "POLAR_ZX", 0, "Polar ZX", "Polar 0 is X."}, + {POLAR_ZY, "POLAR_ZY", 0, "Polar ZY", "Polar 0 is Y."}, + {0, NULL, 0, NULL, NULL} }; RNA_def_enum(ot->srna, "direction", direction_items, VIEW_ON_EQUATOR, "Direction", "Direction of the sphere or cylinder."); @@ -820,9 +820,9 @@ static int unwrap_exec(bContext *C, wmOperator *op) void UV_OT_unwrap(wmOperatorType *ot) { static EnumPropertyItem method_items[] = { - {0, "ANGLE_BASED", "Angle Based", ""}, - {1, "CONFORMAL", "Conformal", ""}, - {0, NULL, NULL, NULL}}; + {0, "ANGLE_BASED", 0, "Angle Based", ""}, + {1, "CONFORMAL", 0, "Conformal", ""}, + {0, NULL, 0, NULL, NULL}}; /* identifiers */ ot->name= "Unwrap"; diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index f8d0957f70d..5edb619f7e5 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -393,7 +393,7 @@ int GPU_verify_image(Image *ima, int tftile, int tfmode, int compare) /* initialize tile mode and number of repeats */ GTS.ima = ima; - GTS.tilemode= (tfmode & TF_TILES) || (ima && (ima->tpageflag & IMA_TWINANIM)); + GTS.tilemode= (ima && (ima->tpageflag & (IMA_TILES|IMA_TWINANIM))); GTS.tileXRep = 0; GTS.tileYRep = 0; @@ -423,7 +423,7 @@ int GPU_verify_image(Image *ima, int tftile, int tfmode, int compare) glMatrixMode(GL_TEXTURE); glLoadIdentity(); - if((tfmode & TF_TILES) && ima!=NULL) + if(ima && (ima->tpageflag & IMA_TILES)) glScalef(ima->xrep, ima->yrep, 1.0); glMatrixMode(GL_MODELVIEW); diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c index 7654c67419b..4984e043031 100644 --- a/source/blender/gpu/intern/gpu_extensions.c +++ b/source/blender/gpu/intern/gpu_extensions.c @@ -746,7 +746,9 @@ GPUShader *GPU_shader_create(const char *vertexcode, const char *fragcode, /*GPU glGetObjectParameterivARB(shader->object, GL_OBJECT_LINK_STATUS_ARB, &status); if (!status) { glGetInfoLogARB(shader->object, sizeof(log), &length, log); - shader_print_errors("linking", log, fragcode); + if (fragcode) shader_print_errors("linking", log, fragcode); + else if (vertexcode) shader_print_errors("linking", log, vertexcode); + else if (libcode) shader_print_errors("linking", log, libcode); GPU_shader_free(shader); return NULL; diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 818b67170c7..7e8b5c18d71 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -1285,7 +1285,7 @@ void GPU_materials_free() GPU_material_free(&defmaterial); - for(ob=G.main->object.first; ma; ma=ma->id.next) + for(ob=G.main->object.first; ob; ob=ob->id.next) GPU_lamp_free(ob); } diff --git a/source/blender/imbuf/intern/radiance_hdr.c b/source/blender/imbuf/intern/radiance_hdr.c index d00e34cfdbe..69c4970df38 100644 --- a/source/blender/imbuf/intern/radiance_hdr.c +++ b/source/blender/imbuf/intern/radiance_hdr.c @@ -191,7 +191,7 @@ struct ImBuf *imb_loadhdr(unsigned char *mem, int size, int flags) break; } } - if (found) { + if (found && (x<(size + 2))) { if (sscanf((char *)&mem[x+1], "%79s %d %79s %d", (char*)&oriY, &height, (char*)&oriX, &width) != 4) return NULL; diff --git a/source/blender/makesdna/DNA_meshdata_types.h b/source/blender/makesdna/DNA_meshdata_types.h index c07989b2ce6..cec27b85b23 100644 --- a/source/blender/makesdna/DNA_meshdata_types.h +++ b/source/blender/makesdna/DNA_meshdata_types.h @@ -239,7 +239,7 @@ typedef struct PartialVisibility { #define TF_LIGHT 16 #define TF_SHAREDCOL 64 -#define TF_TILES 128 +#define TF_TILES 128 /* deprecated */ #define TF_BILLBOARD 256 #define TF_TWOSIDE 512 #define TF_INVISIBLE 1024 diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h index 418cc84205a..4891f44e1cd 100644 --- a/source/blender/makesdna/DNA_screen_types.h +++ b/source/blender/makesdna/DNA_screen_types.h @@ -205,6 +205,9 @@ typedef struct ARegion { #define PNL_SNAP_DIST 9.0 +/* paneltype flag */ +#define PNL_DEFAULT_CLOSED 1 + /* screen handlers */ #define SCREEN_MAXHANDLER 8 diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h index 7fa26aa7572..39e72c34adf 100644 --- a/source/blender/makesdna/DNA_sequence_types.h +++ b/source/blender/makesdna/DNA_sequence_types.h @@ -80,6 +80,9 @@ typedef struct StripProxy { char dir[160]; char file[80]; struct anim *anim; + short size; + short quality; + int pad; } StripProxy; typedef struct Strip { @@ -159,7 +162,7 @@ typedef struct Sequence { struct bSound *sound; /* the linked "bSound" object */ struct hdaudio *hdaudio; /* external hdaudio object */ float level, pan; /* level in dB (0=full), pan -1..1 */ - int curpos; /* last sample position in audio_fill() */ + int scenenr; /* for scene selection */ float strobe; void *effectdata; /* Struct pointer for effect settings */ @@ -170,8 +173,6 @@ typedef struct Sequence { int blend_mode; float blend_opacity; - int scenenr; /* for scene selection */ - int pad; } Sequence; typedef struct MetaStack { diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 3740633b576..28b5f882288 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -273,7 +273,8 @@ typedef struct SpaceText { int tabnumber; int showsyntax; - int overwrite; + short overwrite; + short live_edit; /* run python while editing, evil */ float pix_per_line; struct rcti txtscroll, txtbar; @@ -361,6 +362,21 @@ typedef struct SpaceNode { #define SNODE_TEX_WORLD 1 #define SNODE_TEX_BRUSH 2 +typedef struct SpaceLogic { + SpaceLink *next, *prev; + ListBase regionbase; /* storage of regions for inactive spaces */ + int spacetype; + float blockscale; + + short blockhandler[8]; + + short flag, scaflag; + int pad; + + struct bGPdata *gpd; /* grease-pencil data */ +} SpaceLogic; + + typedef struct SpaceImaSel { SpaceLink *next, *prev; ListBase regionbase; /* storage of regions for inactive spaces */ @@ -756,8 +772,8 @@ enum { SPACE_SCRIPT, SPACE_TIME, SPACE_NODE, - SPACEICONMAX = SPACE_NODE -/* SPACE_LOGIC */ + SPACE_LOGIC, + SPACEICONMAX = SPACE_LOGIC }; #endif diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 022e1cef840..9d554c88a95 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -66,6 +66,8 @@ typedef struct uiFont { typedef struct uiFontStyle { short uifont_id; /* saved in file, 0 is default */ short points; /* actual size depends on 'global' dpi */ + float kerning; /* kerning space between characters. */ + float pad; short italic, bold; /* style hint */ short shadow; /* value is amount of pixels blur */ short shadx, shady; /* shadow offset in pixels */ @@ -242,6 +244,7 @@ typedef struct bTheme { ThemeSpace toops; ThemeSpace ttime; ThemeSpace tnode; + ThemeSpace tlogic; /* 20 sets of bone colors for this theme */ ThemeWireColor tarm[20]; @@ -376,6 +379,7 @@ extern UserDef U; /* from blenkernel blender.c */ #define USER_ZOOM_TO_MOUSEPOS (1 << 20) #define USER_SHOW_FPS (1 << 21) #define USER_MMB_PASTE (1 << 22) +#define USER_DIRECTIONALORDER (1 << 23) /* Auto-Keying mode */ /* AUTOKEY_ON is a bitflag */ diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index d1fd3d78074..d4e952882ce 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -37,6 +37,7 @@ extern "C" { struct bContext; struct ID; struct Main; +struct ReportList; /* Types */ @@ -163,6 +164,7 @@ extern StructRNA RNA_DomainFluidSettings; extern StructRNA RNA_Driver; extern StructRNA RNA_DriverTarget; extern StructRNA RNA_EdgeSplitModifier; +extern StructRNA RNA_EditBone; extern StructRNA RNA_EffectSequence; extern StructRNA RNA_EnumProperty; extern StructRNA RNA_EnumPropertyItem; @@ -482,6 +484,8 @@ void RNA_pointer_create(struct ID *id, StructRNA *type, void *data, PointerRNA * void RNA_blender_rna_pointer_create(PointerRNA *r_ptr); +extern PointerRNA PointerRNA_NULL; + /* Structs */ const char *RNA_struct_identifier(StructRNA *type); @@ -530,6 +534,7 @@ int RNA_property_string_maxlength(PropertyRNA *prop); const char *RNA_property_ui_name(PropertyRNA *prop); const char *RNA_property_ui_description(PropertyRNA *prop); +int RNA_property_ui_icon(PropertyRNA *prop); /* Dynamic Property Information */ @@ -719,13 +724,13 @@ void RNA_parameter_get_lookup(ParameterList *parms, const char *identifier, void void RNA_parameter_set(ParameterList *parms, PropertyRNA *parm, void *value); void RNA_parameter_set_lookup(ParameterList *parms, const char *identifier, void *value); -int RNA_function_call(PointerRNA *ptr, FunctionRNA *func, ParameterList *parms); -int RNA_function_call_lookup(PointerRNA *ptr, const char *identifier, ParameterList *parms); +int RNA_function_call(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, FunctionRNA *func, ParameterList *parms); +int RNA_function_call_lookup(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, const char *identifier, ParameterList *parms); -int RNA_function_call_direct(PointerRNA *ptr, FunctionRNA *func, const char *format, ...); -int RNA_function_call_direct_lookup(PointerRNA *ptr, const char *identifier, const char *format, ...); -int RNA_function_call_direct_va(PointerRNA *ptr, FunctionRNA *func, const char *format, va_list args); -int RNA_function_call_direct_va_lookup(PointerRNA *ptr, const char *identifier, const char *format, va_list args); +int RNA_function_call_direct(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, FunctionRNA *func, const char *format, ...); +int RNA_function_call_direct_lookup(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, const char *identifier, const char *format, ...); +int RNA_function_call_direct_va(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, FunctionRNA *func, const char *format, va_list args); +int RNA_function_call_direct_va_lookup(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, const char *identifier, const char *format, va_list args); /* ID */ diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h index c40f50c34fc..b620a315085 100644 --- a/source/blender/makesrna/RNA_define.h +++ b/source/blender/makesrna/RNA_define.h @@ -42,6 +42,8 @@ extern "C" { BlenderRNA *RNA_create(void); void RNA_define_free(BlenderRNA *brna); void RNA_free(BlenderRNA *brna); + +void RNA_init(void); void RNA_exit(void); /* Struct */ @@ -136,6 +138,7 @@ void RNA_def_property_string_default(PropertyRNA *prop, const char *value); void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description); void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision); +void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, int consecutive); void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *updatefunc); void RNA_def_property_editable_func(PropertyRNA *prop, const char *editable); @@ -146,7 +149,7 @@ void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item); void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set); void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *typef); -void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring); +void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring, const char *add, const char *remove); /* Function */ diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index 7e62ea6d823..75f52ededd0 100644 --- a/source/blender/makesrna/RNA_types.h +++ b/source/blender/makesrna/RNA_types.h @@ -91,9 +91,13 @@ typedef enum PropertyFlag { * and collections */ PROP_ANIMATEABLE = 2, + /* icon */ + PROP_ICONS_CONSECUTIVE = 4096, + /* function paramater flags */ PROP_REQUIRED = 4, PROP_RETURN = 8, + PROP_RNAPTR = 2048, /* registering */ PROP_REGISTER = 16, @@ -133,6 +137,7 @@ typedef struct CollectionPointerLink { typedef struct EnumPropertyItem { int value; const char *identifier; + int icon; const char *name; const char *description; } EnumPropertyItem; @@ -156,11 +161,13 @@ typedef struct ParameterIterator { /* Function */ typedef enum FunctionFlag { - FUNC_TYPESTATIC = 1, /* for static functions, FUNC_ STATIC is taken by some windows header it seems */ + FUNC_NO_SELF = 1, /* for static functions */ + FUNC_USE_CONTEXT = 2, + FUNC_USE_REPORTS = 4, /* registering */ - FUNC_REGISTER = 2, - FUNC_REGISTER_OPTIONAL = 2|4, + FUNC_REGISTER = 8, + FUNC_REGISTER_OPTIONAL = 8|16, /* internal flags */ FUNC_BUILTIN = 128, @@ -168,7 +175,7 @@ typedef enum FunctionFlag { FUNC_RUNTIME = 512 } FunctionFlag; -typedef void (*CallFunc)(PointerRNA *ptr, ParameterList *parms); +typedef void (*CallFunc)(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, ParameterList *parms); typedef struct FunctionRNA FunctionRNA; diff --git a/source/blender/makesrna/SConscript b/source/blender/makesrna/SConscript index 7bf968a0979..967636fe36b 100644 --- a/source/blender/makesrna/SConscript +++ b/source/blender/makesrna/SConscript @@ -7,6 +7,6 @@ o = SConscript('intern/SConscript') objs += o incs = '#/intern/guardedalloc ../blenkernel ../blenlib ../makesdna intern .' -incs += ' ../windowmanager ../editors/include' +incs += ' ../windowmanager ../editors/include ../imbuf' env.BlenderLib ( 'bf_rna', objs, Split(incs), [], libtype=['core'], priority = [195] ) diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index bc3be44aec9..963e4f9aeff 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -25,8 +25,9 @@ # ***** END GPL LICENSE BLOCK ***** FILE(GLOB DEFSRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.c") +FILE(GLOB APISRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*_api.c") LIST(REMOVE_ITEM DEFSRC rna_access.c rna_define.c makesrna.c) -FILE(GLOB_RECURSE APISRC "../../editors/*/*_api.c") +LIST(REMOVE_ITEM DEFSRC ${APISRC}) STRING(REGEX REPLACE "rna_([a-zA-Z0-9_-]*).c" "${CMAKE_CURRENT_BINARY_DIR}/rna_\\1_gen.c" GENSRC "${DEFSRC}") @@ -38,7 +39,7 @@ SET(SRC ../../../../intern/guardedalloc/intern/mallocn.c ../../../../intern/guardedalloc/intern/mmap_win.c) -INCLUDE_DIRECTORIES(../../../../intern/guardedalloc .. ../../makesdna ../../blenkernel ../../blenlib ../../windowmanager ../../editors/include .) +INCLUDE_DIRECTORIES(../../../../intern/guardedalloc .. ../../makesdna ../../blenkernel ../../blenlib ../../windowmanager ../../editors/include ../../imbuf .) FILE(GLOB INC_FILES ../*.h ../../makesdna/*.h) IF(WITH_OPENEXR) diff --git a/source/blender/makesrna/intern/Makefile b/source/blender/makesrna/intern/Makefile index cd1f27f43b7..03f75f0bea6 100644 --- a/source/blender/makesrna/intern/Makefile +++ b/source/blender/makesrna/intern/Makefile @@ -28,10 +28,11 @@ DIR = $(OCGDIR)/blender/makesrna ALLRNA = $(wildcard rna_*.c) DEFRNA = $(filter-out %rna_define.c, $(filter-out %rna_access.c, $(ALLRNA))) -GENSRCS = $(patsubst rna_%.c, rna_%_gen.c, $(DEFRNA)) +GENRNA = $(filter-out %_api.c, $(DEFRNA)) +GENSRCS = $(patsubst rna_%.c, rna_%_gen.c, $(GENRNA)) GENTARGET = $(patsubst %.c, $(DIR)/$(DEBUG_DIR)%.c, $(GENSRCS)) -MAKESRCS = $(DEFRNA) makesrna.c rna_define.c $(wildcard ../../editors/*/*_api.c) +MAKESRCS = $(DEFRNA) makesrna.c rna_define.c MAKEOBJS = $(patsubst %.c, $(DIR)/$(DEBUG_DIR)%.o, $(notdir $(MAKESRCS))) CSRCS = $(GENSRCS) rna_access.c @@ -47,6 +48,7 @@ CFLAGS += $(LEVEL_1_C_WARNINGS) CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include CPPFLAGS += -I../../blenlib CPPFLAGS += -I../../blenkernel +CPPFLAGS += -I../../imbuf CPPFLAGS += -I../../makesdna CPPFLAGS += -I../../windowmanager CPPFLAGS += -I../../editors/include @@ -93,24 +95,6 @@ clean:: # TODO include right .mk for ldflags -# XXX this is an ugly hack, copying code from nan_compile.mk -# we want the .o's to be in the makesrna/ directory, but the -# .c's are in the editors/*/ directories - -$(DIR)/$(DEBUG_DIR)%_api.o: ../../editors/interface/%_api.c - ifdef NAN_DEPEND - @set -e; $(CC) -M $(CPPFLAGS) $< 2>/dev/null \ - | sed 's@\($*\)\.o[ :]*@$(DIR)/$(DEBUG_DIR)\1.o : @g' \ - > $(DIR)/$(DEBUG_DIR)$*.d; \ - [ -s $(DIR)/$(DEBUG_DIR)$*.d ] || $(RM) $(DIR)/$*.d - endif - ifdef NAN_QUIET - @echo " -- $< -- " - @$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ - else - $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ - endif - # A small note: we do not use the debug version of the alloc lib. That # is done quite intentionally. If there is a bug in that lib, it needs # to be fixed by the module maintainer. diff --git a/source/blender/makesrna/intern/SConscript b/source/blender/makesrna/intern/SConscript index 9c8e00da16d..03f0afdb2cc 100644 --- a/source/blender/makesrna/intern/SConscript +++ b/source/blender/makesrna/intern/SConscript @@ -16,9 +16,12 @@ source_files.remove('rna_access.c') generated_files = source_files[:] generated_files.remove('rna_define.c') generated_files.remove('makesrna.c') -generated_files = [filename[:-2] + '_gen.c' for filename in generated_files] -source_files.extend(env.Glob('../../editors/*/*_api.c')) +api_files = env.Glob('*_api.c') +for api_file in api_files: + generated_files.remove(api_file) + +generated_files = [filename[:-2] + '_gen.c' for filename in generated_files] makesrna_tool = env.Clone() rna = env.Clone() @@ -41,11 +44,15 @@ if env['WITH_BF_FFMPEG']: if env['WITH_BF_QUICKTIME']: defs.append('WITH_QUICKTIME') +if env['WITH_BF_LCMS']: + defs.append('WITH_LCMS') + makesrna_tool.Append(CPPDEFINES=defs) makesrna_tool.Append (CPPPATH = ['#/intern/guardedalloc', '../../blenlib', '../../blenkernel', + '../../imbuf', '../../makesdna', '../../makesrna', '../../windowmanager', diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index e820372a077..eacf3a65c7d 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -242,7 +242,7 @@ static const char *rna_parameter_type_name(PropertyRNA *parm) case PROP_POINTER: { PointerPropertyRNA *pparm= (PointerPropertyRNA*)parm; - if(strcmp((char*)pparm->type, "AnyType") == 0) + if(parm->flag & PROP_RNAPTR) return "PointerRNA"; else return rna_find_dna_type((const char *)pparm->type); @@ -394,7 +394,7 @@ static char *rna_def_property_get_func(FILE *f, StructRNA *srna, PropertyRNA *pr else if(rna_color_quantize(prop, dp)) fprintf(f, " values[%d]= (%s)(data->%s[%d]*(1.0f/255.0f));\n", i, rna_type_type(prop), dp->dnaname, i); else - fprintf(f, " values[%d]= (%s)%s(data->%s[%d]);\n", i, rna_type_type(prop), (dp->booleannegative)? "!": "", dp->dnaname, i); + fprintf(f, " values[%d]= (%s)%s(((%s*)data->%s)[%d]);\n", i, rna_type_type(prop), (dp->booleannegative)? "!": "", dp->dnatype, dp->dnaname, i); } } } @@ -559,7 +559,7 @@ static char *rna_def_property_set_func(FILE *f, StructRNA *srna, PropertyRNA *pr fprintf(f, " data->%s[%d]= FTOCHAR(values[%d]);\n", dp->dnaname, i, i); } else { - fprintf(f, " data->%s[%d]= %s", dp->dnaname, i, (dp->booleannegative)? "!": ""); + fprintf(f, " ((%s*)data->%s)[%d]= %s", dp->dnatype, dp->dnaname, i, (dp->booleannegative)? "!": ""); rna_clamp_value(f, prop, 1, i); } } @@ -702,8 +702,10 @@ static char *rna_def_property_begin_func(FILE *f, StructRNA *srna, PropertyRNA * else { if(manualfunc) fprintf(f, "\n %s(iter, ptr);\n", manualfunc); - else + else if(dp->dnapointerlevel == 0) fprintf(f, "\n rna_iterator_listbase_begin(iter, &data->%s, NULL);\n", dp->dnaname); + else + fprintf(f, "\n rna_iterator_listbase_begin(iter, data->%s, NULL);\n", dp->dnaname); } getfunc= rna_alloc_function_name(srna->identifier, prop->identifier, "get"); @@ -1104,6 +1106,7 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA FunctionRNA *func; PropertyDefRNA *dparm; char *funcname, *ptrstr; + int first; srna= dsrna->srna; func= dfunc->func; @@ -1113,10 +1116,10 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA funcname= rna_alloc_function_name(srna->identifier, func->identifier, "call"); - fprintf(f, "void %s(PointerRNA *_ptr, ParameterList *_parms)", funcname); + fprintf(f, "void %s(bContext *C, ReportList *reports, PointerRNA *_ptr, ParameterList *_parms)", funcname); fprintf(f, "\n{\n"); - if((func->flag & FUNC_TYPESTATIC)==0) { + if((func->flag & FUNC_NO_SELF)==0) { if(dsrna->dnaname) fprintf(f, "\tstruct %s *_self;\n", dsrna->dnaname); else fprintf(f, "\tstruct %s *_self;\n", srna->identifier); } @@ -1132,7 +1135,7 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA fprintf(f, ";\n"); fprintf(f, "\t\n"); - if((func->flag & FUNC_TYPESTATIC)==0) { + if((func->flag & FUNC_NO_SELF)==0) { if(dsrna->dnaname) fprintf(f, "\t_self= (struct %s *)_ptr->data;\n", dsrna->dnaname); else fprintf(f, "\t_self= (struct %s *)_ptr->data;\n", srna->identifier); } @@ -1146,9 +1149,7 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA else if(dparm->prop->arraylength) fprintf(f, "\t%s= ((%s%s*)_data);\n", dparm->prop->identifier, rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop)); else if(dparm->prop->type == PROP_POINTER) { - PointerPropertyRNA *pprop= (PointerPropertyRNA*)dparm->prop; - - if(strcmp((char*)pprop->type, "AnyType") == 0) + if(dparm->prop->flag & PROP_RNAPTR) fprintf(f, "\t%s= ((%s%s*)_data);\n", dparm->prop->identifier, rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop)); else fprintf(f, "\t%s= *((%s%s**)_data);\n", dparm->prop->identifier, rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop)); @@ -1166,16 +1167,33 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA if(func->ret) fprintf(f, "%s= ", func->ret->identifier); fprintf(f, "%s(", dfunc->call); - if((func->flag & FUNC_TYPESTATIC)==0) + first= 1; + + if((func->flag & FUNC_NO_SELF)==0) { fprintf(f, "_self"); + first= 0; + } + + if(func->flag & FUNC_USE_CONTEXT) { + if(!first) fprintf(f, ", "); + first= 0; + fprintf(f, "C"); + } + + if(func->flag & FUNC_USE_REPORTS) { + if(!first) fprintf(f, ", "); + first= 0; + fprintf(f, "reports"); + } dparm= dfunc->cont.properties.first; for(; dparm; dparm= dparm->next) { if(dparm->prop==func->ret) continue; - if((func->flag & FUNC_TYPESTATIC)==0 || dparm!=dfunc->cont.properties.first) - fprintf(f, ", "); + if(!first) fprintf(f, ", "); + first= 0; + fprintf(f, "%s", dparm->prop->identifier); } @@ -1358,7 +1376,7 @@ static void rna_generate_function_prototypes(BlenderRNA *brna, StructRNA *srna, base= srna->base; while (base) { for(func= base->functions.first; func; func= func->cont.next) { - fprintf(f, "%s%s rna_%s_%s;\n", "extern ", "FunctionRNA", base->identifier, func->identifier); + fprintf(f, "%s%s rna_%s_%s_func;\n", "extern ", "FunctionRNA", base->identifier, func->identifier); rna_generate_parameter_prototypes(brna, base, func, f); } @@ -1369,7 +1387,7 @@ static void rna_generate_function_prototypes(BlenderRNA *brna, StructRNA *srna, } for(func= srna->functions.first; func; func= func->cont.next) { - fprintf(f, "%s%s rna_%s_%s;\n", "extern ", "FunctionRNA", srna->identifier, func->identifier); + fprintf(f, "%s%s rna_%s_%s_func;\n", "extern ", "FunctionRNA", srna->identifier, func->identifier); rna_generate_parameter_prototypes(brna, srna, func, f); } @@ -1382,6 +1400,7 @@ static void rna_generate_static_parameter_prototypes(BlenderRNA *brna, StructRNA FunctionRNA *func; PropertyDefRNA *dparm; StructDefRNA *dsrna; + int first; dsrna= rna_find_struct_def(srna); func= dfunc->func; @@ -1404,17 +1423,39 @@ static void rna_generate_static_parameter_prototypes(BlenderRNA *brna, StructRNA fprintf(f, "%s(", dfunc->call); - if(dsrna->dnaname) fprintf(f, "struct %s *_self", dsrna->dnaname); - else fprintf(f, "struct %s *_self", srna->identifier); + first= 1; + + if((func->flag & FUNC_NO_SELF)==0) { + if(dsrna->dnaname) fprintf(f, "struct %s *_self", dsrna->dnaname); + else fprintf(f, "struct %s *_self", srna->identifier); + first= 0; + } + + if(func->flag & FUNC_USE_CONTEXT) { + if(!first) fprintf(f, ", "); + first= 0; + fprintf(f, "bContext *C"); + } + + if(func->flag & FUNC_USE_REPORTS) { + if(!first) fprintf(f, ", "); + first= 0; + fprintf(f, "ReportList *reports"); + } for(dparm= dfunc->cont.properties.first; dparm; dparm= dparm->next) { - if(dparm->prop==func->ret) ; - else if(dparm->prop->arraylength) - fprintf(f, ", %s%s %s[%d]", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), dparm->prop->identifier, dparm->prop->arraylength); + if(dparm->prop==func->ret) + continue; + + if(!first) fprintf(f, ", "); + first= 0; + + if(dparm->prop->arraylength) + fprintf(f, "%s%s %s[%d]", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), dparm->prop->identifier, dparm->prop->arraylength); else if(dparm->prop->type == PROP_POINTER) - fprintf(f, ", %s%s *%s", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), dparm->prop->identifier); + fprintf(f, "%s%s *%s", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), dparm->prop->identifier); else - fprintf(f, ", %s%s %s", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), dparm->prop->identifier); + fprintf(f, "%s%s %s", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), dparm->prop->identifier); } fprintf(f, ");\n"); @@ -1447,8 +1488,8 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr if(nest != NULL) { len= strlen(nest); - strnest= MEM_mallocN(sizeof(char)*(len+1), "rna_generate_property -> strnest"); - errnest= MEM_mallocN(sizeof(char)*(len+1), "rna_generate_property -> errnest"); + strnest= MEM_mallocN(sizeof(char)*(len+2), "rna_generate_property -> strnest"); + errnest= MEM_mallocN(sizeof(char)*(len+2), "rna_generate_property -> errnest"); strcpy(strnest, "_"); strcat(strnest, nest); strcpy(errnest, "."); strcat(errnest, nest); @@ -1467,6 +1508,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr for(i=0; i<eprop->totitem; i++) { fprintf(f, "{%d, ", eprop->item[i].value); rna_print_c_string(f, eprop->item[i].identifier); fprintf(f, ", "); + fprintf(f, "%d, ", eprop->item[i].icon); rna_print_c_string(f, eprop->item[i].name); fprintf(f, ", "); rna_print_c_string(f, eprop->item[i].description); fprintf(f, "}"); if(i != eprop->totitem-1) @@ -1565,6 +1607,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr fprintf(f, ", %d, ", prop->flag); rna_print_c_string(f, prop->name); fprintf(f, ",\n\t"); rna_print_c_string(f, prop->description); fprintf(f, ",\n"); + fprintf(f, "%d, ", prop->icon); fprintf(f, "\t%s, %s, %d,\n", rna_property_typename(prop->type), rna_property_subtypename(prop->subtype), prop->arraylength); fprintf(f, "\t%s, %d, %s},\n", rna_function_string(prop->update), prop->noteflag, rna_function_string(prop->editable)); @@ -1629,10 +1672,14 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr case PROP_COLLECTION: { CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop; fprintf(f, "\t%s, %s, %s, %s, %s, %s, %s, ", rna_function_string(cprop->begin), rna_function_string(cprop->next), rna_function_string(cprop->end), rna_function_string(cprop->get), rna_function_string(cprop->length), rna_function_string(cprop->lookupint), rna_function_string(cprop->lookupstring)); + if(cprop->add) fprintf(f, "&rna_%s_%s_func, ", srna->identifier, (char*)cprop->add); + else fprintf(f, "NULL, "); + if(cprop->remove) fprintf(f, "&rna_%s_%s_func, ", srna->identifier, (char*)cprop->remove); + else fprintf(f, "NULL, "); if(cprop->type) fprintf(f, "&RNA_%s\n", (char*)cprop->type); else fprintf(f, "NULL\n"); break; - } + } } fprintf(f, "};\n\n"); @@ -1659,13 +1706,15 @@ static void rna_generate_struct(BlenderRNA *brna, StructRNA *srna, FILE *f) for(parm= func->cont.properties.first; parm; parm= parm->next) rna_generate_property(f, srna, func->identifier, parm); - fprintf(f, "%s%s rna_%s_%s = {\n", "", "FunctionRNA", srna->identifier, func->identifier); + fprintf(f, "%s%s rna_%s_%s_func = {\n", "", "FunctionRNA", srna->identifier, func->identifier); - if(func->cont.next) fprintf(f, "\t{(FunctionRNA*)&rna_%s_%s, ", srna->identifier, ((FunctionRNA*)func->cont.next)->identifier); + if(func->cont.next) fprintf(f, "\t{(FunctionRNA*)&rna_%s_%s_func, ", srna->identifier, ((FunctionRNA*)func->cont.next)->identifier); else fprintf(f, "\t{NULL, "); - if(func->cont.prev) fprintf(f, "(FunctionRNA*)&rna_%s_%s,\n", srna->identifier, ((FunctionRNA*)func->cont.prev)->identifier); + if(func->cont.prev) fprintf(f, "(FunctionRNA*)&rna_%s_%s_func,\n", srna->identifier, ((FunctionRNA*)func->cont.prev)->identifier); else fprintf(f, "NULL,\n"); + fprintf(f, "\tNULL,\n"); + parm= func->cont.properties.first; if(parm) fprintf(f, "\t{(PropertyRNA*)&rna_%s_%s_%s, ", srna->identifier, func->identifier, parm->identifier); else fprintf(f, "\t{NULL, "); @@ -1697,6 +1746,8 @@ static void rna_generate_struct(BlenderRNA *brna, StructRNA *srna, FILE *f) if(srna->cont.prev) fprintf(f, "(ContainerRNA *)&RNA_%s,\n", ((StructRNA*)srna->cont.prev)->identifier); else fprintf(f, "NULL,\n"); + fprintf(f, "\tNULL,\n"); + prop= srna->cont.properties.first; if(prop) fprintf(f, "\t{(PropertyRNA*)&rna_%s_%s, ", srna->identifier, prop->identifier); else fprintf(f, "\t{NULL, "); @@ -1749,11 +1800,11 @@ static void rna_generate_struct(BlenderRNA *brna, StructRNA *srna, FILE *f) } func= srna->functions.first; - if(func) fprintf(f, "\t{(FunctionRNA*)&rna_%s_%s, ", srna->identifier, func->identifier); + if(func) fprintf(f, "\t{(FunctionRNA*)&rna_%s_%s_func, ", srna->identifier, func->identifier); else fprintf(f, "\t{NULL, "); func= srna->functions.last; - if(func) fprintf(f, "(FunctionRNA*)&rna_%s_%s}\n", srna->identifier, func->identifier); + if(func) fprintf(f, "(FunctionRNA*)&rna_%s_%s_func}\n", srna->identifier, func->identifier); else fprintf(f, "NULL}\n"); fprintf(f, "};\n"); @@ -1763,64 +1814,65 @@ static void rna_generate_struct(BlenderRNA *brna, StructRNA *srna, FILE *f) typedef struct RNAProcessItem { char *filename; + char *api_filename; void (*define)(BlenderRNA *brna); } RNAProcessItem; RNAProcessItem PROCESS_ITEMS[]= { - {"rna_rna.c", RNA_def_rna}, - {"rna_ID.c", RNA_def_ID}, - {"rna_texture.c", RNA_def_texture}, - {"rna_action.c", RNA_def_action}, - {"rna_animation.c", RNA_def_animation}, - {"rna_actuator.c", RNA_def_actuator}, - {"rna_armature.c", RNA_def_armature}, - {"rna_brush.c", RNA_def_brush}, - {"rna_camera.c", RNA_def_camera}, - {"rna_cloth.c", RNA_def_cloth}, - {"rna_color.c", RNA_def_color}, - {"rna_constraint.c", RNA_def_constraint}, - {"rna_context.c", RNA_def_context}, - {"rna_controller.c", RNA_def_controller}, - {"rna_curve.c", RNA_def_curve}, - {"rna_fcurve.c", RNA_def_fcurve}, - {"rna_fluidsim.c", RNA_def_fluidsim}, - {"rna_group.c", RNA_def_group}, - {"rna_image.c", RNA_def_image}, - {"rna_key.c", RNA_def_key}, - {"rna_lamp.c", RNA_def_lamp}, - {"rna_lattice.c", RNA_def_lattice}, - {"rna_main.c", RNA_def_main}, - {"rna_material.c", RNA_def_material}, - {"rna_mesh.c", RNA_def_mesh}, - {"rna_meta.c", RNA_def_meta}, - {"rna_modifier.c", RNA_def_modifier}, + {"rna_rna.c", NULL, RNA_def_rna}, + {"rna_ID.c", NULL, RNA_def_ID}, + {"rna_texture.c", NULL, RNA_def_texture}, + {"rna_action.c", NULL, RNA_def_action}, + {"rna_animation.c", NULL, RNA_def_animation}, + {"rna_actuator.c", NULL, RNA_def_actuator}, + {"rna_armature.c", NULL, RNA_def_armature}, + {"rna_brush.c", NULL, RNA_def_brush}, + {"rna_camera.c", NULL, RNA_def_camera}, + {"rna_cloth.c", NULL, RNA_def_cloth}, + {"rna_color.c", NULL, RNA_def_color}, + {"rna_constraint.c", NULL, RNA_def_constraint}, + {"rna_context.c", NULL, RNA_def_context}, + {"rna_controller.c", NULL, RNA_def_controller}, + {"rna_curve.c", NULL, RNA_def_curve}, + {"rna_fcurve.c", NULL, RNA_def_fcurve}, + {"rna_fluidsim.c", NULL, RNA_def_fluidsim}, + {"rna_group.c", NULL, RNA_def_group}, + {"rna_image.c", NULL, RNA_def_image}, + {"rna_key.c", NULL, RNA_def_key}, + {"rna_lamp.c", NULL, RNA_def_lamp}, + {"rna_lattice.c", NULL, RNA_def_lattice}, + {"rna_main.c", "rna_main_api.c", RNA_def_main}, + {"rna_material.c", NULL, RNA_def_material}, + {"rna_mesh.c", "rna_mesh_api.c", RNA_def_mesh}, + {"rna_meta.c", NULL, RNA_def_meta}, + {"rna_modifier.c", NULL, RNA_def_modifier}, {"rna_nla.c", RNA_def_nla}, - {"rna_nodetree.c", RNA_def_nodetree}, - {"rna_object.c", RNA_def_object}, - {"rna_object_force.c", RNA_def_object_force}, - {"rna_packedfile.c", RNA_def_packedfile}, - {"rna_particle.c", RNA_def_particle}, - {"rna_pose.c", RNA_def_pose}, - {"rna_property.c", RNA_def_gameproperty}, - {"rna_radio.c", RNA_def_radio}, - {"rna_scene.c", RNA_def_scene}, - {"rna_screen.c", RNA_def_screen}, - {"rna_scriptlink.c", RNA_def_scriptlink}, - {"rna_sensor.c", RNA_def_sensor}, - {"rna_sequence.c", RNA_def_sequence}, - {"rna_space.c", RNA_def_space}, - {"rna_text.c", RNA_def_text}, - {"rna_timeline.c", RNA_def_timeline_marker}, - {"rna_sound.c", RNA_def_sound}, - {"rna_ui.c", RNA_def_ui}, - {"rna_userdef.c", RNA_def_userdef}, - {"rna_vfont.c", RNA_def_vfont}, - {"rna_vpaint.c", RNA_def_vpaint}, - {"rna_wm.c", RNA_def_wm}, - {"rna_world.c", RNA_def_world}, + {"rna_nodetree.c", NULL, RNA_def_nodetree}, + {"rna_object.c", "rna_object_api.c", RNA_def_object}, + {"rna_object_force.c", NULL, RNA_def_object_force}, + {"rna_packedfile.c", NULL, RNA_def_packedfile}, + {"rna_particle.c", NULL, RNA_def_particle}, + {"rna_pose.c", NULL, RNA_def_pose}, + {"rna_property.c", NULL, RNA_def_gameproperty}, + {"rna_radio.c", NULL, RNA_def_radio}, + {"rna_scene.c", NULL, RNA_def_scene}, + {"rna_screen.c", NULL, RNA_def_screen}, + {"rna_scriptlink.c", NULL, RNA_def_scriptlink}, + {"rna_sensor.c", NULL, RNA_def_sensor}, + {"rna_sequence.c", NULL, RNA_def_sequence}, + {"rna_space.c", NULL, RNA_def_space}, + {"rna_text.c", NULL, RNA_def_text}, + {"rna_timeline.c", NULL, RNA_def_timeline_marker}, + {"rna_sound.c", NULL, RNA_def_sound}, + {"rna_ui.c", "rna_ui_api.c", RNA_def_ui}, + {"rna_userdef.c", NULL, RNA_def_userdef}, + {"rna_vfont.c", NULL, RNA_def_vfont}, + {"rna_vpaint.c", NULL, RNA_def_vpaint}, + {"rna_wm.c", "rna_wm_api.c", RNA_def_wm}, + {"rna_world.c", NULL, RNA_def_world}, {NULL, NULL}}; -static void rna_generate(BlenderRNA *brna, FILE *f, char *filename) +static void rna_generate(BlenderRNA *brna, FILE *f, char *filename, char *api_filename) { StructDefRNA *ds; PropertyDefRNA *dp; @@ -1838,7 +1890,9 @@ static void rna_generate(BlenderRNA *brna, FILE *f, char *filename) fprintf(f, "#include \"BLI_blenlib.h\"\n\n"); + fprintf(f, "#include \"BKE_context.h\"\n"); fprintf(f, "#include \"BKE_library.h\"\n"); + fprintf(f, "#include \"BKE_report.h\"\n"); fprintf(f, "#include \"BKE_utildefines.h\"\n\n"); fprintf(f, "#include \"RNA_define.h\"\n"); @@ -1847,7 +1901,10 @@ static void rna_generate(BlenderRNA *brna, FILE *f, char *filename) rna_generate_prototypes(brna, f); - fprintf(f, "#include \"%s\"\n\n", filename); + fprintf(f, "#include \"%s\"\n", filename); + if(api_filename) + fprintf(f, "#include \"%s\"\n", api_filename); + fprintf(f, "\n"); fprintf(f, "/* Autogenerated Functions */\n\n"); @@ -2170,7 +2227,7 @@ static int rna_preprocess(char *outfile) status = 1; } else { - rna_generate(brna, file, PROCESS_ITEMS[i].filename); + rna_generate(brna, file, PROCESS_ITEMS[i].filename, PROCESS_ITEMS[i].api_filename); fclose(file); status= (DefRNA.error != 0); diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index 56eda4eb735..7d8bab8bee8 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -218,7 +218,6 @@ static void rna_def_ID(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - FunctionRNA *func; srna= RNA_def_struct(brna, "ID", NULL); RNA_def_struct_ui_text(srna, "ID", "Base type for datablocks, defining a unique name, linking from other libraries and garbage collection."); @@ -246,12 +245,6 @@ static void rna_def_ID(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "lib"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Library", "Library file the datablock is linked from."); - - /* XXX temporary for testing */ - func= RNA_def_function(srna, "rename", "rename_id"); - RNA_def_function_ui_description(func, "Rename this ID datablock."); - prop= RNA_def_string(func, "name", "", 0, "", "New name for the datablock."); - RNA_def_property_flag(prop, PROP_REQUIRED); } static void rna_def_library(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 870fa4d9aa3..ba893319ce9 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -32,8 +32,11 @@ #include "BLI_blenlib.h" #include "BLI_dynstr.h" +#include "BLI_ghash.h" +#include "BKE_context.h" #include "BKE_idprop.h" +#include "BKE_report.h" #include "BKE_utildefines.h" #include "WM_api.h" @@ -44,15 +47,42 @@ #include "rna_internal.h" -/* Exit */ +/* Init/Exit */ + +void RNA_init() +{ + StructRNA *srna; + PropertyRNA *prop; + + for(srna=BLENDER_RNA.structs.first; srna; srna=srna->cont.next) { + if(!srna->cont.prophash) { + srna->cont.prophash= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp); + + for(prop=srna->cont.properties.first; prop; prop=prop->next) + if(!(prop->flag & PROP_BUILTIN)) + BLI_ghash_insert(srna->cont.prophash, (void*)prop->identifier, prop); + } + } +} void RNA_exit() { + StructRNA *srna; + + for(srna=BLENDER_RNA.structs.first; srna; srna=srna->cont.next) { + if(srna->cont.prophash) { + BLI_ghash_free(srna->cont.prophash, NULL, NULL); + srna->cont.prophash= NULL; + } + } + RNA_free(&BLENDER_RNA); } /* Pointer */ +PointerRNA PointerRNA_NULL = {{0}, 0, 0}; + void RNA_main_pointer_create(struct Main *main, PointerRNA *r_ptr) { r_ptr->id.data= NULL; @@ -384,24 +414,13 @@ int RNA_struct_is_a(StructRNA *type, StructRNA *srna) PropertyRNA *RNA_struct_find_property(PointerRNA *ptr, const char *identifier) { - CollectionPropertyIterator iter; - PropertyRNA *iterprop, *prop; - int i = 0; - - iterprop= RNA_struct_iterator_property(ptr->type); - RNA_property_collection_begin(ptr, iterprop, &iter); - prop= NULL; - - for(; iter.valid; RNA_property_collection_next(&iter), i++) { - if(strcmp(identifier, RNA_property_identifier(iter.ptr.data)) == 0) { - prop= iter.ptr.data; - break; - } - } - - RNA_property_collection_end(&iter); + PropertyRNA *iterprop= RNA_struct_iterator_property(ptr->type); + PointerRNA propptr; - return prop; + if(RNA_property_collection_lookup_string(ptr, iterprop, identifier, &propptr)) + return propptr.data; + + return NULL; } /* Find the property which uses the given nested struct */ @@ -677,6 +696,11 @@ const char *RNA_property_ui_description(PropertyRNA *prop) return rna_ensure_property(prop)->description; } +int RNA_property_ui_icon(PropertyRNA *prop) +{ + return rna_ensure_property(prop)->icon; +} + int RNA_property_editable(PointerRNA *ptr, PropertyRNA *prop) { ID *id; @@ -718,7 +742,7 @@ int RNA_property_animated(PointerRNA *ptr, PropertyRNA *prop) return 0; } -void RNA_property_update(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop) +void RNA_property_update(bContext *C, PointerRNA *ptr, PropertyRNA *prop) { prop= rna_ensure_property(prop); @@ -1314,6 +1338,7 @@ int RNA_property_collection_length(PointerRNA *ptr, PropertyRNA *prop) void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *r_ptr) { IDProperty *idprop; + //CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop; if((idprop=rna_idproperty_check(&prop, ptr))) { IDPropertyTemplate val = {0}; @@ -1339,8 +1364,17 @@ void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA MEM_freeN(item); } } +#if 0 + else if(cprop->add){ + if(!(cprop->add->flag & FUNC_USE_CONTEXT)) { /* XXX check for this somewhere else */ + ParameterList *params= RNA_parameter_list_create(ptr, cprop->add); + RNA_function_call(NULL, NULL, ptr, cprop->add, params); + RNA_parameter_list_free(params); + } + } +#endif else - printf("RNA_property_collection_add %s.%s: only supported for id properties.\n", ptr->type->identifier, prop->identifier); + printf("RNA_property_collection_add %s.%s: not implemented for this property.\n", ptr->type->identifier, prop->identifier); if(r_ptr) { if(idprop) { @@ -1358,6 +1392,7 @@ void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA void RNA_property_collection_remove(PointerRNA *ptr, PropertyRNA *prop, int key) { IDProperty *idprop; + //CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop; if((idprop=rna_idproperty_check(&prop, ptr))) { IDProperty tmp, *array; @@ -1378,6 +1413,15 @@ void RNA_property_collection_remove(PointerRNA *ptr, PropertyRNA *prop, int key) } } else if(prop->flag & PROP_IDPROPERTY); +#if 0 + else if(cprop->remove){ + if(!(cprop->remove->flag & FUNC_USE_CONTEXT)) { /* XXX check for this somewhere else */ + ParameterList *params= RNA_parameter_list_create(ptr, cprop->remove); + RNA_function_call(NULL, NULL, ptr, cprop->remove, params); + RNA_parameter_list_free(params); + } + } +#endif else printf("RNA_property_collection_remove %s.%s: only supported for id properties.\n", ptr->type->identifier, prop->identifier); } @@ -1471,7 +1515,7 @@ void rna_iterator_listbase_begin(CollectionPropertyIterator *iter, ListBase *lb, ListBaseIterator *internal; internal= MEM_callocN(sizeof(ListBaseIterator), "ListBaseIterator"); - internal->link= lb->first; + internal->link= (lb)? lb->first: NULL; internal->skip= skip; iter->internal= internal; @@ -1614,12 +1658,18 @@ static char *rna_path_token(const char **path, char *fixedbuf, int fixedlen, int buf= MEM_callocN(sizeof(char)*(len+1), "rna_path_token"); /* copy string, taking into account escaped ] */ - for(p=*path, i=0, j=0; i<len; i++, p++) { - if(*p == '\\' && *(p+1) == ']'); - else buf[j++]= *p; - } + if(bracket) { + for(p=*path, i=0, j=0; i<len; i++, p++) { + if(*p == '\\' && *(p+1) == ']'); + else buf[j++]= *p; + } - buf[j]= 0; + buf[j]= 0; + } + else { + memcpy(buf, *path, sizeof(char)*len); + buf[len]= '\0'; + } /* set path to start of next token */ if(*p == ']') p++; @@ -1631,8 +1681,7 @@ static char *rna_path_token(const char **path, char *fixedbuf, int fixedlen, int int RNA_path_resolve(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop) { - CollectionPropertyIterator iter; - PropertyRNA *prop, *iterprop; + PropertyRNA *prop; PointerRNA curptr, nextptr; char fixedbuf[256], *token; int len, intkey; @@ -1647,18 +1696,7 @@ int RNA_path_resolve(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, Prope if(!token) return 0; - iterprop= RNA_struct_iterator_property(curptr.type); - RNA_property_collection_begin(&curptr, iterprop, &iter); - prop= NULL; - - for(; iter.valid; RNA_property_collection_next(&iter)) { - if(strcmp(token, RNA_property_identifier(iter.ptr.data)) == 0) { - prop= iter.ptr.data; - break; - } - } - - RNA_property_collection_end(&iter); + prop= RNA_struct_find_property(&curptr, token); if(token != fixedbuf) MEM_freeN(token); @@ -2517,10 +2555,10 @@ void RNA_parameter_set_lookup(ParameterList *parms, const char *identifier, void RNA_parameter_set(parms, parm, value); } -int RNA_function_call(PointerRNA *ptr, FunctionRNA *func, ParameterList *parms) +int RNA_function_call(bContext *C, ReportList *reports, PointerRNA *ptr, FunctionRNA *func, ParameterList *parms) { if(func->call) { - func->call(ptr, parms); + func->call(C, reports, ptr, parms); return 0; } @@ -2528,33 +2566,33 @@ int RNA_function_call(PointerRNA *ptr, FunctionRNA *func, ParameterList *parms) return -1; } -int RNA_function_call_lookup(PointerRNA *ptr, const char *identifier, ParameterList *parms) +int RNA_function_call_lookup(bContext *C, ReportList *reports, PointerRNA *ptr, const char *identifier, ParameterList *parms) { FunctionRNA *func; func= RNA_struct_find_function(ptr, identifier); if(func) - return RNA_function_call(ptr, func, parms); + return RNA_function_call(C, reports, ptr, func, parms); return -1; } -int RNA_function_call_direct(PointerRNA *ptr, FunctionRNA *func, const char *format, ...) +int RNA_function_call_direct(bContext *C, ReportList *reports, PointerRNA *ptr, FunctionRNA *func, const char *format, ...) { va_list args; int ret; va_start(args, format); - ret= RNA_function_call_direct_va(ptr, func, format, args); + ret= RNA_function_call_direct_va(C, reports, ptr, func, format, args); va_end(args); return ret; } -int RNA_function_call_direct_lookup(PointerRNA *ptr, const char *identifier, const char *format, ...) +int RNA_function_call_direct_lookup(bContext *C, ReportList *reports, PointerRNA *ptr, const char *identifier, const char *format, ...) { FunctionRNA *func; @@ -2566,7 +2604,7 @@ int RNA_function_call_direct_lookup(PointerRNA *ptr, const char *identifier, con va_start(args, format); - ret= RNA_function_call_direct_va(ptr, func, format, args); + ret= RNA_function_call_direct_va(C, reports, ptr, func, format, args); va_end(args); @@ -2674,7 +2712,7 @@ static int rna_function_parameter_parse(PointerRNA *ptr, PropertyRNA *prop, Prop ptype= RNA_property_pointer_type(ptr, prop); - if(ptype == &RNA_AnyType) { + if(prop->flag & PROP_RNAPTR) { *((PointerRNA*)dest)= *((PointerRNA*)src); } else if (ptype!=srna) { @@ -2708,7 +2746,7 @@ static int rna_function_parameter_parse(PointerRNA *ptr, PropertyRNA *prop, Prop return 0; } -int RNA_function_call_direct_va(PointerRNA *ptr, FunctionRNA *func, const char *format, va_list args) +int RNA_function_call_direct_va(bContext *C, ReportList *reports, PointerRNA *ptr, FunctionRNA *func, const char *format, va_list args) { PointerRNA funcptr; ParameterList *parms; @@ -2803,7 +2841,7 @@ int RNA_function_call_direct_va(PointerRNA *ptr, FunctionRNA *func, const char * } if (err==0) - err= RNA_function_call(ptr, func, parms); + err= RNA_function_call(C, reports, ptr, func, parms); /* XXX throw error when more parameters than those needed are passed or leave silent? */ if (err==0 && pret && ofs<flen && format[ofs++]=='R') { @@ -2863,14 +2901,14 @@ int RNA_function_call_direct_va(PointerRNA *ptr, FunctionRNA *func, const char * return err; } -int RNA_function_call_direct_va_lookup(PointerRNA *ptr, const char *identifier, const char *format, va_list args) +int RNA_function_call_direct_va_lookup(bContext *C, ReportList *reports, PointerRNA *ptr, const char *identifier, const char *format, va_list args) { FunctionRNA *func; func= RNA_struct_find_function(ptr, identifier); if(func) - return RNA_function_call_direct_va(ptr, func, format, args); + return RNA_function_call_direct_va(C, reports, ptr, func, format, args); return 0; } diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index 531ae1e2790..3eb88e706e9 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -41,25 +41,25 @@ void RNA_def_actuator(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem actuator_type_items[] ={ - {ACT_OBJECT, "OBJECT", "Object", ""}, - {ACT_IPO, "IPO", "IPO", ""}, - {ACT_CAMERA, "CAMERA", "Camera", ""}, - {ACT_SOUND, "SOUND", "Sound", ""}, - {ACT_PROPERTY, "PROPERTY", "Property", ""}, - {ACT_CONSTRAINT, "CONSTRAINT", "Constraint", ""}, - {ACT_EDIT_OBJECT, "EDIT_OBJECT", "Edit Object", ""}, - {ACT_SCENE, "SCENE", "Scene", ""}, - {ACT_RANDOM, "RANDOM", "Random", ""}, - {ACT_MESSAGE, "MESSAGE", "Message", ""}, - {ACT_ACTION, "ACTION", "Action", ""}, - {ACT_CD, "CD", "CD", ""}, - {ACT_GAME, "GAME", "Game", ""}, - {ACT_VISIBILITY, "VISIBILITY", "Visibility", ""}, - {ACT_2DFILTER, "FILTER_2D", "2D Filter", ""}, - {ACT_PARENT, "PARENT", "Parent", ""}, - {ACT_SHAPEACTION, "SHAPE_ACTION", "Shape Action", ""}, - {ACT_STATE, "STATE", "State", ""}, - {0, NULL, NULL, NULL}}; + {ACT_OBJECT, "OBJECT", 0, "Object", ""}, + {ACT_IPO, "IPO", 0, "IPO", ""}, + {ACT_CAMERA, "CAMERA", 0, "Camera", ""}, + {ACT_SOUND, "SOUND", 0, "Sound", ""}, + {ACT_PROPERTY, "PROPERTY", 0, "Property", ""}, + {ACT_CONSTRAINT, "CONSTRAINT", 0, "Constraint", ""}, + {ACT_EDIT_OBJECT, "EDIT_OBJECT", 0, "Edit Object", ""}, + {ACT_SCENE, "SCENE", 0, "Scene", ""}, + {ACT_RANDOM, "RANDOM", 0, "Random", ""}, + {ACT_MESSAGE, "MESSAGE", 0, "Message", ""}, + {ACT_ACTION, "ACTION", 0, "Action", ""}, + {ACT_CD, "CD", 0, "CD", ""}, + {ACT_GAME, "GAME", 0, "Game", ""}, + {ACT_VISIBILITY, "VISIBILITY", 0, "Visibility", ""}, + {ACT_2DFILTER, "FILTER_2D", 0, "2D Filter", ""}, + {ACT_PARENT, "PARENT", 0, "Parent", ""}, + {ACT_SHAPEACTION, "SHAPE_ACTION", 0, "Shape Action", ""}, + {ACT_STATE, "STATE", 0, "State", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "Actuator", NULL); RNA_def_struct_ui_text(srna, "Actuator", "Game engine logic brick to apply actions in the game engine."); diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index 3da8eb33bfd..3469d716853 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -79,11 +79,11 @@ void rna_def_keyingset_path(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_mode_grouping_items[] = { - {KSP_GROUP_NAMED, "NAMED", "Named Group", ""}, - {KSP_GROUP_NONE, "NONE", "None", ""}, - {KSP_GROUP_KSNAME, "KEYINGSET", "Keying Set Name", ""}, - {KSP_GROUP_TEMPLATE_ITEM, "TEMPLATE", "Innermost Context-Item Name", ""}, - {0, NULL, NULL, NULL}}; + {KSP_GROUP_NAMED, "NAMED", 0, "Named Group", ""}, + {KSP_GROUP_NONE, "NONE", 0, "None", ""}, + {KSP_GROUP_KSNAME, "KEYINGSET", 0, "Keying Set Name", ""}, + {KSP_GROUP_TEMPLATE_ITEM, "TEMPLATE", 0, "Innermost Context-Item Name", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "KeyingSetPath", NULL); RNA_def_struct_sdna(srna, "KS_Path"); diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index d49e5d14714..0f437f8f1a8 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -32,27 +32,36 @@ #include "DNA_armature_types.h" #include "DNA_scene_types.h" +#include "WM_types.h" + #ifdef RNA_RUNTIME -static void rna_Bone_layer_set(PointerRNA *ptr, const int *values) +#include "ED_armature.h" + +static void rna_bone_layer_set(short *layer, const int *values) { - Bone *bone= (Bone*)ptr->data; int i, tot= 0; /* ensure we always have some layer selected */ - for(i=0; i<20; i++) + for(i=0; i<16; i++) if(values[i]) tot++; if(tot==0) return; - for(i=0; i<20; i++) { - if(values[i]) bone->layer |= (1<<i); - else bone->layer &= ~(1<<i); + for(i=0; i<16; i++) { + if(values[i]) *layer |= (1<<i); + else *layer &= ~(1<<i); } } +static void rna_Bone_layer_set(PointerRNA *ptr, const int *values) +{ + Bone *bone= (Bone*)ptr->data; + rna_bone_layer_set(&bone->layer, values); +} + static void rna_Armature_layer_set(PointerRNA *ptr, const int *values) { bArmature *arm= (bArmature*)ptr->data; @@ -100,152 +109,529 @@ static void rna_Armature_path_end_frame_set(PointerRNA *ptr, int value) data->pathef= value; } +PointerRNA rna_EditBone_rna_type_get(PointerRNA *ptr) +{ + return rna_builtin_type_get(ptr); +} + +void rna_EditBone_name_get(PointerRNA *ptr, char *value) +{ + EditBone *data= (EditBone*)(ptr->data); + BLI_strncpy(value, data->name, sizeof(data->name)); +} + +int rna_EditBone_name_length(PointerRNA *ptr) +{ + EditBone *data= (EditBone*)(ptr->data); + return strlen(data->name); +} + +int rna_EditBone_active_get(PointerRNA *ptr) +{ + EditBone *data= (EditBone*)(ptr->data); + return (((data->flag) & BONE_ACTIVE) != 0); +} + +void rna_EditBone_active_set(PointerRNA *ptr, int value) +{ + EditBone *data= (EditBone*)(ptr->data); + if(value) data->flag |= BONE_ACTIVE; + else data->flag &= ~BONE_ACTIVE; +} + +float rna_EditBone_bbone_in_get(PointerRNA *ptr) +{ + EditBone *data= (EditBone*)(ptr->data); + return (float)(data->ease1); +} + +void rna_EditBone_bbone_in_set(PointerRNA *ptr, float value) +{ + EditBone *data= (EditBone*)(ptr->data); + data->ease1= CLAMPIS(value, 0.0f, 2.0f); +} + +float rna_EditBone_bbone_out_get(PointerRNA *ptr) +{ + EditBone *data= (EditBone*)(ptr->data); + return (float)(data->ease2); +} + +void rna_EditBone_bbone_out_set(PointerRNA *ptr, float value) +{ + EditBone *data= (EditBone*)(ptr->data); + data->ease2= CLAMPIS(value, 0.0f, 2.0f); +} + +int rna_EditBone_bbone_segments_get(PointerRNA *ptr) +{ + EditBone *data= (EditBone*)(ptr->data); + return (int)(data->segments); +} + +void rna_EditBone_bbone_segments_set(PointerRNA *ptr, int value) +{ + EditBone *data= (EditBone*)(ptr->data); + data->segments= CLAMPIS(value, 1, 32); +} + +void rna_EditBone_layer_get(PointerRNA *ptr, int values[16]) +{ + EditBone *data= (EditBone*)(ptr->data); + values[0]= ((data->layer & (1<<0)) != 0); + values[1]= ((data->layer & (1<<1)) != 0); + values[2]= ((data->layer & (1<<2)) != 0); + values[3]= ((data->layer & (1<<3)) != 0); + values[4]= ((data->layer & (1<<4)) != 0); + values[5]= ((data->layer & (1<<5)) != 0); + values[6]= ((data->layer & (1<<6)) != 0); + values[7]= ((data->layer & (1<<7)) != 0); + values[8]= ((data->layer & (1<<8)) != 0); + values[9]= ((data->layer & (1<<9)) != 0); + values[10]= ((data->layer & (1<<10)) != 0); + values[11]= ((data->layer & (1<<11)) != 0); + values[12]= ((data->layer & (1<<12)) != 0); + values[13]= ((data->layer & (1<<13)) != 0); + values[14]= ((data->layer & (1<<14)) != 0); + values[15]= ((data->layer & (1<<15)) != 0); +} + +void rna_EditBone_layer_set(PointerRNA *ptr, const int values[16]) +{ + EditBone *data= (EditBone*)(ptr->data); + rna_bone_layer_set(&data->layer, values); +} + +int rna_EditBone_connected_get(PointerRNA *ptr) +{ + EditBone *data= (EditBone*)(ptr->data); + return (((data->flag) & BONE_CONNECTED) != 0); +} + +void rna_EditBone_connected_set(PointerRNA *ptr, int value) +{ + EditBone *data= (EditBone*)(ptr->data); + if(value) data->flag |= BONE_CONNECTED; + else data->flag &= ~BONE_CONNECTED; +} + +int rna_EditBone_cyclic_offset_get(PointerRNA *ptr) +{ + EditBone *data= (EditBone*)(ptr->data); + return (!((data->flag) & BONE_NO_CYCLICOFFSET) != 0); +} + +void rna_EditBone_cyclic_offset_set(PointerRNA *ptr, int value) +{ + EditBone *data= (EditBone*)(ptr->data); + if(!value) data->flag |= BONE_NO_CYCLICOFFSET; + else data->flag &= ~BONE_NO_CYCLICOFFSET; +} + +int rna_EditBone_deform_get(PointerRNA *ptr) +{ + EditBone *data= (EditBone*)(ptr->data); + return (!((data->flag) & BONE_NO_DEFORM) != 0); +} + +void rna_EditBone_deform_set(PointerRNA *ptr, int value) +{ + EditBone *data= (EditBone*)(ptr->data); + if(!value) data->flag |= BONE_NO_DEFORM; + else data->flag &= ~BONE_NO_DEFORM; +} + +int rna_EditBone_draw_wire_get(PointerRNA *ptr) +{ + EditBone *data= (EditBone*)(ptr->data); + return (((data->flag) & BONE_DRAWWIRE) != 0); +} + +void rna_EditBone_draw_wire_set(PointerRNA *ptr, int value) +{ + EditBone *data= (EditBone*)(ptr->data); + if(value) data->flag |= BONE_DRAWWIRE; + else data->flag &= ~BONE_DRAWWIRE; +} + +float rna_EditBone_envelope_distance_get(PointerRNA *ptr) +{ + EditBone *data= (EditBone*)(ptr->data); + return (float)(data->dist); +} + +void rna_EditBone_envelope_distance_set(PointerRNA *ptr, float value) +{ + EditBone *data= (EditBone*)(ptr->data); + data->dist= CLAMPIS(value, 0.0f, 1000.0f); +} + +float rna_EditBone_envelope_weight_get(PointerRNA *ptr) +{ + EditBone *data= (EditBone*)(ptr->data); + return (float)(data->weight); +} + +void rna_EditBone_envelope_weight_set(PointerRNA *ptr, float value) +{ + EditBone *data= (EditBone*)(ptr->data); + data->weight= CLAMPIS(value, 0.0f, 1000.0f); +} + +float rna_EditBone_radius_head_get(PointerRNA *ptr) +{ + EditBone *data= (EditBone*)(ptr->data); + return (float)(data->rad_head); +} + +void rna_EditBone_radius_head_set(PointerRNA *ptr, float value) +{ + EditBone *data= (EditBone*)(ptr->data); + data->rad_head= value; +} + +float rna_EditBone_radius_tail_get(PointerRNA *ptr) +{ + EditBone *data= (EditBone*)(ptr->data); + return (float)(data->rad_tail); +} + +void rna_EditBone_radius_tail_set(PointerRNA *ptr, float value) +{ + EditBone *data= (EditBone*)(ptr->data); + data->rad_tail= value; +} + +void rna_EditBone_head_get(PointerRNA *ptr, float values[3]) +{ + EditBone *data= (EditBone*)(ptr->data); + values[0]= (float)(((float*)data->head)[0]); + values[1]= (float)(((float*)data->head)[1]); + values[2]= (float)(((float*)data->head)[2]); +} + +void rna_EditBone_head_set(PointerRNA *ptr, const float values[3]) +{ + EditBone *data= (EditBone*)(ptr->data); + ((float*)data->head)[0]= values[0]; + ((float*)data->head)[1]= values[1]; + ((float*)data->head)[2]= values[2]; +} + +int rna_EditBone_head_selected_get(PointerRNA *ptr) +{ + EditBone *data= (EditBone*)(ptr->data); + return (((data->flag) & BONE_ROOTSEL) != 0); +} + +void rna_EditBone_head_selected_set(PointerRNA *ptr, int value) +{ + EditBone *data= (EditBone*)(ptr->data); + if(value) data->flag |= BONE_ROOTSEL; + else data->flag &= ~BONE_ROOTSEL; +} + +int rna_EditBone_hidden_get(PointerRNA *ptr) +{ + EditBone *data= (EditBone*)(ptr->data); + return (((data->flag) & BONE_HIDDEN_A) != 0); +} + +void rna_EditBone_hidden_set(PointerRNA *ptr, int value) +{ + EditBone *data= (EditBone*)(ptr->data); + if(value) data->flag |= BONE_HIDDEN_A; + else data->flag &= ~BONE_HIDDEN_A; +} + +int rna_EditBone_hinge_get(PointerRNA *ptr) +{ + EditBone *data= (EditBone*)(ptr->data); + return (!((data->flag) & BONE_HINGE) != 0); +} + +void rna_EditBone_hinge_set(PointerRNA *ptr, int value) +{ + EditBone *data= (EditBone*)(ptr->data); + if(!value) data->flag |= BONE_HINGE; + else data->flag &= ~BONE_HINGE; +} + +int rna_EditBone_inherit_scale_get(PointerRNA *ptr) +{ + EditBone *data= (EditBone*)(ptr->data); + return (!((data->flag) & BONE_NO_SCALE) != 0); +} + +void rna_EditBone_inherit_scale_set(PointerRNA *ptr, int value) +{ + EditBone *data= (EditBone*)(ptr->data); + if(!value) data->flag |= BONE_NO_SCALE; + else data->flag &= ~BONE_NO_SCALE; +} + +int rna_EditBone_locked_get(PointerRNA *ptr) +{ + EditBone *data= (EditBone*)(ptr->data); + return (((data->flag) & BONE_EDITMODE_LOCKED) != 0); +} + +void rna_EditBone_locked_set(PointerRNA *ptr, int value) +{ + EditBone *data= (EditBone*)(ptr->data); + if(value) data->flag |= BONE_EDITMODE_LOCKED; + else data->flag &= ~BONE_EDITMODE_LOCKED; +} + +int rna_EditBone_multiply_vertexgroup_with_envelope_get(PointerRNA *ptr) +{ + EditBone *data= (EditBone*)(ptr->data); + return (((data->flag) & BONE_MULT_VG_ENV) != 0); +} + +void rna_EditBone_multiply_vertexgroup_with_envelope_set(PointerRNA *ptr, int value) +{ + EditBone *data= (EditBone*)(ptr->data); + if(value) data->flag |= BONE_MULT_VG_ENV; + else data->flag &= ~BONE_MULT_VG_ENV; +} + +PointerRNA rna_EditBone_parent_get(PointerRNA *ptr) +{ + EditBone *data= (EditBone*)(ptr->data); + return rna_pointer_inherit_refine(ptr, &RNA_EditBone, data->parent); +} + +float rna_EditBone_roll_get(PointerRNA *ptr) +{ + EditBone *data= (EditBone*)(ptr->data); + return (float)(data->roll); +} + +void rna_EditBone_roll_set(PointerRNA *ptr, float value) +{ + EditBone *data= (EditBone*)(ptr->data); + data->roll= value; +} + +void rna_EditBone_tail_get(PointerRNA *ptr, float values[3]) +{ + EditBone *data= (EditBone*)(ptr->data); + values[0]= (float)(((float*)data->tail)[0]); + values[1]= (float)(((float*)data->tail)[1]); + values[2]= (float)(((float*)data->tail)[2]); +} + +void rna_EditBone_tail_set(PointerRNA *ptr, const float values[3]) +{ + EditBone *data= (EditBone*)(ptr->data); + ((float*)data->tail)[0]= values[0]; + ((float*)data->tail)[1]= values[1]; + ((float*)data->tail)[2]= values[2]; +} + +int rna_EditBone_tail_selected_get(PointerRNA *ptr) +{ + EditBone *data= (EditBone*)(ptr->data); + return (((data->flag) & BONE_TIPSEL) != 0); +} + +void rna_EditBone_tail_selected_set(PointerRNA *ptr, int value) +{ + EditBone *data= (EditBone*)(ptr->data); + if(value) data->flag |= BONE_TIPSEL; + else data->flag &= ~BONE_TIPSEL; +} + #else -// err... bones should not be directly edited (only editbones should be...) -static void rna_def_bone(BlenderRNA *brna) +static void rna_def_bone_common(StructRNA *srna, int editbone) { - StructRNA *srna; PropertyRNA *prop; - - srna= RNA_def_struct(brna, "Bone", NULL); - RNA_def_struct_ui_text(srna, "Bone", "Bone in an Armature datablock."); - RNA_def_struct_ui_icon(srna, ICON_BONE_DATA); - - /* pointers/collections */ - /* parent (pointer) */ - prop= RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Bone"); - RNA_def_property_pointer_sdna(prop, NULL, "parent"); - RNA_def_property_ui_text(prop, "Parent", "Parent bone (in same Armature)."); - - /* children (collection) */ - prop= RNA_def_property(srna, "children", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_sdna(prop, NULL, "childbase", NULL); - RNA_def_property_struct_type(prop, "Bone"); - RNA_def_property_ui_text(prop, "Children", "Bones which are children of this bone"); - + /* strings */ prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* must be unique */ RNA_def_property_ui_text(prop, "Name", ""); RNA_def_struct_name_property(srna, prop); - + if(editbone) RNA_def_property_string_funcs(prop, "rna_EditBone_name_get", "rna_EditBone_name_length", "rna_EditBone_name_set"); + /* flags */ - /* layer */ prop= RNA_def_property(srna, "layer", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "layer", 1); RNA_def_property_array(prop, 16); RNA_def_property_ui_text(prop, "Bone Layers", "Layers bone exists in"); - RNA_def_property_boolean_funcs(prop, NULL, "rna_Bone_layer_set"); + if(editbone) RNA_def_property_boolean_funcs(prop, "rna_EditBone_layer_get", "rna_EditBone_layer_set"); + else { + RNA_def_property_boolean_funcs(prop, NULL, "rna_Bone_layer_set"); + RNA_def_property_boolean_sdna(prop, NULL, "layer", 1); + } - /* flag */ - prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_SELECTED); - RNA_def_property_ui_text(prop, "Selected", ""); - - prop= RNA_def_property(srna, "head_selected", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_ROOTSEL); - RNA_def_property_ui_text(prop, "Head Selected", ""); - - prop= RNA_def_property(srna, "tail_selected", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_TIPSEL); - RNA_def_property_ui_text(prop, "Tail Selected", ""); - prop= RNA_def_property(srna, "connected", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_CONNECTED); + if(editbone) RNA_def_property_boolean_funcs(prop, "rna_EditBone_connected_get", "rna_EditBone_connected_set"); + else RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_CONNECTED); RNA_def_property_ui_text(prop, "Connected", "When bone has a parent, bone's head is struck to the parent's tail."); - // XXX should we define this in PoseChannel wrapping code instead? but PoseChannels directly get some of their flags from here... - prop= RNA_def_property(srna, "pose_channel_hidden", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_HIDDEN_P); - RNA_def_property_ui_text(prop, "Pose Channel Hidden", "Bone is not visible when it is not in Edit Mode (i.e. in Object or Pose Modes)."); - prop= RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_ACTIVE); + if(editbone) RNA_def_property_boolean_funcs(prop, "rna_EditBone_active_get", "rna_EditBone_active_set"); + else RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_ACTIVE); RNA_def_property_ui_text(prop, "Active", "Bone was the last bone clicked on (most operations are applied to only this bone)"); prop= RNA_def_property(srna, "hinge", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", BONE_HINGE); + if(editbone) RNA_def_property_boolean_funcs(prop, "rna_EditBone_hinge_get", "rna_EditBone_hinge_set"); + else RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", BONE_HINGE); RNA_def_property_ui_text(prop, "Inherit Rotation", "Bone doesn't inherit rotation or scale from parent bone."); - prop= RNA_def_property(srna, "editmode_hidden", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_HIDDEN_A); - RNA_def_property_ui_text(prop, "Edit Mode Hidden", "Bone is not visible when in Edit Mode"); - prop= RNA_def_property(srna, "multiply_vertexgroup_with_envelope", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_MULT_VG_ENV); + if(editbone) RNA_def_property_boolean_funcs(prop, "rna_EditBone_multiply_vertexgroup_with_envelope_get", "rna_EditBone_multiply_vertexgroup_with_envelope_set"); + else RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_MULT_VG_ENV); RNA_def_property_ui_text(prop, "Multiply Vertex Group with Envelope", "When deforming bone, multiply effects of Vertex Group weights with Envelope influence."); prop= RNA_def_property(srna, "deform", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", BONE_NO_DEFORM); + if(editbone) RNA_def_property_boolean_funcs(prop, "rna_EditBone_deform_get", "rna_EditBone_deform_set"); + else RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", BONE_NO_DEFORM); RNA_def_property_ui_text(prop, "Deform", "Bone does not deform any geometry."); prop= RNA_def_property(srna, "inherit_scale", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", BONE_NO_SCALE); RNA_def_property_ui_text(prop, "Inherit Scale", "Bone inherits scaling from parent bone."); + if(editbone) RNA_def_property_boolean_funcs(prop, "rna_EditBone_inherit_scale_get", "rna_EditBone_inherit_scale_set"); + else RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", BONE_NO_SCALE); prop= RNA_def_property(srna, "draw_wire", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_DRAWWIRE); + if(editbone) RNA_def_property_boolean_funcs(prop, "rna_EditBone_draw_wire_get", "rna_EditBone_draw_wire_set"); + else RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_DRAWWIRE); RNA_def_property_ui_text(prop, "Draw Wire", "Bone is always drawn as Wireframe regardless of viewport draw mode. Useful for non-obstructive custom bone shapes."); prop= RNA_def_property(srna, "cyclic_offset", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", BONE_NO_CYCLICOFFSET); + if(editbone) RNA_def_property_boolean_funcs(prop, "rna_EditBone_cyclic_offset_get", "rna_EditBone_cyclic_offset_set"); + else RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", BONE_NO_CYCLICOFFSET); RNA_def_property_ui_text(prop, "Cyclic Offset", "When bone doesn't have a parent, it receives cyclic offset effects."); - - prop= RNA_def_property(srna, "editmode_locked", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_EDITMODE_LOCKED); - RNA_def_property_ui_text(prop, "Edit Mode Locked", "Bone is not able to be transformed when in Edit Mode."); - + /* Number values */ /* envelope deform settings */ prop= RNA_def_property(srna, "envelope_distance", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "dist"); + if(editbone) RNA_def_property_float_funcs(prop, "rna_EditBone_envelope_distance_get", "rna_EditBone_envelope_distance_set", NULL); + else RNA_def_property_float_sdna(prop, NULL, "dist"); RNA_def_property_range(prop, 0.0f, 1000.0f); RNA_def_property_ui_text(prop, "Envelope Deform Distance", "Bone deformation distance (for Envelope deform only)."); prop= RNA_def_property(srna, "envelope_weight", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "weight"); + if(editbone) RNA_def_property_float_funcs(prop, "rna_EditBone_envelope_weight_get", "rna_EditBone_envelope_weight_set", NULL); + else RNA_def_property_float_sdna(prop, NULL, "weight"); RNA_def_property_range(prop, 0.0f, 1000.0f); RNA_def_property_ui_text(prop, "Envelope Deform Weight", "Bone deformation weight (for Envelope deform only)."); prop= RNA_def_property(srna, "radius_head", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "rad_head"); + if(editbone) RNA_def_property_float_funcs(prop, "rna_EditBone_radius_head_get", "rna_EditBone_radius_head_set", NULL); + else RNA_def_property_float_sdna(prop, NULL, "rad_head"); //RNA_def_property_range(prop, 0, 1000); // XXX range is 0 to lim, where lim= 10000.0f*MAX2(1.0, view3d->grid); RNA_def_property_ui_text(prop, "Envelope Radius Head", "Radius of head of bone (for Envelope deform only)."); prop= RNA_def_property(srna, "radius_tail", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "rad_tail"); + if(editbone) RNA_def_property_float_funcs(prop, "rna_EditBone_radius_tail_get", "rna_EditBone_radius_tail_set", NULL); + else RNA_def_property_float_sdna(prop, NULL, "rad_tail"); //RNA_def_property_range(prop, 0, 1000); // XXX range is 0 to lim, where lim= 10000.0f*MAX2(1.0, view3d->grid); RNA_def_property_ui_text(prop, "Envelope Radius Tail", "Radius of tail of bone (for Envelope deform only)."); /* b-bones deform settings */ prop= RNA_def_property(srna, "bbone_segments", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "segments"); + if(editbone) RNA_def_property_int_funcs(prop, "rna_EditBone_bbone_segments_get", "rna_EditBone_bbone_segments_set", NULL); + else RNA_def_property_int_sdna(prop, NULL, "segments"); RNA_def_property_range(prop, 1, 32); RNA_def_property_ui_text(prop, "B-Bone Segments", "Number of subdivisions of bone (for B-Bones only)."); prop= RNA_def_property(srna, "bbone_in", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "ease1"); + if(editbone) RNA_def_property_float_funcs(prop, "rna_EditBone_bbone_in_get", "rna_EditBone_bbone_in_set", NULL); + else RNA_def_property_float_sdna(prop, NULL, "ease1"); RNA_def_property_range(prop, 0.0f, 2.0f); RNA_def_property_ui_text(prop, "B-Bone Ease In", "Length of first Bezier Handle (for B-Bones only)."); prop= RNA_def_property(srna, "bbone_out", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "ease2"); + if(editbone) RNA_def_property_float_funcs(prop, "rna_EditBone_bbone_out_get", "rna_EditBone_bbone_out_set", NULL); + else RNA_def_property_float_sdna(prop, NULL, "ease2"); RNA_def_property_range(prop, 0.0f, 2.0f); RNA_def_property_ui_text(prop, "B-Bone Ease Out", "Length of second Bezier Handle (for B-Bones only)."); +} + +// err... bones should not be directly edited (only editbones should be...) +static void rna_def_bone(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; - /* editmode bone coordinates */ - // XXX not sure if we want to wrap these here... besides, changing these requires changing the matrix? - prop= RNA_def_property(srna, "head", PROP_FLOAT, PROP_VECTOR); - RNA_def_property_ui_text(prop, "Bone Head Location", "In Edit Mode, the location of the 'head' of the bone."); + srna= RNA_def_struct(brna, "Bone", NULL); + RNA_def_struct_ui_text(srna, "Bone", "Bone in an Armature datablock."); + RNA_def_struct_ui_icon(srna, ICON_BONE_DATA); - prop= RNA_def_property(srna, "tail", PROP_FLOAT, PROP_VECTOR); - RNA_def_property_ui_text(prop, "Bone Tail Location", "In Edit Mode, the location of the 'head' of the bone."); + /* pointers/collections */ + /* parent (pointer) */ + prop= RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "Bone"); + RNA_def_property_pointer_sdna(prop, NULL, "parent"); + RNA_def_property_ui_text(prop, "Parent", "Parent bone (in same Armature)."); + + /* children (collection) */ + prop= RNA_def_property(srna, "children", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "childbase", NULL); + RNA_def_property_struct_type(prop, "Bone"); + RNA_def_property_ui_text(prop, "Children", "Bones which are children of this bone"); + + rna_def_bone_common(srna, 0); + + // XXX should we define this in PoseChannel wrapping code instead? but PoseChannels directly get some of their flags from here... + prop= RNA_def_property(srna, "hidden", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_HIDDEN_P); + RNA_def_property_ui_text(prop, "Hidden", "Bone is not visible when it is not in Edit Mode (i.e. in Object or Pose Modes)."); + + prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_SELECTED); + RNA_def_property_ui_text(prop, "Selected", ""); +} + +static void rna_def_edit_bone(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna= RNA_def_struct(brna, "EditBone", NULL); + RNA_def_struct_ui_text(srna, "Edit Bone", "Editmode bone in an Armature datablock."); + RNA_def_struct_ui_icon(srna, ICON_BONE_DATA); + + prop= RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "EditBone"); + RNA_def_property_pointer_funcs(prop, "rna_EditBone_parent_get", NULL, NULL); + RNA_def_property_ui_text(prop, "Parent", "Parent edit bone (in same Armature)."); prop= RNA_def_property(srna, "roll", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, 0.0f, 2.0f); - RNA_def_property_ui_text(prop, "Bone Roll", "In Edit Mode, the 'roll' (i.e. rotation around the bone vector, equivalent to local Y-axis rotation)."); + RNA_def_property_float_funcs(prop, "rna_EditBone_roll_get", "rna_EditBone_roll_set", NULL); + RNA_def_property_ui_text(prop, "Roll", "Bone rotation around head-tail axis."); + + prop= RNA_def_property(srna, "head", PROP_FLOAT, PROP_VECTOR); + RNA_def_property_array(prop, 3); + RNA_def_property_float_funcs(prop, "rna_EditBone_head_get", "rna_EditBone_head_set", NULL); + RNA_def_property_ui_text(prop, "Head", "Location of head end of the bone."); + + prop= RNA_def_property(srna, "tail", PROP_FLOAT, PROP_VECTOR); + RNA_def_property_array(prop, 3); + RNA_def_property_float_funcs(prop, "rna_EditBone_tail_get", "rna_EditBone_tail_set", NULL); + RNA_def_property_ui_text(prop, "Tail", "Location of tail end of the bone."); + + rna_def_bone_common(srna, 1); + + prop= RNA_def_property(srna, "hidden", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_EditBone_hidden_get", "rna_EditBone_hidden_set"); + RNA_def_property_ui_text(prop, "Hidden", "Bone is not visible when in Edit Mode"); + + prop= RNA_def_property(srna, "locked", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_EditBone_locked_get", "rna_EditBone_locked_set"); + RNA_def_property_ui_text(prop, "Locked", "Bone is not able to be transformed when in Edit Mode."); + + prop= RNA_def_property(srna, "head_selected", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_EditBone_head_selected_get", "rna_EditBone_head_selected_set"); + RNA_def_property_ui_text(prop, "Head Selected", ""); + + prop= RNA_def_property(srna, "tail_selected", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_EditBone_tail_selected_get", "rna_EditBone_tail_selected_set"); + RNA_def_property_ui_text(prop, "Tail Selected", ""); } void rna_def_armature(BlenderRNA *brna) @@ -254,16 +640,16 @@ void rna_def_armature(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_drawtype_items[] = { - {ARM_OCTA, "OCTAHEDRAL", "Octahedral", "Draw bones as octahedral shape (default)."}, - {ARM_LINE, "STICK", "Stick", "Draw bones as simple 2D lines with dots."}, - {ARM_B_BONE, "BBONE", "B-Bone", "Draw bones as boxes, showing subdivision and B-Splines"}, - {ARM_ENVELOPE, "ENVELOPE", "Envelope", "Draw bones as extruded spheres, showing defomation influence volume."}, - {0, NULL, NULL, NULL}}; + {ARM_OCTA, "OCTAHEDRAL", 0, "Octahedral", "Draw bones as octahedral shape (default)."}, + {ARM_LINE, "STICK", 0, "Stick", "Draw bones as simple 2D lines with dots."}, + {ARM_B_BONE, "BBONE", 0, "B-Bone", "Draw bones as boxes, showing subdivision and B-Splines"}, + {ARM_ENVELOPE, "ENVELOPE", 0, "Envelope", "Draw bones as extruded spheres, showing defomation influence volume."}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_ghost_type_items[] = { - {ARM_GHOST_CUR, "CURRENT_FRAME", "Around Current Frame", "Draw Ghosts of poses within a fixed number of frames around the current frame."}, - {ARM_GHOST_RANGE, "RANGE", "In Range", "Draw Ghosts of poses within specified range."}, - {ARM_GHOST_KEYS, "KEYS", "On Keyframes", "Draw Ghosts of poses on Keyframes."}, - {0, NULL, NULL, NULL}}; + {ARM_GHOST_CUR, "CURRENT_FRAME", 0, "Around Current Frame", "Draw Ghosts of poses within a fixed number of frames around the current frame."}, + {ARM_GHOST_RANGE, "RANGE", 0, "In Range", "Draw Ghosts of poses within specified range."}, + {ARM_GHOST_KEYS, "KEYS", 0, "On Keyframes", "Draw Ghosts of poses on Keyframes."}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "Armature", "ID"); RNA_def_struct_ui_text(srna, "Armature", "Armature datablock containing a hierarchy of bones, usually used for rigging characters."); @@ -276,6 +662,11 @@ void rna_def_armature(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "bonebase", NULL); RNA_def_property_struct_type(prop, "Bone"); RNA_def_property_ui_text(prop, "Bones", ""); + + prop= RNA_def_property(srna, "edit_bones", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "edbo", NULL); + RNA_def_property_struct_type(prop, "EditBone"); + RNA_def_property_ui_text(prop, "Edit Bones", ""); /* Enum values */ prop= RNA_def_property(srna, "drawtype", PROP_ENUM, PROP_NONE); @@ -294,6 +685,7 @@ void rna_def_armature(BlenderRNA *brna) RNA_def_property_array(prop, 16); RNA_def_property_ui_text(prop, "Visible Layers", "Armature layer visibility."); RNA_def_property_boolean_funcs(prop, NULL, "rna_Armature_layer_set"); + RNA_def_property_update(prop, NC_OBJECT|ND_POSE, NULL); /* layer protection */ prop= RNA_def_property(srna, "layer_protection", PROP_BOOLEAN, PROP_NONE); @@ -433,6 +825,7 @@ void RNA_def_armature(BlenderRNA *brna) { rna_def_armature(brna); rna_def_bone(brna); + rna_def_edit_bone(brna); } #endif diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 3deb38a3a07..90617d01833 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -67,29 +67,29 @@ void rna_def_brush(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem prop_blend_items[] = { - {BRUSH_BLEND_MIX, "MIX", "Mix", "Use mix blending mode while painting."}, - {BRUSH_BLEND_ADD, "ADD", "Add", "Use add blending mode while painting."}, - {BRUSH_BLEND_SUB, "SUB", "Subtract", "Use subtract blending mode while painting."}, - {BRUSH_BLEND_MUL, "MUL", "Multiply", "Use multiply blending mode while painting."}, - {BRUSH_BLEND_LIGHTEN, "LIGHTEN", "Lighten", "Use lighten blending mode while painting."}, - {BRUSH_BLEND_DARKEN, "DARKEN", "Darken", "Use darken blending mode while painting."}, - {BRUSH_BLEND_ERASE_ALPHA, "ERASE_ALPHA", "Erase Alpha", "Erase alpha while painting."}, - {BRUSH_BLEND_ADD_ALPHA, "ADD_ALPHA", "Add Alpha", "Add alpha while painting."}, - {0, NULL, NULL, NULL}}; + {BRUSH_BLEND_MIX, "MIX", 0, "Mix", "Use mix blending mode while painting."}, + {BRUSH_BLEND_ADD, "ADD", 0, "Add", "Use add blending mode while painting."}, + {BRUSH_BLEND_SUB, "SUB", 0, "Subtract", "Use subtract blending mode while painting."}, + {BRUSH_BLEND_MUL, "MUL", 0, "Multiply", "Use multiply blending mode while painting."}, + {BRUSH_BLEND_LIGHTEN, "LIGHTEN", 0, "Lighten", "Use lighten blending mode while painting."}, + {BRUSH_BLEND_DARKEN, "DARKEN", 0, "Darken", "Use darken blending mode while painting."}, + {BRUSH_BLEND_ERASE_ALPHA, "ERASE_ALPHA", 0, "Erase Alpha", "Erase alpha while painting."}, + {BRUSH_BLEND_ADD_ALPHA, "ADD_ALPHA", 0, "Add Alpha", "Add alpha while painting."}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_texture_mode_items[] = { - {BRUSH_TEX_DRAG, "TEX_DRAG", "Drag", ""}, - {BRUSH_TEX_TILE, "TEX_TILE", "Tile", ""}, - {BRUSH_TEX_3D, "TEX_3D", "3D", ""}, - {0, NULL, NULL, NULL}}; + {BRUSH_TEX_DRAG, "TEX_DRAG", 0, "Drag", ""}, + {BRUSH_TEX_TILE, "TEX_TILE", 0, "Tile", ""}, + {BRUSH_TEX_3D, "TEX_3D", 0, "3D", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_sculpt_tool_items[] = { - {SCULPT_TOOL_DRAW, "DRAW", "Draw", ""}, - {SCULPT_TOOL_SMOOTH, "SMOOTH", "Smooth", ""}, - {SCULPT_TOOL_PINCH, "PINCH", "Pinch", ""}, - {SCULPT_TOOL_INFLATE, "INFLATE", "Inflate", ""}, - {SCULPT_TOOL_GRAB, "GRAB", "Grab", ""}, - {SCULPT_TOOL_LAYER, "LAYER", "Layer", ""}, - {SCULPT_TOOL_FLATTEN, "FLATTEN", "Flatten", ""}, - {0, NULL, NULL, NULL}}; + {SCULPT_TOOL_DRAW, "DRAW", 0, "Draw", ""}, + {SCULPT_TOOL_SMOOTH, "SMOOTH", 0, "Smooth", ""}, + {SCULPT_TOOL_PINCH, "PINCH", 0, "Pinch", ""}, + {SCULPT_TOOL_INFLATE, "INFLATE", 0, "Inflate", ""}, + {SCULPT_TOOL_GRAB, "GRAB", 0, "Grab", ""}, + {SCULPT_TOOL_LAYER, "LAYER", 0, "Layer", ""}, + {SCULPT_TOOL_FLATTEN, "FLATTEN", 0, "Flatten", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "Brush", "ID"); RNA_def_struct_ui_text(srna, "Brush", "Brush datablock for storing brush settings for painting and sculpting."); diff --git a/source/blender/makesrna/intern/rna_camera.c b/source/blender/makesrna/intern/rna_camera.c index bee8a21ad7d..4814f9583a9 100644 --- a/source/blender/makesrna/intern/rna_camera.c +++ b/source/blender/makesrna/intern/rna_camera.c @@ -42,13 +42,13 @@ void RNA_def_camera(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem prop_type_items[] = { - {CAM_PERSP, "PERSP", "Perspective", ""}, - {CAM_ORTHO, "ORTHO", "Orthographic", ""}, - {0, NULL, NULL, NULL}}; + {CAM_PERSP, "PERSP", 0, "Perspective", ""}, + {CAM_ORTHO, "ORTHO", 0, "Orthographic", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_lens_unit_items[] = { - {0, "MILLIMETERS", "Millimeters", ""}, - {CAM_ANGLETOGGLE, "DEGREES", "Degrees", ""}, - {0, NULL, NULL, NULL}}; + {0, "MILLIMETERS", 0, "Millimeters", ""}, + {CAM_ANGLETOGGLE, "DEGREES", 0, "Degrees", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "Camera", "ID"); RNA_def_struct_ui_text(srna, "Camera", "Camera datablock for storing camera settings."); @@ -62,7 +62,7 @@ void RNA_def_camera(BlenderRNA *brna) /* Number values */ - prop= RNA_def_property(srna, "passepartout_alpha", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "passepartout_alpha", PROP_FLOAT, PROP_PERCENTAGE); RNA_def_property_float_sdna(prop, NULL, "passepartalpha"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Passepartout Alpha", "Opacity (alpha) of the darkened overlay in Camera view."); diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c index 919ae210801..361c1b61303 100644 --- a/source/blender/makesrna/intern/rna_cloth.c +++ b/source/blender/makesrna/intern/rna_cloth.c @@ -31,6 +31,8 @@ #include "rna_internal.h" #include "BKE_cloth.h" +#include "BKE_modifier.h" + #include "DNA_cloth_types.h" #ifdef RNA_RUNTIME @@ -129,6 +131,22 @@ static void rna_ClothSettings_gravity_set(PointerRNA *ptr, const float *values) sim->gravity[2]= values[2]; } +static char *rna_ClothSettings_path(PointerRNA *ptr) +{ + Object *ob= (Object*)ptr->id.data; + ModifierData *md= modifiers_findByType(ob, eModifierType_Cloth); + + return BLI_sprintfN("modifiers[%s].settings", md->name); +} + +static char *rna_ClothCollisionSettings_path(PointerRNA *ptr) +{ + Object *ob= (Object*)ptr->id.data; + ModifierData *md= modifiers_findByType(ob, eModifierType_Cloth); + + return BLI_sprintfN("modifiers[%s].collision_settings", md->name); +} + #else static void rna_def_cloth_sim_settings(BlenderRNA *brna) @@ -139,6 +157,7 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna) srna = RNA_def_struct(brna, "ClothSettings", NULL); RNA_def_struct_ui_text(srna, "Cloth Settings", "Cloth simulation settings for an object."); RNA_def_struct_sdna(srna, "ClothSimSettings"); + RNA_def_struct_path_func(srna, "rna_ClothSettings_path"); /* goal */ @@ -297,6 +316,7 @@ static void rna_def_cloth_collision_settings(BlenderRNA *brna) srna = RNA_def_struct(brna, "ClothCollisionSettings", NULL); RNA_def_struct_ui_text(srna, "Cloth Collision Settings", "Cloth simulation settings for self collision and collision with other objects."); RNA_def_struct_sdna(srna, "ClothCollSettings"); + RNA_def_struct_path_func(srna, "rna_ClothCollisionSettings_path"); /* general collision */ diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index dcd5a494e5d..179808ab66d 100644 --- a/source/blender/makesrna/intern/rna_color.c +++ b/source/blender/makesrna/intern/rna_color.c @@ -120,9 +120,9 @@ static void rna_def_curvemappoint(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem prop_handle_type_items[] = { - {0, "AUTO", "Auto Handle", ""}, - {CUMA_VECTOR, "VECTOR", "Vector Handle", ""}, - {0, NULL, NULL, NULL} + {0, "AUTO", 0, "Auto Handle", ""}, + {CUMA_VECTOR, "VECTOR", 0, "Vector Handle", ""}, + {0, NULL, 0, NULL, NULL} }; srna= RNA_def_struct(brna, "CurveMapPoint", NULL); @@ -152,9 +152,9 @@ static void rna_def_curvemap(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem prop_extend_items[] = { - {0, "HORIZONTAL", "Horizontal", ""}, - {CUMA_EXTEND_EXTRAPOLATE, "EXTRAPOLATED", "Extrapolated", ""}, - {0, NULL, NULL, NULL} + {0, "HORIZONTAL", 0, "Horizontal", ""}, + {CUMA_EXTEND_EXTRAPOLATE, "EXTRAPOLATED", 0, "Extrapolated", ""}, + {0, NULL, 0, NULL, NULL} }; srna= RNA_def_struct(brna, "CurveMap", NULL); @@ -212,7 +212,7 @@ static void rna_def_curvemapping(BlenderRNA *brna) RNA_def_property_float_funcs(prop, NULL, NULL, "rna_CurveMapping_clipmaxy_range"); prop= RNA_def_property(srna, "curves", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_funcs(prop, "rna_CurveMapping_curves_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_CurveMapping_curves_length", 0, 0); + RNA_def_property_collection_funcs(prop, "rna_CurveMapping_curves_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_CurveMapping_curves_length", 0, 0, 0, 0); RNA_def_property_struct_type(prop, "CurveMap"); RNA_def_property_ui_text(prop, "Curves", ""); diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index a98bc41d129..80c145911b1 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -36,28 +36,37 @@ #include "WM_types.h" EnumPropertyItem constraint_type_items[] ={ - {CONSTRAINT_TYPE_NULL, "NULL", "Null", ""}, - {CONSTRAINT_TYPE_CHILDOF, "CHILD_OF", "Child Of", ""}, - {CONSTRAINT_TYPE_TRACKTO, "TRACK_TO", "Track To", ""}, - {CONSTRAINT_TYPE_KINEMATIC, "IK", "IK", ""}, - {CONSTRAINT_TYPE_FOLLOWPATH, "FOLLOW_PATH", "Follow Path", ""}, - {CONSTRAINT_TYPE_ROTLIMIT, "LIMIT_ROTATION", "Limit Rotation", ""}, - {CONSTRAINT_TYPE_LOCLIMIT, "LIMIT_LOCATION", "Limit Location", ""}, - {CONSTRAINT_TYPE_SIZELIMIT, "LIMIT_SCALE", "Limit Scale", ""}, - {CONSTRAINT_TYPE_ROTLIKE, "COPY_ROTATION", "Copy Rotation", ""}, - {CONSTRAINT_TYPE_LOCLIKE, "COPY_LOCATION", "Copy Location", ""}, - {CONSTRAINT_TYPE_SIZELIKE, "COPY_SCALE", "Copy Scale", ""}, - {CONSTRAINT_TYPE_PYTHON, "SCRIPT", "Script", ""}, - {CONSTRAINT_TYPE_ACTION, "ACTION", "Action", ""}, - {CONSTRAINT_TYPE_LOCKTRACK, "LOCKED_TRACK", "Locked Track", ""}, - {CONSTRAINT_TYPE_DISTLIMIT, "LIMIT_DISTANCE", "Limit Distance", ""}, - {CONSTRAINT_TYPE_STRETCHTO, "STRETCH_TO", "Stretch To", ""}, - {CONSTRAINT_TYPE_MINMAX, "FLOOR", "Floor", ""}, - {CONSTRAINT_TYPE_RIGIDBODYJOINT, "RIGID_BODY_JOINT", "Rigid Body Joint", ""}, - {CONSTRAINT_TYPE_CLAMPTO, "CLAMP_TO", "Clamp To", ""}, - {CONSTRAINT_TYPE_TRANSFORM, "TRANSFORM", "Transformation", ""}, - {CONSTRAINT_TYPE_SHRINKWRAP, "SHRINKWRAP", "Shrinkwrap", ""}, - {0, NULL, NULL, NULL}}; + {CONSTRAINT_TYPE_CHILDOF, "CHILD_OF", 0, "Child Of", ""}, + {CONSTRAINT_TYPE_TRANSFORM, "TRANSFORM", 0, "Transformation", ""}, + + {CONSTRAINT_TYPE_LOCLIKE, "COPY_LOCATION", 0, "Copy Location", ""}, + {CONSTRAINT_TYPE_ROTLIKE, "COPY_ROTATION", 0, "Copy Rotation", ""}, + {CONSTRAINT_TYPE_SIZELIKE, "COPY_SCALE", 0, "Copy Scale", ""}, + + {CONSTRAINT_TYPE_LOCLIMIT, "LIMIT_LOCATION", 0, "Limit Location", ""}, + {CONSTRAINT_TYPE_ROTLIMIT, "LIMIT_ROTATION", 0, "Limit Rotation", ""}, + {CONSTRAINT_TYPE_SIZELIMIT, "LIMIT_SCALE", 0, "Limit Scale", ""}, + {CONSTRAINT_TYPE_DISTLIMIT, "LIMIT_DISTANCE", 0, "Limit Distance", ""}, + + {CONSTRAINT_TYPE_TRACKTO, "TRACK_TO", 0, "Track To", ""}, + {CONSTRAINT_TYPE_LOCKTRACK, "LOCKED_TRACK", 0, "Locked Track", ""}, + + {CONSTRAINT_TYPE_MINMAX, "FLOOR", 0, "Floor", ""}, + {CONSTRAINT_TYPE_SHRINKWRAP, "SHRINKWRAP", 0, "Shrinkwrap", ""}, + {CONSTRAINT_TYPE_FOLLOWPATH, "FOLLOW_PATH", 0, "Follow Path", ""}, + + {CONSTRAINT_TYPE_CLAMPTO, "CLAMP_TO", 0, "Clamp To", ""}, + {CONSTRAINT_TYPE_STRETCHTO, "STRETCH_TO", 0, "Stretch To", ""}, + + {CONSTRAINT_TYPE_KINEMATIC, "IK", 0, "IK", ""}, + {CONSTRAINT_TYPE_RIGIDBODYJOINT, "RIGID_BODY_JOINT", 0, "Rigid Body Joint", ""}, + + {CONSTRAINT_TYPE_ACTION, "ACTION", 0, "Action", ""}, + + {CONSTRAINT_TYPE_PYTHON, "SCRIPT", 0, "Script", ""}, + + {CONSTRAINT_TYPE_NULL, "NULL", 0, "Null", ""}, + {0, NULL, 0, NULL, NULL}}; #ifdef RNA_RUNTIME @@ -158,16 +167,16 @@ static void rna_Constraint_influence_update(bContext *C, PointerRNA *ptr) } static EnumPropertyItem space_pchan_items[] = { - {0, "WORLD", "World Space", ""}, - {2, "POSE", "Pose Space", ""}, - {3, "LOCAL_WITH_PARENT", "Local With Parent", ""}, - {1, "LOCAL", "Local Space", ""}, - {0, NULL, NULL, NULL}}; + {0, "WORLD", 0, "World Space", ""}, + {2, "POSE", 0, "Pose Space", ""}, + {3, "LOCAL_WITH_PARENT", 0, "Local With Parent", ""}, + {1, "LOCAL", 0, "Local Space", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem space_object_items[] = { - {0, "WORLD", "World Space", ""}, - {1, "LOCAL", "Local (Without Parent) Space", ""}, - {0, NULL, NULL, NULL}}; + {0, "WORLD", 0, "World Space", ""}, + {1, "LOCAL", 0, "Local (Without Parent) Space", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem *rna_Constraint_owner_space_itemf(PointerRNA *ptr) { @@ -415,19 +424,19 @@ static void rna_def_constraint_track_to(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem track_items[] = { - {TRACK_X, "TRACK_X", "X", ""}, - {TRACK_Y, "TRACK_Y", "Y", ""}, - {TRACK_Z, "TRACK_Z", "Z", ""}, - {TRACK_nX, "TRACK_NEGATIVE_X", "-X", ""}, - {TRACK_nY, "TRACK_NEGATIVE_Y", "-Y", ""}, - {TRACK_nZ, "TRACK_NEGATIVE_Z", "-Z", ""}, - {0, NULL, NULL, NULL}}; + {TRACK_X, "TRACK_X", 0, "X", ""}, + {TRACK_Y, "TRACK_Y", 0, "Y", ""}, + {TRACK_Z, "TRACK_Z", 0, "Z", ""}, + {TRACK_nX, "TRACK_NEGATIVE_X", 0, "-X", ""}, + {TRACK_nY, "TRACK_NEGATIVE_Y", 0, "-Y", ""}, + {TRACK_nZ, "TRACK_NEGATIVE_Z", 0, "-Z", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem up_items[] = { - {TRACK_X, "UP_X", "X", ""}, - {TRACK_Y, "UP_Y", "Y", ""}, - {TRACK_Z, "UP_Z", "Z", ""}, - {0, NULL, NULL, NULL}}; + {TRACK_X, "UP_X", 0, "X", ""}, + {TRACK_Y, "UP_Y", 0, "Y", ""}, + {TRACK_Z, "UP_Z", 0, "Z", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "TrackToConstraint", "Constraint"); RNA_def_struct_ui_text(srna, "Track To Constraint", "Aims the constrained object toward the target."); @@ -588,13 +597,13 @@ static void rna_def_constraint_minmax(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem minmax_items[] = { - {LOCLIKE_X, "FLOOR_X", "X", ""}, - {LOCLIKE_Y, "FLOOR_Y", "Y", ""}, - {LOCLIKE_Z, "FLOOR_Z", "Z", ""}, - {LOCLIKE_X_INVERT, "FLOOR_NEGATIVE_X", "-X", ""}, - {LOCLIKE_Y_INVERT, "FLOOR_NEGATIVE_Y", "-Y", ""}, - {LOCLIKE_Z_INVERT, "FLOOR_NEGATIVE_Z", "-Z", ""}, - {0, NULL, NULL, NULL}}; + {LOCLIKE_X, "FLOOR_X", 0, "X", ""}, + {LOCLIKE_Y, "FLOOR_Y", 0, "Y", ""}, + {LOCLIKE_Z, "FLOOR_Z", 0, "Z", ""}, + {LOCLIKE_X_INVERT, "FLOOR_NEGATIVE_X", 0, "-X", ""}, + {LOCLIKE_Y_INVERT, "FLOOR_NEGATIVE_Y", 0, "-Y", ""}, + {LOCLIKE_Z_INVERT, "FLOOR_NEGATIVE_Z", 0, "-Z", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "FloorConstraint", "Constraint"); RNA_def_struct_ui_text(srna, "Floor Constraint", "Uses the target object for location limitation."); @@ -681,16 +690,16 @@ static void rna_def_constraint_action(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem transform_channel_items[] = { - {00, "ROTATION_X", "Rotation X", ""}, - {01, "ROTATION_Y", "Rotation Y", ""}, - {02, "ROTATION_Z", "Rotation Z", ""}, - {10, "SIZE_X", "Scale X", ""}, - {11, "SIZE_Y", "Scale Y", ""}, - {12, "SIZE_Z", "Scale Z", ""}, - {20, "LOCATION_X", "Location X", ""}, - {21, "LOCATION_Y", "Location Y", ""}, - {22, "LOCATION_Z", "Location Z", ""}, - {0, NULL, NULL, NULL}}; + {00, "ROTATION_X", 0, "Rotation X", ""}, + {01, "ROTATION_Y", 0, "Rotation Y", ""}, + {02, "ROTATION_Z", 0, "Rotation Z", ""}, + {10, "SIZE_X", 0, "Scale X", ""}, + {11, "SIZE_Y", 0, "Scale Y", ""}, + {12, "SIZE_Z", 0, "Scale Z", ""}, + {20, "LOCATION_X", 0, "Location X", ""}, + {21, "LOCATION_Y", 0, "Location Y", ""}, + {22, "LOCATION_Z", 0, "Location Z", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "ActionConstraint", "Constraint"); RNA_def_struct_ui_text(srna, "Action Constraint", "Map an action to the transform axes of a bone."); @@ -750,19 +759,19 @@ static void rna_def_constraint_locked_track(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem locktrack_items[] = { - {TRACK_X, "TRACK_X", "X", ""}, - {TRACK_Y, "TRACK_Y", "Y", ""}, - {TRACK_Z, "TRACK_Z", "Z", ""}, - {TRACK_nX, "TRACK_NEGATIVE_X", "-X", ""}, - {TRACK_nY, "TRACK_NEGATIVE_Y", "-Y", ""}, - {TRACK_nZ, "TRACK_NEGATIVE_Z", "-Z", ""}, - {0, NULL, NULL, NULL}}; + {TRACK_X, "TRACK_X", 0, "X", ""}, + {TRACK_Y, "TRACK_Y", 0, "Y", ""}, + {TRACK_Z, "TRACK_Z", 0, "Z", ""}, + {TRACK_nX, "TRACK_NEGATIVE_X", 0, "-X", ""}, + {TRACK_nY, "TRACK_NEGATIVE_Y", 0, "-Y", ""}, + {TRACK_nZ, "TRACK_NEGATIVE_Z", 0, "-Z", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem lock_items[] = { - {TRACK_X, "LOCK_X", "X", ""}, - {TRACK_Y, "LOCK_Y", "Y", ""}, - {TRACK_Z, "LOCK_Z", "Z", ""}, - {0, NULL, NULL, NULL}}; + {TRACK_X, "LOCK_X", 0, "X", ""}, + {TRACK_Y, "LOCK_Y", 0, "Y", ""}, + {TRACK_Z, "LOCK_Z", 0, "Z", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "LockedTrackConstraint", "Constraint"); RNA_def_struct_ui_text(srna, "Locked Track Constraint", "Points toward the target along the track axis, while locking the other axis."); @@ -798,19 +807,19 @@ static void rna_def_constraint_follow_path(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem forwardpath_items[] = { - {TRACK_X, "FORWARD_X", "X", ""}, - {TRACK_Y, "FORWARD_Y", "Y", ""}, - {TRACK_Z, "FORWARD_Z", "Z", ""}, - {TRACK_nX, "TRACK_NEGATIVE_X", "-X", ""}, - {TRACK_nY, "TRACK_NEGATIVE_Y", "-Y", ""}, - {TRACK_nZ, "TRACK_NEGATIVE_Z", "-Z", ""}, - {0, NULL, NULL, NULL}}; + {TRACK_X, "FORWARD_X", 0, "X", ""}, + {TRACK_Y, "FORWARD_Y", 0, "Y", ""}, + {TRACK_Z, "FORWARD_Z", 0, "Z", ""}, + {TRACK_nX, "TRACK_NEGATIVE_X", 0, "-X", ""}, + {TRACK_nY, "TRACK_NEGATIVE_Y", 0, "-Y", ""}, + {TRACK_nZ, "TRACK_NEGATIVE_Z", 0, "-Z", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem pathup_items[] = { - {TRACK_X, "UP_X", "X", ""}, - {TRACK_Y, "UP_Y", "Y", ""}, - {TRACK_Z, "UP_Z", "Z", ""}, - {0, NULL, NULL, NULL}}; + {TRACK_X, "UP_X", 0, "X", ""}, + {TRACK_Y, "UP_Y", 0, "Y", ""}, + {TRACK_Z, "UP_Z", 0, "Z", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "FollowPathConstraint", "Constraint"); RNA_def_struct_ui_text(srna, "Follow Path Constraint", "Locks motion to the target path."); @@ -851,16 +860,16 @@ static void rna_def_constraint_stretch_to(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem volume_items[] = { - {VOLUME_XZ, "VOLUME_XZX", "XZ", ""}, - {VOLUME_X, "VOLUME_X", "Y", ""}, - {VOLUME_Z, "VOLUME_Z", "Z", ""}, - {NO_VOLUME, "NO_VOLUME", "None", ""}, - {0, NULL, NULL, NULL}}; + {VOLUME_XZ, "VOLUME_XZX", 0, "XZ", ""}, + {VOLUME_X, "VOLUME_X", 0, "Y", ""}, + {VOLUME_Z, "VOLUME_Z", 0, "Z", ""}, + {NO_VOLUME, "NO_VOLUME", 0, "None", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem plane_items[] = { - {PLANE_X, "PLANE_X", "X", "Keep X Axis"}, - {PLANE_Z, "PLANE_Z", "Z", "Keep Z Axis"}, - {0, NULL, NULL, NULL}}; + {PLANE_X, "PLANE_X", 0, "X", "Keep X Axis"}, + {PLANE_Z, "PLANE_Z", 0, "Z", "Keep Z Axis"}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "StretchToConstraint", "Constraint"); RNA_def_struct_ui_text(srna, "Stretch To Constraint", "Stretches to meet the target object."); @@ -902,11 +911,11 @@ static void rna_def_constraint_rigid_body_joint(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem pivot_items[] = { - {CONSTRAINT_RB_BALL, "BALL", "Ball", ""}, - {CONSTRAINT_RB_HINGE, "HINGE", "Hinge", ""}, - {CONSTRAINT_RB_CONETWIST, "CONE_TWIST", "Cone Twist", ""}, - {CONSTRAINT_RB_GENERIC6DOF, "GENERIC_6_DOF", "Generic 6 DoF", ""}, - {0, NULL, NULL, NULL}}; + {CONSTRAINT_RB_BALL, "BALL", 0, "Ball", ""}, + {CONSTRAINT_RB_HINGE, "HINGE", 0, "Hinge", ""}, + {CONSTRAINT_RB_CONETWIST, "CONE_TWIST", 0, "Cone Twist", ""}, + {CONSTRAINT_RB_GENERIC6DOF, "GENERIC_6_DOF", 0, "Generic 6 DoF", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "RigidBodyJointConstraint", "Constraint"); RNA_def_struct_ui_text(srna, "Rigid Body Joint Constraint", "For use with the Game Engine."); @@ -986,11 +995,11 @@ static void rna_def_constraint_clamp_to(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem clamp_items[] = { - {CLAMPTO_AUTO, "CLAMPTO_AUTO", "Auto", ""}, - {CLAMPTO_X, "CLAMPTO_X", "X", ""}, - {CLAMPTO_Y, "CLAMPTO_Y", "Y", ""}, - {CLAMPTO_Z, "CLAMPTO_Z", "Z", ""}, - {0, NULL, NULL, NULL}}; + {CLAMPTO_AUTO, "CLAMPTO_AUTO", 0, "Auto", ""}, + {CLAMPTO_X, "CLAMPTO_X", 0, "X", ""}, + {CLAMPTO_Y, "CLAMPTO_Y", 0, "Y", ""}, + {CLAMPTO_Z, "CLAMPTO_Z", 0, "Z", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "ClampToConstraint", "Constraint"); RNA_def_struct_ui_text(srna, "Clamp To Constraint", "Constrains an object's location to the nearest point along the target path."); @@ -1020,16 +1029,16 @@ static void rna_def_constraint_transform(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem transform_items[] = { - {0, "LOCATION", "Loc", ""}, - {1, "ROTATION", "Rot", ""}, - {2, "SCALE", "Scale", ""}, - {0, NULL, NULL, NULL}}; + {0, "LOCATION", 0, "Loc", ""}, + {1, "ROTATION", 0, "Rot", ""}, + {2, "SCALE", 0, "Scale", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem axis_map_items[] = { - {0, "X", "X", ""}, - {1, "Y", "Y", ""}, - {2, "Z", "Z", ""}, - {0, NULL, NULL, NULL}}; + {0, "X", 0, "X", ""}, + {1, "Y", 0, "Y", ""}, + {2, "Z", 0, "Z", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "TransformConstraint", "Constraint"); RNA_def_struct_ui_text(srna, "Transformation Constraint", "Maps transformations of the target to the object."); @@ -1388,10 +1397,10 @@ static void rna_def_constraint_distance_limit(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem distance_items[] = { - {LIMITDIST_INSIDE, "LIMITDIST_INSIDE", "Inside", ""}, - {LIMITDIST_OUTSIDE, "LIMITDIST_OUTSIDE", "Outside", ""}, - {LIMITDIST_ONSURFACE, "LIMITDIST_ONSURFACE", "On Surface", ""}, - {0, NULL, NULL, NULL}}; + {LIMITDIST_INSIDE, "LIMITDIST_INSIDE", 0, "Inside", ""}, + {LIMITDIST_OUTSIDE, "LIMITDIST_OUTSIDE", 0, "Outside", ""}, + {LIMITDIST_ONSURFACE, "LIMITDIST_ONSURFACE", 0, "On Surface", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "LimitDistanceConstraint", "Constraint"); RNA_def_struct_ui_text(srna, "Limit Distance Constraint", "Limits the distance from target object."); @@ -1427,10 +1436,10 @@ static void rna_def_constraint_shrinkwrap(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem type_items[] = { - {MOD_SHRINKWRAP_NEAREST_SURFACE, "NEAREST_SURFACE", "Nearest Surface Point", ""}, - {MOD_SHRINKWRAP_PROJECT, "PROJECT", "Project", ""}, - {MOD_SHRINKWRAP_NEAREST_VERTEX, "NEAREST_VERTEX", "Nearest Vertex", ""}, - {0, NULL, NULL, NULL}}; + {MOD_SHRINKWRAP_NEAREST_SURFACE, "NEAREST_SURFACE", 0, "Nearest Surface Point", ""}, + {MOD_SHRINKWRAP_PROJECT, "PROJECT", 0, "Project", ""}, + {MOD_SHRINKWRAP_NEAREST_VERTEX, "NEAREST_VERTEX", 0, "Nearest Vertex", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "ShrinkwrapConstraint", "Constraint"); RNA_def_struct_ui_text(srna, "Shrinkwrap Constraint", "Creates constraint-based shrinkwrap relationship."); diff --git a/source/blender/makesrna/intern/rna_context.c b/source/blender/makesrna/intern/rna_context.c index ed609c48e50..07a50235733 100644 --- a/source/blender/makesrna/intern/rna_context.c +++ b/source/blender/makesrna/intern/rna_context.c @@ -55,25 +55,33 @@ static PointerRNA rna_Context_screen_get(PointerRNA *ptr) static PointerRNA rna_Context_area_get(PointerRNA *ptr) { bContext *C= (bContext*)ptr->data; - return rna_pointer_inherit_refine(ptr, &RNA_Area, CTX_wm_area(C)); + PointerRNA newptr; + RNA_pointer_create((ID*)CTX_wm_screen(C), &RNA_Area, CTX_wm_area(C), &newptr); + return newptr; } static PointerRNA rna_Context_space_data_get(PointerRNA *ptr) { bContext *C= (bContext*)ptr->data; - return rna_pointer_inherit_refine(ptr, &RNA_Space, CTX_wm_space_data(C)); + PointerRNA newptr; + RNA_pointer_create((ID*)CTX_wm_screen(C), &RNA_Space, CTX_wm_space_data(C), &newptr); + return newptr; } static PointerRNA rna_Context_region_get(PointerRNA *ptr) { bContext *C= (bContext*)ptr->data; - return rna_pointer_inherit_refine(ptr, &RNA_Region, CTX_wm_region(C)); + PointerRNA newptr; + RNA_pointer_create((ID*)CTX_wm_screen(C), &RNA_Region, CTX_wm_region(C), &newptr); + return newptr; } /*static PointerRNA rna_Context_region_data_get(PointerRNA *ptr) { bContext *C= (bContext*)ptr->data; - return rna_pointer_inherit_refine(ptr, &RNA_RegionData, CTX_wm_region_data(C)); + PointerRNA newptr; + RNA_pointer_create((ID*)CTX_wm_screen(C), &RNA_RegionData, CTX_wm_region_data(C), &newptr); + return newptr; }*/ static PointerRNA rna_Context_main_get(PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_controller.c b/source/blender/makesrna/intern/rna_controller.c index df603e7920f..4d5ef7aa123 100644 --- a/source/blender/makesrna/intern/rna_controller.c +++ b/source/blender/makesrna/intern/rna_controller.c @@ -66,15 +66,15 @@ void RNA_def_controller(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem controller_type_items[] ={ - {CONT_LOGIC_AND, "LOGIC_AND", "Logic And", ""}, - {CONT_LOGIC_OR, "LOGIC_OR", "Logic Or", ""}, - {CONT_LOGIC_NAND, "LOGIC_NAND", "Logic Nand", ""}, - {CONT_LOGIC_NOR, "LOGIC_NOR", "Logic Nor", ""}, - {CONT_LOGIC_XOR, "LOGIC_XOR", "Logic Xor", ""}, - {CONT_LOGIC_XNOR, "LOGIC_XNOR", "Logic Xnor", ""}, - {CONT_EXPRESSION, "EXPRESSION", "Expression", ""}, - {CONT_PYTHON, "PYTHON", "Python Script", ""}, - {0, NULL, NULL, NULL}}; + {CONT_LOGIC_AND, "LOGIC_AND", 0, "Logic And", ""}, + {CONT_LOGIC_OR, "LOGIC_OR", 0, "Logic Or", ""}, + {CONT_LOGIC_NAND, "LOGIC_NAND", 0, "Logic Nand", ""}, + {CONT_LOGIC_NOR, "LOGIC_NOR", 0, "Logic Nor", ""}, + {CONT_LOGIC_XOR, "LOGIC_XOR", 0, "Logic Xor", ""}, + {CONT_LOGIC_XNOR, "LOGIC_XNOR", 0, "Logic Xnor", ""}, + {CONT_EXPRESSION, "EXPRESSION", 0, "Expression", ""}, + {CONT_PYTHON, "PYTHON", 0, "Python Script", ""}, + {0, NULL, 0, NULL, NULL}}; /* Controller */ srna= RNA_def_struct(brna, "Controller", NULL); diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index aac9d75c6a6..41a47e279e9 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -33,18 +33,18 @@ #include "DNA_material_types.h" EnumPropertyItem beztriple_handle_type_items[] = { - {HD_FREE, "FREE", "Free", ""}, - {HD_AUTO, "AUTO", "Auto", ""}, - {HD_VECT, "VECTOR", "Vector", ""}, - {HD_ALIGN, "ALIGNED", "Aligned", ""}, - {HD_AUTO_ANIM, "AUTO_CLAMPED", "Auto Clamped", ""}, - {0, NULL, NULL, NULL}}; + {HD_FREE, "FREE", 0, "Free", ""}, + {HD_AUTO, "AUTO", 0, "Auto", ""}, + {HD_VECT, "VECTOR", 0, "Vector", ""}, + {HD_ALIGN, "ALIGNED", 0, "Aligned", ""}, + {HD_AUTO_ANIM, "AUTO_CLAMPED", 0, "Auto Clamped", ""}, + {0, NULL, 0, NULL, NULL}}; EnumPropertyItem beztriple_interpolation_mode_items[] = { - {BEZT_IPO_CONST, "CONSTANT", "Constant", ""}, - {BEZT_IPO_LIN, "LINEAR", "Linear", ""}, - {BEZT_IPO_BEZ, "BEZIER", "Bezier", ""}, - {0, NULL, NULL, NULL}}; + {BEZT_IPO_CONST, "CONSTANT", 0, "Constant", ""}, + {BEZT_IPO_LIN, "LINEAR", 0, "Linear", ""}, + {BEZT_IPO_BEZ, "BEZIER", 0, "Bezier", ""}, + {0, NULL, 0, NULL, NULL}}; #ifdef RNA_RUNTIME @@ -307,12 +307,12 @@ static void rna_def_font(BlenderRNA *brna, StructRNA *srna) PropertyRNA *prop; static EnumPropertyItem prop_align_items[] = { - {CU_LEFT, "LEFT", "Left", "Align text to the left"}, - {CU_MIDDLE, "CENTRAL", "Center", "Center text"}, - {CU_RIGHT, "RIGHT", "Right", "Align text to the right"}, - {CU_JUSTIFY, "JUSTIFY", "Justify", "Align to the left and the right"}, - {CU_FLUSH, "FLUSH", "Flush", "Align to the left and the right, with equal character spacing"}, - {0, NULL, NULL, NULL}}; + {CU_LEFT, "LEFT", 0, "Left", "Align text to the left"}, + {CU_MIDDLE, "CENTRAL", 0, "Center", "Center text"}, + {CU_RIGHT, "RIGHT", 0, "Right", "Align text to the right"}, + {CU_JUSTIFY, "JUSTIFY", 0, "Justify", "Align to the left and the right"}, + {CU_FLUSH, "FLUSH", 0, "Flush", "Align to the left and the right, with equal character spacing"}, + {0, NULL, 0, NULL, NULL}}; /* Enums */ prop= RNA_def_property(srna, "spacemode", PROP_ENUM, PROP_NONE); @@ -590,11 +590,11 @@ static void rna_def_curve(BlenderRNA *brna) static void rna_def_curve_nurb(BlenderRNA *brna) { static EnumPropertyItem spline_interpolation_items[] = { - {BEZT_IPO_CONST, "LINEAR", "Linear", ""}, - {BEZT_IPO_LIN, "CARDINAL", "Cardinal", ""}, - {BEZT_IPO_BEZ, "BSPLINE", "BSpline", ""}, - {BEZT_IPO_BEZ, "EASE", "Ease", ""}, - {0, NULL, NULL, NULL}}; + {BEZT_IPO_CONST, "LINEAR", 0, "Linear", ""}, + {BEZT_IPO_LIN, "CARDINAL", 0, "Cardinal", ""}, + {BEZT_IPO_BEZ, "BSPLINE", 0, "BSpline", ""}, + {BEZT_IPO_BEZ, "EASE", 0, "Ease", ""}, + {0, NULL, 0, NULL, NULL}}; StructRNA *srna; PropertyRNA *prop; @@ -605,7 +605,7 @@ static void rna_def_curve_nurb(BlenderRNA *brna) prop= RNA_def_property(srna, "points", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "bp", NULL); RNA_def_property_struct_type(prop, "CurvePoint"); - RNA_def_property_collection_funcs(prop, "rna_BPoint_array_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_Nurb_length", 0, 0); + RNA_def_property_collection_funcs(prop, "rna_BPoint_array_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_Nurb_length", 0, 0, 0, 0); RNA_def_property_ui_text(prop, "Points", "Collection of points for Poly and Nurbs curves."); prop= RNA_def_property(srna, "bezier_points", PROP_COLLECTION, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 33d94e800d1..51c1818eed9 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -38,6 +38,8 @@ #include "RNA_define.h" #include "RNA_types.h" +#include "BLI_ghash.h" + #include "rna_internal.h" /* Global used during defining */ @@ -557,6 +559,7 @@ StructRNA *RNA_def_struct(BlenderRNA *brna, const char *identifier, const char * /* copy from struct to derive stuff, a bit clumsy since we can't * use MEM_dupallocN, data structs may not be alloced but builtin */ memcpy(srna, srnafrom, sizeof(StructRNA)); + srna->cont.prophash= NULL; srna->cont.properties.first= srna->cont.properties.last= NULL; srna->functions.first= srna->functions.last= NULL; srna->py_type= NULL; @@ -604,7 +607,7 @@ StructRNA *RNA_def_struct(BlenderRNA *brna, const char *identifier, const char * if(DefRNA.preprocess) { RNA_def_property_struct_type(prop, "Property"); - RNA_def_property_collection_funcs(prop, "rna_builtin_properties_begin", "rna_builtin_properties_next", "rna_iterator_listbase_end", "rna_builtin_properties_get", 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_builtin_properties_begin", "rna_builtin_properties_next", "rna_iterator_listbase_end", "rna_builtin_properties_get", 0, 0, "rna_builtin_properties_lookup_string", 0, 0); } else { #ifdef RNA_RUNTIME @@ -923,8 +926,13 @@ PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier break; } } - else + else { prop->flag |= PROP_IDPROPERTY|PROP_RUNTIME; +#ifdef RNA_RUNTIME + if(cont->prophash) + BLI_ghash_insert(cont->prophash, (void*)prop->identifier, prop); +#endif + } rna_addtail(&cont->properties, prop); @@ -976,6 +984,13 @@ void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *d prop->description= description; } +void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, int consecutive) +{ + prop->icon= icon; + if(consecutive) + prop->flag |= PROP_ICONS_CONSECUTIVE; +} + void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision) { StructRNA *srna= DefRNA.laststruct; @@ -1769,7 +1784,7 @@ void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const ch } } -void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring) +void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring, const char *add, const char *remove) { StructRNA *srna= DefRNA.laststruct; @@ -1789,6 +1804,8 @@ void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, con if(length) cprop->length= (PropCollectionLengthFunc)length; if(lookupint) cprop->lookupint= (PropCollectionLookupIntFunc)lookupint; if(lookupstring) cprop->lookupstring= (PropCollectionLookupStringFunc)lookupstring; + if(add) cprop->add= (FunctionRNA*)add; + if(remove) cprop->remove= (FunctionRNA*)remove; break; } default: @@ -2219,15 +2236,13 @@ int rna_parameter_size(PropertyRNA *parm) case PROP_STRING: return sizeof(char *); case PROP_POINTER: { - PointerPropertyRNA *pprop= (PointerPropertyRNA*)parm; - #ifdef RNA_RUNTIME - if(pprop->type == &RNA_AnyType) + if(parm->flag & PROP_RNAPTR) return sizeof(PointerRNA); else return sizeof(void *); #else - if(strcmp((char*)pprop->type, "AnyType") == 0) + if(parm->flag & PROP_RNAPTR) return sizeof(PointerRNA); else return sizeof(void *); diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index 69103536310..a1cd95c9d90 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -35,15 +35,15 @@ #include "MEM_guardedalloc.h" EnumPropertyItem fmodifier_type_items[] = { - {FMODIFIER_TYPE_NULL, "NULL", "Invalid", ""}, - {FMODIFIER_TYPE_GENERATOR, "GENERATOR", "Generator", ""}, - {FMODIFIER_TYPE_ENVELOPE, "ENVELOPE", "Envelope", ""}, - {FMODIFIER_TYPE_CYCLES, "CYCLES", "Cycles", ""}, - {FMODIFIER_TYPE_NOISE, "NOISE", "Noise", ""}, - {FMODIFIER_TYPE_FILTER, "FILTER", "Filter", ""}, - {FMODIFIER_TYPE_PYTHON, "PYTHON", "Python", ""}, - {FMODIFIER_TYPE_LIMITS, "LIMITS", "Limits", ""}, - {0, NULL, NULL, NULL}}; + {FMODIFIER_TYPE_NULL, "NULL", 0, "Invalid", ""}, + {FMODIFIER_TYPE_GENERATOR, "GENERATOR", 0, "Generator", ""}, + {FMODIFIER_TYPE_ENVELOPE, "ENVELOPE", 0, "Envelope", ""}, + {FMODIFIER_TYPE_CYCLES, "CYCLES", 0, "Cycles", ""}, + {FMODIFIER_TYPE_NOISE, "NOISE", 0, "Noise", ""}, + {FMODIFIER_TYPE_FILTER, "FILTER", 0, "Filter", ""}, + {FMODIFIER_TYPE_PYTHON, "PYTHON", 0, "Python", ""}, + {FMODIFIER_TYPE_LIMITS, "LIMITS", 0, "Limits", ""}, + {0, NULL, 0, NULL, NULL}}; #ifdef RNA_RUNTIME @@ -220,11 +220,11 @@ static void rna_def_fmodifier_generator_common(StructRNA *srna) PropertyRNA *prop; static EnumPropertyItem prop_mode_items[] = { - {FCM_GENERATOR_POLYNOMIAL, "POLYNOMIAL", "Expanded Polynomial", ""}, - {FCM_GENERATOR_POLYNOMIAL_FACTORISED, "POLYNOMIAL_FACTORISED", "Factorised Polynomial", ""}, - {FCM_GENERATOR_FUNCTION, "FUNCTION", "Built-In Function", ""}, - {FCM_GENERATOR_EXPRESSION, "EXPRESSION", "Expression", ""}, - {0, NULL, NULL, NULL}}; + {FCM_GENERATOR_POLYNOMIAL, "POLYNOMIAL", 0, "Expanded Polynomial", ""}, + {FCM_GENERATOR_POLYNOMIAL_FACTORISED, "POLYNOMIAL_FACTORISED", 0, "Factorised Polynomial", ""}, + {FCM_GENERATOR_FUNCTION, "FUNCTION", 0, "Built-In Function", ""}, + {FCM_GENERATOR_EXPRESSION, "EXPRESSION", 0, "Expression", ""}, + {0, NULL, 0, NULL, NULL}}; /* struct wrapping settings */ RNA_def_struct_sdna_from(srna, "FMod_Generator", "data"); @@ -279,13 +279,13 @@ static void rna_def_fmodifier_generator_function(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_type_items[] = { - {0, "SIN", "Sine", ""}, - {1, "COS", "Cosine", ""}, - {2, "TAN", "Tangent", ""}, - {3, "SQRT", "Square Root", ""}, - {4, "LN", "Natural Logarithm", ""}, - {5, "SINC", "Normalised Sine", "sin(x) / x"}, - {0, NULL, NULL, NULL}}; + {0, "SIN", 0, "Sine", ""}, + {1, "COS", 0, "Cosine", ""}, + {2, "TAN", 0, "Tangent", ""}, + {3, "SQRT", 0, "Square Root", ""}, + {4, "LN", 0, "Natural Logarithm", ""}, + {5, "SINC", 0, "Normalised Sine", "sin(x) / x"}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "FModifierGenerator_Function", "FModifier"); @@ -337,11 +337,11 @@ static void rna_def_fmodifier_cycles(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_type_items[] = { - {FCM_EXTRAPOLATE_NONE, "NONE", "No Cycles", "Don't do anything."}, - {FCM_EXTRAPOLATE_CYCLIC, "REPEAT", "Repeat Motion", "Repeat keyframe range as-is."}, - {FCM_EXTRAPOLATE_CYCLIC_OFFSET, "REPEAT_OFFSET", "Repeat with Offset", "Repeat keyframe range, but with offset based on gradient between values"}, - {FCM_EXTRAPOLATE_MIRROR, "MIRROR", "Repeat Mirrored", "Alternate between forward and reverse playback of keyframe range"}, - {0, NULL, NULL, NULL}}; + {FCM_EXTRAPOLATE_NONE, "NONE", 0, "No Cycles", "Don't do anything."}, + {FCM_EXTRAPOLATE_CYCLIC, "REPEAT", 0, "Repeat Motion", "Repeat keyframe range as-is."}, + {FCM_EXTRAPOLATE_CYCLIC_OFFSET, "REPEAT_OFFSET", 0, "Repeat with Offset", "Repeat keyframe range, but with offset based on gradient between values"}, + {FCM_EXTRAPOLATE_MIRROR, "MIRROR", 0, "Repeat Mirrored", "Alternate between forward and reverse playback of keyframe range"}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "FModifierCycles", "FModifier"); RNA_def_struct_ui_text(srna, "Cycles F-Curve Modifier", "Repeats the values of the modified F-Curve."); @@ -429,11 +429,11 @@ static void rna_def_fmodifier_noise(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_modification_items[] = { - {FCM_NOISE_MODIF_REPLACE, "REPLACE", "Replace", ""}, - {FCM_NOISE_MODIF_ADD, "ADD", "Add", ""}, - {FCM_NOISE_MODIF_SUBTRACT, "SUBTRACT", "Subtract", ""}, - {FCM_NOISE_MODIF_MULTIPLY, "MULTIPLY", "Multiply", ""}, - {0, NULL, NULL, NULL}}; + {FCM_NOISE_MODIF_REPLACE, "REPLACE", 0, "Replace", ""}, + {FCM_NOISE_MODIF_ADD, "ADD", 0, "Add", ""}, + {FCM_NOISE_MODIF_SUBTRACT, "SUBTRACT", 0, "Subtract", ""}, + {FCM_NOISE_MODIF_MULTIPLY, "MULTIPLY", 0, "Multiply", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "FModifierNoise", "FModifier"); RNA_def_struct_ui_text(srna, "Noise F-Curve Modifier", "Gives randomness to the modified F-Curve."); @@ -543,10 +543,10 @@ void rna_def_channeldriver(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_type_items[] = { - {DRIVER_TYPE_AVERAGE, "AVERAGE", "Averaged Value", ""}, - {DRIVER_TYPE_PYTHON, "SCRIPTED", "Scripted Expression", ""}, - {DRIVER_TYPE_ROTDIFF, "ROTDIFF", "Rotational Difference", ""}, - {0, NULL, NULL, NULL}}; + {DRIVER_TYPE_AVERAGE, "AVERAGE", 0, "Averaged Value", ""}, + {DRIVER_TYPE_PYTHON, "SCRIPTED", 0, "Scripted Expression", ""}, + {DRIVER_TYPE_ROTDIFF, "ROTDIFF", 0, "Rotational Difference", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "Driver", NULL); RNA_def_struct_sdna(srna, "ChannelDriver"); @@ -576,14 +576,14 @@ void rna_def_fcurve(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_mode_extend_items[] = { - {FCURVE_EXTRAPOLATE_CONSTANT, "CONSTANT", "Constant", ""}, - {FCURVE_EXTRAPOLATE_LINEAR, "LINEAR", "Linear", ""}, - {0, NULL, NULL, NULL}}; + {FCURVE_EXTRAPOLATE_CONSTANT, "CONSTANT", 0, "Constant", ""}, + {FCURVE_EXTRAPOLATE_LINEAR, "LINEAR", 0, "Linear", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_mode_color_items[] = { - {FCURVE_COLOR_AUTO_RAINBOW, "AUTO_RAINBOW", "Automatic Rainbow", ""}, - {FCURVE_COLOR_AUTO_RGB, "AUTO_RGB", "Automatic XYZ to RGB", ""}, - {FCURVE_COLOR_CUSTOM, "CUSTOM", "User Defined", ""}, - {0, NULL, NULL, NULL}}; + {FCURVE_COLOR_AUTO_RAINBOW, "AUTO_RAINBOW", 0, "Automatic Rainbow", ""}, + {FCURVE_COLOR_AUTO_RGB, "AUTO_RGB", 0, "Automatic XYZ to RGB", ""}, + {FCURVE_COLOR_CUSTOM, "CUSTOM", 0, "User Defined", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "FCurve", NULL); RNA_def_struct_ui_text(srna, "F-Curve", "F-Curve defining values of a period of time."); diff --git a/source/blender/makesrna/intern/rna_fluidsim.c b/source/blender/makesrna/intern/rna_fluidsim.c index 210024f0859..4e047ff7772 100644 --- a/source/blender/makesrna/intern/rna_fluidsim.c +++ b/source/blender/makesrna/intern/rna_fluidsim.c @@ -64,10 +64,10 @@ static void rna_def_fluidsim_slip(StructRNA *srna) PropertyRNA *prop; static EnumPropertyItem slip_items[] = { - {OB_FSBND_NOSLIP, "NOSLIP", "No Slip", "Obstacle causes zero normal and tangential velocity (=sticky). Default for all. Only option for moving objects."}, - {OB_FSBND_PARTSLIP, "PARTIALSLIP", "Partial Slip", "Mix between no-slip and free-slip. Non moving objects only!"}, - {OB_FSBND_FREESLIP, "FREESLIP", "Free Slip", "Obstacle only causes zero normal velocity (=not sticky). Non moving objects only!"}, - {0, NULL, NULL, NULL}}; + {OB_FSBND_NOSLIP, "NOSLIP", 0, "No Slip", "Obstacle causes zero normal and tangential velocity (=sticky). Default for all. Only option for moving objects."}, + {OB_FSBND_PARTSLIP, "PARTIALSLIP", 0, "Partial Slip", "Mix between no-slip and free-slip. Non moving objects only!"}, + {OB_FSBND_FREESLIP, "FREESLIP", 0, "Free Slip", "Obstacle only causes zero normal velocity (=not sticky). Non moving objects only!"}, + {0, NULL, 0, NULL, NULL}}; prop= RNA_def_property(srna, "slip_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "typeFlags"); @@ -86,17 +86,17 @@ static void rna_def_fluidsim_domain(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem quality_items[] = { - {OB_FSDOM_GEOM, "GEOMETRY", "Geometry", "Display geometry."}, - {OB_FSDOM_PREVIEW, "PREVIEW", "Preview", "Display preview quality results."}, - {OB_FSDOM_FINAL, "FINAL", "Final", "Display final quality results."}, - {0, NULL, NULL, NULL}}; + {OB_FSDOM_GEOM, "GEOMETRY", 0, "Geometry", "Display geometry."}, + {OB_FSDOM_PREVIEW, "PREVIEW", 0, "Preview", "Display preview quality results."}, + {OB_FSDOM_FINAL, "FINAL", 0, "Final", "Display final quality results."}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem viscosity_items[] = { - {1, "MANUAL", "Manual", "Manual viscosity settings."}, - {2, "WATER", "Water", "Viscosity of 1.0 * 10^-6."}, - {3, "OIL", "Oil", "Viscosity of 5.0 * 10^-5."}, - {4, "HONEY", "Honey", "Viscosity of 2.0 * 10^-3."}, - {0, NULL, NULL, NULL}}; + {1, "MANUAL", 0, "Manual", "Manual viscosity settings."}, + {2, "WATER", 0, "Water", "Viscosity of 1.0 * 10^-6."}, + {3, "OIL", 0, "Oil", "Viscosity of 5.0 * 10^-5."}, + {4, "HONEY", 0, "Honey", "Viscosity of 2.0 * 10^-3."}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "DomainFluidSettings", "FluidSettings"); RNA_def_struct_sdna(srna, "FluidsimSettings"); @@ -217,10 +217,10 @@ static void rna_def_fluidsim_volume(StructRNA *srna) PropertyRNA *prop; static EnumPropertyItem volume_type_items[] = { - {1, "VOLUME", "Volume", "Use only the inner volume of the mesh."}, - {2, "SHELL", "Shell", "Use only the outer shell of the mesh."}, - {3, "BOTH", "Both", "Use both the inner volume and the outer shell of the mesh."}, - {0, NULL, NULL, NULL}}; + {1, "VOLUME", 0, "Volume", "Use only the inner volume of the mesh."}, + {2, "SHELL", 0, "Shell", "Use only the outer shell of the mesh."}, + {3, "BOTH", 0, "Both", "Use both the inner volume and the outer shell of the mesh."}, + {0, NULL, 0, NULL, NULL}}; prop= RNA_def_property(srna, "volume_initialization", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "volumeInitType"); @@ -393,15 +393,15 @@ void RNA_def_fluidsim(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_fluid_type_items[] = { - {0, "NONE", "None", ""}, - {OB_FLUIDSIM_DOMAIN, "DOMAIN", "Domain", "Bounding box of this object represents the computational domain of the fluid simulation."}, - {OB_FLUIDSIM_FLUID, "FLUID", "Fluid", "Object represents a volume of fluid in the simulation."}, - {OB_FLUIDSIM_OBSTACLE, "OBSTACLE", "Obstacle", "Object is a fixed obstacle."}, - {OB_FLUIDSIM_INFLOW, "INFLOW", "Inflow", "Object adds fluid to the simulation."}, - {OB_FLUIDSIM_OUTFLOW, "OUTFLOW", "Outflow", "Object removes fluid from the simulation."}, - {OB_FLUIDSIM_PARTICLE, "PARTICLE", "Particle", "Object is made a particle system to display particles generated by a fluidsim domain object."}, - {OB_FLUIDSIM_CONTROL, "CONTROL", "Control", "Object is made a fluid control mesh, which influences the fluid."}, - {0, NULL, NULL, NULL}}; + {0, "NONE", 0, "None", ""}, + {OB_FLUIDSIM_DOMAIN, "DOMAIN", 0, "Domain", "Bounding box of this object represents the computational domain of the fluid simulation."}, + {OB_FLUIDSIM_FLUID, "FLUID", 0, "Fluid", "Object represents a volume of fluid in the simulation."}, + {OB_FLUIDSIM_OBSTACLE, "OBSTACLE", 0, "Obstacle", "Object is a fixed obstacle."}, + {OB_FLUIDSIM_INFLOW, "INFLOW", 0, "Inflow", "Object adds fluid to the simulation."}, + {OB_FLUIDSIM_OUTFLOW, "OUTFLOW", 0, "Outflow", "Object removes fluid from the simulation."}, + {OB_FLUIDSIM_PARTICLE, "PARTICLE", 0, "Particle", "Object is made a particle system to display particles generated by a fluidsim domain object."}, + {OB_FLUIDSIM_CONTROL, "CONTROL", 0, "Control", "Object is made a fluid control mesh, which influences the fluid."}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "FluidSettings", NULL); diff --git a/source/blender/makesrna/intern/rna_group.c b/source/blender/makesrna/intern/rna_group.c index 059b2ce78f7..1406ad1ae60 100644 --- a/source/blender/makesrna/intern/rna_group.c +++ b/source/blender/makesrna/intern/rna_group.c @@ -61,7 +61,7 @@ void RNA_def_group(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "gobject", NULL); RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Objects", "A collection of this groups objects."); - RNA_def_property_collection_funcs(prop, 0, 0, 0, "rna_Group_objects_get", 0, 0, 0); + RNA_def_property_collection_funcs(prop, 0, 0, 0, "rna_Group_objects_get", 0, 0, 0, 0, 0); prop= RNA_def_property(srna, "layer", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "layer", 1); diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index 8620a933d61..252cd633b69 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -32,10 +32,24 @@ #include "DNA_image_types.h" #include "DNA_scene_types.h" +#include "BKE_context.h" #include "BKE_image.h" #ifdef RNA_RUNTIME +static void rna_Image_animated_update(bContext *C, PointerRNA *ptr) +{ + Image *ima= (Image*)ptr->data; + int nr; + + if(ima->flag & IMA_TWINANIM) { + nr= ima->xrep*ima->yrep; + if(ima->twsta>=nr) ima->twsta= 1; + if(ima->twend>=nr) ima->twend= nr-1; + if(ima->twsta>ima->twend) ima->twsta= 1; + } +} + #else static void rna_def_imageuser(BlenderRNA *brna) @@ -89,27 +103,27 @@ static void rna_def_image(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; static const EnumPropertyItem prop_type_items[]= { - {IMA_TYPE_IMAGE, "IMAGE", "Image", ""}, - {IMA_TYPE_MULTILAYER, "MULTILAYER", "Multilayer", ""}, - {IMA_TYPE_UV_TEST, "UVTEST", "UV Test", ""}, - {IMA_TYPE_R_RESULT, "RENDERRESULT", "Render Result", ""}, - {IMA_TYPE_COMPOSITE, "COMPOSITING", "Compositing", ""}, - {0, NULL, NULL, NULL}}; + {IMA_TYPE_IMAGE, "IMAGE", 0, "Image", ""}, + {IMA_TYPE_MULTILAYER, "MULTILAYER", 0, "Multilayer", ""}, + {IMA_TYPE_UV_TEST, "UVTEST", 0, "UV Test", ""}, + {IMA_TYPE_R_RESULT, "RENDERRESULT", 0, "Render Result", ""}, + {IMA_TYPE_COMPOSITE, "COMPOSITING", 0, "Compositing", ""}, + {0, NULL, 0, NULL, NULL}}; static const EnumPropertyItem prop_source_items[]= { - {IMA_SRC_FILE, "FILE", "File", "Single image file"}, - {IMA_SRC_SEQUENCE, "SEQUENCE", "Sequence", "Multiple image files, as a sequence"}, - {IMA_SRC_MOVIE, "MOVIE", "Movie", "Movie file"}, - {IMA_SRC_GENERATED, "GENERATED", "Generated", "Generated image"}, - {IMA_SRC_VIEWER, "VIEWER", "Viewer", "Compositing node viewer"}, - {0, NULL, NULL, NULL}}; + {IMA_SRC_FILE, "FILE", 0, "File", "Single image file"}, + {IMA_SRC_SEQUENCE, "SEQUENCE", 0, "Sequence", "Multiple image files, as a sequence"}, + {IMA_SRC_MOVIE, "MOVIE", 0, "Movie", "Movie file"}, + {IMA_SRC_GENERATED, "GENERATED", 0, "Generated", "Generated image"}, + {IMA_SRC_VIEWER, "VIEWER", 0, "Viewer", "Compositing node viewer"}, + {0, NULL, 0, NULL, NULL}}; static const EnumPropertyItem prop_generated_type_items[]= { - {0, "BLANK", "Blank", "Generate a blank image"}, - {1, "UVTESTGRID", "UV Test Grid", "Generated grid to test UV mappings"}, - {0, NULL, NULL, NULL}}; + {0, "BLANK", 0, "Blank", "Generate a blank image"}, + {1, "UVTESTGRID", 0, "UV Test Grid", "Generated grid to test UV mappings"}, + {0, NULL, 0, NULL, NULL}}; static const EnumPropertyItem prop_mapping_items[]= { - {0, "UV", "UV Coordinates", "Use UV coordinates for mapping the image"}, - {IMA_REFLECT, "REFLECTION", "Reflection", "Use reflection mapping for mapping the image"}, - {0, NULL, NULL, NULL}}; + {0, "UV", 0, "UV Coordinates", "Use UV coordinates for mapping the image"}, + {IMA_REFLECT, "REFLECTION", 0, "Reflection", "Use reflection mapping for mapping the image"}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "Image", "ID"); RNA_def_struct_ui_text(srna, "Image", "Image datablock referencing an external or packed image."); @@ -180,19 +194,21 @@ static void rna_def_image(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Display Aspect", "Display Aspect for this image, does not affect rendering."); prop= RNA_def_property(srna, "animated", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* B_TWINANIM */ RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_TWINANIM); RNA_def_property_ui_text(prop, "Animated", "Use as animated texture in the game engine."); + RNA_def_property_update(prop, 0, "rna_Image_animated_update"); prop= RNA_def_property(srna, "animation_start", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "twsta"); RNA_def_property_range(prop, 0, 128); RNA_def_property_ui_text(prop, "Animation Start", "Start frame of an animated texture."); + RNA_def_property_update(prop, 0, "rna_Image_animated_update"); prop= RNA_def_property(srna, "animation_end", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "twend"); RNA_def_property_range(prop, 0, 128); RNA_def_property_ui_text(prop, "Animation End", "End frame of an animated texture."); + RNA_def_property_update(prop, 0, "rna_Image_animated_update"); prop= RNA_def_property(srna, "animation_speed", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "animspeed"); @@ -200,7 +216,6 @@ static void rna_def_image(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Animation Speed", "Speed of the animation in frames per second."); prop= RNA_def_property(srna, "tiles", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* B_SIMAGETILE */ RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_TILES); RNA_def_property_ui_text(prop, "Tiles", "Use of tilemode for faces (default shift-LMB to pick the tile for selected faces)."); diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 16f7a11d1be..a3d5c4fe388 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -189,7 +189,11 @@ void rna_object_vcollayer_name_set(struct PointerRNA *ptr, const char *value, ch /* API functions */ +void RNA_api_main(struct StructRNA *srna); +void RNA_api_mesh(struct StructRNA *srna); +void RNA_api_object(struct StructRNA *srna); void RNA_api_ui_layout(struct StructRNA *srna); +void RNA_api_wm(struct StructRNA *srna); /* ID Properties */ @@ -214,6 +218,7 @@ void rna_builtin_properties_begin(struct CollectionPropertyIterator *iter, struc void rna_builtin_properties_next(struct CollectionPropertyIterator *iter); PointerRNA rna_builtin_properties_get(struct CollectionPropertyIterator *iter); PointerRNA rna_builtin_type_get(struct PointerRNA *ptr); +PointerRNA rna_builtin_properties_lookup_string(PointerRNA *ptr, const char *key); /* Iterators */ diff --git a/source/blender/makesrna/intern/rna_internal_types.h b/source/blender/makesrna/intern/rna_internal_types.h index d690251f503..8bae21cca2b 100644 --- a/source/blender/makesrna/intern/rna_internal_types.h +++ b/source/blender/makesrna/intern/rna_internal_types.h @@ -37,6 +37,7 @@ struct ReportList; struct CollectionPropertyIterator; struct bContext; struct IDProperty; +struct GHash; #define RNA_MAX_ARRAY 32 @@ -83,6 +84,7 @@ typedef PointerRNA (*PropCollectionLookupStringFunc)(struct PointerRNA *ptr, con typedef struct ContainerRNA { void *next, *prev; + struct GHash *prophash; ListBase properties; } ContainerRNA; @@ -128,6 +130,8 @@ struct PropertyRNA { const char *name; /* single line description, displayed in the tooltip for example */ const char *description; + /* icon ID */ + int icon; /* property type as it appears to the outside */ PropertyType type; @@ -243,6 +247,7 @@ typedef struct CollectionPropertyRNA { PropCollectionLengthFunc length; /* optional */ PropCollectionLookupIntFunc lookupint; /* optional */ PropCollectionLookupStringFunc lookupstring; /* optional */ + FunctionRNA *add, *remove; struct StructRNA *type; } CollectionPropertyRNA; diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c index ae03cca74c2..b97dd95c4d4 100644 --- a/source/blender/makesrna/intern/rna_key.c +++ b/source/blender/makesrna/intern/rna_key.c @@ -277,10 +277,10 @@ static void rna_def_keyblock(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_keyblock_type_items[] = { - {KEY_LINEAR, "KEY_LINEAR", "Linear", ""}, - {KEY_CARDINAL, "KEY_CARDINAL", "Cardinal", ""}, - {KEY_BSPLINE, "KEY_BSPLINE", "BSpline", ""}, - {0, NULL, NULL, NULL}}; + {KEY_LINEAR, "KEY_LINEAR", 0, "Linear", ""}, + {KEY_CARDINAL, "KEY_CARDINAL", 0, "Cardinal", ""}, + {KEY_BSPLINE, "KEY_BSPLINE", 0, "BSpline", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "ShapeKey", NULL); RNA_def_struct_ui_text(srna, "Shape Key", "Shape key in a shape keys datablock."); @@ -335,7 +335,7 @@ static void rna_def_keyblock(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "data", "totelem"); RNA_def_property_struct_type(prop, "UnknownType"); RNA_def_property_ui_text(prop, "Data", ""); - RNA_def_property_collection_funcs(prop, "rna_ShapeKey_data_begin", 0, 0, "rna_ShapeKey_data_get", "rna_ShapeKey_data_length", 0, 0); + RNA_def_property_collection_funcs(prop, "rna_ShapeKey_data_begin", 0, 0, "rna_ShapeKey_data_get", "rna_ShapeKey_data_length", 0, 0, 0, 0); } static void rna_def_key(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_lamp.c b/source/blender/makesrna/intern/rna_lamp.c index 97ad5b7f6a4..092a5804a74 100644 --- a/source/blender/makesrna/intern/rna_lamp.c +++ b/source/blender/makesrna/intern/rna_lamp.c @@ -91,10 +91,10 @@ static void rna_def_lamp_mtex(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_texture_coordinates_items[] = { - {TEXCO_GLOB, "GLOBAL", "Global", "Uses global coordinates for the texture coordinates."}, - {TEXCO_VIEW, "VIEW", "View", "Uses view coordinates for the texture coordinates."}, - {TEXCO_OBJECT, "OBJECT", "Object", "Uses linked object's coordinates for texture coordinates."}, - {0, NULL, NULL, NULL}}; + {TEXCO_GLOB, "GLOBAL", 0, "Global", "Uses global coordinates for the texture coordinates."}, + {TEXCO_VIEW, "VIEW", 0, "View", "Uses view coordinates for the texture coordinates."}, + {TEXCO_OBJECT, "OBJECT", 0, "Object", "Uses linked object's coordinates for texture coordinates."}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "LampTextureSlot", "TextureSlot"); RNA_def_struct_sdna(srna, "MTex"); @@ -126,29 +126,29 @@ static void rna_def_lamp_sky_settings(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_skycolorspace_items[] = { - {0, "SMPTE", "SMPTE", ""}, - {1, "REC709", "REC709", ""}, - {2, "CIE", "CIE", ""}, - {0, NULL, NULL, NULL}}; + {0, "SMPTE", 0, "SMPTE", ""}, + {1, "REC709", 0, "REC709", ""}, + {2, "CIE", 0, "CIE", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_blendmode_items[] = { - {0, "MIX", "Mix", ""}, - {1, "ADD", "Add", ""}, - {2, "MULTIPLY", "Multiply", ""}, - {3, "SUBTRACT", "Subtract", ""}, - {4, "SCREEN", "Screen", ""}, - {5, "DIVIDE", "Divide", ""}, - {6, "DIFFERENCE", "Difference", ""}, - {7, "DARKEN", "Darken", ""}, - {8, "LIGHTEN", "Lighten", ""}, - {9, "OVERLAY", "Overlay", ""}, - {10, "DODGE", "Dodge", ""}, - {11, "BURN", "Burn", ""}, - {12, "HUE", "Hue", ""}, - {13, "SATURATION", "Saturation", ""}, - {14, "VALUE", "Value", ""}, - {15, "COLOR", "Color", ""}, - {0, NULL, NULL, NULL}}; + {0, "MIX", 0, "Mix", ""}, + {1, "ADD", 0, "Add", ""}, + {2, "MULTIPLY", 0, "Multiply", ""}, + {3, "SUBTRACT", 0, "Subtract", ""}, + {4, "SCREEN", 0, "Screen", ""}, + {5, "DIVIDE", 0, "Divide", ""}, + {6, "DIFFERENCE", 0, "Difference", ""}, + {7, "DARKEN", 0, "Darken", ""}, + {8, "LIGHTEN", 0, "Lighten", ""}, + {9, "OVERLAY", 0, "Overlay", ""}, + {10, "DODGE", 0, "Dodge", ""}, + {11, "BURN", 0, "Burn", ""}, + {12, "HUE", 0, "Hue", ""}, + {13, "SATURATION", 0, "Saturation", ""}, + {14, "VALUE", 0, "Value", ""}, + {15, "COLOR", 0, "Color", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "LampSkySettings", NULL); RNA_def_struct_sdna(srna, "Lamp"); @@ -253,12 +253,12 @@ static void rna_def_lamp(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_type_items[] = { - {LA_LOCAL, "POINT", "Point", "Omnidirectional point light source."}, - {LA_SUN, "SUN", "Sun", "Constant direction parallel ray light source."}, - {LA_SPOT, "SPOT", "Spot", "Directional cone light source."}, - {LA_HEMI, "HEMI", "Hemi", "180 degree constant light source."}, - {LA_AREA, "AREA", "Area", "Directional area light source."}, - {0, NULL, NULL, NULL}}; + {LA_LOCAL, "POINT", 0, "Point", "Omnidirectional point light source."}, + {LA_SUN, "SUN", 0, "Sun", "Constant direction parallel ray light source."}, + {LA_SPOT, "SPOT", 0, "Spot", "Directional cone light source."}, + {LA_HEMI, "HEMI", 0, "Hemi", "180 degree constant light source."}, + {LA_AREA, "AREA", 0, "Area", "Directional area light source."}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "Lamp", "ID"); RNA_def_struct_refine_func(srna, "rna_Lamp_refine"); @@ -322,12 +322,12 @@ static void rna_def_lamp_falloff(StructRNA *srna) PropertyRNA *prop; static EnumPropertyItem prop_fallofftype_items[] = { - {LA_FALLOFF_CONSTANT, "CONSTANT", "Constant", ""}, - {LA_FALLOFF_INVLINEAR, "INVERSE_LINEAR", "Inverse Linear", ""}, - {LA_FALLOFF_INVSQUARE, "INVERSE_SQUARE", "Inverse Square", ""}, - {LA_FALLOFF_CURVE, "CUSTOM_CURVE", "Custom Curve", ""}, - {LA_FALLOFF_SLIDERS, "LINEAR_QUADRATIC_WEIGHTED", "Lin/Quad Weighted", ""}, - {0, NULL, NULL, NULL}}; + {LA_FALLOFF_CONSTANT, "CONSTANT", 0, "Constant", ""}, + {LA_FALLOFF_INVLINEAR, "INVERSE_LINEAR", 0, "Inverse Linear", ""}, + {LA_FALLOFF_INVSQUARE, "INVERSE_SQUARE", 0, "Inverse Square", ""}, + {LA_FALLOFF_CURVE, "CUSTOM_CURVE", 0, "Custom Curve", ""}, + {LA_FALLOFF_SLIDERS, "LINEAR_QUADRATIC_WEIGHTED", 0, "Lin/Quad Weighted", ""}, + {0, NULL, 0, NULL, NULL}}; prop= RNA_def_property(srna, "falloff_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, prop_fallofftype_items); @@ -362,26 +362,26 @@ static void rna_def_lamp_shadow(StructRNA *srna, int spot, int area) PropertyRNA *prop; static EnumPropertyItem prop_shadow_items[] = { - {0, "NOSHADOW", "No Shadow", ""}, - {LA_SHAD_RAY, "RAY_SHADOW", "Ray Shadow", "Use ray tracing for shadow."}, - {0, NULL, NULL, NULL}}; + {0, "NOSHADOW", 0, "No Shadow", ""}, + {LA_SHAD_RAY, "RAY_SHADOW", 0, "Ray Shadow", "Use ray tracing for shadow."}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_spot_shadow_items[] = { - {0, "NOSHADOW", "No Shadow", ""}, - {LA_SHAD_BUF, "BUFFER_SHADOW", "Buffer Shadow", "Lets spotlight produce shadows using shadow buffer."}, - {LA_SHAD_RAY, "RAY_SHADOW", "Ray Shadow", "Use ray tracing for shadow."}, - {0, NULL, NULL, NULL}}; + {0, "NOSHADOW", 0, "No Shadow", ""}, + {LA_SHAD_BUF, "BUFFER_SHADOW", 0, "Buffer Shadow", "Lets spotlight produce shadows using shadow buffer."}, + {LA_SHAD_RAY, "RAY_SHADOW", 0, "Ray Shadow", "Use ray tracing for shadow."}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_ray_sampling_method_items[] = { - {LA_SAMP_HALTON, "ADAPTIVE_QMC", "Adaptive QMC", ""}, - {LA_SAMP_HAMMERSLEY, "CONSTANT_QMC", "Constant QMC", ""}, - {0, NULL, NULL, NULL}}; + {LA_SAMP_HALTON, "ADAPTIVE_QMC", 0, "Adaptive QMC", ""}, + {LA_SAMP_HAMMERSLEY, "CONSTANT_QMC", 0, "Constant QMC", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_spot_ray_sampling_method_items[] = { - {LA_SAMP_HALTON, "ADAPTIVE_QMC", "Adaptive QMC", ""}, - {LA_SAMP_HAMMERSLEY, "CONSTANT_QMC", "Constant QMC", ""}, - {LA_SAMP_CONSTANT, "CONSTANT_JITTERED", "Constant Jittered", ""}, - {0, NULL, NULL, NULL}}; + {LA_SAMP_HALTON, "ADAPTIVE_QMC", 0, "Adaptive QMC", ""}, + {LA_SAMP_HAMMERSLEY, "CONSTANT_QMC", 0, "Constant QMC", ""}, + {LA_SAMP_CONSTANT, "CONSTANT_JITTERED", 0, "Constant Jittered", ""}, + {0, NULL, 0, NULL, NULL}}; prop= RNA_def_property(srna, "shadow_method", PROP_ENUM, PROP_NONE); @@ -457,9 +457,9 @@ static void rna_def_area_lamp(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_areashape_items[] = { - {LA_AREA_SQUARE, "SQUARE", "Square", ""}, - {LA_AREA_RECT, "RECTANGLE", "Rectangle", ""}, - {0, NULL, NULL, NULL}}; + {LA_AREA_SQUARE, "SQUARE", 0, "Square", ""}, + {LA_AREA_RECT, "RECTANGLE", 0, "Rectangle", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "AreaLamp", "Lamp"); RNA_def_struct_sdna(srna, "Lamp"); @@ -513,22 +513,22 @@ static void rna_def_spot_lamp(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_shadbuftype_items[] = { - {LA_SHADBUF_REGULAR , "REGULAR", "Classical", "Classic shadow buffer."}, - {LA_SHADBUF_HALFWAY, "HALFWAY", "Classic-Halfway", "Regular buffer, averaging the closest and 2nd closest Z value to reducing bias artifaces."}, - {LA_SHADBUF_IRREGULAR, "IRREGULAR", "Irregular", "Irregular buffer produces sharp shadow always, but it doesn't show up for raytracing."}, - {0, NULL, NULL, NULL}}; + {LA_SHADBUF_REGULAR , "REGULAR", 0, "Classical", "Classic shadow buffer."}, + {LA_SHADBUF_HALFWAY, "HALFWAY", 0, "Classic-Halfway", "Regular buffer, averaging the closest and 2nd closest Z value to reducing bias artifaces."}, + {LA_SHADBUF_IRREGULAR, "IRREGULAR", 0, "Irregular", "Irregular buffer produces sharp shadow always, but it doesn't show up for raytracing."}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_shadbuffiltertype_items[] = { - {LA_SHADBUF_BOX , "BOX", "Box", "Apply the Box filter to shadow buffer samples."}, - {LA_SHADBUF_TENT, "TENT", "Tent", "Apply the Tent Filter to shadow buffer samples."}, - {LA_SHADBUF_GAUSS, "GAUSS", "Gauss", "Apply the Gauss filter to shadow buffer samples."}, - {0, NULL, NULL, NULL}}; + {LA_SHADBUF_BOX , "BOX", 0, "Box", "Apply the Box filter to shadow buffer samples."}, + {LA_SHADBUF_TENT, "TENT", 0, "Tent", "Apply the Tent Filter to shadow buffer samples."}, + {LA_SHADBUF_GAUSS, "GAUSS", 0, "Gauss", "Apply the Gauss filter to shadow buffer samples."}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_numbuffer_items[] = { - {1, "BUFFERS_1", "1", "Only one buffer rendered."}, - {4, "BUFFERS_4", "4", "Renders 4 buffers for better AA, this quadruples memory usage."}, - {9, "BUFFERS_9", "9", "Renders 9 buffers for better AA, this uses nine times more memory."}, - {0, NULL, NULL, NULL}}; + {1, "BUFFERS_1", 0, "1", "Only one buffer rendered."}, + {4, "BUFFERS_4", 0, "4", "Renders 4 buffers for better AA, this quadruples memory usage."}, + {9, "BUFFERS_9", 0, "9", "Renders 9 buffers for better AA, this uses nine times more memory."}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "SpotLamp", "Lamp"); RNA_def_struct_sdna(srna, "Lamp"); diff --git a/source/blender/makesrna/intern/rna_lattice.c b/source/blender/makesrna/intern/rna_lattice.c index 26c4ebb7b23..3af448b0233 100644 --- a/source/blender/makesrna/intern/rna_lattice.c +++ b/source/blender/makesrna/intern/rna_lattice.c @@ -99,7 +99,7 @@ static void rna_def_latticepoint(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Deformed Location", ""); prop= RNA_def_property(srna, "groups", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_funcs(prop, "rna_LatticePoint_groups_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_LatticePoint_groups_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0, 0, 0); RNA_def_property_struct_type(prop, "VertexGroupElement"); RNA_def_property_ui_text(prop, "Groups", "Weights for the vertex groups this point is member of."); } @@ -110,10 +110,10 @@ static void rna_def_lattice(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_keyblock_type_items[] = { - {KEY_LINEAR, "KEY_LINEAR", "Linear", ""}, - {KEY_CARDINAL, "KEY_CARDINAL", "Cardinal", ""}, - {KEY_BSPLINE, "KEY_BSPLINE", "BSpline", ""}, - {0, NULL, NULL, NULL}}; + {KEY_LINEAR, "KEY_LINEAR", 0, "Linear", ""}, + {KEY_CARDINAL, "KEY_CARDINAL", 0, "Cardinal", ""}, + {KEY_BSPLINE, "KEY_BSPLINE", 0, "BSpline", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "Lattice", "ID"); RNA_def_struct_ui_text(srna, "Lattice", "Lattice datablock defining a grid for deforming other objects."); @@ -159,7 +159,7 @@ static void rna_def_lattice(BlenderRNA *brna) prop= RNA_def_property(srna, "points", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "LatticePoint"); - RNA_def_property_collection_funcs(prop, "rna_Lattice_points_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_Lattice_points_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0, 0, 0); RNA_def_property_ui_text(prop, "Points", "Points of the lattice."); } diff --git a/source/blender/makesrna/intern/rna_main.c b/source/blender/makesrna/intern/rna_main.c index fdd0349b25e..8d98036290a 100644 --- a/source/blender/makesrna/intern/rna_main.c +++ b/source/blender/makesrna/intern/rna_main.c @@ -33,6 +33,7 @@ #ifdef RNA_RUNTIME #include "BKE_main.h" +#include "BKE_mesh.h" /* all the list begin functions are added manually here, Main is not in SDNA */ @@ -218,6 +219,7 @@ void RNA_def_main(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; + const char *lists[][5]= { {"cameras", "Camera", "rna_Main_camera_begin", "Cameras", "Camera datablocks."}, {"scenes", "Scene", "rna_Main_scene_begin", "Scenes", "Scene datablocks."}, @@ -262,9 +264,11 @@ void RNA_def_main(BlenderRNA *brna) { prop= RNA_def_property(srna, lists[i][0], PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, lists[i][1]); - RNA_def_property_collection_funcs(prop, lists[i][2], "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0); + RNA_def_property_collection_funcs(prop, lists[i][2], "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0, "add_mesh", "remove_mesh"); RNA_def_property_ui_text(prop, lists[i][3], lists[i][4]); } + + RNA_api_main(srna); } #endif diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c new file mode 100644 index 00000000000..6d56b2b00f9 --- /dev/null +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -0,0 +1,81 @@ +/** + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2009 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include <stdlib.h> +#include <stdio.h> + +#include "RNA_define.h" +#include "RNA_types.h" + +#ifdef RNA_RUNTIME + +#include "BKE_main.h" +#include "BKE_mesh.h" +#include "BKE_library.h" + +#include "DNA_mesh_types.h" + +Mesh *rna_Main_add_mesh(Main *main, char *name) +{ + Mesh *me= add_mesh(name); + me->id.us--; + return me; +} + +void rna_Main_remove_mesh(Main *main, ReportList *reports, Mesh *me) +{ + if(me->id.us == 0) + free_libblock(&main->mesh, me); + else + BKE_report(reports, RPT_ERROR, "Mesh must have zero users to be removed."); + + /* XXX python now has invalid pointer? */ +} + +#else + +void RNA_api_main(StructRNA *srna) +{ + FunctionRNA *func; + PropertyRNA *prop; + + func= RNA_def_function(srna, "add_mesh", "rna_Main_add_mesh"); + RNA_def_function_ui_description(func, "Add a new mesh."); + prop= RNA_def_string(func, "name", "Mesh", 0, "", "New name for the datablock."); + prop= RNA_def_pointer(func, "mesh", "Mesh", "", "New mesh."); + RNA_def_function_return(func, prop); + + func= RNA_def_function(srna, "remove_mesh", "rna_Main_remove_mesh"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Remove a mesh if it has zero users."); + prop= RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh to remove."); + RNA_def_property_flag(prop, PROP_REQUIRED); +} + +#endif + diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 7e66c9fb5e5..41f31594f6e 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -112,6 +112,35 @@ static void rna_MaterialStrand_end_size_range(PointerRNA *ptr, float *min, float } } +static int rna_MaterialTextureSlot_enabled_get(PointerRNA *ptr) +{ + Material *ma= (Material*)ptr->id.data; + MTex *mtex= (MTex*)ptr->data; + int a; + + for(a=0; a<MAX_MTEX; a++) + if(ma->mtex[a] == mtex) + return (ma->septex & (1<<a)) == 0; + + return 0; +} + +static void rna_MaterialTextureSlot_enabled_set(PointerRNA *ptr, int value) +{ + Material *ma= (Material*)ptr->id.data; + MTex *mtex= (MTex*)ptr->data; + int a; + + for(a=0; a<MAX_MTEX; a++) { + if(ma->mtex[a] == mtex) { + if(value) + ma->septex &= ~(1<<a); + else + ma->septex |= (1<<a); + } + } +} + #else static void rna_def_material_mtex(BlenderRNA *brna) @@ -120,54 +149,54 @@ static void rna_def_material_mtex(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_texture_coordinates_items[] = { - {TEXCO_GLOB, "GLOBAL", "Global", "Uses global coordinates for the texture coordinates."}, - {TEXCO_OBJECT, "OBJECT", "Object", "Uses linked object's coordinates for texture coordinates."}, - {TEXCO_UV, "UV", "UV", "Uses UV coordinates for texture coordinates."}, - {TEXCO_ORCO, "ORCO", "Orco", "Uses the original undeformed coordinates of the object."}, - {TEXCO_STRAND, "STRAND", "Strand", "Uses normalized strand texture coordinate (1D)."}, - {TEXCO_STICKY, "STICKY", "Sticky", "Uses mesh's sticky coordinates for the texture coordinates."}, - {TEXCO_WINDOW, "WINDOW", "Window", "Uses screen coordinates as texture coordinates."}, - {TEXCO_NORM, "NORMAL", "Normal", "Uses normal vector as texture coordinates."}, - {TEXCO_REFL, "REFLECTION", "Reflection", "Uses reflection vector as texture coordinates."}, - {TEXCO_STRESS, "STRESS", "Stress", "Uses the difference of edge lengths compared to original coordinates of the mesh."}, - {TEXCO_SPEED, "TANGENT", "Tangent", "Uses the optional tangent vector as texture coordinates."}, - - {0, NULL, NULL, NULL}}; + {TEXCO_GLOB, "GLOBAL", 0, "Global", "Uses global coordinates for the texture coordinates."}, + {TEXCO_OBJECT, "OBJECT", 0, "Object", "Uses linked object's coordinates for texture coordinates."}, + {TEXCO_UV, "UV", 0, "UV", "Uses UV coordinates for texture coordinates."}, + {TEXCO_ORCO, "ORCO", 0, "Generated", "Uses the original undeformed coordinates of the object."}, + {TEXCO_STRAND, "STRAND", 0, "Strand", "Uses normalized strand texture coordinate (1D)."}, + {TEXCO_STICKY, "STICKY", 0, "Sticky", "Uses mesh's sticky coordinates for the texture coordinates."}, + {TEXCO_WINDOW, "WINDOW", 0, "Window", "Uses screen coordinates as texture coordinates."}, + {TEXCO_NORM, "NORMAL", 0, "Normal", "Uses normal vector as texture coordinates."}, + {TEXCO_REFL, "REFLECTION", 0, "Reflection", "Uses reflection vector as texture coordinates."}, + {TEXCO_STRESS, "STRESS", 0, "Stress", "Uses the difference of edge lengths compared to original coordinates of the mesh."}, + {TEXCO_TANGENT, "TANGENT", 0, "Tangent", "Uses the optional tangent vector as texture coordinates."}, + + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_mapping_items[] = { - {MTEX_FLAT, "FLAT", "Flat", "Maps X and Y coordinates directly."}, - {MTEX_CUBE, "CUBE", "Cube", "Maps using the normal vector."}, - {MTEX_TUBE, "TUBE", "Tube", "Maps with Z as central axis."}, - {MTEX_SPHERE, "SPHERE", "Sphere", "Maps with Z as central axis."}, - {0, NULL, NULL, NULL}}; + {MTEX_FLAT, "FLAT", 0, "Flat", "Maps X and Y coordinates directly."}, + {MTEX_CUBE, "CUBE", 0, "Cube", "Maps using the normal vector."}, + {MTEX_TUBE, "TUBE", 0, "Tube", "Maps with Z as central axis."}, + {MTEX_SPHERE, "SPHERE", 0, "Sphere", "Maps with Z as central axis."}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_x_mapping_items[] = { - {0, "NONE", "None", ""}, - {1, "X", "X", ""}, - {2, "Y", "Y", ""}, - {3, "Z", "Z", ""}, - {0, NULL, NULL, NULL}}; + {0, "NONE", 0, "None", ""}, + {1, "X", 0, "X", ""}, + {2, "Y", 0, "Y", ""}, + {3, "Z", 0, "Z", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_y_mapping_items[] = { - {0, "NONE", "None", ""}, - {1, "X", "X", ""}, - {2, "Y", "Y", ""}, - {3, "Z", "Z", ""}, - {0, NULL, NULL, NULL}}; + {0, "NONE", 0, "None", ""}, + {1, "X", 0, "X", ""}, + {2, "Y", 0, "Y", ""}, + {3, "Z", 0, "Z", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_z_mapping_items[] = { - {0, "NONE", "None", ""}, - {1, "X", "X", ""}, - {2, "Y", "Y", ""}, - {3, "Z", "Z", ""}, - {0, NULL, NULL, NULL}}; + {0, "NONE", 0, "None", ""}, + {1, "X", 0, "X", ""}, + {2, "Y", 0, "Y", ""}, + {3, "Z", 0, "Z", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_normal_map_space_items[] = { - {MTEX_NSPACE_CAMERA, "CAMERA", "Camera", ""}, - {MTEX_NSPACE_WORLD, "WORLD", "World", ""}, - {MTEX_NSPACE_OBJECT, "OBJECT", "Object", ""}, - {MTEX_NSPACE_TANGENT, "TANGENT", "Tangent", ""}, - {0, NULL, NULL, NULL}}; + {MTEX_NSPACE_CAMERA, "CAMERA", 0, "Camera", ""}, + {MTEX_NSPACE_WORLD, "WORLD", 0, "World", ""}, + {MTEX_NSPACE_OBJECT, "OBJECT", 0, "Object", ""}, + {MTEX_NSPACE_TANGENT, "TANGENT", 0, "Tangent", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "MaterialTextureSlot", "TextureSlot"); RNA_def_struct_sdna(srna, "MTex"); @@ -287,6 +316,12 @@ static void rna_def_material_mtex(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "warpfac"); RNA_def_property_range(prop, 0, 1); RNA_def_property_ui_text(prop, "Warp Factor", "Amount texture affects color values."); + + prop= RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_MaterialTextureSlot_enabled_get", "rna_MaterialTextureSlot_enabled_set"); + RNA_def_property_ui_text(prop, "Enabled", "Enable this material texture slot."); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); + } static void rna_def_material_colors(StructRNA *srna) @@ -333,12 +368,12 @@ static void rna_def_material_diffuse(StructRNA *srna) PropertyRNA *prop; static EnumPropertyItem prop_diff_shader_items[] = { - {MA_DIFF_LAMBERT, "LAMBERT", "Lambert", ""}, - {MA_DIFF_ORENNAYAR, "OREN_NAYAR", "Oren-Nayar", ""}, - {MA_DIFF_TOON, "TOON", "Toon", ""}, - {MA_DIFF_MINNAERT, "MINNAERT", "Minnaert", ""}, - {MA_DIFF_FRESNEL, "FRESNEL", "Fresnel", ""}, - {0, NULL, NULL, NULL}}; + {MA_DIFF_LAMBERT, "LAMBERT", 0, "Lambert", ""}, + {MA_DIFF_ORENNAYAR, "OREN_NAYAR", 0, "Oren-Nayar", ""}, + {MA_DIFF_TOON, "TOON", 0, "Toon", ""}, + {MA_DIFF_MINNAERT, "MINNAERT", 0, "Minnaert", ""}, + {MA_DIFF_FRESNEL, "FRESNEL", 0, "Fresnel", ""}, + {0, NULL, 0, NULL, NULL}}; prop= RNA_def_property(srna, "diffuse_shader", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "diff_shader"); @@ -356,12 +391,29 @@ static void rna_def_material_diffuse(StructRNA *srna) RNA_def_property_range(prop, 0.0f, 3.14f); RNA_def_property_ui_text(prop, "Roughness", "Oren-Nayar Roughness"); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - - prop= RNA_def_property(srna, "params1_4", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "param"); - RNA_def_property_array(prop, 4); + + prop= RNA_def_property(srna, "diffuse_toon_size", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "param[0]"); + RNA_def_property_range(prop, 0.0f, 3.14f); + RNA_def_property_ui_text(prop, "Diffuse Toon Size", "Size of diffuse toon area."); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); + + prop= RNA_def_property(srna, "diffuse_toon_smooth", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "param[1]"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Diffuse Toon Smooth", "Smoothness of diffuse toon area."); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); + + prop= RNA_def_property(srna, "diffuse_fresnel", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "param[1]"); + RNA_def_property_range(prop, 0.0f, 5.0f); + RNA_def_property_ui_text(prop, "Diffuse Fresnel", "Power of Fresnel."); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); + + prop= RNA_def_property(srna, "diffuse_fresnel_factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "param[0]"); RNA_def_property_range(prop, 0.0f, 5.0f); - RNA_def_property_ui_text(prop, "Params 1-4", "Parameters used for diffuse and specular Toon, and diffuse Fresnel shaders. Check documentation for details."); + RNA_def_property_ui_text(prop, "Diffuse Fresnel Factor", "Blending factor of Frensel."); RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); prop= RNA_def_property(srna, "darkness", PROP_FLOAT, PROP_NONE); @@ -376,9 +428,9 @@ static void rna_def_material_raymirror(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_fadeto_mir_items[] = { - {MA_RAYMIR_FADETOSKY, "FADE_TO_SKY", "Fade to Sky Color", ""}, - {MA_RAYMIR_FADETOMAT, "FADE_TO_MATERIAL", "Fade to Material Color", ""}, - {0, NULL, NULL, NULL}}; + {MA_RAYMIR_FADETOSKY, "FADE_TO_SKY", 0, "Fade to Sky Color", ""}, + {MA_RAYMIR_FADETOMAT, "FADE_TO_MATERIAL", 0, "Fade to Material Color", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "MaterialRaytraceMirror", NULL); RNA_def_struct_sdna(srna, "Material"); @@ -734,29 +786,61 @@ static void rna_def_material_sss(BlenderRNA *brna) void rna_def_material_specularity(StructRNA *srna) { PropertyRNA *prop; - - prop= RNA_def_property(srna, "specularity", PROP_FLOAT, PROP_NONE); + + static EnumPropertyItem prop_spec_shader_items[] = { + {MA_SPEC_COOKTORR, "COOKTORR", 0, "CookTorr", ""}, + {MA_SPEC_PHONG, "PHONG", 0, "Phong", ""}, + {MA_SPEC_BLINN, "BLINN", 0, "Blinn", ""}, + {MA_SPEC_TOON, "TOON", 0, "Toon", ""}, + {MA_SPEC_WARDISO, "WARDISO", 0, "WardIso", ""}, + {0, NULL, 0, NULL, NULL}}; + + prop= RNA_def_property(srna, "spec_shader", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "spec_shader"); + RNA_def_property_enum_items(prop, prop_spec_shader_items); + RNA_def_property_ui_text(prop, "Specular Shader Model", ""); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); + + prop= RNA_def_property(srna, "specular_reflection", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "spec"); RNA_def_property_range(prop, 0, 1); RNA_def_property_ui_text(prop, "Specularity Intensity", ""); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); + + /* NOTE: "har", "param", etc are used for multiple purposes depending on + * settings. This should be fixed in DNA once, for RNA we just expose them + * multiple times, which may give somewhat strange changes in the outliner, + * but in the UI they are never visible at the same time. */ - /* XXX: this field is also used for Halo hardness. should probably be fixed in DNA */ prop= RNA_def_property(srna, "specular_hardness", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "har"); RNA_def_property_range(prop, 1, 511); RNA_def_property_ui_text(prop, "Specular Hardness", ""); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - prop= RNA_def_property(srna, "specular_refraction", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "specular_ior", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "refrac"); RNA_def_property_range(prop, 1, 10); RNA_def_property_ui_text(prop, "Specular IOR", ""); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); - /* XXX: evil "param" field also does specular stuff */ + prop= RNA_def_property(srna, "specular_toon_size", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "param[2]"); + RNA_def_property_range(prop, 0.0f, 1.53f); + RNA_def_property_ui_text(prop, "Specular Toon Size", "Size of specular toon area."); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); + + prop= RNA_def_property(srna, "specular_toon_smooth", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "param[3]"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Specular Toon Smooth", "Ssmoothness of specular toon area."); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); prop= RNA_def_property(srna, "specular_slope", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "rms"); RNA_def_property_range(prop, 0, 0.4); RNA_def_property_ui_text(prop, "Specular Slope", "The standard deviation of surface slope."); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); } void rna_def_material_strand(BlenderRNA *brna) @@ -772,48 +856,58 @@ void rna_def_material_strand(BlenderRNA *brna) prop= RNA_def_property(srna, "tangent_shading", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_TANGENT_STR); RNA_def_property_ui_text(prop, "Tangent Shading", "Uses direction of strands as normal for tangent-shading."); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); prop= RNA_def_property(srna, "surface_diffuse", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_STR_SURFDIFF); RNA_def_property_ui_text(prop, "Surface Diffuse", "Make diffuse shading more similar to shading the surface."); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); prop= RNA_def_property(srna, "blend_distance", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "strand_surfnor"); RNA_def_property_range(prop, 0, 10); RNA_def_property_ui_text(prop, "Blend Distance", "Distance in Blender units over which to blend in the surface normal."); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); prop= RNA_def_property(srna, "blender_units", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_STR_B_UNITS); RNA_def_property_ui_text(prop, "Blender Units", "Use Blender units for widths instead of pixels."); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); prop= RNA_def_property(srna, "start_size", PROP_FLOAT, PROP_UNSIGNED); RNA_def_property_float_sdna(prop, NULL, "strand_sta"); RNA_def_property_float_funcs(prop, NULL, NULL, "rna_MaterialStrand_start_size_range"); RNA_def_property_ui_text(prop, "Start Size", "Start size of strands in pixels Blender units."); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); prop= RNA_def_property(srna, "end_size", PROP_FLOAT, PROP_UNSIGNED); RNA_def_property_float_sdna(prop, NULL, "strand_end"); RNA_def_property_float_funcs(prop, NULL, NULL, "rna_MaterialStrand_end_size_range"); RNA_def_property_ui_text(prop, "End Size", "Start size of strands in pixels or Blender units."); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); prop= RNA_def_property(srna, "min_size", PROP_FLOAT, PROP_UNSIGNED); RNA_def_property_float_sdna(prop, NULL, "strand_min"); RNA_def_property_range(prop, 0.001, 10); RNA_def_property_ui_text(prop, "Minimum Size", "Minimum size of strands in pixels."); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); prop= RNA_def_property(srna, "shape", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "strand_ease"); RNA_def_property_range(prop, -0.9, 0.9); RNA_def_property_ui_text(prop, "Shape", "Positive values make strands rounder, negative makes strands spiky."); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); prop= RNA_def_property(srna, "width_fade", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "strand_widthfade"); RNA_def_property_range(prop, 0, 2); RNA_def_property_ui_text(prop, "Width Fade", "Transparency along the width of the strand."); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); prop= RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "strand_uvname"); RNA_def_property_ui_text(prop, "UV Layer", "Name of UV layer to override."); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); } void RNA_def_material(BlenderRNA *brna) @@ -822,10 +916,10 @@ void RNA_def_material(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_type_items[] = { - {MA_TYPE_SURFACE, "SURFACE", "Surface", "Render object as a surface."}, - {MA_TYPE_VOLUME, "VOLUME", "Volume", "Render object as a volume."}, - {MA_TYPE_HALO, "HALO", "Halo", "Render object as halo particles."}, - {0, NULL, NULL, NULL}}; + {MA_TYPE_SURFACE, "SURFACE", 0, "Surface", "Render object as a surface."}, + {MA_TYPE_VOLUME, "VOLUME", 0, "Volume", "Render object as a volume."}, + {MA_TYPE_HALO, "HALO", 0, "Halo", "Render object as halo particles."}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "Material", "ID"); RNA_def_struct_ui_text(srna, "Material", "Material datablock to defined the appearance of geometric objects for rendering."); @@ -847,6 +941,7 @@ void RNA_def_material(BlenderRNA *brna) prop= RNA_def_property(srna, "emit", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0, 2); RNA_def_property_ui_text(prop, "Emit", "Amount of light to emit."); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); prop= RNA_def_property(srna, "translucency", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0, 1); @@ -856,10 +951,12 @@ void RNA_def_material(BlenderRNA *brna) prop= RNA_def_property(srna, "cubic", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "shade_flag", MA_CUBIC); RNA_def_property_ui_text(prop, "Cubic Interpolation", "Use cubic interpolation for diffuse values, for smoother transitions."); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); prop= RNA_def_property(srna, "object_color", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "shade_flag", MA_OBCOLOR); RNA_def_property_ui_text(prop, "Object Color", "Modulate the result with a per-object color."); + RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING, NULL); prop= RNA_def_property(srna, "shadow_ray_bias", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "sbias"); @@ -1025,8 +1122,6 @@ void RNA_def_material(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "scriptlink"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Script Link", "Scripts linked to this material."); - - /* XXX: does Material.septex get RNA? */ rna_def_material_colors(srna); rna_def_material_diffuse(srna); @@ -1048,7 +1143,7 @@ void rna_def_mtex_common(StructRNA *srna, const char *begin, const char *activeg /* mtex */ prop= RNA_def_property(srna, "textures", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, structname); - RNA_def_property_collection_funcs(prop, begin, "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_dereference_get", 0, 0, 0); + RNA_def_property_collection_funcs(prop, begin, "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_dereference_get", 0, 0, 0, 0, 0); RNA_def_property_ui_text(prop, "Textures", "Texture slots defining the mapping and influence of textures."); prop= RNA_def_property(srna, "active_texture", PROP_POINTER, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index e58b3c51fec..653f9d61fa5 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -646,7 +646,7 @@ static void rna_def_mvert(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Bevel Weight", "Weight used by the Bevel modifier 'Only Vertices' option"); prop= RNA_def_property(srna, "groups", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_funcs(prop, "rna_MeshVertex_groups_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_MeshVertex_groups_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0, 0, 0); RNA_def_property_struct_type(prop, "VertexGroupElement"); RNA_def_property_ui_text(prop, "Groups", "Weights for the vertex groups this vertex is member of."); } @@ -734,11 +734,11 @@ static void rna_def_mtface(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; static const EnumPropertyItem transp_items[]= { - {TF_SOLID, "OPAQUE", "Opaque", "Render color of textured face as color"}, - {TF_ADD, "ADD", "Add", "Render face transparent and add color of face"}, - {TF_ALPHA, "ALPHA", "Alpha", "Render polygon transparent, depending on alpha channel of the texture"}, - {TF_CLIP, "CLIPALPHA", "Clip Alpha", "Use the images alpha values clipped with no blending (binary alpha)"}, - {0, NULL, NULL, NULL}}; + {TF_SOLID, "OPAQUE", 0, "Opaque", "Render color of textured face as color"}, + {TF_ADD, "ADD", 0, "Add", "Render face transparent and add color of face"}, + {TF_ALPHA, "ALPHA", 0, "Alpha", "Render polygon transparent, depending on alpha channel of the texture"}, + {TF_CLIP, "CLIPALPHA", 0, "Clip Alpha", "Use the images alpha values clipped with no blending (binary alpha)"}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "MeshTextureFaceLayer", NULL); RNA_def_struct_ui_text(srna, "Mesh Texture Face Layer", "Layer of texture faces in a Mesh datablock."); @@ -761,7 +761,7 @@ static void rna_def_mtface(BlenderRNA *brna) prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "MeshTextureFace"); RNA_def_property_ui_text(prop, "Data", ""); - RNA_def_property_collection_funcs(prop, "rna_MeshTextureFaceLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_MeshTextureFaceLayer_data_length", 0, 0); + RNA_def_property_collection_funcs(prop, "rna_MeshTextureFaceLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_MeshTextureFaceLayer_data_length", 0, 0, 0, 0); srna= RNA_def_struct(brna, "MeshTextureFace", NULL); RNA_def_struct_sdna(srna, "MTFace"); @@ -779,10 +779,6 @@ static void rna_def_mtface(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "mode", TF_TEX); RNA_def_property_ui_text(prop, "Tex", "Render face with texture"); - prop= RNA_def_property(srna, "tiles", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "mode", TF_TILES); - RNA_def_property_ui_text(prop, "Tiles", "Use tilemode for face"); - prop= RNA_def_property(srna, "light", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", TF_LIGHT); RNA_def_property_ui_text(prop, "Light", "Use light for face"); @@ -902,7 +898,7 @@ static void rna_def_mcol(BlenderRNA *brna) prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "MeshColor"); RNA_def_property_ui_text(prop, "Data", ""); - RNA_def_property_collection_funcs(prop, "rna_MeshColorLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_MeshColorLayer_data_length", 0, 0); + RNA_def_property_collection_funcs(prop, "rna_MeshColorLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_MeshColorLayer_data_length", 0, 0, 0, 0); srna= RNA_def_struct(brna, "MeshColor", NULL); RNA_def_struct_sdna(srna, "MCol"); @@ -948,7 +944,7 @@ static void rna_def_mproperties(BlenderRNA *brna) prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "MeshFloatProperty"); RNA_def_property_ui_text(prop, "Data", ""); - RNA_def_property_collection_funcs(prop, "rna_MeshFloatPropertyLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_MeshFloatPropertyLayer_data_length", 0, 0); + RNA_def_property_collection_funcs(prop, "rna_MeshFloatPropertyLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_MeshFloatPropertyLayer_data_length", 0, 0, 0, 0); srna= RNA_def_struct(brna, "MeshFloatProperty", NULL); RNA_def_struct_sdna(srna, "MFloatProperty"); @@ -972,7 +968,7 @@ static void rna_def_mproperties(BlenderRNA *brna) prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "MeshIntProperty"); RNA_def_property_ui_text(prop, "Data", ""); - RNA_def_property_collection_funcs(prop, "rna_MeshIntPropertyLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_MeshIntPropertyLayer_data_length", 0, 0); + RNA_def_property_collection_funcs(prop, "rna_MeshIntPropertyLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_MeshIntPropertyLayer_data_length", 0, 0, 0, 0); srna= RNA_def_struct(brna, "MeshIntProperty", NULL); RNA_def_struct_sdna(srna, "MIntProperty"); @@ -996,7 +992,7 @@ static void rna_def_mproperties(BlenderRNA *brna) prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "MeshStringProperty"); RNA_def_property_ui_text(prop, "Data", ""); - RNA_def_property_collection_funcs(prop, "rna_MeshStringPropertyLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_MeshStringPropertyLayer_data_length", 0, 0); + RNA_def_property_collection_funcs(prop, "rna_MeshStringPropertyLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_MeshStringPropertyLayer_data_length", 0, 0, 0, 0); srna= RNA_def_struct(brna, "MeshStringProperty", NULL); RNA_def_struct_sdna(srna, "MStringProperty"); @@ -1053,6 +1049,7 @@ static void rna_def_mesh(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "mvert", "totvert"); RNA_def_property_struct_type(prop, "MeshVertex"); RNA_def_property_ui_text(prop, "Vertices", "Vertices of the mesh."); + // XXX RNA_def_property_collection_funcs(prop, "rna_Mesh_verts_begin", 0, 0, 0, 0, 0, 0, "add_verts", "remove_verts"); prop= RNA_def_property(srna, "edges", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "medge", "totedge"); @@ -1071,31 +1068,31 @@ static void rna_def_mesh(BlenderRNA *brna) prop= RNA_def_property(srna, "uv_layers", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer"); - RNA_def_property_collection_funcs(prop, "rna_Mesh_uv_layers_begin", 0, 0, 0, "rna_Mesh_uv_layers_length", 0, 0); + RNA_def_property_collection_funcs(prop, "rna_Mesh_uv_layers_begin", 0, 0, 0, "rna_Mesh_uv_layers_length", 0, 0, 0, 0); RNA_def_property_struct_type(prop, "MeshTextureFaceLayer"); RNA_def_property_ui_text(prop, "UV Layers", ""); prop= RNA_def_property(srna, "vcol_layers", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer"); - RNA_def_property_collection_funcs(prop, "rna_Mesh_vcol_layers_begin", 0, 0, 0, "rna_Mesh_vcol_layers_length", 0, 0); + RNA_def_property_collection_funcs(prop, "rna_Mesh_vcol_layers_begin", 0, 0, 0, "rna_Mesh_vcol_layers_length", 0, 0, 0, 0); RNA_def_property_struct_type(prop, "MeshColorLayer"); RNA_def_property_ui_text(prop, "Vertex Color Layers", ""); prop= RNA_def_property(srna, "float_layers", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer"); - RNA_def_property_collection_funcs(prop, "rna_Mesh_float_layers_begin", 0, 0, 0, "rna_Mesh_float_layers_length", 0, 0); + RNA_def_property_collection_funcs(prop, "rna_Mesh_float_layers_begin", 0, 0, 0, "rna_Mesh_float_layers_length", 0, 0, 0, 0); RNA_def_property_struct_type(prop, "MeshFloatPropertyLayer"); RNA_def_property_ui_text(prop, "Float Property Layers", ""); prop= RNA_def_property(srna, "int_layers", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer"); - RNA_def_property_collection_funcs(prop, "rna_Mesh_int_layers_begin", 0, 0, 0, "rna_Mesh_int_layers_length", 0, 0); + RNA_def_property_collection_funcs(prop, "rna_Mesh_int_layers_begin", 0, 0, 0, "rna_Mesh_int_layers_length", 0, 0, 0, 0); RNA_def_property_struct_type(prop, "MeshIntPropertyLayer"); RNA_def_property_ui_text(prop, "Int Property Layers", ""); prop= RNA_def_property(srna, "string_layers", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer"); - RNA_def_property_collection_funcs(prop, "rna_Mesh_string_layers_begin", 0, 0, 0, "rna_Mesh_string_layers_length", 0, 0); + RNA_def_property_collection_funcs(prop, "rna_Mesh_string_layers_begin", 0, 0, 0, "rna_Mesh_string_layers_length", 0, 0, 0, 0); RNA_def_property_struct_type(prop, "MeshStringPropertyLayer"); RNA_def_property_ui_text(prop, "String Property Layers", ""); @@ -1126,6 +1123,8 @@ static void rna_def_mesh(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Shape Keys", ""); rna_def_texmat_common(srna, "rna_Mesh_texspace_editable"); + + RNA_api_mesh(srna); } void RNA_def_mesh(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_mesh_api.c b/source/blender/makesrna/intern/rna_mesh_api.c new file mode 100644 index 00000000000..26fb77777d7 --- /dev/null +++ b/source/blender/makesrna/intern/rna_mesh_api.c @@ -0,0 +1,108 @@ +/** + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2009 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include <stdlib.h> +#include <stdio.h> + +#include "RNA_define.h" +#include "RNA_types.h" + +#ifdef RNA_RUNTIME + +#include "BKE_customdata.h" +#include "BKE_DerivedMesh.h" + +#include "DNA_mesh_types.h" +#include "DNA_scene_types.h" + +/* +void rna_Mesh_copy(Mesh *me, Mesh *from) +{ + copy_mesh_data(me, from); +} + +void rna_Mesh_copy_applied(Mesh *me, Scene *sce, Object *ob) +{ + DerivedMesh *dm= mesh_create_derived_view(sce, ob, CD_MASK_MESH); + DM_to_mesh(dm, me); + dm->release(dm); +} +*/ + +void rna_Mesh_transform(Mesh *me, float **mat) +{ +} + +#if 0 +/* extern struct EditVert *addvertlist(EditMesh *em, float *vec, struct EditVert *example); */ + +static void rna_Mesh_verts_add(PointerRNA *ptr, PointerRNA *ptr_item) +{ + //Mesh *me= (Mesh*)ptr->data; + + /* + // XXX if item is not MVert we fail silently + if (item->type == RNA_MeshVertex) + return; + + // XXX this must be slow... + EditMesh *em= BKE_mesh_get_editmesh(me); + + MVert *v = (MVert*)ptr_item->ptr->data; + addvertlist(em, v->co, NULL); + + BKE_mesh_end_editmesh(me, em); + */ +} +#endif + +#else + +void RNA_api_mesh(StructRNA *srna) +{ + /*FunctionRNA *func; + PropertyRNA *prop;*/ + + /* + func= RNA_def_function(srna, "copy", "rna_Mesh_copy"); + RNA_def_function_ui_description(func, "Copy mesh data."); + prop= RNA_def_pointer(func, "src", "Mesh", "", "A mesh to copy data from."); + RNA_def_property_flag(prop, PROP_REQUIRED);*/ + + /* + func= RNA_def_function(srna, "add_geom", "rna_Mesh_add_geom"); + RNA_def_function_ui_description(func, "Add geometry data to mesh."); + prop= RNA_def_collection(func, "verts", "?", "", "Vertices."); + RNA_def_property_flag(prop, PROP_REQUIRED); + prop= RNA_def_collection(func, "faces", "?", "", "Faces."); + RNA_def_property_flag(prop, PROP_REQUIRED); + */ +} + +#endif + diff --git a/source/blender/makesrna/intern/rna_meta.c b/source/blender/makesrna/intern/rna_meta.c index 472e776f500..5f95336af2d 100644 --- a/source/blender/makesrna/intern/rna_meta.c +++ b/source/blender/makesrna/intern/rna_meta.c @@ -47,12 +47,12 @@ void rna_def_metaelement(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem prop_type_items[] = { - {MB_BALL, "BALL", "Ball", ""}, - {MB_TUBE, "TUBE", "Tube", ""}, - {MB_PLANE, "PLANE", "Plane", ""}, - {MB_ELIPSOID, "ELLIPSOID", "Ellipsoid", ""}, // NOTE: typo at original definition! - {MB_CUBE, "CUBE", "Cube", ""}, - {0, NULL, NULL, NULL}}; + {MB_BALL, "BALL", 0, "Ball", ""}, + {MB_TUBE, "TUBE", 0, "Tube", ""}, + {MB_PLANE, "PLANE", 0, "Plane", ""}, + {MB_ELIPSOID, "ELLIPSOID", 0, "Ellipsoid", ""}, // NOTE: typo at original definition! + {MB_CUBE, "CUBE", 0, "Cube", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "MetaElement", NULL); RNA_def_struct_sdna(srna, "MetaElem"); @@ -105,11 +105,11 @@ void rna_def_metaball(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem prop_update_items[] = { - {MB_UPDATE_ALWAYS, "UPDATE_ALWAYS", "Always", "While editing, update metaball always."}, - {MB_UPDATE_HALFRES, "HALFRES", "Half Resolution", "While editing, update metaball in half resolution."}, - {MB_UPDATE_FAST, "FAST", "Fast", "While editing, update metaball without polygonization."}, - {MB_UPDATE_NEVER, "NEVER", "Never", "While editing, don't update metaball at all."}, - {0, NULL, NULL, NULL}}; + {MB_UPDATE_ALWAYS, "UPDATE_ALWAYS", 0, "Always", "While editing, update metaball always."}, + {MB_UPDATE_HALFRES, "HALFRES", 0, "Half Resolution", "While editing, update metaball in half resolution."}, + {MB_UPDATE_FAST, "FAST", 0, "Fast", "While editing, update metaball without polygonization."}, + {MB_UPDATE_NEVER, "NEVER", 0, "Never", "While editing, don't update metaball at all."}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "MetaBall", "ID"); RNA_def_struct_ui_text(srna, "MetaBall", "Metaball datablock to defined blobby surfaces."); diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index be1e6a317a2..dab7a94584f 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -41,36 +41,36 @@ #include "WM_types.h" EnumPropertyItem modifier_type_items[] ={ - {eModifierType_Armature, "ARMATURE", "Armature", ""}, - {eModifierType_Array, "ARRAY", "Array", ""}, - {eModifierType_Bevel, "BEVEL", "Bevel", ""}, - {eModifierType_Boolean, "BOOLEAN", "Boolean", ""}, - {eModifierType_Build, "BUILD", "Build", ""}, - {eModifierType_Cast, "CAST", "Cast", ""}, - {eModifierType_Cloth, "CLOTH", "Cloth", ""}, - {eModifierType_Collision, "COLLISION", "Collision", ""}, - {eModifierType_Curve, "CURVE", "Curve", ""}, - {eModifierType_Decimate, "DECIMATE", "Decimate", ""}, - {eModifierType_Displace, "DISPLACE", "Displace", ""}, - {eModifierType_EdgeSplit, "EDGE_SPLIT", "Edge Split", ""}, - {eModifierType_Explode, "EXPLODE", "Explode", ""}, - {eModifierType_Fluidsim, "FLUID_SIMULATION", "Fluid Simulation", ""}, - {eModifierType_Hook, "HOOK", "Hook", ""}, - {eModifierType_Lattice, "LATTICE", "Lattice", ""}, - {eModifierType_Mask, "MASK", "Mask", ""}, - {eModifierType_MeshDeform, "MESH_DEFORM", "Mesh Deform", ""}, - {eModifierType_Mirror, "MIRROR", "Mirror", ""}, - {eModifierType_Multires, "MULTIRES", "Multires", ""}, - {eModifierType_ParticleInstance, "PARTICLE_INSTANCE", "Particle Instance", ""}, - {eModifierType_ParticleSystem, "PARTICLE_SYSTEM", "Particle System", ""}, - {eModifierType_Shrinkwrap, "SHRINKWRAP", "Shrinkwrap", ""}, - {eModifierType_SimpleDeform, "SIMPLE_DEFORM", "Simple Deform", ""}, - {eModifierType_Smooth, "SMOOTH", "Smooth", ""}, - {eModifierType_Softbody, "SOFTBODY", "Softbody", ""}, - {eModifierType_Subsurf, "SUBSURF", "Subsurf", ""}, - {eModifierType_UVProject, "UV_PROJECT", "UV Project", ""}, - {eModifierType_Wave, "WAVE", "Wave", ""}, - {0, NULL, NULL, NULL}}; + {eModifierType_Armature, "ARMATURE", 0, "Armature", ""}, + {eModifierType_Array, "ARRAY", 0, "Array", ""}, + {eModifierType_Bevel, "BEVEL", 0, "Bevel", ""}, + {eModifierType_Boolean, "BOOLEAN", 0, "Boolean", ""}, + {eModifierType_Build, "BUILD", 0, "Build", ""}, + {eModifierType_Cast, "CAST", 0, "Cast", ""}, + {eModifierType_Cloth, "CLOTH", 0, "Cloth", ""}, + {eModifierType_Collision, "COLLISION", 0, "Collision", ""}, + {eModifierType_Curve, "CURVE", 0, "Curve", ""}, + {eModifierType_Decimate, "DECIMATE", 0, "Decimate", ""}, + {eModifierType_Displace, "DISPLACE", 0, "Displace", ""}, + {eModifierType_EdgeSplit, "EDGE_SPLIT", 0, "Edge Split", ""}, + {eModifierType_Explode, "EXPLODE", 0, "Explode", ""}, + {eModifierType_Fluidsim, "FLUID_SIMULATION", 0, "Fluid Simulation", ""}, + {eModifierType_Hook, "HOOK", 0, "Hook", ""}, + {eModifierType_Lattice, "LATTICE", 0, "Lattice", ""}, + {eModifierType_Mask, "MASK", 0, "Mask", ""}, + {eModifierType_MeshDeform, "MESH_DEFORM", 0, "Mesh Deform", ""}, + {eModifierType_Mirror, "MIRROR", 0, "Mirror", ""}, + {eModifierType_Multires, "MULTIRES", 0, "Multires", ""}, + {eModifierType_ParticleInstance, "PARTICLE_INSTANCE", 0, "Particle Instance", ""}, + {eModifierType_ParticleSystem, "PARTICLE_SYSTEM", 0, "Particle System", ""}, + {eModifierType_Shrinkwrap, "SHRINKWRAP", 0, "Shrinkwrap", ""}, + {eModifierType_SimpleDeform, "SIMPLE_DEFORM", 0, "Simple Deform", ""}, + {eModifierType_Smooth, "SMOOTH", 0, "Smooth", ""}, + {eModifierType_Softbody, "SOFTBODY", 0, "Softbody", ""}, + {eModifierType_Subsurf, "SUBSURF", 0, "Subsurf", ""}, + {eModifierType_UVProject, "UV_PROJECT", 0, "UV Project", ""}, + {eModifierType_Wave, "WAVE", 0, "Wave", ""}, + {0, NULL, 0, NULL, NULL}}; #ifdef RNA_RUNTIME @@ -353,9 +353,9 @@ static void rna_ArrayModifier_curve_set(PointerRNA *ptr, PointerRNA value) static void rna_def_property_subdivision_common(StructRNA *srna, const char type[]) { static EnumPropertyItem prop_subdivision_type_items[] = { - {0, "CATMULL_CLARK", "Catmull-Clark", ""}, - {1, "SIMPLE", "Simple", ""}, - {0, NULL, NULL, NULL}}; + {0, "CATMULL_CLARK", 0, "Catmull-Clark", ""}, + {1, "SIMPLE", 0, "Simple", ""}, + {0, NULL, 0, NULL, NULL}}; PropertyRNA *prop= RNA_def_property(srna, "subdivision_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, type); @@ -378,14 +378,14 @@ static void rna_def_modifier_subsurf(BlenderRNA *brna) prop= RNA_def_property(srna, "levels", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "levels"); - RNA_def_property_range(prop, 1, 20); + RNA_def_property_range(prop, 1, 6); RNA_def_property_ui_range(prop, 1, 6, 1, 0); RNA_def_property_ui_text(prop, "Levels", "Number of subdivisions to perform."); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); prop= RNA_def_property(srna, "render_levels", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "renderLevels"); - RNA_def_property_range(prop, 1, 20); + RNA_def_property_range(prop, 1, 6); RNA_def_property_ui_range(prop, 1, 6, 1, 0); RNA_def_property_ui_text(prop, "Render Levels", "Number of subdivisions to perform when rendering."); @@ -448,13 +448,13 @@ static void rna_def_modifier_curve(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_deform_axis_items[] = { - {MOD_CURVE_POSX, "POS_X", "X", ""}, - {MOD_CURVE_POSY, "POS_Y", "Y", ""}, - {MOD_CURVE_POSZ, "POS_Z", "Z", ""}, - {MOD_CURVE_NEGX, "NEG_X", "-X", ""}, - {MOD_CURVE_NEGY, "NEG_Y", "-Y", ""}, - {MOD_CURVE_NEGZ, "NEG_Z", "-Z", ""}, - {0, NULL, NULL, NULL}}; + {MOD_CURVE_POSX, "POS_X", 0, "X", ""}, + {MOD_CURVE_POSY, "POS_Y", 0, "Y", ""}, + {MOD_CURVE_POSZ, "POS_Z", 0, "Z", ""}, + {MOD_CURVE_NEGX, "NEG_X", 0, "-X", ""}, + {MOD_CURVE_NEGY, "NEG_Y", 0, "-Y", ""}, + {MOD_CURVE_NEGZ, "NEG_Z", 0, "-Z", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "CurveModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Curve Modifier", "Curve deformation modifier."); @@ -597,11 +597,11 @@ static void rna_def_modifier_wave(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_texture_coordinates_items[] = { - {MOD_WAV_MAP_LOCAL, "LOCAL", "Local", ""}, - {MOD_WAV_MAP_GLOBAL, "GLOBAL", "Global", ""}, - {MOD_WAV_MAP_OBJECT, "OBJECT", "Object", ""}, - {MOD_WAV_MAP_UV, "MAP_UV", "UV", ""}, - {0, NULL, NULL, NULL}}; + {MOD_WAV_MAP_LOCAL, "LOCAL", 0, "Local", ""}, + {MOD_WAV_MAP_GLOBAL, "GLOBAL", 0, "Global", ""}, + {MOD_WAV_MAP_OBJECT, "OBJECT", 0, "Object", ""}, + {MOD_WAV_MAP_UV, "MAP_UV", 0, "UV", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "WaveModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Wave Modifier", "Wave effect modifier."); @@ -669,14 +669,14 @@ static void rna_def_modifier_wave(BlenderRNA *brna) prop= RNA_def_property(srna, "start_position_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "startx"); - RNA_def_property_range(prop, FLT_MIN, FLT_MAX); + RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); RNA_def_property_ui_range(prop, -100, 100, 100, 2); RNA_def_property_ui_text(prop, "Start Position X", ""); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); prop= RNA_def_property(srna, "start_position_y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "starty"); - RNA_def_property_range(prop, FLT_MIN, FLT_MAX); + RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); RNA_def_property_ui_range(prop, -100, 100, 100, 2); RNA_def_property_ui_text(prop, "Start Position Y", ""); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); @@ -717,13 +717,13 @@ static void rna_def_modifier_wave(BlenderRNA *brna) RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_dependency_update"); prop= RNA_def_property(srna, "speed", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, FLT_MIN, FLT_MAX); + RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); RNA_def_property_ui_range(prop, -2, 2, 10, 2); RNA_def_property_ui_text(prop, "Speed", ""); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); prop= RNA_def_property(srna, "height", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, FLT_MIN, FLT_MAX); + RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); RNA_def_property_ui_range(prop, -2, 2, 10, 2); RNA_def_property_ui_text(prop, "Height", ""); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); @@ -844,10 +844,10 @@ static void rna_def_modifier_boolean(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_operation_items[] = { - {eBooleanModifierOp_Intersect, "INTERSECT", "Intersect", ""}, - {eBooleanModifierOp_Union, "UNION", "Union", ""}, - {eBooleanModifierOp_Difference, "DIFFERENCE", "Difference", ""}, - {0, NULL, NULL, NULL}}; + {eBooleanModifierOp_Intersect, "INTERSECT", 0, "Intersect", ""}, + {eBooleanModifierOp_Union, "UNION", 0, "Union", ""}, + {eBooleanModifierOp_Difference, "DIFFERENCE", 0, "Difference", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "BooleanModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Boolean Modifier", "Boolean operations modifier."); @@ -872,10 +872,10 @@ static void rna_def_modifier_array(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_fit_type_items[] = { - {MOD_ARR_FIXEDCOUNT, "FIXED_COUNT", "Fixed Count", ""}, - {MOD_ARR_FITLENGTH, "FIT_LENGTH", "Fit Length", ""}, - {MOD_ARR_FITCURVE, "FIT_CURVE", "Fit Curve", ""}, - {0, NULL, NULL, NULL}}; + {MOD_ARR_FIXEDCOUNT, "FIXED_COUNT", 0, "Fixed Count", ""}, + {MOD_ARR_FITLENGTH, "FIT_LENGTH", 0, "Fit Length", ""}, + {MOD_ARR_FITCURVE, "FIT_CURVE", 0, "Fit Curve", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "ArrayModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Array Modifier", "Array duplication modifier."); @@ -1005,19 +1005,19 @@ static void rna_def_modifier_displace(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_direction_items[] = { - {MOD_DISP_DIR_X, "X", "X", ""}, - {MOD_DISP_DIR_Y, "Y", "Y", ""}, - {MOD_DISP_DIR_Z, "Z", "Z", ""}, - {MOD_DISP_DIR_NOR, "NORMAL", "Normal", ""}, - {MOD_DISP_DIR_RGB_XYZ, "RGB_TO_XYZ", "RGB to XYZ", ""}, - {0, NULL, NULL, NULL}}; + {MOD_DISP_DIR_X, "X", 0, "X", ""}, + {MOD_DISP_DIR_Y, "Y", 0, "Y", ""}, + {MOD_DISP_DIR_Z, "Z", 0, "Z", ""}, + {MOD_DISP_DIR_NOR, "NORMAL", 0, "Normal", ""}, + {MOD_DISP_DIR_RGB_XYZ, "RGB_TO_XYZ", 0, "RGB to XYZ", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_texture_coordinates_items[] = { - {MOD_DISP_MAP_LOCAL, "LOCAL", "Map", ""}, - {MOD_DISP_MAP_GLOBAL, "GLOBAL", "Global", ""}, - {MOD_DISP_MAP_OBJECT, "OBJECT", "Object", ""}, - {MOD_DISP_MAP_UV, "UV", "UV", ""}, - {0, NULL, NULL, NULL}}; + {MOD_DISP_MAP_LOCAL, "LOCAL", 0, "Map", ""}, + {MOD_DISP_MAP_GLOBAL, "GLOBAL", 0, "Global", ""}, + {MOD_DISP_MAP_OBJECT, "OBJECT", 0, "Object", ""}, + {MOD_DISP_MAP_UV, "UV", 0, "UV", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "DisplaceModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Displace Modifier", "Displacement modifier."); @@ -1042,7 +1042,7 @@ static void rna_def_modifier_displace(BlenderRNA *brna) RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); prop= RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, FLT_MIN, FLT_MAX); + RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); RNA_def_property_ui_range(prop, -100, 100, 10, 2); RNA_def_property_ui_text(prop, "Strength", ""); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); @@ -1089,7 +1089,7 @@ static void rna_def_modifier_uvproject(BlenderRNA *brna) prop= RNA_def_property(srna, "projectors", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "Object"); - RNA_def_property_collection_funcs(prop, "rna_UVProject_projectors_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_dereference_get", 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_UVProject_projectors_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_dereference_get", 0, 0, 0, 0, 0); RNA_def_property_ui_text(prop, "Projectors", ""); prop= RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE); @@ -1167,10 +1167,10 @@ static void rna_def_modifier_cast(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_cast_type_items[] = { - {MOD_CAST_TYPE_SPHERE, "SPHERE", "Sphere", ""}, - {MOD_CAST_TYPE_CYLINDER, "CYLINDER", "Cylinder", ""}, - {MOD_CAST_TYPE_CUBOID, "CUBOID", "Cuboid", ""}, - {0, NULL, NULL, NULL}}; + {MOD_CAST_TYPE_SPHERE, "SPHERE", 0, "Sphere", ""}, + {MOD_CAST_TYPE_CYLINDER, "CYLINDER", 0, "Cylinder", ""}, + {MOD_CAST_TYPE_CUBOID, "CUBOID", 0, "Cuboid", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "CastModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Cast Modifier", "Cast modifier to cast to other shapes."); @@ -1412,16 +1412,16 @@ static void rna_def_modifier_bevel(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_limit_method_items[] = { - {0, "NONE", "None", "Bevel the entire mesh by a constant amount."}, - {BME_BEVEL_ANGLE, "ANGLE", "Angle", "Only bevel edges with sharp enough angles between faces."}, - {BME_BEVEL_WEIGHT, "WEIGHT", "Weight", "Use bevel weights to determine how much bevel is applied; apply them separately in vert/edge select mode."}, - {0, NULL, NULL, NULL}}; + {0, "NONE", 0, "None", "Bevel the entire mesh by a constant amount."}, + {BME_BEVEL_ANGLE, "ANGLE", 0, "Angle", "Only bevel edges with sharp enough angles between faces."}, + {BME_BEVEL_WEIGHT, "WEIGHT", 0, "Weight", "Use bevel weights to determine how much bevel is applied; apply them separately in vert/edge select mode."}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_edge_weight_method_items[] = { - {0, "AVERAGE", "Average", ""}, - {BME_BEVEL_EMIN, "SHARPEST", "Sharpest", ""}, - {BME_BEVEL_EMAX, "LARGEST", "Largest", ""}, - {0, NULL, NULL, NULL}}; + {0, "AVERAGE", 0, "Average", ""}, + {BME_BEVEL_EMIN, "SHARPEST", 0, "Sharpest", ""}, + {BME_BEVEL_EMAX, "LARGEST", 0, "Largest", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "BevelModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Bevel Modifier", "Bevel modifier to make edges and vertices more rounded."); @@ -1465,10 +1465,10 @@ static void rna_def_modifier_shrinkwrap(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_mode_items[] = { - {MOD_SHRINKWRAP_NEAREST_SURFACE, "NEAREST_SURFACEPOINT", "Nearest Surface Point", ""}, - {MOD_SHRINKWRAP_PROJECT, "PROJECT", "Project", ""}, - {MOD_SHRINKWRAP_NEAREST_VERTEX, "NEAREST_VERTEX", "Nearest Vertex", ""}, - {0, NULL, NULL, NULL}}; + {MOD_SHRINKWRAP_NEAREST_SURFACE, "NEAREST_SURFACEPOINT", 0, "Nearest Surface Point", ""}, + {MOD_SHRINKWRAP_PROJECT, "PROJECT", 0, "Project", ""}, + {MOD_SHRINKWRAP_NEAREST_VERTEX, "NEAREST_VERTEX", 0, "Nearest Vertex", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "ShrinkwrapModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Shrinkwrap Modifier", "Shrink wrapping modifier to shrink wrap and object to a target."); @@ -1524,7 +1524,7 @@ static void rna_def_modifier_shrinkwrap(BlenderRNA *brna) prop= RNA_def_property(srna, "subsurf_levels", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "subsurfLevels"); - RNA_def_property_range(prop, 0, 20); + RNA_def_property_range(prop, 0, 6); RNA_def_property_ui_range(prop, 0, 6, 1, 0); RNA_def_property_ui_text(prop, "Subsurf Levels", "Number of subdivisions that must be performed before extracting vertices' positions and normals."); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Modifier_update"); @@ -1576,9 +1576,9 @@ static void rna_def_modifier_mask(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_mode_items[] = { - {MOD_MASK_MODE_VGROUP, "VERTEX_GROUP", "Vertex Group", ""}, - {MOD_MASK_MODE_ARM, "ARMATURE", "Armature", ""}, - {0, NULL, NULL, NULL}}; + {MOD_MASK_MODE_VGROUP, "VERTEX_GROUP", 0, "Vertex Group", ""}, + {MOD_MASK_MODE_ARM, "ARMATURE", 0, "Armature", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "MaskModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Mask Modifier", "Mask modifier to hide parts of the mesh."); @@ -1615,11 +1615,11 @@ static void rna_def_modifier_simpledeform(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_mode_items[] = { - {MOD_SIMPLEDEFORM_MODE_TWIST, "TWIST", "Twist", ""}, - {MOD_SIMPLEDEFORM_MODE_BEND, "BEND", "Bend", ""}, - {MOD_SIMPLEDEFORM_MODE_TAPER, "TAPER", "Taper", ""}, - {MOD_SIMPLEDEFORM_MODE_STRETCH, "STRETCH", "Stretch", ""}, - {0, NULL, NULL, NULL}}; + {MOD_SIMPLEDEFORM_MODE_TWIST, "TWIST", 0, "Twist", ""}, + {MOD_SIMPLEDEFORM_MODE_BEND, "BEND", 0, "Bend", ""}, + {MOD_SIMPLEDEFORM_MODE_TAPER, "TAPER", 0, "Taper", ""}, + {MOD_SIMPLEDEFORM_MODE_STRETCH, "STRETCH", 0, "Stretch", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "SimpleDeformModifier", "Modifier"); RNA_def_struct_ui_text(srna, "SimpleDeform Modifier", "Simple deformation modifier to apply effects such as twisting and bending."); diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 8a90af69641..b35b02b2063 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -76,6 +76,7 @@ typedef struct NodeInfo const char *enum_name; const char *struct_name; const char *base_name; + int icon; const char *ui_name; const char *ui_desc; } NodeInfo; @@ -146,6 +147,7 @@ static EnumPropertyItem* alloc_node_type_items(int category) if(node->defined && node->category == category) { item->value = i; item->identifier = node->enum_name; + item->icon = node->icon; item->name = node->ui_name; item->description = node->ui_desc; @@ -173,25 +175,25 @@ static void def_math(StructRNA *srna) PropertyRNA *prop; static EnumPropertyItem items[] = { - { 0, "ADD", "Add", ""}, - { 1, "SUBTRACT", "Subtract", ""}, - { 2, "MULTIPLY", "Multiply", ""}, - { 3, "DIVIDE", "Divide", ""}, - { 4, "SINE", "Sine", ""}, - { 5, "COSINE", "Cosine", ""}, - { 6, "TANGENT", "Tangent", ""}, - { 7, "ARCSINE", "Arcsine", ""}, - { 8, "ARCCOSINE", "Arccosine", ""}, - { 9, "ARCTANGENT", "Arctangent", ""}, - {10, "POWER", "Power", ""}, - {11, "LOGARITHM", "Logarithm", ""}, - {12, "MINIMUM", "Minimum", ""}, - {13, "MAXIMUM", "Maximum", ""}, - {14, "ROUND", "Round", ""}, - {15, "LESS_THAN", "Less Than", ""}, - {16, "GREATER_THAN", "Greater Than", ""}, + { 0, "ADD", 0, "Add", ""}, + { 1, "SUBTRACT", 0, "Subtract", ""}, + { 2, "MULTIPLY", 0, "Multiply", ""}, + { 3, "DIVIDE", 0, "Divide", ""}, + { 4, "SINE", 0, "Sine", ""}, + { 5, "COSINE", 0, "Cosine", ""}, + { 6, "TANGENT", 0, "Tangent", ""}, + { 7, "ARCSINE", 0, "Arcsine", ""}, + { 8, "ARCCOSINE", 0, "Arccosine", ""}, + { 9, "ARCTANGENT", 0, "Arctangent", ""}, + {10, "POWER", 0, "Power", ""}, + {11, "LOGARITHM", 0, "Logarithm", ""}, + {12, "MINIMUM", 0, "Minimum", ""}, + {13, "MAXIMUM", 0, "Maximum", ""}, + {14, "ROUND", 0, "Round", ""}, + {15, "LESS_THAN", 0, "Less Than", ""}, + {16, "GREATER_THAN", 0, "Greater Than", ""}, - {0, NULL, NULL, NULL} + {0, NULL, 0, NULL, NULL} }; prop = RNA_def_property(srna, "operation", PROP_ENUM, PROP_NONE); @@ -205,14 +207,14 @@ static void def_vector_math(StructRNA *srna) PropertyRNA *prop; static EnumPropertyItem items[] = { - {0, "ADD", "Add", ""}, - {1, "SUBTRACT", "Subtract", ""}, - {2, "AVERAGE", "Average", ""}, - {3, "DOT_PRODUCT", "Dot Product", ""}, - {4, "CROSS_PRODUCT", "Cross Product", ""}, - {5, "NORMALIZE", "Normalize", ""}, + {0, "ADD", 0, "Add", ""}, + {1, "SUBTRACT", 0, "Subtract", ""}, + {2, "AVERAGE", 0, "Average", ""}, + {3, "DOT_PRODUCT", 0, "Dot Product", ""}, + {4, "CROSS_PRODUCT", 0, "Cross Product", ""}, + {5, "NORMALIZE", 0, "Normalize", ""}, - {0, NULL, NULL, NULL} + {0, NULL, 0, NULL, NULL} }; prop = RNA_def_property(srna, "operation", PROP_ENUM, PROP_NONE); @@ -275,23 +277,23 @@ static void def_mix_rgb(StructRNA *srna) PropertyRNA *prop; static EnumPropertyItem blend_type_items[] = { - { 0, "MIX", "Mix", ""}, - { 1, "ADD", "Add", ""}, - { 3, "SUBTRACT", "Subtract", ""}, - { 2, "MULTIPLY", "Multiply", ""}, - { 4, "SCREEN", "Screen", ""}, - { 9, "OVERLAY", "Overlay", ""}, - { 5, "DIVIDE", "Divide", ""}, - { 6, "DIFFERENCE", "Difference", ""}, - { 7, "DARKEN", "Darken", ""}, - { 8, "LIGHTEN", "Lighten", ""}, - {10, "DODGE", "Dodge", ""}, - {11, "BURN", "Burn", ""}, - {15, "COLOR", "Color", ""}, - {14, "VALUE", "Value", ""}, - {13, "SATURATION", "Saturation", ""}, - {12, "HUE", "Hue", ""}, - {0, NULL, NULL, NULL} + { 0, "MIX", 0, "Mix", ""}, + { 1, "ADD", 0, "Add", ""}, + { 3, "SUBTRACT", 0, "Subtract", ""}, + { 2, "MULTIPLY", 0, "Multiply", ""}, + { 4, "SCREEN", 0, "Screen", ""}, + { 9, "OVERLAY", 0, "Overlay", ""}, + { 5, "DIVIDE", 0, "Divide", ""}, + { 6, "DIFFERENCE", 0, "Difference", ""}, + { 7, "DARKEN", 0, "Darken", ""}, + { 8, "LIGHTEN", 0, "Lighten", ""}, + {10, "DODGE", 0, "Dodge", ""}, + {11, "BURN", 0, "Burn", ""}, + {15, "COLOR", 0, "Color", ""}, + {14, "VALUE", 0, "Value", ""}, + {13, "SATURATION", 0, "Saturation", ""}, + {12, "HUE", 0, "Hue", ""}, + {0, NULL, 0, NULL, NULL} }; prop = RNA_def_property(srna, "blend_type", PROP_ENUM, PROP_NONE); @@ -393,15 +395,15 @@ static void def_cmp_blur(StructRNA *srna) PropertyRNA *prop; static EnumPropertyItem filter_type_items[] = { - {R_FILTER_BOX, "FLAT", "Flat", ""}, - {R_FILTER_TENT, "TENT", "Tent", ""}, - {R_FILTER_QUAD, "QUAD", "Quadratic", ""}, - {R_FILTER_CUBIC, "CUBIC", "Cubic", ""}, - {R_FILTER_GAUSS, "GAUSS", "Gaussian", ""}, - {R_FILTER_FAST_GAUSS, "FAST_GAUSS", "Fast Gaussian", ""}, - {R_FILTER_CATROM, "CATROM", "Catrom", ""}, - {R_FILTER_MITCH, "MITCH", "Mitch", ""}, - {0, NULL, NULL, NULL} + {R_FILTER_BOX, "FLAT", 0, "Flat", ""}, + {R_FILTER_TENT, "TENT", 0, "Tent", ""}, + {R_FILTER_QUAD, "QUAD", 0, "Quadratic", ""}, + {R_FILTER_CUBIC, "CUBIC", 0, "Cubic", ""}, + {R_FILTER_GAUSS, "GAUSS", 0, "Gaussian", ""}, + {R_FILTER_FAST_GAUSS, "FAST_GAUSS", 0, "Fast Gaussian", ""}, + {R_FILTER_CATROM, "CATROM", 0, "Catrom", ""}, + {R_FILTER_MITCH, "MITCH", 0, "Mitch", ""}, + {0, NULL, 0, NULL, NULL} }; RNA_def_struct_sdna_from(srna, "NodeBlurData", "storage"); @@ -471,14 +473,14 @@ static void def_cmp_filter(StructRNA *srna) PropertyRNA *prop; static EnumPropertyItem type_items[] = { - {0, "SOFTEN", "Soften", ""}, - {1, "SHARPEN", "Sharpen", ""}, - {2, "LAPLACE", "Laplace", ""}, - {3, "SOBEL", "Sobel", ""}, - {4, "PREWITT", "Prewitt", ""}, - {5, "KIRSCH", "Kirsch", ""}, - {6, "SHADOW", "Shadow", ""}, - {0, NULL, NULL, NULL} + {0, "SOFTEN", 0, "Soften", ""}, + {1, "SHARPEN", 0, "Sharpen", ""}, + {2, "LAPLACE", 0, "Laplace", ""}, + {3, "SOBEL", 0, "Sobel", ""}, + {4, "PREWITT", 0, "Prewitt", ""}, + {5, "KIRSCH", 0, "Kirsch", ""}, + {6, "SHADOW", 0, "Shadow", ""}, + {0, NULL, 0, NULL, NULL} }; prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); @@ -550,11 +552,11 @@ static void def_cmp_image(StructRNA *srna) PropertyRNA *prop; /*static EnumPropertyItem type_items[] = { - {IMA_SRC_FILE, "IMAGE", "Image", ""}, + {IMA_SRC_FILE, "IMAGE", 0, "Image", ""}, {IMA_SRC_MOVIE, "MOVIE", "Movie", ""}, {IMA_SRC_SEQUENCE, "SEQUENCE", "Sequence", ""}, {IMA_SRC_GENERATED, "GENERATED", "Generated", ""}, - {0, NULL, NULL, NULL} + {0, NULL, 0, NULL, NULL} };*/ prop = RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE); @@ -627,26 +629,26 @@ static void def_cmp_output_file(StructRNA *srna) PropertyRNA *prop; static EnumPropertyItem type_items[] = { - {R_TARGA, "TARGA", "Targa", ""}, - {R_RAWTGA, "RAW_TARGA", "Targa Raw", ""}, - {R_PNG, "PNG", "PNG", ""}, - {R_BMP, "BMP", "BMP", ""}, - {R_JPEG90, "JPEG", "JPEG", ""}, - {R_IRIS, "IRIS", "IRIS", ""}, - {R_RADHDR, "RADIANCE_HDR", "Radiance HDR", ""}, - {R_CINEON, "CINEON", "Cineon", ""}, - {R_DPX, "DPX", "DPX", ""}, - {R_OPENEXR, "OPENEXR", "OpenEXR", ""}, - {0, NULL, NULL, NULL} + {R_TARGA, "TARGA", 0, "Targa", ""}, + {R_RAWTGA, "RAW_TARGA", 0, "Targa Raw", ""}, + {R_PNG, "PNG", 0, "PNG", ""}, + {R_BMP, "BMP", 0, "BMP", ""}, + {R_JPEG90, "JPEG", 0, "JPEG", ""}, + {R_IRIS, "IRIS", 0, "IRIS", ""}, + {R_RADHDR, "RADIANCE_HDR", 0, "Radiance HDR", ""}, + {R_CINEON, "CINEON", 0, "Cineon", ""}, + {R_DPX, "DPX", 0, "DPX", ""}, + {R_OPENEXR, "OPENEXR", 0, "OpenEXR", ""}, + {0, NULL, 0, NULL, NULL} }; static EnumPropertyItem openexr_codec_items[] = { - {0, "NONE", "None", ""}, - {1, "PXR24", "Pxr24 (lossy)", ""}, - {2, "ZIP", "ZIP (lossless)", ""}, - {3, "PIZ", "PIX (lossless)", ""}, - {4, "RLE", "RLE (lossless)", ""}, - {0, NULL, NULL, NULL} + {0, "NONE", 0, "None", ""}, + {1, "PXR24", 0, "Pxr24 (lossy)", ""}, + {2, "ZIP", 0, "ZIP (lossless)", ""}, + {3, "PIZ", 0, "PIX (lossless)", ""}, + {4, "RLE", 0, "RLE (lossless)", ""}, + {0, NULL, 0, NULL, NULL} }; RNA_def_struct_sdna_from(srna, "NodeImageFile", "storage"); @@ -702,10 +704,10 @@ static void def_cmp_scale(StructRNA *srna) PropertyRNA *prop; static EnumPropertyItem space_items[] = { - {0, "RELATIVE", "Relative", ""}, - {1, "ABSOLUTE", "Absolute", ""}, - {2, "SCENE_SIZE", "Scene Size", ""}, - {0, NULL, NULL, NULL} + {0, "RELATIVE", 0, "Relative", ""}, + {1, "ABSOLUTE", 0, "Absolute", ""}, + {2, "SCENE_SIZE", 0, "Scene Size", ""}, + {0, NULL, 0, NULL, NULL} }; prop = RNA_def_property(srna, "space", PROP_ENUM, PROP_NONE); @@ -719,11 +721,11 @@ static void def_cmp_diff_matte(StructRNA *srna) PropertyRNA *prop; static EnumPropertyItem color_space_items[] = { - {1, "RGB", "RGB", ""}, - {2, "HSV", "HSV", ""}, - {3, "YUV", "YUV", ""}, - {4, "YCC", "YCbCr", ""}, - {0, NULL, NULL, NULL} + {1, "RGB", 0, "RGB", ""}, + {2, "HSV", 0, "HSV", ""}, + {3, "YUV", 0, "YUV", ""}, + {4, "YCC", 0, "YCbCr", ""}, + {0, NULL, 0, NULL, NULL} }; prop = RNA_def_property(srna, "color_space", PROP_ENUM, PROP_NONE); @@ -757,10 +759,10 @@ static void def_cmp_color_spill(StructRNA *srna) PropertyRNA *prop; static EnumPropertyItem channel_items[] = { - {1, "R", "Red", ""}, - {2, "G", "Green", ""}, - {3, "B", "Blue", ""}, - {0, NULL, NULL, NULL} + {1, "R", 0, "Red", ""}, + {2, "G", 0, "Green", ""}, + {3, "B", 0, "Blue", ""}, + {0, NULL, 0, NULL, NULL} }; prop = RNA_def_property(srna, "channel", PROP_ENUM, PROP_NONE); @@ -812,11 +814,11 @@ static void def_cmp_channel_matte(StructRNA *srna) PropertyRNA *prop; static EnumPropertyItem color_space_items[] = { - {1, "RGB", "RGB", ""}, - {2, "HSV", "HSV", ""}, - {3, "YUV", "YUV", ""}, - {4, "YCC", "YCbCr", ""}, - {0, NULL, NULL, NULL} + {1, "RGB", 0, "RGB", ""}, + {2, "HSV", 0, "HSV", ""}, + {3, "YUV", 0, "YUV", ""}, + {4, "YCC", 0, "YCbCr", ""}, + {0, NULL, 0, NULL, NULL} }; prop = RNA_def_property(srna, "color_space", PROP_ENUM, PROP_NONE); @@ -850,10 +852,10 @@ static void def_cmp_flip(StructRNA *srna) PropertyRNA *prop; static EnumPropertyItem axis_items[] = { - {0, "X", "X", ""}, - {1, "Y", "Y", ""}, - {2, "XY", "X & Y", ""}, - {0, NULL, NULL, NULL} + {0, "X", 0, "X", ""}, + {1, "Y", 0, "Y", ""}, + {2, "XY", 0, "X & Y", ""}, + {0, NULL, 0, NULL, NULL} }; prop = RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE); @@ -867,9 +869,9 @@ static void def_cmp_splitviewer(StructRNA *srna) PropertyRNA *prop; static EnumPropertyItem axis_items[] = { - {0, "X", "X", ""}, - {1, "Y", "Y", ""}, - {0, NULL, NULL, NULL} + {0, "X", 0, "X", ""}, + {1, "Y", 0, "Y", ""}, + {0, NULL, 0, NULL, NULL} }; prop = RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE); @@ -907,14 +909,14 @@ static void def_cmp_defocus(StructRNA *srna) PropertyRNA *prop; static EnumPropertyItem bokeh_items[] = { - {8, "OCTAGON", "Octagonal", "8 sides"}, - {7, "HEPTAGON", "Heptagonal", "7 sides"}, - {6, "HEXAGON", "Hexagonal", "6 sides"}, - {5, "PENTAGON", "Pentagonal", "5 sides"}, - {4, "SQUARE", "Square", "4 sides"}, - {3, "TRIANGLE", "Triangular", "3 sides"}, - {0, "CIRCLE", "Circular", ""}, - {0, NULL, NULL, NULL} + {8, "OCTAGON", 0, "Octagonal", "8 sides"}, + {7, "HEPTAGON", 0, "Heptagonal", "7 sides"}, + {6, "HEXAGON", 0, "Hexagonal", "6 sides"}, + {5, "PENTAGON", 0, "Pentagonal", "5 sides"}, + {4, "SQUARE", 0, "Square", "4 sides"}, + {3, "TRIANGLE", 0, "Triangular", "3 sides"}, + {0, "CIRCLE", 0, "Circular", ""}, + {0, NULL, 0, NULL, NULL} }; RNA_def_struct_sdna_from(srna, "NodeDefocus", "storage"); @@ -1085,9 +1087,9 @@ static void def_cmp_premul_key(StructRNA *srna) PropertyRNA *prop; static EnumPropertyItem type_items[] = { - {0, "KEY_TO_PREMUL", "Key to Premul", ""}, - {1, "PREMUL_TO_KEY", "Premul to Key", ""}, - {0, NULL, NULL, NULL} + {0, "KEY_TO_PREMUL", 0, "Key to Premul", ""}, + {1, "PREMUL_TO_KEY", 0, "Premul to Key", ""}, + {0, NULL, 0, NULL, NULL} }; prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); @@ -1102,18 +1104,18 @@ static void def_cmp_glare(StructRNA *srna) PropertyRNA *prop; static EnumPropertyItem type_items[] = { - {3, "GHOSTS", "Ghosts", ""}, - {2, "STREAKS", "Streaks", ""}, - {1, "FOG_GLOW", "Fog Glow", ""}, - {0, "SIMPLE_STAR", "Simple Star", ""}, - {0, NULL, NULL, NULL} + {3, "GHOSTS", 0, "Ghosts", ""}, + {2, "STREAKS", 0, "Streaks", ""}, + {1, "FOG_GLOW", 0, "Fog Glow", ""}, + {0, "SIMPLE_STAR", 0, "Simple Star", ""}, + {0, NULL, 0, NULL, NULL} }; /*static EnumPropertyItem quality_items[] = { - {0, "HIGH", "High", ""}, - {1, "MEDIUM", "Medium", ""}, - {2, "LOW", "Low", ""}, - {0, NULL, NULL, NULL} + {0, "HIGH", 0, "High", ""}, + {1, "MEDIUM", 0, "Medium", ""}, + {2, "LOW", 0, "Low", ""}, + {0, NULL, 0, NULL, NULL} };*/ RNA_def_struct_sdna_from(srna, "NodeGlare", "storage"); @@ -1172,9 +1174,9 @@ static void def_cmp_tonemap(StructRNA *srna) PropertyRNA *prop; static EnumPropertyItem type_items[] = { - {1, "RD_PHOTORECEPTOR", "R/D Photoreceptor", ""}, - {0, "RH_SIMPLE", "Rh Simple", ""}, - {0, NULL, NULL, NULL} + {1, "RD_PHOTORECEPTOR", 0, "R/D Photoreceptor", ""}, + {0, "RH_SIMPLE", 0, "Rh Simple", ""}, + {0, NULL, 0, NULL, NULL} }; RNA_def_struct_sdna_from(srna, "NodeTonemap", "storage"); diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index edfaf5cb21a..a17cc1aca3d 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -392,9 +392,9 @@ static void rna_def_material_slot(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem link_items[] = { - {0, "DATA", "Data", ""}, - {1, "OBJECT", "Object", ""}, - {0, NULL, NULL, NULL}}; + {0, "DATA", 0, "Data", ""}, + {1, "OBJECT", 0, "Object", ""}, + {0, NULL, 0, NULL, NULL}}; /* NOTE: there is no MaterialSlot equivalent in DNA, so the internal * pointer data points to ob->mat + index, and we manually implement @@ -428,22 +428,22 @@ static void rna_def_object_game_settings(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem body_type_items[] = { - {OB_BODY_TYPE_NO_COLLISION, "NO_COLLISION", "No Collision", ""}, - {OB_BODY_TYPE_STATIC, "STATIC", "Static", ""}, - {OB_BODY_TYPE_DYNAMIC, "DYNAMIC", "Dynamic", ""}, - {OB_BODY_TYPE_RIGID, "RIGID_BODY", "Rigid Body", ""}, - {OB_BODY_TYPE_SOFT, "SOFT_BODY", "Soft Body", ""}, - {0, NULL, NULL, NULL}}; + {OB_BODY_TYPE_NO_COLLISION, "NO_COLLISION", 0, "No Collision", ""}, + {OB_BODY_TYPE_STATIC, "STATIC", 0, "Static", ""}, + {OB_BODY_TYPE_DYNAMIC, "DYNAMIC", 0, "Dynamic", ""}, + {OB_BODY_TYPE_RIGID, "RIGID_BODY", 0, "Rigid Body", ""}, + {OB_BODY_TYPE_SOFT, "SOFT_BODY", 0, "Soft Body", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem collision_bounds_items[] = { - {OB_BOUND_BOX, "BOX", "Box", ""}, - {OB_BOUND_SPHERE, "SPHERE", "Sphere", ""}, - {OB_BOUND_CYLINDER, "CYLINDER", "Cylinder", ""}, - {OB_BOUND_CONE, "CONE", "Cone", ""}, - {OB_BOUND_POLYH, "CONVEX_HULL", "Convex Hull", ""}, - {OB_BOUND_POLYT, "TRIANGLE_MESH", "Triangle Mesh", ""}, - //{OB_DYN_MESH, "DYNAMIC_MESH", "Dynamic Mesh", ""}, - {0, NULL, NULL, NULL}}; + {OB_BOUND_BOX, "BOX", 0, "Box", ""}, + {OB_BOUND_SPHERE, "SPHERE", 0, "Sphere", ""}, + {OB_BOUND_CYLINDER, "CYLINDER", 0, "Cylinder", ""}, + {OB_BOUND_CONE, "CONE", 0, "Cone", ""}, + {OB_BOUND_POLYH, "CONVEX_HULL", 0, "Convex Hull", ""}, + {OB_BOUND_POLYT, "TRIANGLE_MESH", 0, "Triangle Mesh", ""}, + //{OB_DYN_MESH, "DYNAMIC_MESH", 0, "Dynamic Mesh", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "GameObjectSettings", NULL); RNA_def_struct_sdna(srna, "Object"); @@ -584,84 +584,84 @@ static void rna_def_object_game_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Debug State", "Print state debug info in the game engine."); } -static StructRNA *rna_def_object(BlenderRNA *brna) +static void rna_def_object(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem parent_type_items[] = { - {PAROBJECT, "OBJECT", "Object", ""}, - {PARCURVE, "CURVE", "Curve", ""}, - //{PARKEY, "KEY", "Key", ""}, - {PARSKEL, "ARMATURE", "Armature", ""}, - {PARSKEL, "LATTICE", "Lattice", ""}, // PARSKEL reuse will give issues - {PARVERT1, "VERTEX", "Vertex", ""}, - {PARVERT3, "VERTEX_3", "3 Vertices", ""}, - {PARBONE, "BONE", "Bone", ""}, - {0, NULL, NULL, NULL}}; + {PAROBJECT, "OBJECT", 0, "Object", ""}, + {PARCURVE, "CURVE", 0, "Curve", ""}, + //{PARKEY, "KEY", 0, "Key", ""}, + {PARSKEL, "ARMATURE", 0, "Armature", ""}, + {PARSKEL, "LATTICE", 0, "Lattice", ""}, // PARSKEL reuse will give issues + {PARVERT1, "VERTEX", 0, "Vertex", ""}, + {PARVERT3, "VERTEX_3", 0, "3 Vertices", ""}, + {PARBONE, "BONE", 0, "Bone", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem object_type_items[] = { - {OB_EMPTY, "EMPTY", "Empty", ""}, - {OB_MESH, "MESH", "Mesh", ""}, - {OB_CURVE, "CURVE", "Curve", ""}, - {OB_SURF, "SURFACE", "Surface", ""}, - {OB_FONT, "TEXT", "Text", ""}, - {OB_MBALL, "META", "Meta", ""}, - {OB_LAMP, "LAMP", "Lamp", ""}, - {OB_CAMERA, "CAMERA", "Camera", ""}, - {OB_WAVE, "WAVE", "Wave", ""}, - {OB_LATTICE, "LATTICE", "Lattice", ""}, - {OB_ARMATURE, "ARMATURE", "Armature", ""}, - {0, NULL, NULL, NULL}}; + {OB_EMPTY, "EMPTY", 0, "Empty", ""}, + {OB_MESH, "MESH", 0, "Mesh", ""}, + {OB_CURVE, "CURVE", 0, "Curve", ""}, + {OB_SURF, "SURFACE", 0, "Surface", ""}, + {OB_FONT, "TEXT", 0, "Text", ""}, + {OB_MBALL, "META", 0, "Meta", ""}, + {OB_LAMP, "LAMP", 0, "Lamp", ""}, + {OB_CAMERA, "CAMERA", 0, "Camera", ""}, + {OB_WAVE, "WAVE", 0, "Wave", ""}, + {OB_LATTICE, "LATTICE", 0, "Lattice", ""}, + {OB_ARMATURE, "ARMATURE", 0, "Armature", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem empty_drawtype_items[] = { - {OB_ARROWS, "ARROWS", "Arrows", ""}, - {OB_SINGLE_ARROW, "SINGLE_ARROW", "Single Arrow", ""}, - {OB_PLAINAXES, "PLAIN_AXES", "Plain Axes", ""}, - {OB_CIRCLE, "CIRCLE", "Circle", ""}, - {OB_CUBE, "CUBE", "Cube", ""}, - {OB_EMPTY_SPHERE, "SPHERE", "Sphere", ""}, - {OB_EMPTY_CONE, "CONE", "Cone", ""}, - {0, NULL, NULL, NULL}}; + {OB_ARROWS, "ARROWS", 0, "Arrows", ""}, + {OB_SINGLE_ARROW, "SINGLE_ARROW", 0, "Single Arrow", ""}, + {OB_PLAINAXES, "PLAIN_AXES", 0, "Plain Axes", ""}, + {OB_CIRCLE, "CIRCLE", 0, "Circle", ""}, + {OB_CUBE, "CUBE", 0, "Cube", ""}, + {OB_EMPTY_SPHERE, "SPHERE", 0, "Sphere", ""}, + {OB_EMPTY_CONE, "CONE", 0, "Cone", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem track_items[] = { - {OB_POSX, "POSX", "+X", ""}, - {OB_POSY, "POSY", "+Y", ""}, - {OB_POSZ, "POSZ", "+Z", ""}, - {OB_NEGX, "NEGX", "-X", ""}, - {OB_NEGY, "NEGY", "-Y", ""}, - {OB_NEGZ, "NEGZ", "-Z", ""}, - {0, NULL, NULL, NULL}}; + {OB_POSX, "POSX", 0, "+X", ""}, + {OB_POSY, "POSY", 0, "+Y", ""}, + {OB_POSZ, "POSZ", 0, "+Z", ""}, + {OB_NEGX, "NEGX", 0, "-X", ""}, + {OB_NEGY, "NEGY", 0, "-Y", ""}, + {OB_NEGZ, "NEGZ", 0, "-Z", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem up_items[] = { - {OB_POSX, "X", "X", ""}, - {OB_POSY, "Y", "Y", ""}, - {OB_POSZ, "Z", "Z", ""}, - {0, NULL, NULL, NULL}}; + {OB_POSX, "X", 0, "X", ""}, + {OB_POSY, "Y", 0, "Y", ""}, + {OB_POSZ, "Z", 0, "Z", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem drawtype_items[] = { - {OB_BOUNDBOX, "BOUNDS", "Bounds", ""}, - {OB_WIRE, "WIRE", "Wire", ""}, - {OB_SOLID, "SOLID", "Solid", ""}, - {OB_SHADED, "SHADED", "Shaded", ""}, - {OB_TEXTURE, "TEXTURED", "Textured", ""}, - {0, NULL, NULL, NULL}}; + {OB_BOUNDBOX, "BOUNDS", 0, "Bounds", ""}, + {OB_WIRE, "WIRE", 0, "Wire", ""}, + {OB_SOLID, "SOLID", 0, "Solid", ""}, + {OB_SHADED, "SHADED", 0, "Shaded", ""}, + {OB_TEXTURE, "TEXTURED", 0, "Textured", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem boundtype_items[] = { - {OB_BOUND_BOX, "BOX", "Box", ""}, - {OB_BOUND_SPHERE, "SPHERE", "Sphere", ""}, - {OB_BOUND_CYLINDER, "CYLINDER", "Cylinder", ""}, - {OB_BOUND_CONE, "CONE", "Cone", ""}, - {OB_BOUND_POLYH, "POLYHEDER", "Polyheder", ""}, - {0, NULL, NULL, NULL}}; + {OB_BOUND_BOX, "BOX", 0, "Box", ""}, + {OB_BOUND_SPHERE, "SPHERE", 0, "Sphere", ""}, + {OB_BOUND_CYLINDER, "CYLINDER", 0, "Cylinder", ""}, + {OB_BOUND_CONE, "CONE", 0, "Cone", ""}, + {OB_BOUND_POLYH, "POLYHEDER", 0, "Polyheder", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem dupli_items[] = { - {0, "NONE", "None", ""}, - {OB_DUPLIFRAMES, "FRAMES", "Frames", "Make copy of object for every frame."}, - {OB_DUPLIVERTS, "VERTS", "Verts", "Duplicate child objects on all vertices."}, - {OB_DUPLIFACES, "FACES", "Faces", "Duplicate child objects on all faces."}, - {OB_DUPLIGROUP, "GROUP", "Group", "Enable group instancing."}, - {0, NULL, NULL, NULL}}; + {0, "NONE", 0, "None", ""}, + {OB_DUPLIFRAMES, "FRAMES", 0, "Frames", "Make copy of object for every frame."}, + {OB_DUPLIVERTS, "VERTS", 0, "Verts", "Duplicate child objects on all vertices."}, + {OB_DUPLIFACES, "FACES", 0, "Faces", "Duplicate child objects on all faces."}, + {OB_DUPLIGROUP, "GROUP", 0, "Group", "Enable group instancing."}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "Object", "ID"); RNA_def_struct_ui_text(srna, "Object", "Object datablock defining an object in a scene.."); @@ -739,7 +739,7 @@ static StructRNA *rna_def_object(BlenderRNA *brna) prop= RNA_def_property(srna, "materials", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol"); RNA_def_property_struct_type(prop, "MaterialSlot"); - RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_iterator_array_get", 0, 0, 0); /* don't dereference pointer! */ + RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_iterator_array_get", 0, 0, 0, 0, 0); /* don't dereference pointer! */ RNA_def_property_ui_text(prop, "Materials", "Material slots in the object."); prop= RNA_def_property(srna, "active_material", PROP_POINTER, PROP_NONE); @@ -799,6 +799,12 @@ static StructRNA *rna_def_object(BlenderRNA *brna) RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Lock Scale", "Lock editing of scale in the interface."); + /* matrix */ + prop= RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX); + RNA_def_property_float_sdna(prop, NULL, "obmat"); + RNA_def_property_array(prop, 16); + RNA_def_property_ui_text(prop, "Matrix", "Transformation matrix."); + /* collections */ prop= RNA_def_property(srna, "constraints", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "Constraint"); @@ -1080,8 +1086,8 @@ static StructRNA *rna_def_object(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "shapenr"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Active Shape Key", "Current shape key index."); - - return srna; + + RNA_api_object(srna); } void RNA_def_object(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c new file mode 100644 index 00000000000..053ab115b3b --- /dev/null +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -0,0 +1,83 @@ +/** + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2009 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include <stdlib.h> +#include <stdio.h> + +#include "RNA_define.h" +#include "RNA_types.h" + +#ifdef RNA_RUNTIME + +#include "BKE_customdata.h" +#include "BKE_DerivedMesh.h" + +#include "DNA_mesh_types.h" +#include "DNA_scene_types.h" + +/* copied from init_render_mesh (render code) */ +Mesh *rna_Object_create_render_mesh(Object *ob, Scene *scene) +{ + CustomDataMask mask = CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL; + DerivedMesh *dm; + Mesh *me; + + /* TODO: other types */ + if(ob->type != OB_MESH) + return NULL; + + dm= mesh_create_derived_render(scene, ob, mask); + + if(!dm) + return NULL; + + me= add_mesh("tmp_render_mesh"); + me->id.us--; /* we don't assign it to anything */ + DM_to_mesh(dm, me); + dm->release(dm); + + return me; +} + +#else + +void RNA_api_object(StructRNA *srna) +{ + FunctionRNA *func; + PropertyRNA *prop; + + func= RNA_def_function(srna, "create_render_mesh", "rna_Object_create_render_mesh"); + RNA_def_function_ui_description(func, "Create a Mesh datablock with all modifiers applied."); + prop= RNA_def_pointer(func, "scene", "Scene", "", ""); + RNA_def_property_flag(prop, PROP_REQUIRED); + prop= RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh created from object, remove it if it is only used for export."); + RNA_def_function_return(func, prop); +} + +#endif + diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index 4f4530e0424..d144ed5f28b 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -136,29 +136,29 @@ static void rna_def_field(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem field_type_items[] = { - {0, "NONE", "None", ""}, - {PFIELD_FORCE, "SPHERICAL", "Spherical", ""}, - {PFIELD_VORTEX, "VORTEX", "Vortex", ""}, - {PFIELD_MAGNET, "MAGNET", "Magnetic", ""}, - {PFIELD_WIND, "WIND", "Wind", ""}, - {PFIELD_GUIDE, "GUIDE", "Curve Guide", ""}, - {PFIELD_TEXTURE, "TEXTURE", "Texture", ""}, - {PFIELD_HARMONIC, "HARMONIC", "Harmonic", ""}, - {PFIELD_CHARGE, "CHARGE", "Charge", ""}, - {PFIELD_LENNARDJ, "LENNARDJ", "Lennard-Jones", ""}, - {0, NULL, NULL, NULL}}; + {0, "NONE", 0, "None", ""}, + {PFIELD_FORCE, "SPHERICAL", 0, "Spherical", ""}, + {PFIELD_VORTEX, "VORTEX", 0, "Vortex", ""}, + {PFIELD_MAGNET, "MAGNET", 0, "Magnetic", ""}, + {PFIELD_WIND, "WIND", 0, "Wind", ""}, + {PFIELD_GUIDE, "GUIDE", 0, "Curve Guide", ""}, + {PFIELD_TEXTURE, "TEXTURE", 0, "Texture", ""}, + {PFIELD_HARMONIC, "HARMONIC", 0, "Harmonic", ""}, + {PFIELD_CHARGE, "CHARGE", 0, "Charge", ""}, + {PFIELD_LENNARDJ, "LENNARDJ", 0, "Lennard-Jones", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem falloff_items[] = { - {PFIELD_FALL_SPHERE, "SPHERE", "Sphere", ""}, - {PFIELD_FALL_TUBE, "TUBE", "Tube", ""}, - {PFIELD_FALL_CONE, "CONE", "Cone", ""}, - {0, NULL, NULL, NULL}}; + {PFIELD_FALL_SPHERE, "SPHERE", 0, "Sphere", ""}, + {PFIELD_FALL_TUBE, "TUBE", 0, "Tube", ""}, + {PFIELD_FALL_CONE, "CONE", 0, "Cone", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem texture_items[] = { - {PFIELD_TEX_RGB, "RGB", "RGB", ""}, - {PFIELD_TEX_GRAD, "GRADIENT", "Gradient", ""}, - {PFIELD_TEX_CURL, "CURL", "Curl", ""}, - {0, NULL, NULL, NULL}}; + {PFIELD_TEX_RGB, "RGB", 0, "RGB", ""}, + {PFIELD_TEX_GRAD, "GRADIENT", 0, "Gradient", ""}, + {PFIELD_TEX_CURL, "CURL", 0, "Curl", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "FieldSettings", NULL); RNA_def_struct_sdna(srna, "PartDeflect"); diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 8d23f9538a5..8ee71b6fd9e 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -160,18 +160,18 @@ static void rna_ParticleSystem_name_get(PointerRNA *ptr, char *str) } static EnumPropertyItem from_items[] = { - {PART_FROM_VERT, "VERT", "Vertexes", ""}, - {PART_FROM_FACE, "FACE", "Faces", ""}, - {PART_FROM_VOLUME, "VOLUME", "Volume", ""}, - {0, NULL, NULL, NULL} + {PART_FROM_VERT, "VERT", 0, "Vertexes", ""}, + {PART_FROM_FACE, "FACE", 0, "Faces", ""}, + {PART_FROM_VOLUME, "VOLUME", 0, "Volume", ""}, + {0, NULL, 0, NULL, NULL} }; static EnumPropertyItem reactor_from_items[] = { - {PART_FROM_VERT, "VERT", "Vertexes", ""}, - {PART_FROM_FACE, "FACE", "Faces", ""}, - {PART_FROM_VOLUME, "VOLUME", "Volume", ""}, - {PART_FROM_PARTICLE, "PARTICLE", "Particle", ""}, - {0, NULL, NULL, NULL} + {PART_FROM_VERT, "VERT", 0, "Vertexes", ""}, + {PART_FROM_FACE, "FACE", 0, "Faces", ""}, + {PART_FROM_VOLUME, "VOLUME", 0, "Volume", ""}, + {PART_FROM_PARTICLE, "PARTICLE", 0, "Particle", ""}, + {0, NULL, 0, NULL, NULL} }; static EnumPropertyItem *rna_Particle_from_itemf(PointerRNA *ptr) @@ -185,39 +185,39 @@ static EnumPropertyItem *rna_Particle_from_itemf(PointerRNA *ptr) } static EnumPropertyItem draw_as_items[] = { - {PART_DRAW_NOT, "NONE", "None", ""}, - {PART_DRAW_REND, "RENDER", "Rendered", ""}, - {PART_DRAW_DOT, "DOT", "Point", ""}, - {PART_DRAW_CIRC, "CIRC", "Circle", ""}, - {PART_DRAW_CROSS, "CROSS", "Cross", ""}, - {PART_DRAW_AXIS, "AXIS", "Axis", ""}, - {0, NULL, NULL, NULL} + {PART_DRAW_NOT, "NONE", 0, "None", ""}, + {PART_DRAW_REND, "RENDER", 0, "Rendered", ""}, + {PART_DRAW_DOT, "DOT", 0, "Point", ""}, + {PART_DRAW_CIRC, "CIRC", 0, "Circle", ""}, + {PART_DRAW_CROSS, "CROSS", 0, "Cross", ""}, + {PART_DRAW_AXIS, "AXIS", 0, "Axis", ""}, + {0, NULL, 0, NULL, NULL} }; static EnumPropertyItem hair_draw_as_items[] = { - {PART_DRAW_NOT, "NONE", "None", ""}, - {PART_DRAW_REND, "RENDER", "Rendered", ""}, - {PART_DRAW_PATH, "PATH", "Path", ""}, - {0, NULL, NULL, NULL} + {PART_DRAW_NOT, "NONE", 0, "None", ""}, + {PART_DRAW_REND, "RENDER", 0, "Rendered", ""}, + {PART_DRAW_PATH, "PATH", 0, "Path", ""}, + {0, NULL, 0, NULL, NULL} }; static EnumPropertyItem ren_as_items[] = { - {PART_DRAW_NOT, "NONE", "None", ""}, - {PART_DRAW_HALO, "HALO", "Halo", ""}, - {PART_DRAW_LINE, "LINE", "Line", ""}, - {PART_DRAW_PATH, "PATH", "Path", ""}, - {PART_DRAW_OB, "OBJECT", "Object", ""}, - {PART_DRAW_GR, "GROUP", "Group", ""}, - {PART_DRAW_BB, "BILLBOARD", "Billboard", ""}, - {0, NULL, NULL, NULL} + {PART_DRAW_NOT, "NONE", 0, "None", ""}, + {PART_DRAW_HALO, "HALO", 0, "Halo", ""}, + {PART_DRAW_LINE, "LINE", 0, "Line", ""}, + {PART_DRAW_PATH, "PATH", 0, "Path", ""}, + {PART_DRAW_OB, "OBJECT", 0, "Object", ""}, + {PART_DRAW_GR, "GROUP", 0, "Group", ""}, + {PART_DRAW_BB, "BILLBOARD", 0, "Billboard", ""}, + {0, NULL, 0, NULL, NULL} }; static EnumPropertyItem hair_ren_as_items[] = { - {PART_DRAW_NOT, "NONE", "None", ""}, - {PART_DRAW_PATH, "PATH", "Path", ""}, - {PART_DRAW_OB, "OBJECT", "Object", ""}, - {PART_DRAW_GR, "GROUP", "Group", ""}, - {0, NULL, NULL, NULL} + {PART_DRAW_NOT, "NONE", 0, "None", ""}, + {PART_DRAW_PATH, "PATH", 0, "Path", ""}, + {PART_DRAW_OB, "OBJECT", 0, "Object", ""}, + {PART_DRAW_GR, "GROUP", 0, "Group", ""}, + {0, NULL, 0, NULL, NULL} }; static EnumPropertyItem *rna_Particle_draw_as_itemf(PointerRNA *ptr) @@ -313,12 +313,12 @@ static void rna_def_particle(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem alive_items[] = { - {PARS_KILLED, "KILLED", "Killed", ""}, - {PARS_DEAD, "DEAD", "Dead", ""}, - {PARS_UNBORN, "UNBORN", "Unborn", ""}, - {PARS_ALIVE, "ALIVE", "Alive", ""}, - {PARS_DYING, "DYING", "Dying", ""}, - {0, NULL, NULL, NULL} + {PARS_KILLED, "KILLED", 0, "Killed", ""}, + {PARS_DEAD, "DEAD", 0, "Dead", ""}, + {PARS_UNBORN, "UNBORN", 0, "Unborn", ""}, + {PARS_ALIVE, "ALIVE", 0, "Alive", ""}, + {PARS_DYING, "DYING", 0, "Dying", ""}, + {0, NULL, 0, NULL, NULL} }; srna = RNA_def_struct(brna, "Particle", NULL); @@ -453,115 +453,115 @@ static void rna_def_particle_settings(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem type_items[] = { - {PART_EMITTER, "EMITTER", "Emitter", ""}, - {PART_REACTOR, "REACTOR", "Reactor", ""}, - {PART_HAIR, "HAIR", "Hair", ""}, - {0, NULL, NULL, NULL} + {PART_EMITTER, "EMITTER", 0, "Emitter", ""}, + {PART_REACTOR, "REACTOR", 0, "Reactor", ""}, + {PART_HAIR, "HAIR", 0, "Hair", ""}, + {0, NULL, 0, NULL, NULL} }; static EnumPropertyItem dist_items[] = { - {PART_DISTR_JIT, "JIT", "Jittered", ""}, - {PART_DISTR_RAND, "RAND", "Random", ""}, - {PART_DISTR_GRID, "GRID", "Grid", ""}, - {0, NULL, NULL, NULL} + {PART_DISTR_JIT, "JIT", 0, "Jittered", ""}, + {PART_DISTR_RAND, "RAND", 0, "Random", ""}, + {PART_DISTR_GRID, "GRID", 0, "Grid", ""}, + {0, NULL, 0, NULL, NULL} }; static EnumPropertyItem phys_type_items[] = { - {PART_PHYS_NO, "NO", "No", ""}, - {PART_PHYS_NEWTON, "NEWTON", "Newtonian", ""}, - {PART_PHYS_KEYED, "KEYED", "Keyed", ""}, - {PART_PHYS_BOIDS, "BOIDS", "Boids", ""}, - {0, NULL, NULL, NULL} + {PART_PHYS_NO, "NO", 0, "No", ""}, + {PART_PHYS_NEWTON, "NEWTON", 0, "Newtonian", ""}, + {PART_PHYS_KEYED, "KEYED", 0, "Keyed", ""}, + {PART_PHYS_BOIDS, "BOIDS", 0, "Boids", ""}, + {0, NULL, 0, NULL, NULL} }; static EnumPropertyItem rot_mode_items[] = { - {0, "NONE", "None", ""}, - {PART_ROT_NOR, "NOR", "Normal", ""}, - {PART_ROT_VEL, "VEL", "Velocity", ""}, - {PART_ROT_GLOB_X, "GLOB_X", "Global X", ""}, - {PART_ROT_GLOB_Y, "GLOB_Y", "Global Y", ""}, - {PART_ROT_GLOB_Z, "GLOB_Z", "Global Z", ""}, - {PART_ROT_OB_X, "OB_X", "Object X", ""}, - {PART_ROT_OB_Y, "OB_Y", "Object Y", ""}, - {PART_ROT_OB_Z, "OB_Z", "Object Z", ""}, - {0, NULL, NULL, NULL} + {0, "NONE", 0, "None", ""}, + {PART_ROT_NOR, "NOR", 0, "Normal", ""}, + {PART_ROT_VEL, "VEL", 0, "Velocity", ""}, + {PART_ROT_GLOB_X, "GLOB_X", 0, "Global X", ""}, + {PART_ROT_GLOB_Y, "GLOB_Y", 0, "Global Y", ""}, + {PART_ROT_GLOB_Z, "GLOB_Z", 0, "Global Z", ""}, + {PART_ROT_OB_X, "OB_X", 0, "Object X", ""}, + {PART_ROT_OB_Y, "OB_Y", 0, "Object Y", ""}, + {PART_ROT_OB_Z, "OB_Z", 0, "Object Z", ""}, + {0, NULL, 0, NULL, NULL} }; static EnumPropertyItem ave_mode_items[] = { - {0, "NONE", "None", ""}, - {PART_AVE_SPIN, "SPIN", "Spin", ""}, - {PART_AVE_RAND, "RAND", "Random", ""} , - {0, NULL, NULL, NULL} + {0, "NONE", 0, "None", ""}, + {PART_AVE_SPIN, "SPIN", 0, "Spin", ""}, + {PART_AVE_RAND, "RAND", 0, "Random", ""} , + {0, NULL, 0, NULL, NULL} }; static EnumPropertyItem react_event_items[] = { - {PART_EVENT_DEATH, "DEATH", "Death", ""}, - {PART_EVENT_COLLIDE, "COLLIDE", "Collision", ""}, - {PART_EVENT_NEAR, "NEAR", "Near", ""}, - {0, NULL, NULL, NULL} + {PART_EVENT_DEATH, "DEATH", 0, "Death", ""}, + {PART_EVENT_COLLIDE, "COLLIDE", 0, "Collision", ""}, + {PART_EVENT_NEAR, "NEAR", 0, "Near", ""}, + {0, NULL, 0, NULL, NULL} }; static EnumPropertyItem child_type_items[] = { - {0, "NONE", "None", ""}, - {PART_CHILD_PARTICLES, "PARTICLES", "Particles", ""}, - {PART_CHILD_FACES, "FACES", "Faces", ""}, - {0, NULL, NULL, NULL} + {0, "NONE", 0, "None", ""}, + {PART_CHILD_PARTICLES, "PARTICLES", 0, "Particles", ""}, + {PART_CHILD_FACES, "FACES", 0, "Faces", ""}, + {0, NULL, 0, NULL, NULL} }; //TODO: names, tooltips static EnumPropertyItem rot_from_items[] = { - {PART_ROT_KEYS, "KEYS", "keys", ""}, - {PART_ROT_ZINCR, "ZINCR", "zincr", ""}, - {PART_ROT_IINCR, "IINCR", "iincr", ""}, - {0, NULL, NULL, NULL} + {PART_ROT_KEYS, "KEYS", 0, "keys", ""}, + {PART_ROT_ZINCR, "ZINCR", 0, "zincr", ""}, + {PART_ROT_IINCR, "IINCR", 0, "iincr", ""}, + {0, NULL, 0, NULL, NULL} }; static EnumPropertyItem integrator_type_items[] = { - {PART_INT_EULER, "EULER", "Euler", ""}, - {PART_INT_MIDPOINT, "MIDPOINT", "Midpoint", ""}, - {PART_INT_RK4, "RK4", "RK4", ""}, - {0, NULL, NULL, NULL} + {PART_INT_EULER, "EULER", 0, "Euler", ""}, + {PART_INT_MIDPOINT, "MIDPOINT", 0, "Midpoint", ""}, + {PART_INT_RK4, "RK4", 0, "RK4", ""}, + {0, NULL, 0, NULL, NULL} }; static EnumPropertyItem kink_type_items[] = { - {PART_KINK_NO, "NO", "Nothing", ""}, - {PART_KINK_CURL, "CURL", "Curl", ""}, - {PART_KINK_RADIAL, "RADIAL", "Radial", ""}, - {PART_KINK_WAVE, "WAVE", "Wave", ""}, - {PART_KINK_BRAID, "BRAID", "Braid", ""}, - {0, NULL, NULL, NULL} + {PART_KINK_NO, "NO", 0, "Nothing", ""}, + {PART_KINK_CURL, "CURL", 0, "Curl", ""}, + {PART_KINK_RADIAL, "RADIAL", 0, "Radial", ""}, + {PART_KINK_WAVE, "WAVE", 0, "Wave", ""}, + {PART_KINK_BRAID, "BRAID", 0, "Braid", ""}, + {0, NULL, 0, NULL, NULL} }; static EnumPropertyItem kink_axis_items[] = { - {0, "X", "X", ""}, - {1, "Y", "Y", ""}, - {2, "Z", "Z", ""}, - {0, NULL, NULL, NULL} + {0, "X", 0, "X", ""}, + {1, "Y", 0, "Y", ""}, + {2, "Z", 0, "Z", ""}, + {0, NULL, 0, NULL, NULL} }; static EnumPropertyItem bb_align_items[] = { - {PART_BB_X, "X", "X", ""}, - {PART_BB_Y, "Y", "Y", ""}, - {PART_BB_Z, "Z", "Z", ""}, - {PART_BB_VIEW, "VIEW", "View", ""}, - {PART_BB_VEL, "VEL", "Velocity", ""}, - {0, NULL, NULL, NULL} + {PART_BB_X, "X", 0, "X", ""}, + {PART_BB_Y, "Y", 0, "Y", ""}, + {PART_BB_Z, "Z", 0, "Z", ""}, + {PART_BB_VIEW, "VIEW", 0, "View", ""}, + {PART_BB_VEL, "VEL", 0, "Velocity", ""}, + {0, NULL, 0, NULL, NULL} }; static EnumPropertyItem bb_anim_items[] = { - {PART_BB_ANIM_NONE, "NONE", "None", ""}, - {PART_BB_ANIM_TIME, "TIME", "Time", ""}, - {PART_BB_ANIM_ANGLE, "ANGLE", "Angle", ""}, - //{PART_BB_ANIM_OFF_TIME, "OFF_TIME", "off_time", ""}, - //{PART_BB_ANIM_OFF_ANGLE, "OFF_ANGLE", "off_angle", ""}, - {0, NULL, NULL, NULL} + {PART_BB_ANIM_NONE, "NONE", 0, "None", ""}, + {PART_BB_ANIM_TIME, "TIME", 0, "Time", ""}, + {PART_BB_ANIM_ANGLE, "ANGLE", 0, "Angle", ""}, + //{PART_BB_ANIM_OFF_TIME, "OFF_TIME", 0, "off_time", ""}, + //{PART_BB_ANIM_OFF_ANGLE, "OFF_ANGLE", 0, "off_angle", ""}, + {0, NULL, 0, NULL, NULL} }; static EnumPropertyItem bb_split_offset_items[] = { - {PART_BB_OFF_NONE, "NONE", "None", ""}, - {PART_BB_OFF_LINEAR, "LINEAR", "Linear", ""}, - {PART_BB_OFF_RANDOM, "RANDOM", "Random", ""}, - {0, NULL, NULL, NULL} + {PART_BB_OFF_NONE, "NONE", 0, "None", ""}, + {PART_BB_OFF_LINEAR, "LINEAR", 0, "Linear", ""}, + {PART_BB_OFF_RANDOM, "RANDOM", 0, "Random", ""}, + {0, NULL, 0, NULL, NULL} }; srna= RNA_def_struct(brna, "ParticleSettings", "ID"); diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index 8edcc4c72f4..b8863540bdf 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -69,9 +69,9 @@ IDProperty *rna_PoseChannel_idproperties(PointerRNA *ptr, int create) static void rna_def_pose_channel(BlenderRNA *brna) { static EnumPropertyItem prop_rotmode_items[] = { - {PCHAN_ROT_QUAT, "QUATERNION", "Quaternion (WXYZ)", "No Gimbal Lock (default)"}, - {PCHAN_ROT_EUL, "EULER", "Euler (XYZ)", "Prone to Gimbal Lock"}, - {0, NULL, NULL, NULL}}; + {PCHAN_ROT_QUAT, "QUATERNION", 0, "Quaternion (WXYZ)", "No Gimbal Lock (default)"}, + {PCHAN_ROT_EUL, "EULER", 0, "Euler (XYZ)", "Prone to Gimbal Lock"}, + {0, NULL, 0, NULL, NULL}}; StructRNA *srna; PropertyRNA *prop; diff --git a/source/blender/makesrna/intern/rna_property.c b/source/blender/makesrna/intern/rna_property.c index c38b6342942..a840552b86f 100644 --- a/source/blender/makesrna/intern/rna_property.c +++ b/source/blender/makesrna/intern/rna_property.c @@ -75,12 +75,12 @@ void RNA_def_gameproperty(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem gameproperty_type_items[] ={ - {GPROP_BOOL, "BOOL", "Boolean", ""}, - {GPROP_INT, "INT", "Integer", ""}, - {GPROP_FLOAT, "FLOAT", "Float", ""}, - {GPROP_STRING, "STRING", "String", ""}, - {GPROP_TIME, "TIMER", "Timer", ""}, - {0, NULL, NULL, NULL}}; + {GPROP_BOOL, "BOOL", 0, "Boolean", ""}, + {GPROP_INT, "INT", 0, "Integer", ""}, + {GPROP_FLOAT, "FLOAT", 0, "Float", ""}, + {GPROP_STRING, "STRING", 0, "String", ""}, + {GPROP_TIME, "TIMER", 0, "Timer", ""}, + {0, NULL, 0, NULL, NULL}}; /* Base Struct for GameProperty */ srna= RNA_def_struct(brna, "GameProperty", NULL); diff --git a/source/blender/makesrna/intern/rna_radio.c b/source/blender/makesrna/intern/rna_radio.c index 54dbd59b52d..8b862b4c535 100644 --- a/source/blender/makesrna/intern/rna_radio.c +++ b/source/blender/makesrna/intern/rna_radio.c @@ -40,10 +40,10 @@ void RNA_def_radio(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem prop_drawtype_items[] = { - {RAD_WIREFRAME, "WIREFRAME", "Wireframe", "Enables Wireframe draw mode"}, - {RAD_SOLID, "SOLID", "Solid", "Enables Solid draw mode"}, - {RAD_GOURAUD, "GOURAUD", "Gouraud", "Enables Gouraud draw mode"}, - {0, NULL, NULL, NULL}}; + {RAD_WIREFRAME, "WIREFRAME", 0, "Wireframe", "Enables Wireframe draw mode"}, + {RAD_SOLID, "SOLID", 0, "Solid", "Enables Solid draw mode"}, + {RAD_GOURAUD, "GOURAUD", 0, "Gouraud", "Enables Gouraud draw mode"}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "Radiosity", NULL); RNA_def_struct_ui_text(srna, "Radiosity", "Settings for radiosity simulation of indirect diffuse lighting."); diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index 8ea8844c65f..6fa275cec91 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -34,6 +34,8 @@ #ifdef RNA_RUNTIME +#include "BLI_ghash.h" + /* Struct */ static void rna_Struct_identifier_get(PointerRNA *ptr, char *value) @@ -277,6 +279,51 @@ PointerRNA rna_builtin_properties_get(CollectionPropertyIterator *iter) return rna_Struct_properties_get(iter); } +PointerRNA rna_builtin_properties_lookup_string(PointerRNA *ptr, const char *key) +{ + StructRNA *srna; + PropertyRNA *prop; + IDProperty *group, *idp; + PointerRNA propptr; + + memset(&propptr, 0, sizeof(propptr)); + srna= ptr->type; + + do { + if(srna->cont.prophash) { + prop= BLI_ghash_lookup(srna->cont.prophash, (void*)key); + + if(prop) { + propptr.type= &RNA_Property; + propptr.data= prop; + return propptr; + } + } + + for(prop=srna->cont.properties.first; prop; prop=prop->next) { + if(!(prop->flag & PROP_BUILTIN) && strcmp(prop->identifier, key)==0) { + propptr.type= &RNA_Property; + propptr.data= prop; + return propptr; + } + } + } while((srna=srna->base)); + + group= RNA_struct_idproperties(ptr, 0); + + if(group) { + for(idp=group->data.group.first; idp; idp=idp->next) { + if(strcmp(idp->name, key) == 0) { + propptr.type= &RNA_Property; + propptr.data= idp; + return propptr; + } + } + } + + return propptr; +} + PointerRNA rna_builtin_type_get(PointerRNA *ptr) { return rna_pointer_inherit_refine(ptr, &RNA_Struct, ptr->type); @@ -611,13 +658,13 @@ static void rna_def_struct(BlenderRNA *brna) prop= RNA_def_property(srna, "properties", PROP_COLLECTION, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "Property"); - RNA_def_property_collection_funcs(prop, "rna_Struct_properties_begin", "rna_Struct_properties_next", "rna_iterator_listbase_end", "rna_Struct_properties_get", 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_Struct_properties_begin", "rna_Struct_properties_next", "rna_iterator_listbase_end", "rna_Struct_properties_get", 0, 0, 0, 0, 0); RNA_def_property_ui_text(prop, "Properties", "Properties in the struct."); prop= RNA_def_property(srna, "functions", PROP_COLLECTION, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "Function"); - RNA_def_property_collection_funcs(prop, "rna_Struct_functions_begin", "rna_Struct_functions_next", "rna_iterator_listbase_end", "rna_Struct_functions_get", 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_Struct_functions_begin", "rna_Struct_functions_next", "rna_iterator_listbase_end", "rna_Struct_functions_get", 0, 0, 0, 0, 0); RNA_def_property_ui_text(prop, "Functions", ""); } @@ -626,26 +673,26 @@ static void rna_def_property(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem type_items[] = { - {PROP_BOOLEAN, "BOOLEAN", "Boolean", ""}, - {PROP_INT, "INT", "Integer", ""}, - {PROP_FLOAT, "FLOAT", "Float", ""}, - {PROP_STRING, "STRING", "String", ""}, - {PROP_ENUM, "ENUM", "Enumeration", ""}, - {PROP_POINTER, "POINTER", "Pointer", ""}, - {PROP_COLLECTION, "COLLECTION", "Collection", ""}, - {0, NULL, NULL, NULL}}; + {PROP_BOOLEAN, "BOOLEAN", 0, "Boolean", ""}, + {PROP_INT, "INT", 0, "Integer", ""}, + {PROP_FLOAT, "FLOAT", 0, "Float", ""}, + {PROP_STRING, "STRING", 0, "String", ""}, + {PROP_ENUM, "ENUM", 0, "Enumeration", ""}, + {PROP_POINTER, "POINTER", 0, "Pointer", ""}, + {PROP_COLLECTION, "COLLECTION", 0, "Collection", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem subtype_items[] = { - {PROP_NONE, "NONE", "None", ""}, - {PROP_UNSIGNED, "UNSIGNED", "Unsigned Number", ""}, - {PROP_FILEPATH, "FILE_PATH", "File Path", ""}, - {PROP_DIRPATH, "DIRECTORY_PATH", "Directory Path", ""}, - {PROP_COLOR, "COLOR", "Color", ""}, - {PROP_VECTOR, "VECTOR", "Vector", ""}, - {PROP_MATRIX, "MATRIX", "Matrix", ""}, - {PROP_ROTATION, "ROTATION", "Rotation", ""}, - {PROP_NEVER_NULL, "NEVER_NULL", "Never Null", ""}, - {PROP_PERCENTAGE, "PERCENTAGE", "Percentage", ""}, - {0, NULL, NULL, NULL}}; + {PROP_NONE, "NONE", 0, "None", ""}, + {PROP_UNSIGNED, "UNSIGNED", 0, "Unsigned Number", ""}, + {PROP_FILEPATH, "FILE_PATH", 0, "File Path", ""}, + {PROP_DIRPATH, "DIRECTORY_PATH", 0, "Directory Path", ""}, + {PROP_COLOR, "COLOR", 0, "Color", ""}, + {PROP_VECTOR, "VECTOR", 0, "Vector", ""}, + {PROP_MATRIX, "MATRIX", 0, "Matrix", ""}, + {PROP_ROTATION, "ROTATION", 0, "Rotation", ""}, + {PROP_NEVER_NULL, "NEVER_NULL", 0, "Never Null", ""}, + {PROP_PERCENTAGE, "PERCENTAGE", 0, "Percentage", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "Property", NULL); RNA_def_struct_ui_text(srna, "Property Definition", "RNA property definition."); @@ -719,7 +766,7 @@ static void rna_def_function(BlenderRNA *brna) prop= RNA_def_property(srna, "parameters", PROP_COLLECTION, PROP_NONE); /*RNA_def_property_clear_flag(prop, PROP_EDITABLE);*/ RNA_def_property_struct_type(prop, "Property"); - RNA_def_property_collection_funcs(prop, "rna_Function_parameters_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_Function_parameters_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0, 0, 0); RNA_def_property_ui_text(prop, "Parameters", "Parameters for the function."); prop= RNA_def_property(srna, "registered", PROP_BOOLEAN, PROP_NONE); @@ -800,7 +847,7 @@ static void rna_def_enum_property(BlenderRNA *brna, StructRNA *srna) prop= RNA_def_property(srna, "items", PROP_COLLECTION, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "EnumPropertyItem"); - RNA_def_property_collection_funcs(prop, "rna_EnumProperty_items_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_EnumProperty_items_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0, 0, 0); RNA_def_property_ui_text(prop, "Items", "Possible values for the property."); srna= RNA_def_struct(brna, "EnumPropertyItem", NULL); @@ -895,7 +942,7 @@ void RNA_def_rna(BlenderRNA *brna) prop= RNA_def_property(srna, "structs", PROP_COLLECTION, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "Struct"); - RNA_def_property_collection_funcs(prop, "rna_BlenderRNA_structs_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_BlenderRNA_structs_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0, 0, 0); RNA_def_property_ui_text(prop, "Structs", ""); } diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index b7487f46f8d..1365ab75fc7 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -31,18 +31,24 @@ #include "DNA_scene_types.h" +/* +#include "BKE_writeffmpeg.h" +#include <libavcodec/avcodec.h> +#include <libavformat/avformat.h> +*/ + #include "WM_types.h" /* prop_mode needs to be accessible from transform operator */ EnumPropertyItem prop_mode_items[] ={ - {PROP_SMOOTH, "SMOOTH", "Smooth", ""}, - {PROP_SPHERE, "SPHERE", "Sphere", ""}, - {PROP_ROOT, "ROOT", "Root", ""}, - {PROP_SHARP, "SHARP", "Sharp", ""}, - {PROP_LIN, "LINEAR", "Linear", ""}, - {PROP_CONST, "CONSTANT", "Constant", ""}, - {PROP_RANDOM, "RANDOM", "Random", ""}, - {0, NULL, NULL, NULL}}; + {PROP_SMOOTH, "SMOOTH", 0, "Smooth", ""}, + {PROP_SPHERE, "SPHERE", 0, "Sphere", ""}, + {PROP_ROOT, "ROOT", 0, "Root", ""}, + {PROP_SHARP, "SHARP", 0, "Sharp", ""}, + {PROP_LIN, "LINEAR", 0, "Linear", ""}, + {PROP_CONST, "CONSTANT", 0, "Constant", ""}, + {PROP_RANDOM, "RANDOM", 0, "Random", ""}, + {0, NULL, 0, NULL, NULL}}; #ifdef RNA_RUNTIME @@ -166,126 +172,164 @@ void rna_def_scene_render_data(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem pixel_filter_items[] ={ - {R_FILTER_BOX, "BOX", "Box", ""}, - {R_FILTER_TENT, "TENT", "Tent", ""}, - {R_FILTER_QUAD, "QUADRATIC", "Quadratic", ""}, - {R_FILTER_CUBIC, "CUBIC", "Cubic", ""}, - {R_FILTER_CATROM, "CATMULLROM", "Catmull-Rom", ""}, - {R_FILTER_GAUSS, "GAUSSIAN", "Gaussian", ""}, - {R_FILTER_MITCH, "MITCHELL", "Mitchell-Netravali", ""}, - {0, NULL, NULL, NULL}}; + {R_FILTER_BOX, "BOX", 0, "Box", ""}, + {R_FILTER_TENT, "TENT", 0, "Tent", ""}, + {R_FILTER_QUAD, "QUADRATIC", 0, "Quadratic", ""}, + {R_FILTER_CUBIC, "CUBIC", 0, "Cubic", ""}, + {R_FILTER_CATROM, "CATMULLROM", 0, "Catmull-Rom", ""}, + {R_FILTER_GAUSS, "GAUSSIAN", 0, "Gaussian", ""}, + {R_FILTER_MITCH, "MITCHELL", 0, "Mitchell-Netravali", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem alpha_mode_items[] ={ - {R_ADDSKY, "SKY", "Sky", "Transparent pixels are filled with sky color"}, - {R_ALPHAPREMUL, "PREMUL", "Premultiplied", "Transparent RGB pixels are multiplied by the alpha channel"}, - {R_ALPHAKEY, "STRAIGHT", "Straight Alpha", "Transparent RGB and alpha pixels are unmodified"}, - {0, NULL, NULL, NULL}}; + {R_ADDSKY, "SKY", 0, "Sky", "Transparent pixels are filled with sky color"}, + {R_ALPHAPREMUL, "PREMUL", 0, "Premultiplied", "Transparent RGB pixels are multiplied by the alpha channel"}, + {R_ALPHAKEY, "STRAIGHT", 0, "Straight Alpha", "Transparent RGB and alpha pixels are unmodified"}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem color_mode_items[] ={ - {R_PLANESBW, "BW", "BW", "Images are saved with BW (grayscale) data"}, - {R_PLANES24, "RGB", "RGB", "Images are saved with RGB (color) data"}, - {R_PLANES32, "RGBA", "RGBA", "Images are saved with RGB and Alpha data (if supported)"}, - {0, NULL, NULL, NULL}}; + {R_PLANESBW, "BW", 0, "BW", "Images are saved with BW (grayscale) data"}, + {R_PLANES24, "RGB", 0, "RGB", "Images are saved with RGB (color) data"}, + {R_PLANES32, "RGBA", 0, "RGBA", "Images are saved with RGB and Alpha data (if supported)"}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem octree_resolution_items[] = { - {64, "OCTREE_RES_64", "64", ""}, - {128, "OCTREE_RES_128", "128", ""}, - {256, "OCTREE_RES_256", "256", ""}, - {512, "OCTREE_RES_512", "512", ""}, - {0, NULL, NULL, NULL}}; + {64, "OCTREE_RES_64", 0, "64", ""}, + {128, "OCTREE_RES_128", 0, "128", ""}, + {256, "OCTREE_RES_256", 0, "256", ""}, + {512, "OCTREE_RES_512", 0, "512", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem fixed_oversample_items[] = { - {5, "OVERSAMPLE_5", "5", ""}, - {8, "OVERSAMPLE_8", "8", ""}, - {11, "OVERSAMPLE_11", "11", ""}, - {16, "OVERSAMPLE_16", "16", ""}, - {0, NULL, NULL, NULL}}; + {5, "OVERSAMPLE_5", 0, "5", ""}, + {8, "OVERSAMPLE_8", 0, "8", ""}, + {11, "OVERSAMPLE_11", 0, "11", ""}, + {16, "OVERSAMPLE_16", 0, "16", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem field_order_items[] = { - {0, "FIELDS_EVENFIRST", "Even", "Even Fields First"}, - {R_ODDFIELD, "FIELDS_ODDFIRST", "Odd", "Odd Fields First"}, - {0, NULL, NULL, NULL}}; + {0, "FIELDS_EVENFIRST", 0, "Even", "Even Fields First"}, + {R_ODDFIELD, "FIELDS_ODDFIRST", 0, "Odd", "Odd Fields First"}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem threads_mode_items[] = { - {0, "THREADS_AUTO", "Auto-detect", ""}, - {R_FIXED_THREADS, "THREADS_FIXED", "Fixed Number", ""}, - {0, NULL, NULL, NULL}}; + {0, "THREADS_AUTO", 0, "Auto-detect", "Automatically determine the number of threads, based on CPUs"}, + {R_FIXED_THREADS, "THREADS_FIXED", 0, "Fixed", "Manually determine the number of threads"}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem stamp_font_size_items[] = { - {1, "STAMP_FONT_TINY", "Tiny", ""}, - {2, "STAMP_FONT_SMALL", "Small", ""}, - {3, "STAMP_FONT_MEDIUM", "Medium", ""}, - {0, "STAMP_FONT_LARGE", "Large", ""}, - {4, "STAMP_FONT_EXTRALARGE", "Extra Large", ""}, - {0, NULL, NULL, NULL}}; + {1, "STAMP_FONT_TINY", 0, "Tiny", ""}, + {2, "STAMP_FONT_SMALL", 0, "Small", ""}, + {3, "STAMP_FONT_MEDIUM", 0, "Medium", ""}, + {0, "STAMP_FONT_LARGE", 0, "Large", ""}, + {4, "STAMP_FONT_EXTRALARGE", 0, "Extra Large", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem image_type_items[] = { - {R_FRAMESERVER, "FRAMESERVER", "Frame Server", ""}, + {R_FRAMESERVER, "FRAMESERVER", 0, "Frame Server", ""}, #ifdef WITH_FFMPEG - {R_FFMPEG, "FFMPEG", "FFMpeg", ""}, + {R_FFMPEG, "FFMPEG", 0, "FFMpeg", ""}, #endif - {R_AVIRAW, "AVIRAW", "AVI Raw", ""}, - {R_AVIJPEG, "AVIJPEG", "AVI JPEG", ""}, + {R_AVIRAW, "AVIRAW", 0, "AVI Raw", ""}, + {R_AVIJPEG, "AVIJPEG", 0, "AVI JPEG", ""}, #ifdef _WIN32 - {R_AVICODEC, "AVICODEC", "AVI Codec", ""}, + {R_AVICODEC, "AVICODEC", 0, "AVI Codec", ""}, #endif #ifdef WITH_QUICKTIME - {R_QUICKTIME, "QUICKTIME", "QuickTime", ""}, + {R_QUICKTIME, "QUICKTIME", 0, "QuickTime", ""}, #endif - {R_TARGA, "TARGA", "Targa", ""}, - {R_RAWTGA, "RAWTARGA", "Targa Raw", ""}, - {R_PNG, "PNG", "PNG", ""}, - //{R_DDS, "DDS", "DDS", ""}, // XXX not yet implemented -#ifdef WITH_OPENJPEG - {R_JP2, "JPEG2000", "JPEG 2000", ""}, -#endif - {R_BMP, "BMP", "BMP", ""}, - {R_JPEG90, "JPEG", "JPEG", ""}, - {R_HAMX, "HAMX", "HamX", ""}, - {R_IRIS, "IRIS", "Iris", ""}, - {R_RADHDR, "RADHDR", "Radiance HDR", ""}, - {R_CINEON, "CINEON", "Cineon", ""}, - {R_DPX, "DPX", "DPX", ""}, + {R_TARGA, "TARGA", 0, "Targa", ""}, + {R_RAWTGA, "RAWTARGA", 0, "Targa Raw", ""}, + {R_PNG, "PNG", 0, "PNG", ""}, + //{R_DDS, "DDS", 0, "DDS", ""}, // XXX not yet implemented +//#ifdef WITH_OPENJPEG + {R_JP2, "JPEG2000", 0, "JPEG 2000", ""}, +//#endif + {R_BMP, "BMP", 0, "BMP", ""}, + {R_JPEG90, "JPEG", 0, "JPEG", ""}, + {R_HAMX, "HAMX", 0, "HamX", ""}, + {R_IRIS, "IRIS", 0, "Iris", ""}, + {R_RADHDR, "RADHDR", 0, "Radiance HDR", ""}, + {R_CINEON, "CINEON", 0, "Cineon", ""}, + {R_DPX, "DPX", 0, "DPX", ""}, #ifdef __sgi - {R_MOVIE, "MOVIE", "Movie", ""}, -#endif -#ifdef WITH_OPENEXR - {R_OPENEXR, "OPENEXR", "OpenEXR", ""}, - {R_MULTILAYER, "MULTILAYER", "MultiLayer", ""}, + {R_MOVIE, "MOVIE", 0, "Movie", ""}, #endif - {R_TIFF, "TIFF", "TIFF", ""}, // XXX only with G.have_libtiff - {0, NULL, NULL, NULL}}; +//#ifdef WITH_OPENEXR + {R_OPENEXR, "OPENEXR", 0, "OpenEXR", ""}, + {R_MULTILAYER, "MULTILAYER", 0, "MultiLayer", ""}, +//#endif + {R_TIFF, "TIFF", 0, "TIFF", ""}, // XXX only with G.have_libtiff + {0, NULL, 0, NULL, NULL}}; -#ifdef WITH_OPENEXR +//#ifdef WITH_OPENEXR static EnumPropertyItem exr_codec_items[] = { - {0, "NONE", "None", ""}, - {1, "PXR24", "Pxr24 (lossy)", ""}, - {2, "ZIP", "ZIP (lossless)", ""}, - {3, "PIZ", "PIZ (lossless)", ""}, - {4, "RLE", "RLE (lossless)", ""}, - {0, NULL, NULL, NULL}}; -#endif - -#ifdef WITH_OPENJPEG + {0, "NONE", 0, "None", ""}, + {1, "PXR24", 0, "Pxr24 (lossy)", ""}, + {2, "ZIP", 0, "ZIP (lossless)", ""}, + {3, "PIZ", 0, "PIZ (lossless)", ""}, + {4, "RLE", 0, "RLE (lossless)", ""}, + {0, NULL, 0, NULL, NULL}}; +//#endif + +//#ifdef WITH_OPENJPEG static EnumPropertyItem jp2_preset_items[] = { - {0, "NO_PRESET", "No Preset", ""}, - {1, "R_JPEG2K_CINE_PRESET", "Cinema 24fps 2048x1080", ""}, - {2, "R_JPEG2K_CINE_PRESET|R_JPEG2K_CINE_48FPS", "Cinema 48fps 2048x1080", ""}, - {3, "R_JPEG2K_CINE_PRESET", "Cinema 24fps 4096x2160", ""}, - {4, "R_JPEG2K_CINE_PRESET", "Cine-Scope 24fps 2048x858", ""}, - {5, "R_JPEG2K_CINE_PRESET|R_JPEG2K_CINE_48FPS", "Cine-Scope 48fps 2048x858", ""}, - {6, "R_JPEG2K_CINE_PRESET", "Cine-Flat 24fps 1998x1080", ""}, - {7, "R_JPEG2K_CINE_PRESET|R_JPEG2K_CINE_48FPS", "Cine-Flat 48fps 1998x1080", ""}, - {0, NULL, NULL, NULL}}; + {0, "NO_PRESET", 0, "No Preset", ""}, + {1, "R_JPEG2K_CINE_PRESET", 0, "Cinema 24fps 2048x1080", ""}, + {2, "R_JPEG2K_CINE_PRESET|R_JPEG2K_CINE_48FPS", 0, "Cinema 48fps 2048x1080", ""}, + {3, "R_JPEG2K_CINE_PRESET", 0, "Cinema 24fps 4096x2160", ""}, + {4, "R_JPEG2K_CINE_PRESET", 0, "Cine-Scope 24fps 2048x858", ""}, + {5, "R_JPEG2K_CINE_PRESET|R_JPEG2K_CINE_48FPS", 0, "Cine-Scope 48fps 2048x858", ""}, + {6, "R_JPEG2K_CINE_PRESET", 0, "Cine-Flat 24fps 1998x1080", ""}, + {7, "R_JPEG2K_CINE_PRESET|R_JPEG2K_CINE_48FPS", 0, "Cine-Flat 48fps 1998x1080", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem jp2_depth_items[] = { - {0, "8", "8", ""}, - {R_JPEG2K_12BIT, "16", "16", ""}, - {R_JPEG2K_16BIT, "32", "32", ""}, - {0, NULL, NULL, NULL}}; + {0, "8", 0, "8", ""}, + {R_JPEG2K_12BIT, "16", 0, "16", ""}, + {R_JPEG2K_16BIT, "32", 0, "32", ""}, + {0, NULL, 0, NULL, NULL}}; +//#endif + +/* +#ifdef WITH_FFMPEG + static EnumPropertyItem ffmpeg_format_items[] = { + {FFMPEG_MPEG1, "MPEG1", 0, "MPEG-1", ""}, + {FFMPEG_MPEG2, "MPEG2", 0, "MPEG-2", ""}, + {FFMPEG_MPEG4, "MPEG4", 0, "MPEG-4", ""}, + {FFMPEG_AVI, "AVI", 0, "Avi", ""}, + {FFMPEG_MOV, "QUICKTIME", 0, "Quicktime", ""}, + {FFMPEG_DV, "DV", 0, "DV", ""}, + {FFMPEG_H264, "H264", 0, "H264", ""}, + {FFMPEG_XVID, "XVID", 0, "XVid", ""}, + {FFMPEG_OGG, "OGG", 0, "OGG", ""}, + {FFMPEG_FLV, "FLASH", 0, "Flash", ""}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem ffmpeg_codec_items[] = { + {CODEC_ID_MPEG1VIDEO, "MPEG1", 0, "MPEG-1", ""}, + {CODEC_ID_MPEG2VIDEO, "MPEG2", 0, "MPEG-2", ""}, + {CODEC_ID_MPEG4, "MPEG4", 0, "MPEG-4(divx)", ""}, + {CODEC_ID_HUFFYUV, "HUFFYUV", 0, "HuffYUV", ""}, + {CODEC_ID_DVVIDEO, "DV", 0, "DV", ""}, + {CODEC_ID_H264, "H264", 0, "H264", ""}, + {CODEC_ID_XVID, "XVID", 0, "XVid", ""}, + {CODEC_ID_THEORA, "THEORA", 0, "OGG Theora", ""}, + {CODEC_ID_FLV1, "FLASH", 0, "FlashVideo1", ""}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem ffmpeg_audio_codec_items[] = { + {CODEC_ID_MP2, "MP2", 0, "MP2", ""}, + {CODEC_ID_MP3, "MP3", 0, "MP3", ""}, + {CODEC_ID_AC3, "AC3", 0, "AC3", ""}, + {CODEC_ID_AAC, "AAC", 0, "AAC", ""}, + {CODEC_ID_VORBIS, "VORBIS", 0, "Vorbis", ""}, + {CODEC_ID_PCM_S16LE, "PCM", 0, "PCM", ""}, + {0, NULL, 0, NULL, NULL}}; #endif - +*/ + srna= RNA_def_struct(brna, "SceneRenderData", NULL); RNA_def_struct_sdna(srna, "RenderData"); RNA_def_struct_nested(brna, srna, "Scene"); @@ -294,7 +338,7 @@ void rna_def_scene_render_data(BlenderRNA *brna) prop= RNA_def_property(srna, "color_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "planes"); RNA_def_property_enum_items(prop, color_mode_items); - RNA_def_property_ui_text(prop, "Color Mode", "What Color Mode images are saved in (BW, RGB, RGBA)"); + RNA_def_property_ui_text(prop, "Color Mode", "Choose BW for saving greyscale images, RGB for saving red, green and blue channels, AND RGBA for saving red, green, blue + alpha channels"); prop= RNA_def_property(srna, "resolution_x", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "xsch"); @@ -311,7 +355,7 @@ void rna_def_scene_render_data(BlenderRNA *brna) prop= RNA_def_property(srna, "resolution_percentage", PROP_INT, PROP_PERCENTAGE); RNA_def_property_int_sdna(prop, NULL, "size"); RNA_def_property_ui_range(prop, 1, 100, 10, 1); - RNA_def_property_ui_text(prop, "Resolution %", "Preview scale for render resolution"); + RNA_def_property_ui_text(prop, "Resolution %", "Percentage scale for render resolution"); prop= RNA_def_property(srna, "parts_x", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "xparts"); @@ -342,33 +386,33 @@ void rna_def_scene_render_data(BlenderRNA *brna) prop= RNA_def_property(srna, "quality", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "quality"); RNA_def_property_range(prop, 1, 100); - RNA_def_property_ui_text(prop, "Quality", "Quality setting for JPEG images, AVI Jpeg and SGI movies."); + RNA_def_property_ui_text(prop, "Quality", "Quality of JPEG images, AVI Jpeg and SGI movies."); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); /* Tiff */ prop= RNA_def_property(srna, "tiff_bit", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "subimtype", R_TIFF_16BIT); - RNA_def_property_ui_text(prop, "16 Bit", "Save 16 bit per channel TIFF"); + RNA_def_property_ui_text(prop, "16 Bit", "Save TIFF with 16 bits per channel"); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); /* Cineon and DPX */ prop= RNA_def_property(srna, "cineon_log", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "subimtype", R_CINEON_LOG); - RNA_def_property_ui_text(prop, "Log", "Convert to log color space"); + RNA_def_property_ui_text(prop, "Log", "Convert to logarithmic color space"); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); prop= RNA_def_property(srna, "cineon_black", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "cineonblack"); RNA_def_property_range(prop, 0, 1024); - RNA_def_property_ui_text(prop, "B", "Log conversion reference black"); + RNA_def_property_ui_text(prop, "B", "Log conversion reference blackpoint"); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); prop= RNA_def_property(srna, "cineon_white", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "cineonwhite"); RNA_def_property_range(prop, 0, 1024); - RNA_def_property_ui_text(prop, "W", "Log conversion reference white"); + RNA_def_property_ui_text(prop, "W", "Log conversion reference whitepoint"); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); prop= RNA_def_property(srna, "cineon_gamma", PROP_FLOAT, PROP_NONE); @@ -377,13 +421,13 @@ void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "G", "Log conversion gamma"); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); -#ifdef WITH_OPENEXR +//#ifdef WITH_OPENEXR /* OpenEXR */ prop= RNA_def_property(srna, "exr_codec", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "quality"); RNA_def_property_enum_items(prop, exr_codec_items); - RNA_def_property_ui_text(prop, "Codec", "Set codec settings for OpenEXR"); + RNA_def_property_ui_text(prop, "Codec", "Codec settings for OpenEXR"); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); prop= RNA_def_property(srna, "exr_half", PROP_BOOLEAN, PROP_NONE); @@ -398,11 +442,11 @@ void rna_def_scene_render_data(BlenderRNA *brna) prop= RNA_def_property(srna, "exr_preview", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "subimtype", R_PREVIEW_JPG); - RNA_def_property_ui_text(prop, "Preview", "When animation render, save JPG preview images in same directory"); + RNA_def_property_ui_text(prop, "Preview", "When rendering animations, save JPG preview images in same directory"); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); -#endif +//#endif -#ifdef WITH_OPENJPEG +//#ifdef WITH_OPENJPEG /* Jpeg 2000 */ prop= RNA_def_property(srna, "jpeg_preset", PROP_ENUM, PROP_NONE); @@ -414,25 +458,111 @@ void rna_def_scene_render_data(BlenderRNA *brna) prop= RNA_def_property(srna, "jpeg_depth", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "jp2_depth"); RNA_def_property_enum_items(prop, jp2_depth_items); - RNA_def_property_ui_text(prop, "Depth", ""); + RNA_def_property_ui_text(prop, "Depth", "Bit depth per channel"); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); prop= RNA_def_property(srna, "jpeg_ycc", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "subimtype", R_JPEG2K_YCC); - RNA_def_property_ui_text(prop, "YCC", "Save luminance-chrominance-chrominance instead of RGB color channels"); + RNA_def_property_ui_text(prop, "YCC", "Save luminance-chrominance-chrominance channels instead of RGB colors"); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); +//#endif + +#ifdef WITH_FFMPEG + /* FFMPEG Video*/ + + /* + prop= RNA_def_property(srna, "ffmpeg_format", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "ffcodecdata.type"); + RNA_def_property_enum_items(prop, ffmpeg_format_items); + RNA_def_property_ui_text(prop, "Format", "Output file format"); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + + prop= RNA_def_property(srna, "ffmpeg_codec", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "ffcodecdata.codec"); + RNA_def_property_enum_items(prop, ffmpeg_codec_items); + RNA_def_property_ui_text(prop, "Codec", "FFMpeg codec to use"); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + */ + + prop= RNA_def_property(srna, "ffmpeg_video_bitrate", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "ffcodecdata.video_bitrate"); + RNA_def_property_range(prop, 1, 14000); + RNA_def_property_ui_text(prop, "Bitrate", "Video bitrate(kb/s)"); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + + prop= RNA_def_property(srna, "ffmpeg_minrate", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "ffcodecdata.rc_min_rate"); + RNA_def_property_range(prop, 0, 9000); + RNA_def_property_ui_text(prop, "Min Rate", "Rate control: min rate(kb/s)"); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + + prop= RNA_def_property(srna, "ffmpeg_maxrate", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "ffcodecdata.rc_max_rate"); + RNA_def_property_range(prop, 1, 14000); + RNA_def_property_ui_text(prop, "Max Rate", "Rate control: max rate(kb/s)"); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + + prop= RNA_def_property(srna, "ffmpeg_muxrate", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "ffcodecdata.mux_rate"); + RNA_def_property_range(prop, 0, 100000000); + RNA_def_property_ui_text(prop, "Mux Rate", "Mux rate (bits/s(!))"); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + + prop= RNA_def_property(srna, "ffmpeg_gopsize", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "ffcodecdata.gop_size"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_text(prop, "GOP Size", "Distance between key frames"); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + + prop= RNA_def_property(srna, "ffmpeg_buffersize", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "ffcodecdata.rc_buffer_size"); + RNA_def_property_range(prop, 0, 2000); + RNA_def_property_ui_text(prop, "Buffersize", "Rate control: buffer size (kb)"); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + + prop= RNA_def_property(srna, "ffmpeg_packetsize", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "ffcodecdata.mux_packet_size"); + RNA_def_property_range(prop, 0, 16384); + RNA_def_property_ui_text(prop, "Mux Packet Size", "Mux packet size (byte)"); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); -#endif + prop= RNA_def_property(srna, "ffmpeg_autosplit", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "ffcodecdata.flags", FFMPEG_AUTOSPLIT_OUTPUT); + RNA_def_property_ui_text(prop, "Autosplit Output", "Autosplit output at 2GB boundary."); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + + /* FFMPEG Audio*/ + + /* + prop= RNA_def_property(srna, "ffmpeg_audio_codec", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "ffcodecdata.audio_codec"); + RNA_def_property_enum_items(prop, ffmpeg_audio_codec_items); + RNA_def_property_ui_text(prop, Codec", "FFMpeg codec to use"); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + */ + + prop= RNA_def_property(srna, "ffmpeg_audio_bitrate", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "ffcodecdata.audio_bitrate"); + RNA_def_property_range(prop, 32, 384); + RNA_def_property_ui_text(prop, "Bitrate", "Audio bitrate(kb/s)"); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + + prop= RNA_def_property(srna, "ffmpeg_multiplex_audio", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "ffcodecdata.flags", FFMPEG_MULTIPLEX_AUDIO); + RNA_def_property_ui_text(prop, "Multiplex Audio", "Interleave audio with the output video"); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); +#endif + prop= RNA_def_property(srna, "fps", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "frs_sec"); RNA_def_property_range(prop, 1, 120); - RNA_def_property_ui_text(prop, "FPS", "Frames per second."); + RNA_def_property_ui_text(prop, "FPS", "Framerate, expressed in frames per second."); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); prop= RNA_def_property(srna, "fps_base", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "frs_sec_base"); RNA_def_property_range(prop, 0.1f, 120.0f); - RNA_def_property_ui_text(prop, "FPS Base", "Frames per second base"); + RNA_def_property_ui_text(prop, "FPS Base", "Framerate base"); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); prop= RNA_def_property(srna, "dither_intensity", PROP_FLOAT, PROP_NONE); @@ -444,7 +574,7 @@ void rna_def_scene_render_data(BlenderRNA *brna) prop= RNA_def_property(srna, "pixel_filter", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "filtertype"); RNA_def_property_enum_items(prop, pixel_filter_items); - RNA_def_property_ui_text(prop, "Pixel Filter", "Reconstruction filter used for combining AA samples."); + RNA_def_property_ui_text(prop, "Pixel Filter", "Reconstruction filter used for combining anti-aliasing samples."); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); prop= RNA_def_property(srna, "filter_size", PROP_FLOAT, PROP_NONE); @@ -462,33 +592,33 @@ void rna_def_scene_render_data(BlenderRNA *brna) prop= RNA_def_property(srna, "octree_resolution", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "ocres"); RNA_def_property_enum_items(prop, octree_resolution_items); - RNA_def_property_ui_text(prop, "Octree Resolution", "Resolution of raytrace accelerator - use higher resolutions for larger scenes."); + RNA_def_property_ui_text(prop, "Octree Resolution", "Resolution of raytrace accelerator. Use higher resolutions for larger scenes."); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); prop= RNA_def_property(srna, "antialiasing", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", R_OSA); - RNA_def_property_ui_text(prop, "Anti-Aliasing", "Renders and combines multiple samples per pixel to prevent aliasing."); + RNA_def_property_ui_text(prop, "Anti-Aliasing", "Render and combine multiple samples per pixel to prevent jagged edges."); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); prop= RNA_def_property(srna, "antialiasing_samples", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "osa"); RNA_def_property_enum_items(prop, fixed_oversample_items); - RNA_def_property_ui_text(prop, "Anti-Aliasing Samples", "The number of fixed samples per pixel for anti-aliasing."); + RNA_def_property_ui_text(prop, "Anti-Aliasing Samples", "Amount of anti-aliasing samples per pixel."); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); prop= RNA_def_property(srna, "fields", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", R_FIELDS); - RNA_def_property_ui_text(prop, "Fields", "Renders image to two fields per frame, for interlaced TV display."); + RNA_def_property_ui_text(prop, "Fields", "Render image to two fields per frame, for interlaced TV output."); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); prop= RNA_def_property(srna, "field_order", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "mode"); RNA_def_property_enum_items(prop, field_order_items); - RNA_def_property_ui_text(prop, "Field Order", ""); + RNA_def_property_ui_text(prop, "Field Order", "Order of video fields. Select which lines get rendered first, to create smooth motion for TV output"); prop= RNA_def_property(srna, "fields_still", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", R_FIELDSTILL); - RNA_def_property_ui_text(prop, "Fields Still", "Disables the time difference between fields."); + RNA_def_property_ui_text(prop, "Fields Still", "Disable the time difference between fields."); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); prop= RNA_def_property(srna, "render_shadows", PROP_BOOLEAN, PROP_NONE); @@ -552,7 +682,7 @@ void rna_def_scene_render_data(BlenderRNA *brna) prop= RNA_def_property(srna, "threads_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "mode"); RNA_def_property_enum_items(prop, threads_mode_items); - RNA_def_property_ui_text(prop, "Threads Mode", ""); + RNA_def_property_ui_text(prop, "Threads Mode", "Determine the amount of render threads used"); prop= RNA_def_property(srna, "motion_blur", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", R_MBLUR); @@ -607,12 +737,12 @@ void rna_def_scene_render_data(BlenderRNA *brna) prop= RNA_def_property(srna, "save_buffers", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_EXR_TILE_FILE); - RNA_def_property_ui_text(prop, "Save Buffers","Save tiles for all RenderLayers and used SceneNodes to files in the temp directory (saves memory, allows Full Sampling)."); + RNA_def_property_ui_text(prop, "Save Buffers","Save tiles for all RenderLayers and SceneNodes to files in the temp directory (saves memory, allows Full Sampling)."); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); prop= RNA_def_property(srna, "full_sample", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_FULL_SAMPLE); - RNA_def_property_ui_text(prop, "Full Sample","Saves for every OSA sample the entire RenderLayer results (Higher quality sampling but slower)."); + RNA_def_property_ui_text(prop, "Full Sample","Save for every anti-aliasing sample the entire RenderLayer results. This solves anti-aliasing issues with compositing"); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); prop= RNA_def_property(srna, "backbuf", PROP_BOOLEAN, PROP_NONE); @@ -688,19 +818,19 @@ void rna_def_scene_render_data(BlenderRNA *brna) prop= RNA_def_property(srna, "stamp_font_size", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "stamp_font_id"); RNA_def_property_enum_items(prop, stamp_font_size_items); - RNA_def_property_ui_text(prop, "Stamp Font Size", "Size of the font used when rendering stamp info text"); + RNA_def_property_ui_text(prop, "Stamp Font Size", "Size of the font used when rendering stamp text"); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); prop= RNA_def_property(srna, "stamp_foreground", PROP_FLOAT, PROP_COLOR); RNA_def_property_float_sdna(prop, NULL, "fg_stamp"); RNA_def_property_array(prop, 4); - RNA_def_property_ui_text(prop, "Stamp Foreground", ""); + RNA_def_property_ui_text(prop, "Stamp Foreground", "Stamp text color"); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); prop= RNA_def_property(srna, "stamp_background", PROP_FLOAT, PROP_COLOR); RNA_def_property_float_sdna(prop, NULL, "bg_stamp"); RNA_def_property_array(prop, 4); - RNA_def_property_ui_text(prop, "Stamp Background", ""); + RNA_def_property_ui_text(prop, "Stamp Background", "Color to use behind stamp text"); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); } @@ -710,9 +840,9 @@ void RNA_def_scene(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem unwrapper_items[] = { - {0, "CONFORMAL", "Conformal", ""}, - {1, "ANGLEBASED", "Angle Based", ""}, - {0, NULL, NULL, NULL}}; + {0, "CONFORMAL", 0, "Conformal", ""}, + {1, "ANGLEBASED", 0, "Angle Based", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "Scene", "ID"); RNA_def_struct_ui_text(srna, "Scene", "Scene consisting objects and defining time and render related settings."); @@ -736,7 +866,7 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "base", NULL); RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Objects", ""); - RNA_def_property_collection_funcs(prop, 0, 0, 0, "rna_Scene_objects_get", 0, 0, 0); + RNA_def_property_collection_funcs(prop, 0, 0, 0, "rna_Scene_objects_get", 0, 0, 0, 0, 0); prop= RNA_def_property(srna, "visible_layers", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "lay", 1); diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c index e153994e7a6..b7279757455 100644 --- a/source/blender/makesrna/intern/rna_screen.c +++ b/source/blender/makesrna/intern/rna_screen.c @@ -33,12 +33,12 @@ #include "DNA_scene_types.h" EnumPropertyItem region_type_items[] = { - {RGN_TYPE_WINDOW, "WINDOW", "Window", ""}, - {RGN_TYPE_HEADER, "HEADER", "Header", ""}, - {RGN_TYPE_CHANNELS, "CHANNELS", "Channels", ""}, - {RGN_TYPE_TEMPORARY, "TEMPORARY", "Temporary", ""}, - {RGN_TYPE_UI, "UI", "UI", ""}, - {0, NULL, NULL, NULL}}; + {RGN_TYPE_WINDOW, "WINDOW", 0, "Window", ""}, + {RGN_TYPE_HEADER, "HEADER", 0, "Header", ""}, + {RGN_TYPE_CHANNELS, "CHANNELS", 0, "Channels", ""}, + {RGN_TYPE_TEMPORARY, "TEMPORARY", 0, "Temporary", ""}, + {RGN_TYPE_UI, "UI", 0, "UI", ""}, + {0, NULL, 0, NULL, NULL}}; #ifdef RNA_RUNTIME diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c index 265b59c97ae..53bd230870f 100644 --- a/source/blender/makesrna/intern/rna_sensor.c +++ b/source/blender/makesrna/intern/rna_sensor.c @@ -78,21 +78,21 @@ void rna_def_sensor(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem sensor_type_items[] ={ - {SENS_ALWAYS, "ALWAYS", "Always", ""}, - {SENS_TOUCH, "TOUCH", "Touch", ""}, - {SENS_NEAR, "NEAR", "Near", ""}, - {SENS_KEYBOARD, "KEYBOARD", "Keyboard", ""}, - {SENS_PROPERTY, "PROPERTY", "Property", ""}, - {SENS_MOUSE, "MOUSE", "Mouse", ""}, - {SENS_COLLISION, "COLLISION", "Collision", ""}, - {SENS_RADAR, "RADAR", "Radar", ""}, - {SENS_RANDOM, "RANDOM", "Random", ""}, - {SENS_RAY, "RAY", "Ray", ""}, - {SENS_MESSAGE, "MESSAGE", "Message", ""}, - {SENS_JOYSTICK, "JOYSTICK", "joystick", ""}, - {SENS_ACTUATOR, "ACTUATOR", "Actuator", ""}, - {SENS_DELAY, "DELAY", "Delay", ""}, - {0, NULL, NULL, NULL}}; + {SENS_ALWAYS, "ALWAYS", 0, "Always", ""}, + {SENS_TOUCH, "TOUCH", 0, "Touch", ""}, + {SENS_NEAR, "NEAR", 0, "Near", ""}, + {SENS_KEYBOARD, "KEYBOARD", 0, "Keyboard", ""}, + {SENS_PROPERTY, "PROPERTY", 0, "Property", ""}, + {SENS_MOUSE, "MOUSE", 0, "Mouse", ""}, + {SENS_COLLISION, "COLLISION", 0, "Collision", ""}, + {SENS_RADAR, "RADAR", 0, "Radar", ""}, + {SENS_RANDOM, "RANDOM", 0, "Random", ""}, + {SENS_RAY, "RAY", 0, "Ray", ""}, + {SENS_MESSAGE, "MESSAGE", 0, "Message", ""}, + {SENS_JOYSTICK, "JOYSTICK", 0, "joystick", ""}, + {SENS_ACTUATOR, "ACTUATOR", 0, "Actuator", ""}, + {SENS_DELAY, "DELAY", 0, "Delay", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "Sensor", NULL); RNA_def_struct_ui_text(srna, "Sensor", "Game engine logic brick to detect events."); @@ -166,15 +166,15 @@ void rna_def_mouse_sensor(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem mouse_event_items[] ={ - {BL_SENS_MOUSE_LEFT_BUTTON, "LEFTCLICK", "Left Button", ""}, - {BL_SENS_MOUSE_MIDDLE_BUTTON, "MIDDLECLICK", "Middle Button", ""}, - {BL_SENS_MOUSE_RIGHT_BUTTON, "RIGHTCLICK", "Right Button", ""}, - {BL_SENS_MOUSE_WHEEL_UP, "WHEELUP", "Wheel Up", ""}, - {BL_SENS_MOUSE_WHEEL_DOWN, "WHEELDOWN", "Wheel Down", ""}, - {BL_SENS_MOUSE_MOVEMENT, "MOVEMENT", "Movement", ""}, - {BL_SENS_MOUSE_MOUSEOVER, "MOUSEOVER", "Mouse Over", ""}, - {BL_SENS_MOUSE_MOUSEOVER_ANY, "MOUSEOVERANY", "Mouse Over Any", ""}, - {0, NULL, NULL, NULL}}; + {BL_SENS_MOUSE_LEFT_BUTTON, "LEFTCLICK", 0, "Left Button", ""}, + {BL_SENS_MOUSE_MIDDLE_BUTTON, "MIDDLECLICK", 0, "Middle Button", ""}, + {BL_SENS_MOUSE_RIGHT_BUTTON, "RIGHTCLICK", 0, "Right Button", ""}, + {BL_SENS_MOUSE_WHEEL_UP, "WHEELUP", 0, "Wheel Up", ""}, + {BL_SENS_MOUSE_WHEEL_DOWN, "WHEELDOWN", 0, "Wheel Down", ""}, + {BL_SENS_MOUSE_MOVEMENT, "MOVEMENT", 0, "Movement", ""}, + {BL_SENS_MOUSE_MOUSEOVER, "MOUSEOVER", 0, "Mouse Over", ""}, + {BL_SENS_MOUSE_MOUSEOVER_ANY, "MOUSEOVERANY", 0, "Mouse Over Any", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "MouseSensor", "Sensor"); RNA_def_struct_ui_text(srna, "Mouse Sensor", "Sensor to detect mouse events."); @@ -245,12 +245,12 @@ void rna_def_property_sensor(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem prop_type_items[] ={ - {SENS_PROP_EQUAL, "PROPEQUAL", "Equal", ""}, - {SENS_PROP_NEQUAL, "PROPNEQUAL", "Not Equal", ""}, - {SENS_PROP_INTERVAL, "PROPINTERVAL", "Interval", ""}, - {SENS_PROP_CHANGED, "PROPCHANGED", "Changed", ""}, - /* {SENS_PROP_EXPRESSION, "PROPEXPRESSION", "Expression", ""}, NOT_USED_IN_UI */ - {0, NULL, NULL, NULL}}; + {SENS_PROP_EQUAL, "PROPEQUAL", 0, "Equal", ""}, + {SENS_PROP_NEQUAL, "PROPNEQUAL", 0, "Not Equal", ""}, + {SENS_PROP_INTERVAL, "PROPINTERVAL", 0, "Interval", ""}, + {SENS_PROP_CHANGED, "PROPCHANGED", 0, "Changed", ""}, + /* {SENS_PROP_EXPRESSION, "PROPEXPRESSION", 0, "Expression", ""}, NOT_USED_IN_UI */ + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "PropertySensor", "Sensor"); RNA_def_struct_ui_text(srna, "Property Sensor", "Sensor to detect values and changes in values of properties."); @@ -319,9 +319,9 @@ void rna_def_collision_sensor(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem prop_type_items[] ={ - {0, "PROPERTY", "Property", ""}, - {1, "MATERIAL", "Material", ""}, - {0, NULL, NULL, NULL}}; + {0, "PROPERTY", 0, "Property", ""}, + {1, "MATERIAL", 0, "Material", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "CollisionSensor", "Sensor"); RNA_def_struct_ui_text(srna, "Collision Sensor", "Sensor to detect objects colliding with the current object, with more settings than the Touch sensor."); @@ -346,13 +346,13 @@ void rna_def_radar_sensor(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem axis_items[] ={ - {SENS_RAY_X_AXIS, "XAXIS", "+X axis", ""}, - {SENS_RAY_Y_AXIS, "YAXIS", "+Y axis", ""}, - {SENS_RAY_Z_AXIS, "ZAXIS", "+Z axis", ""}, - {SENS_RAY_NEG_X_AXIS, "NEGXAXIS", "-X axis", ""}, - {SENS_RAY_NEG_Y_AXIS, "NEGYAXIS", "-Y axis", ""}, - {SENS_RAY_NEG_Z_AXIS, "NEGZAXIS", "-Z axis", ""}, - {0, NULL, NULL, NULL}}; + {SENS_RAY_X_AXIS, "XAXIS", 0, "+X axis", ""}, + {SENS_RAY_Y_AXIS, "YAXIS", 0, "+Y axis", ""}, + {SENS_RAY_Z_AXIS, "ZAXIS", 0, "+Z axis", ""}, + {SENS_RAY_NEG_X_AXIS, "NEGXAXIS", 0, "-X axis", ""}, + {SENS_RAY_NEG_Y_AXIS, "NEGYAXIS", 0, "-Y axis", ""}, + {SENS_RAY_NEG_Z_AXIS, "NEGZAXIS", 0, "-Z axis", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "RadarSensor", "Sensor"); RNA_def_struct_ui_text(srna, "Radar Sensor", "Sensor to detect objects in a cone shaped radar emanating from the current object."); @@ -395,17 +395,17 @@ void rna_def_ray_sensor(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem axis_items[] ={ - {SENS_RAY_X_AXIS, "XAXIS", "+X axis", ""}, - {SENS_RAY_Y_AXIS, "YAXIS", "+Y axis", ""}, - {SENS_RAY_Z_AXIS, "ZAXIS", "+Z axis", ""}, - {SENS_RAY_NEG_X_AXIS, "NEGXAXIS", "-X axis", ""}, - {SENS_RAY_NEG_Y_AXIS, "NEGYAXIS", "-Y axis", ""}, - {SENS_RAY_NEG_Z_AXIS, "NEGZAXIS", "-Z axis", ""}, - {0, NULL, NULL, NULL}}; + {SENS_RAY_X_AXIS, "XAXIS", 0, "+X axis", ""}, + {SENS_RAY_Y_AXIS, "YAXIS", 0, "+Y axis", ""}, + {SENS_RAY_Z_AXIS, "ZAXIS", 0, "+Z axis", ""}, + {SENS_RAY_NEG_X_AXIS, "NEGXAXIS", 0, "-X axis", ""}, + {SENS_RAY_NEG_Y_AXIS, "NEGYAXIS", 0, "-Y axis", ""}, + {SENS_RAY_NEG_Z_AXIS, "NEGZAXIS", 0, "-Z axis", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_type_items[] ={ - {0, "PROPERTY", "Property", ""}, - {1, "MATERIAL", "Material", ""}, - {0, NULL, NULL, NULL}}; + {0, "PROPERTY", 0, "Property", ""}, + {1, "MATERIAL", 0, "Material", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "RaySensor", "Sensor"); RNA_def_struct_ui_text(srna, "Ray Sensor", "Sensor to detect intersections with a ray emanating from the current object."); @@ -457,17 +457,17 @@ void rna_def_joystick_sensor(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem event_type_items[] ={ - {SENS_JOY_BUTTON, "BUTTON", "Button", ""}, - {SENS_JOY_AXIS, "AXIS", "Axis", ""}, - {SENS_JOY_HAT, "HAT", "Hat", ""}, - {0, NULL, NULL, NULL}}; + {SENS_JOY_BUTTON, "BUTTON", 0, "Button", ""}, + {SENS_JOY_AXIS, "AXIS", 0, "Axis", ""}, + {SENS_JOY_HAT, "HAT", 0, "Hat", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem axis_direction_items[] ={ - {SENS_JOY_X_AXIS, "RIGHTAXIS", "Right Axis", ""}, - {SENS_JOY_Y_AXIS, "UPAXIS", "Up Axis", ""}, - {SENS_JOY_NEG_X_AXIS, "LEFTAXIS", "Left Axis", ""}, - {SENS_JOY_NEG_Y_AXIS, "DOWNAXIS", "Down Axis", ""}, - {0, NULL, NULL, NULL}}; + {SENS_JOY_X_AXIS, "RIGHTAXIS", 0, "Right Axis", ""}, + {SENS_JOY_Y_AXIS, "UPAXIS", 0, "Up Axis", ""}, + {SENS_JOY_NEG_X_AXIS, "LEFTAXIS", 0, "Left Axis", ""}, + {SENS_JOY_NEG_Y_AXIS, "DOWNAXIS", 0, "Down Axis", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "JoystickSensor", "Sensor"); RNA_def_struct_ui_text(srna, "Joystick Sensor", "Sensor to detect joystick events."); diff --git a/source/blender/makesrna/intern/rna_sequence.c b/source/blender/makesrna/intern/rna_sequence.c index 0cf627a20fc..055e67fb135 100644 --- a/source/blender/makesrna/intern/rna_sequence.c +++ b/source/blender/makesrna/intern/rna_sequence.c @@ -34,8 +34,14 @@ #include "DNA_scene_types.h" #include "DNA_sequence_types.h" +#include "BKE_sequence.h" + +#include "MEM_guardedalloc.h" + #ifdef RNA_RUNTIME +#include "MEM_guardedalloc.h" + static int rna_SequenceEditor_name_length(PointerRNA *ptr) { return strlen("Sequence Editor"); @@ -46,6 +52,115 @@ static void rna_SequenceEditor_name_get(PointerRNA *ptr, char *str) strcpy(str, "Sequence Editor"); } +static void rna_SequenceEditor_start_frame_set(PointerRNA *ptr, int value) +{ + Sequence *seq= (Sequence*)ptr->data; + Scene *sce= (Scene*)ptr->id.data; + Editing *ed= seq_give_editing(sce, FALSE); + + seq->start= value; + calc_sequence_disp(seq); + + if( seq_test_overlap(ed->seqbasep, seq) ) { + shuffle_seq(ed->seqbasep, seq); + } + sort_seq(sce); +} + +static void rna_SequenceEditor_length_set(PointerRNA *ptr, int value) +{ + Sequence *seq= (Sequence*)ptr->data; + Scene *sce= (Scene*)ptr->id.data; + Editing *ed= seq_give_editing(sce, FALSE); + + seq_tx_set_final_right(seq, seq->start+value); + calc_sequence_disp(seq); + + if( seq_test_overlap(ed->seqbasep, seq) ) { + shuffle_seq(ed->seqbasep, seq); + } + sort_seq(sce); +} + +static int rna_SequenceEditor_length_get(PointerRNA *ptr) +{ + Sequence *seq= (Sequence*)ptr->data; + return seq_tx_get_final_right(seq, 1)-seq_tx_get_final_left(seq, 1); +} + +static void rna_SequenceEditor_channel_set(PointerRNA *ptr, int value) +{ + Sequence *seq= (Sequence*)ptr->data; + Scene *sce= (Scene*)ptr->id.data; + Editing *ed= seq_give_editing(sce, FALSE); + + seq->machine= value; + + if( seq_test_overlap(ed->seqbasep, seq) ) { + shuffle_seq(ed->seqbasep, seq); + } + sort_seq(sce); +} + +/* properties that need to allocate structs */ +static void rna_SequenceEditor_use_color_balance_set(PointerRNA *ptr, int value) +{ + Sequence *seq= (Sequence*)ptr->data; + int c; + + if(value) { + seq->flag |= SEQ_USE_COLOR_BALANCE; + if(seq->strip->color_balance == NULL) { + seq->strip->color_balance = MEM_callocN(sizeof(struct StripColorBalance), "StripColorBalance"); + for (c=0; c<3; c++) { + seq->strip->color_balance->lift[c] = 1.0f; + seq->strip->color_balance->gamma[c] = 1.0f; + seq->strip->color_balance->gain[c] = 1.0f; + } + } + } else { + seq->flag ^= SEQ_USE_COLOR_BALANCE; + } +} + +static void rna_SequenceEditor_use_proxy_set(PointerRNA *ptr, int value) +{ + Sequence *seq= (Sequence*)ptr->data; + if(value) { + seq->flag |= SEQ_USE_PROXY; + if(seq->strip->proxy == NULL) { + seq->strip->proxy = MEM_callocN(sizeof(struct StripProxy), "StripProxy"); + } + } else { + seq->flag ^= SEQ_USE_PROXY; + } +} + +static void rna_SequenceEditor_use_translation_set(PointerRNA *ptr, int value) +{ + Sequence *seq= (Sequence*)ptr->data; + if(value) { + seq->flag |= SEQ_USE_TRANSFORM; + if(seq->strip->transform == NULL) { + seq->strip->transform = MEM_callocN(sizeof(struct StripTransform), "StripTransform"); + } + } else { + seq->flag ^= SEQ_USE_TRANSFORM; + } +} + +static void rna_SequenceEditor_use_crop_set(PointerRNA *ptr, int value) +{ + Sequence *seq= (Sequence*)ptr->data; + if(value) { + seq->flag |= SEQ_USE_CROP; + if(seq->strip->crop == NULL) { + seq->strip->crop = MEM_callocN(sizeof(struct StripCrop), "StripCrop"); + } + } else { + seq->flag ^= SEQ_USE_CROP; + } +} /* name functions that ignore the first two characters */ static void rna_Sequence_name_get(PointerRNA *ptr, char *value) { @@ -240,43 +355,44 @@ static void rna_def_sequence(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; + FunctionRNA *func; static const EnumPropertyItem seq_type_items[]= { - {SEQ_IMAGE, "IMAGE", "Image", ""}, - {SEQ_META, "META", "Meta", ""}, - {SEQ_SCENE, "SCENE", "Scene", ""}, - {SEQ_MOVIE, "MOVIE", "Movie", ""}, - {SEQ_RAM_SOUND, "RAM_SOUND", "Ram Sound", ""}, - {SEQ_HD_SOUND, "HD_SOUND", "HD Sound", ""}, - {SEQ_MOVIE_AND_HD_SOUND, "MOVIE_AND_HD_SOUND", "Movie and HD Sound", ""}, - {SEQ_EFFECT, "REPLACE", "Replace", ""}, - {SEQ_CROSS, "CROSS", "Cross", ""}, - {SEQ_ADD, "ADD", "Add", ""}, - {SEQ_SUB, "SUBTRACT", "Subtract", ""}, - {SEQ_ALPHAOVER, "ALPHA_OVER", "Alpha Over", ""}, - {SEQ_ALPHAUNDER, "ALPHA_UNDER", "Alpha Under", ""}, - {SEQ_GAMCROSS, "GAMMA_CROSS", "Gamma Cross", ""}, - {SEQ_MUL, "MULTIPLY", "Multiply", ""}, - {SEQ_OVERDROP, "OVER_DROP", "Over Drop", ""}, - {SEQ_PLUGIN, "PLUGIN", "plugin", ""}, - {SEQ_WIPE, "WIPE", "Wipe", ""}, - {SEQ_GLOW, "GLOW", "Glow", ""}, - {SEQ_TRANSFORM, "TRANSFORM", "Transform", ""}, - {SEQ_COLOR, "COLOR", "Color", ""}, - {SEQ_SPEED, "SPEED", "Speed", ""}, - {0, NULL, NULL, NULL}}; + {SEQ_IMAGE, "IMAGE", 0, "Image", ""}, + {SEQ_META, "META", 0, "Meta", ""}, + {SEQ_SCENE, "SCENE", 0, "Scene", ""}, + {SEQ_MOVIE, "MOVIE", 0, "Movie", ""}, + {SEQ_RAM_SOUND, "RAM_SOUND", 0, "Ram Sound", ""}, + {SEQ_HD_SOUND, "HD_SOUND", 0, "HD Sound", ""}, + {SEQ_MOVIE_AND_HD_SOUND, "MOVIE_AND_HD_SOUND", 0, "Movie and HD Sound", ""}, + {SEQ_EFFECT, "REPLACE", 0, "Replace", ""}, + {SEQ_CROSS, "CROSS", 0, "Cross", ""}, + {SEQ_ADD, "ADD", 0, "Add", ""}, + {SEQ_SUB, "SUBTRACT", 0, "Subtract", ""}, + {SEQ_ALPHAOVER, "ALPHA_OVER", 0, "Alpha Over", ""}, + {SEQ_ALPHAUNDER, "ALPHA_UNDER", 0, "Alpha Under", ""}, + {SEQ_GAMCROSS, "GAMMA_CROSS", 0, "Gamma Cross", ""}, + {SEQ_MUL, "MULTIPLY", 0, "Multiply", ""}, + {SEQ_OVERDROP, "OVER_DROP", 0, "Over Drop", ""}, + {SEQ_PLUGIN, "PLUGIN", 0, "plugin", ""}, + {SEQ_WIPE, "WIPE", 0, "Wipe", ""}, + {SEQ_GLOW, "GLOW", 0, "Glow", ""}, + {SEQ_TRANSFORM, "TRANSFORM", 0, "Transform", ""}, + {SEQ_COLOR, "COLOR", 0, "Color", ""}, + {SEQ_SPEED, "SPEED", 0, "Speed", ""}, + {0, NULL, 0, NULL, NULL}}; static const EnumPropertyItem blend_mode_items[]= { - {SEQ_BLEND_REPLACE, "REPLACE", "Replace", ""}, - {SEQ_CROSS, "CROSS", "Cross", ""}, - {SEQ_ADD, "ADD", "Add", ""}, - {SEQ_SUB, "SUBTRACT", "Subtract", ""}, - {SEQ_ALPHAOVER, "ALPHA_OVER", "Alpha Over", ""}, - {SEQ_ALPHAUNDER, "ALPHA_UNDER", "Alpha Under", ""}, - {SEQ_GAMCROSS, "GAMMA_CROSS", "Gamma Cross", ""}, - {SEQ_MUL, "MULTIPLY", "Multiply", ""}, - {SEQ_OVERDROP, "OVER_DROP", "Over Drop", ""}, - {0, NULL, NULL, NULL}}; + {SEQ_BLEND_REPLACE, "REPLACE", 0, "Replace", ""}, + {SEQ_CROSS, "CROSS", 0, "Cross", ""}, + {SEQ_ADD, "ADD", 0, "Add", ""}, + {SEQ_SUB, "SUBTRACT", 0, "Subtract", ""}, + {SEQ_ALPHAOVER, "ALPHA_OVER", 0, "Alpha Over", ""}, + {SEQ_ALPHAUNDER, "ALPHA_UNDER", 0, "Alpha Under", ""}, + {SEQ_GAMCROSS, "GAMMA_CROSS", 0, "Gamma Cross", ""}, + {SEQ_MUL, "MULTIPLY", 0, "Multiply", ""}, + {SEQ_OVERDROP, "OVER_DROP", 0, "Over Drop", ""}, + {0, NULL, 0, NULL, NULL}}; srna = RNA_def_struct(brna, "Sequence", NULL); RNA_def_struct_ui_text(srna, "Sequence", "Sequence strip in the sequence editor."); @@ -326,13 +442,14 @@ static void rna_def_sequence(BlenderRNA *brna) prop= RNA_def_property(srna, "length", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "len"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); // computed from other values + RNA_def_property_range(prop, 1, MAXFRAME); RNA_def_property_ui_text(prop, "Length", "The length of the contents of this strip before the handles are applied"); - + RNA_def_property_int_funcs(prop, "rna_SequenceEditor_length_get", "rna_SequenceEditor_length_set",NULL); + prop= RNA_def_property(srna, "start_frame", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "start"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); // overlap tests RNA_def_property_ui_text(prop, "Start Frame", ""); + RNA_def_property_int_funcs(prop, NULL, "rna_SequenceEditor_start_frame_set",NULL); // overlap tests and calc_seq_disp prop= RNA_def_property(srna, "start_offset", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "startofs"); @@ -358,8 +475,8 @@ static void rna_def_sequence(BlenderRNA *brna) prop= RNA_def_property(srna, "channel", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "machine"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); // overlap test RNA_def_property_ui_text(prop, "Channel", "Y position of the sequence strip."); + RNA_def_property_int_funcs(prop, NULL, "rna_SequenceEditor_channel_set",NULL); // overlap test /* blending */ @@ -370,6 +487,13 @@ static void rna_def_sequence(BlenderRNA *brna) prop= RNA_def_property(srna, "blend_opacity", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.0f, 100.0f); RNA_def_property_ui_text(prop, "Blend Opacity", ""); + + /* funcsions */ + func= RNA_def_function(srna, "getStripElem", "give_stripelem"); + RNA_def_function_ui_description(func, "Return the strip element from a given frame or None."); + prop= RNA_def_int(func, "frame", 0, INT_MIN, INT_MAX, "Frame", "The frame to get the strip element from", INT_MIN, INT_MAX); + RNA_def_property_flag(prop, PROP_REQUIRED); + RNA_def_function_return(func, RNA_def_pointer(func, "elem", "SequenceElement", "", "strip element of the current frame")); } void rna_def_editor(BlenderRNA *brna) @@ -397,7 +521,7 @@ void rna_def_editor(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "metastack", NULL); RNA_def_property_struct_type(prop, "Sequence"); RNA_def_property_ui_text(prop, "Meta Stack", "Meta strip stack, last is currently edited meta strip."); - RNA_def_property_collection_funcs(prop, 0, 0, 0, "rna_SequenceEdtior_meta_stack_get", 0, 0, 0); + RNA_def_property_collection_funcs(prop, 0, 0, 0, "rna_SequenceEdtior_meta_stack_get", 0, 0, 0, 0, 0); prop= RNA_def_property(srna, "active_strip", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "act_seq"); @@ -443,8 +567,8 @@ static void rna_def_filter_video(StructRNA *srna) prop= RNA_def_property(srna, "use_color_balance", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_USE_COLOR_BALANCE); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); // allocate color balance RNA_def_property_ui_text(prop, "Use Color Balance", "(3-Way color correction) on input."); + RNA_def_property_boolean_funcs(prop, NULL, "rna_SequenceEditor_use_color_balance_set"); prop= RNA_def_property(srna, "color_balance", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "strip->color_balance"); @@ -452,8 +576,8 @@ static void rna_def_filter_video(StructRNA *srna) prop= RNA_def_property(srna, "use_translation", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_USE_TRANSFORM); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); // allocate transform RNA_def_property_ui_text(prop, "Use Translation", "Translate image before processing."); + RNA_def_property_boolean_funcs(prop, NULL, "rna_SequenceEditor_use_translation_set"); prop= RNA_def_property(srna, "transform", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "strip->transform"); @@ -461,8 +585,8 @@ static void rna_def_filter_video(StructRNA *srna) prop= RNA_def_property(srna, "use_crop", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_USE_CROP); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); // allocate crop RNA_def_property_ui_text(prop, "Use Crop", "Crop image before processing."); + RNA_def_property_boolean_funcs(prop, NULL, "rna_SequenceEditor_use_crop_set"); prop= RNA_def_property(srna, "crop", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "strip->crop"); @@ -490,8 +614,8 @@ static void rna_def_proxy(StructRNA *srna) prop= RNA_def_property(srna, "use_proxy", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_USE_PROXY); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); // allocate proxy RNA_def_property_ui_text(prop, "Use Proxy", "Use a preview proxy for this strip."); + RNA_def_property_boolean_funcs(prop, NULL, "rna_SequenceEditor_use_proxy_set"); prop= RNA_def_property(srna, "proxy", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "strip->proxy"); @@ -663,19 +787,19 @@ static void rna_def_wipe(BlenderRNA *brna) PropertyRNA *prop; static const EnumPropertyItem wipe_type_items[]= { - {0, "SINGLE", "Single", ""}, - {1, "DOUBLE", "Double", ""}, - /* not used yet {2, "BOX", "Box", ""}, */ - /* not used yet {3, "CROSS", "Cross", ""}, */ - {4, "IRIS", "Iris", ""}, - {5, "CLOCK", "Clock", ""}, - {0, NULL, NULL, NULL} + {0, "SINGLE", 0, "Single", ""}, + {1, "DOUBLE", 0, "Double", ""}, + /* not used yet {2, "BOX", 0, "Box", ""}, */ + /* not used yet {3, "CROSS", 0, "Cross", ""}, */ + {4, "IRIS", 0, "Iris", ""}, + {5, "CLOCK", 0, "Clock", ""}, + {0, NULL, 0, NULL, NULL} }; static const EnumPropertyItem wipe_direction_items[]= { - {0, "OUT", "Out", ""}, - {1, "IN", "In", ""}, - {0, NULL, NULL, NULL} + {0, "OUT", 0, "Out", ""}, + {1, "IN", 0, "In", ""}, + {0, NULL, 0, NULL, NULL} }; srna = RNA_def_struct(brna, "WipeSequence", "EffectSequence"); @@ -748,16 +872,16 @@ static void rna_def_transform(BlenderRNA *brna) PropertyRNA *prop; static const EnumPropertyItem interpolation_items[]= { - {0, "NONE", "None", "No interpolation."}, - {1, "BILINEAR", "Bilinear", "Bilinear interpolation."}, - {2, "BICUBIC", "Bicubic", "Bicubic interpolation."}, - {0, NULL, NULL, NULL} + {0, "NONE", 0, "None", "No interpolation."}, + {1, "BILINEAR", 0, "Bilinear", "Bilinear interpolation."}, + {2, "BICUBIC", 0, "Bicubic", "Bicubic interpolation."}, + {0, NULL, 0, NULL, NULL} }; static const EnumPropertyItem translation_unit_items[]= { - {0, "PIXELS", "Pixels", ""}, - {1, "PERCENT", "Percent", ""}, - {0, NULL, NULL, NULL} + {0, "PIXELS", 0, "Pixels", ""}, + {1, "PERCENT", 0, "Percent", ""}, + {0, NULL, 0, NULL, NULL} }; srna = RNA_def_struct(brna, "TransformSequence", "EffectSequence"); diff --git a/source/blender/makesrna/intern/rna_sound.c b/source/blender/makesrna/intern/rna_sound.c index 118c39655e8..363a5595b43 100644 --- a/source/blender/makesrna/intern/rna_sound.c +++ b/source/blender/makesrna/intern/rna_sound.c @@ -46,17 +46,17 @@ static void rna_def_sample(BlenderRNA *brna) /* sound types */ static EnumPropertyItem prop_sample_type_items[] = { - {SAMPLE_INVALID, "INVALID", "Invalid", ""}, - {SAMPLE_UNKNOWN, "UNKNOWN", "Unknown", ""}, - {SAMPLE_RAW, "RAW", "Raw", ""}, - {SAMPLE_WAV, "WAV", "WAV", "Uncompressed"}, - {SAMPLE_MP2, "MP2", "MP2", "MPEG-1 Audio Layer 2"}, - {SAMPLE_MP3, "MP3", "MP3", "MPEG-1 Audio Layer 3"}, - {SAMPLE_OGG_VORBIS, "OGG_VORBIS", "Ogg Vorbis", ""}, - {SAMPLE_WMA, "WMA", "WMA", "Windows Media Audio"}, - {SAMPLE_ASF, "ASF", "ASF", "Windows Advanced Systems Format"}, - {SAMPLE_AIFF, "AIFF", "AIFF", "Audio Interchange File Format"}, - {0, NULL, NULL, NULL}}; + {SAMPLE_INVALID, "INVALID", 0, "Invalid", ""}, + {SAMPLE_UNKNOWN, "UNKNOWN", 0, "Unknown", ""}, + {SAMPLE_RAW, "RAW", 0, "Raw", ""}, + {SAMPLE_WAV, "WAV", 0, "WAV", "Uncompressed"}, + {SAMPLE_MP2, "MP2", 0, "MP2", "MPEG-1 Audio Layer 2"}, + {SAMPLE_MP3, "MP3", 0, "MP3", "MPEG-1 Audio Layer 3"}, + {SAMPLE_OGG_VORBIS, "OGG_VORBIS", 0, "Ogg Vorbis", ""}, + {SAMPLE_WMA, "WMA", 0, "WMA", "Windows Media Audio"}, + {SAMPLE_ASF, "ASF", 0, "ASF", "Windows Advanced Systems Format"}, + {SAMPLE_AIFF, "AIFF", 0, "AIFF", "Audio Interchange File Format"}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "SoundSample", "ID"); RNA_def_struct_sdna(srna, "bSample"); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 1b776b727ce..78c49a493f4 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -37,32 +37,51 @@ #include "WM_types.h" EnumPropertyItem space_type_items[] = { - {SPACE_EMPTY, "EMPTY", "Empty", ""}, - {SPACE_VIEW3D, "VIEW_3D", "3D View", ""}, - {SPACE_IPO, "GRAPH_EDITOR", "Graph Editor", ""}, - {SPACE_OUTLINER, "OUTLINER", "Outliner", ""}, - {SPACE_BUTS, "BUTTONS_WINDOW", "Buttons Window", ""}, - {SPACE_FILE, "FILE_BROWSER", "File Browser", ""}, - {SPACE_IMAGE, "IMAGE_EDITOR", "Image Editor", ""}, - {SPACE_INFO, "USER_PREFERENCES", "User Preferences", ""}, - {SPACE_SEQ, "SEQUENCE_EDITOR", "Sequence Editor", ""}, - {SPACE_TEXT, "TEXT_EDITOR", "Text Editor", ""}, - //{SPACE_IMASEL, "IMAGE_BROWSER", "Image Browser", ""}, - {SPACE_SOUND, "AUDIO_WINDOW", "Audio Window", ""}, - {SPACE_ACTION, "DOPESHEET_EDITOR", "DopeSheet Editor", ""}, - {SPACE_NLA, "NLA_EDITOR", "NLA Editor", ""}, - {SPACE_SCRIPT, "SCRIPTS_WINDOW", "Scripts Window", ""}, - {SPACE_TIME, "TIMELINE", "Timeline", ""}, - {SPACE_NODE, "NODE_EDITOR", "Node Editor", ""}, - {0, NULL, NULL, NULL}}; + {SPACE_EMPTY, "EMPTY", 0, "Empty", ""}, + {SPACE_VIEW3D, "VIEW_3D", 0, "3D View", ""}, + {SPACE_IPO, "GRAPH_EDITOR", 0, "Graph Editor", ""}, + {SPACE_OUTLINER, "OUTLINER", 0, "Outliner", ""}, + {SPACE_BUTS, "BUTTONS_WINDOW", 0, "Buttons Window", ""}, + {SPACE_FILE, "FILE_BROWSER", 0, "File Browser", ""}, + {SPACE_IMAGE, "IMAGE_EDITOR", 0, "Image Editor", ""}, + {SPACE_INFO, "USER_PREFERENCES", 0, "User Preferences", ""}, + {SPACE_SEQ, "SEQUENCE_EDITOR", 0, "Sequence Editor", ""}, + {SPACE_TEXT, "TEXT_EDITOR", 0, "Text Editor", ""}, + //{SPACE_IMASEL, "IMAGE_BROWSER", 0, "Image Browser", ""}, + {SPACE_SOUND, "AUDIO_WINDOW", 0, "Audio Window", ""}, + {SPACE_ACTION, "DOPESHEET_EDITOR", 0, "DopeSheet Editor", ""}, + {SPACE_NLA, "NLA_EDITOR", 0, "NLA Editor", ""}, + {SPACE_SCRIPT, "SCRIPTS_WINDOW", 0, "Scripts Window", ""}, + {SPACE_TIME, "TIMELINE", 0, "Timeline", ""}, + {SPACE_NODE, "NODE_EDITOR", 0, "Node Editor", ""}, + {SPACE_LOGIC, "LOGIC_EDITOR", 0, "Logic Editor", ""}, + {0, NULL, 0, NULL, NULL}}; + +#define DC_RGB {0, "COLOR", ICON_IMAGE_RGB, "Color", "Draw image with RGB colors."} +#define DC_RGBA {SI_USE_ALPHA, "COLOR_ALPHA", ICON_IMAGE_RGB_ALPHA, "Color and Alpha", "Draw image with RGB colors and alpha transparency."} +#define DC_ALPHA {SI_SHOW_ALPHA, "ALPHA", ICON_IMAGE_ALPHA, "Alpha", "Draw alpha transparency channel."} +#define DC_Z {SI_SHOW_ZBUF, "Z_BUFFER", ICON_IMAGE_ZDEPTH, "Z-Buffer", "Draw Z-buffer associated with image (mapped from camera clip start to end)."} +#ifdef WITH_LCMS +#define DC_LCMS {SI_COLOR_CORRECTION, "COLOR_CORRECTED", ICON_IMAGE_ALPHA, "Color Corrected", "Display color corrected image."} +#else +#define DC_LCMS {0, NULL, 0, NULL, NULL} +#endif +#define DC_ZERO {0, NULL, 0, NULL, NULL} + +static EnumPropertyItem dc_all_items[] = {DC_RGB, DC_RGBA, DC_ALPHA, DC_Z, DC_LCMS, DC_ZERO}; #ifdef RNA_RUNTIME #include "DNA_scene_types.h" +#include "DNA_screen_types.h" #include "BKE_brush.h" #include "BKE_context.h" +#include "ED_image.h" + +#include "IMB_imbuf_types.h" + static StructRNA* rna_Space_refine(struct PointerRNA *ptr) { SpaceLink *space= (SpaceLink*)ptr->data; @@ -100,18 +119,22 @@ static StructRNA* rna_Space_refine(struct PointerRNA *ptr) case SPACE_TIME: return &RNA_SpaceTimeline; case SPACE_NODE: - return &RNA_SpaceNodeEditor;*/ + return &RNA_SpaceNodeEditor; + case SPACE_LOGIC: + return &RNA_SpaceLogicEditor;*/ default: return &RNA_Space; } } -static PointerRNA rna_SpaceImage_uvedit_get(PointerRNA *ptr) +/* Space Image Editor */ + +static PointerRNA rna_SpaceImageEditor_uvedit_get(PointerRNA *ptr) { return rna_pointer_inherit_refine(ptr, &RNA_SpaceUVEditor, ptr->data); } -static void rna_SpaceImage_paint_update(bContext *C, PointerRNA *ptr) +static void rna_SpaceImageEditor_paint_update(bContext *C, PointerRNA *ptr) { Scene *scene= CTX_data_scene(C); @@ -119,6 +142,58 @@ static void rna_SpaceImage_paint_update(bContext *C, PointerRNA *ptr) brush_check_exists(&scene->toolsettings->imapaint.brush); } +static int rna_SpaceImageEditor_show_render_get(PointerRNA *ptr) +{ + SpaceImage *sima= (SpaceImage*)(ptr->data); + return ED_space_image_show_render(sima); +} + +static int rna_SpaceImageEditor_show_paint_get(PointerRNA *ptr) +{ + SpaceImage *sima= (SpaceImage*)(ptr->data); + return ED_space_image_show_paint(sima); +} + +static int rna_SpaceImageEditor_show_uvedit_get(PointerRNA *ptr) +{ + SpaceImage *sima= (SpaceImage*)(ptr->data); + bScreen *sc= (bScreen*)ptr->id.data; + return ED_space_image_show_uvedit(sima, sc->scene->obedit); +} + +static void rna_SpaceImageEditor_image_set(PointerRNA *ptr, PointerRNA value) +{ + SpaceImage *sima= (SpaceImage*)(ptr->data); + bScreen *sc= (bScreen*)ptr->id.data; + + ED_space_image_set(NULL, sima, sc->scene, sc->scene->obedit, (Image*)value.data); +} + +static EnumPropertyItem dc_rgb_items[] = {DC_RGB, DC_LCMS, DC_ZERO}; +static EnumPropertyItem dc_alpha_items[] = {DC_RGB, DC_RGBA, DC_ALPHA, DC_LCMS, DC_ZERO}; +static EnumPropertyItem dc_z_items[] = {DC_RGB, DC_Z, DC_LCMS, DC_ZERO}; + +static EnumPropertyItem *rna_SpaceImageEditor_draw_channels_itemf(PointerRNA *ptr) +{ + SpaceImage *sima= (SpaceImage*)ptr->data; + ImBuf *ibuf= ED_space_image_buffer(sima); + int zbuf, alpha; + + alpha= ibuf && (ibuf->channels == 4); + zbuf= ibuf && (ibuf->zbuf || ibuf->zbuf_float || (ibuf->channels==1)); + + if(alpha && zbuf) + return dc_all_items; + else if(alpha) + return dc_alpha_items; + else if(zbuf) + return dc_z_items; + else + return dc_rgb_items; +} + +/* Space Text Editor */ + void rna_SpaceTextEditor_word_wrap_set(PointerRNA *ptr, int value) { SpaceText *st= (SpaceText*)(ptr->data); @@ -135,6 +210,8 @@ void rna_SpaceTextEditor_text_set(PointerRNA *ptr, PointerRNA value) st->top= 0; } +/* Space Buttons */ + StructRNA *rna_SpaceButtonsWindow_pin_id_typef(PointerRNA *ptr) { SpaceButs *sbuts= (SpaceButs*)(ptr->data); @@ -171,30 +248,30 @@ static void rna_def_space_image_uv(BlenderRNA *brna) #if 0 static EnumPropertyItem select_mode_items[] = { - {SI_SELECT_VERTEX, "VERTEX", "Vertex", "Vertex selection mode."}, - //{SI_SELECT_EDGE, "Edge", "Edge", "Edge selection mode."}, - {SI_SELECT_FACE, "FACE", "Face", "Face selection mode."}, - {SI_SELECT_ISLAND, "ISLAND", "Island", "Island selection mode."}, - {0, NULL, NULL, NULL}}; + {SI_SELECT_VERTEX, "VERTEX", 0, "Vertex", "Vertex selection mode."}, + //{SI_SELECT_EDGE, "Edge", 0, "Edge", "Edge selection mode."}, + {SI_SELECT_FACE, "FACE", 0, "Face", "Face selection mode."}, + {SI_SELECT_ISLAND, "ISLAND", 0, "Island", "Island selection mode."}, + {0, NULL, 0, NULL, NULL}}; #endif static EnumPropertyItem sticky_mode_items[] = { - {SI_STICKY_DISABLE, "DISABLED", "Disabled", "Sticky vertex selection disabled."}, - {SI_STICKY_LOC, "SHARED_LOCATION", "SHARED_LOCATION", "Select UVs that are at the same location and share a mesh vertex."}, - {SI_STICKY_VERTEX, "SHARED_VERTEX", "SHARED_VERTEX", "Select UVs that share mesh vertex, irrespective if they are in the same location."}, - {0, NULL, NULL, NULL}}; + {SI_STICKY_DISABLE, "DISABLED", 0, "Disabled", "Sticky vertex selection disabled."}, + {SI_STICKY_LOC, "SHARED_LOCATION", 0, "SHARED_LOCATION", "Select UVs that are at the same location and share a mesh vertex."}, + {SI_STICKY_VERTEX, "SHARED_VERTEX", 0, "SHARED_VERTEX", "Select UVs that share mesh vertex, irrespective if they are in the same location."}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem dt_uv_items[] = { - {SI_UVDT_OUTLINE, "OUTLINE", "Outline", "Draw white edges with black outline."}, - {SI_UVDT_DASH, "DASH", "Dash", "Draw dashed black-white edges."}, - {SI_UVDT_BLACK, "BLACK", "Black", "Draw black edges."}, - {SI_UVDT_WHITE, "WHITE", "White", "Draw white edges."}, - {0, NULL, NULL, NULL}}; + {SI_UVDT_OUTLINE, "OUTLINE", 0, "Outline", "Draw white edges with black outline."}, + {SI_UVDT_DASH, "DASH", 0, "Dash", "Draw dashed black-white edges."}, + {SI_UVDT_BLACK, "BLACK", 0, "Black", "Draw black edges."}, + {SI_UVDT_WHITE, "WHITE", 0, "White", "Draw white edges."}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem dt_uvstretch_items[] = { - {SI_UVDT_STRETCH_ANGLE, "ANGLE", "Angle", "Angular distortion between UV and 3D angles."}, - {SI_UVDT_STRETCH_AREA, "AREA", "Area", "Area distortion between UV and 3D faces."}, - {0, NULL, NULL, NULL}}; + {SI_UVDT_STRETCH_ANGLE, "ANGLE", 0, "Angle", "Angular distortion between UV and 3D angles."}, + {SI_UVDT_STRETCH_AREA, "AREA", 0, "Area", "Area distortion between UV and 3D faces."}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "SpaceUVEditor", NULL); RNA_def_struct_sdna(srna, "SpaceImage"); @@ -211,45 +288,54 @@ static void rna_def_space_image_uv(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "sticky"); RNA_def_property_enum_items(prop, sticky_mode_items); RNA_def_property_ui_text(prop, "Sticky Selection Mode", "Automatically select also UVs sharing the same vertex as the ones being selected."); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); /* drawing */ prop= RNA_def_property(srna, "edge_draw_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "dt_uv"); RNA_def_property_enum_items(prop, dt_uv_items); RNA_def_property_ui_text(prop, "Edge Draw Type", "Draw type for drawing UV edges."); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); prop= RNA_def_property(srna, "draw_smooth_edges", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_SMOOTH_UV); RNA_def_property_ui_text(prop, "Draw Smooth Edges", "Draw UV edges anti-aliased."); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); prop= RNA_def_property(srna, "draw_stretch", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DRAW_STRETCH); RNA_def_property_ui_text(prop, "Draw Stretch", "Draw faces colored according to the difference in shape between UVs and their 3D coordinates (blue for low distortion, red for high distortion)."); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); prop= RNA_def_property(srna, "draw_stretch_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "dt_uvstretch"); RNA_def_property_enum_items(prop, dt_uvstretch_items); RNA_def_property_ui_text(prop, "Draw Stretch Type", "Type of stretch to draw."); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); prop= RNA_def_property(srna, "draw_modified_edges", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "dt_uvstretch"); RNA_def_property_enum_items(prop, dt_uvstretch_items); RNA_def_property_ui_text(prop, "Draw Modified Edges", "Draw edges from the final mesh after object modifier evaluation."); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); /*prop= RNA_def_property(srna, "local_view", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_LOCAL_UV); - RNA_def_property_ui_text(prop, "Local View", "Draw only faces with the currently displayed image assigned.");*/ + RNA_def_property_ui_text(prop, "Local View", "Draw only faces with the currently displayed image assigned."); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL);*/ prop= RNA_def_property(srna, "normalized_coordinates", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_COORDFLOATS); RNA_def_property_ui_text(prop, "Normalized Coordinates", "Display UV coordinates from 0.0 to 1.0 rather than in pixels."); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); /* todo: move edge and face drawing options here from G.f */ /* editing */ /*prop= RNA_def_property(srna, "sync_selection", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_SYNC_UVSEL); - RNA_def_property_ui_text(prop, "Sync Selection", "Keep UV and edit mode mesh selection in sync.");*/ + RNA_def_property_ui_text(prop, "Sync Selection", "Keep UV and edit mode mesh selection in sync."); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL);*/ prop= RNA_def_property(srna, "snap_to_pixels", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_PIXELSNAP); @@ -270,18 +356,18 @@ static void rna_def_space_outliner(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem display_mode_items[] = { - {0, "ALL_SCENES", "All Scenes", ""}, - {1, "CURRENT_SCENE", "Current Scene", ""}, - {2, "VISIBLE_LAYERS", "Visible Layers", ""}, - {3, "SELECTED", "Selected", ""}, - {4, "ACTIVE", "Active", ""}, - {5, "SAME_TYPES", "Same Types", ""}, - {6, "GROUPS", "Groups", ""}, - {7, "LIBRARIES", "Libraries", ""}, - {10, "SEQUENCE", "Sequence", ""}, - {11, "DATABLOCKS", "Datablocks", ""}, - {12, "USER_PREFERENCES", "User Preferences", ""}, - {0, NULL, NULL, NULL}}; + {0, "ALL_SCENES", 0, "All Scenes", ""}, + {1, "CURRENT_SCENE", 0, "Current Scene", ""}, + {2, "VISIBLE_LAYERS", 0, "Visible Layers", ""}, + {3, "SELECTED", 0, "Selected", ""}, + {4, "ACTIVE", 0, "Active", ""}, + {5, "SAME_TYPES", 0, "Same Types", ""}, + {6, "GROUPS", 0, "Groups", ""}, + {7, "LIBRARIES", 0, "Libraries", ""}, + {10, "SEQUENCE", 0, "Sequence", ""}, + {11, "DATABLOCKS", 0, "Datablocks", ""}, + {12, "USER_PREFERENCES", 0, "User Preferences", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "SpaceOutliner", "Space"); RNA_def_struct_sdna(srna, "SpaceOops"); @@ -312,6 +398,7 @@ static void rna_def_background_image(BlenderRNA *brna) prop= RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "ima"); RNA_def_property_ui_text(prop, "Image", "Image displayed and edited in this space."); + RNA_def_property_update(prop, NC_OBJECT|ND_GEOM_DATA, NULL); prop= RNA_def_property(srna, "image_user", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_pointer_sdna(prop, NULL, "iuser"); @@ -343,28 +430,28 @@ static void rna_def_space_3dview(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem viewport_shading_items[] = { - {OB_BOUNDBOX, "BOUNDBOX", "Bounding Box", "Display the object's local bounding boxes only"}, - {OB_WIRE, "WIREFRAME", "Wireframe", "Display the object as wire edges"}, - {OB_SOLID, "SOLID", "Solid", "Display the object solid, lit with default OpenGL lights"}, - {OB_SHADED, "SHADED", "Shaded", "Display the object solid, with preview shading interpolated at vertices"}, - {OB_TEXTURE, "TEXTURED", "Textured", "Display the object solid, with face-assigned textures"}, - {0, NULL, NULL, NULL}}; + {OB_BOUNDBOX, "BOUNDBOX", 0, "Bounding Box", "Display the object's local bounding boxes only"}, + {OB_WIRE, "WIREFRAME", 0, "Wireframe", "Display the object as wire edges"}, + {OB_SOLID, "SOLID", 0, "Solid", "Display the object solid, lit with default OpenGL lights"}, + {OB_SHADED, "SHADED", 0, "Shaded", "Display the object solid, with preview shading interpolated at vertices"}, + {OB_TEXTURE, "TEXTURED", 0, "Textured", "Display the object solid, with face-assigned textures"}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem pivot_items[] = { - {V3D_CENTER, "BOUNDING_BOX_CENTER", "Bounding Box Center", ""}, - {V3D_CURSOR, "CURSOR", "3D Cursor", ""}, - {V3D_LOCAL, "INDIVIDUAL_CENTERS", "Individual Centers", ""}, - {V3D_CENTROID, "MEDIAN_POINT", "Median Point", ""}, - {V3D_ACTIVE, "ACTIVE_ELEMENT", "Active Element", ""}, - {0, NULL, NULL, NULL}}; + {V3D_CENTER, "BOUNDING_BOX_CENTER", 0, "Bounding Box Center", ""}, + {V3D_CURSOR, "CURSOR", 0, "3D Cursor", ""}, + {V3D_LOCAL, "INDIVIDUAL_CENTERS", 0, "Individual Centers", ""}, + {V3D_CENTROID, "MEDIAN_POINT", 0, "Median Point", ""}, + {V3D_ACTIVE, "ACTIVE_ELEMENT", 0, "Active Element", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem transform_orientation_items[] = { - {V3D_MANIP_GLOBAL, "ORIENT_GLOBAL", "Global", "Align the transformation axes to world space"}, - {V3D_MANIP_LOCAL, "ORIENT_LOCAL", "Local", "Align the transformation axes to the selected objects' local space"}, - {V3D_MANIP_NORMAL, "ORIENT_NORMAL", "Normal", "Align the transformation axes to average normal of selected elements (bone Y axis for pose mode)"}, - {V3D_MANIP_VIEW, "ORIENT_VIEW", "View", "Align the transformation axes to the window"}, - {V3D_MANIP_CUSTOM, "ORIENT_CUSTOM", "Custom", "Use a custom transform orientation"}, - {0, NULL, NULL, NULL}}; + {V3D_MANIP_GLOBAL, "ORIENT_GLOBAL", 0, "Global", "Align the transformation axes to world space"}, + {V3D_MANIP_LOCAL, "ORIENT_LOCAL", 0, "Local", "Align the transformation axes to the selected objects' local space"}, + {V3D_MANIP_NORMAL, "ORIENT_NORMAL", 0, "Normal", "Align the transformation axes to average normal of selected elements (bone Y axis for pose mode)"}, + {V3D_MANIP_VIEW, "ORIENT_VIEW", 0, "View", "Align the transformation axes to the window"}, + {V3D_MANIP_CUSTOM, "ORIENT_CUSTOM", 0, "Custom", "Use a custom transform orientation"}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "Space3DView", "Space"); RNA_def_struct_sdna(srna, "View3D"); @@ -488,24 +575,24 @@ static void rna_def_space_buttons(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem buttons_context_items[] = { - {BCONTEXT_SCENE, "SCENE", "Scene", ""}, - {BCONTEXT_WORLD, "WORLD", "World", ""}, - {BCONTEXT_OBJECT, "OBJECT", "Object", ""}, - {BCONTEXT_DATA, "DATA", "Data", ""}, - {BCONTEXT_MATERIAL, "MATERIAL", "Material", ""}, - {BCONTEXT_TEXTURE, "TEXTURE", "Texture", ""}, - {BCONTEXT_PARTICLE, "PARTICLE", "Particle", ""}, - {BCONTEXT_PHYSICS, "PHYSICS", "Physics", ""}, - {BCONTEXT_GAME, "GAME", "Game", ""}, - {BCONTEXT_BONE, "BONE", "Bone", ""}, - {BCONTEXT_MODIFIER, "MODIFIER", "Modifier", ""}, - {BCONTEXT_CONSTRAINT, "CONSTRAINT", "Constraint", ""}, - {0, NULL, NULL, NULL}}; + {BCONTEXT_SCENE, "SCENE", 0, "Scene", ""}, + {BCONTEXT_WORLD, "WORLD", 0, "World", ""}, + {BCONTEXT_OBJECT, "OBJECT", 0, "Object", ""}, + {BCONTEXT_DATA, "DATA", 0, "Data", ""}, + {BCONTEXT_MATERIAL, "MATERIAL", 0, "Material", ""}, + {BCONTEXT_TEXTURE, "TEXTURE", 0, "Texture", ""}, + {BCONTEXT_PARTICLE, "PARTICLE", 0, "Particle", ""}, + {BCONTEXT_PHYSICS, "PHYSICS", 0, "Physics", ""}, + {BCONTEXT_GAME, "GAME", 0, "Game", ""}, + {BCONTEXT_BONE, "BONE", 0, "Bone", ""}, + {BCONTEXT_MODIFIER, "MODIFIER", 0, "Modifier", ""}, + {BCONTEXT_CONSTRAINT, "CONSTRAINT", 0, "Constraint", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem panel_alignment_items[] = { - {1, "HORIZONTAL", "Horizontal", ""}, - {2, "VERTICAL", "Vertical", ""}, - {0, NULL, NULL, NULL}}; + {1, "HORIZONTAL", 0, "Horizontal", ""}, + {2, "VERTICAL", 0, "Vertical", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "SpaceButtonsWindow", "Space"); RNA_def_struct_sdna(srna, "SpaceButs"); @@ -534,55 +621,57 @@ static void rna_def_space_image(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static EnumPropertyItem draw_channels_items[] = { - {0, "COLOR", "Color", "Draw image with RGB colors."}, - {SI_USE_ALPHA, "COLOR_ALPHA", "Color and Alpha", "Draw image with RGB colors and alpha transparency."}, - {SI_SHOW_ALPHA, "ALPHA", "Alpha", "Draw alpha transparency channel."}, - {SI_SHOW_ZBUF, "Z_BUFFER", "Z-Buffer", "Draw Z-buffer associated with image (mapped from camera clip start to end)."}, - {SI_COLOR_CORRECTION, "COLOR_CORRECTED", "Color Corrected", "Display color corrected image."}, - {0, NULL, NULL, NULL}}; - srna= RNA_def_struct(brna, "SpaceImageEditor", "Space"); RNA_def_struct_sdna(srna, "SpaceImage"); RNA_def_struct_ui_text(srna, "Space Image Editor", "Image and UV editor space data."); /* image */ prop= RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_funcs(prop, NULL, "rna_SpaceImageEditor_image_set", NULL); RNA_def_property_ui_text(prop, "Image", "Image displayed and edited in this space."); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); prop= RNA_def_property(srna, "image_user", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_pointer_sdna(prop, NULL, "iuser"); RNA_def_property_ui_text(prop, "Image User", "Parameters defining which layer, pass and frame of the image is displayed."); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); prop= RNA_def_property(srna, "curves", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "cumap"); RNA_def_property_ui_text(prop, "Curves", "Color curve mapping to use for displaying the image."); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); prop= RNA_def_property(srna, "image_pin", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "pin", 0); RNA_def_property_ui_text(prop, "Image Pin", "Display current image regardless of object selection."); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); /* image draw */ prop= RNA_def_property(srna, "draw_repeated", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DRAW_TILE); RNA_def_property_ui_text(prop, "Draw Repeated", "Draw the image repeated outside of the main view."); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); prop= RNA_def_property(srna, "draw_channels", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); - RNA_def_property_enum_items(prop, draw_channels_items); + RNA_def_property_enum_items(prop, dc_all_items); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_SpaceImageEditor_draw_channels_itemf"); RNA_def_property_ui_text(prop, "Draw Channels", "Channels of the image to draw."); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, NULL); /* uv */ prop= RNA_def_property(srna, "uv_editor", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_struct_type(prop, "SpaceUVEditor"); - RNA_def_property_pointer_funcs(prop, "rna_SpaceImage_uvedit_get", NULL, NULL); + RNA_def_property_pointer_funcs(prop, "rna_SpaceImageEditor_uvedit_get", NULL, NULL); RNA_def_property_ui_text(prop, "UV Editor", "UV editor settings."); /* paint */ prop= RNA_def_property(srna, "image_painting", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DRAWTOOL); RNA_def_property_ui_text(prop, "Image Painting", "Enable image painting mode."); - RNA_def_property_update(prop, 0, "rna_SpaceImage_paint_update"); + RNA_def_property_ui_icon(prop, ICON_TPAINT_HLT, 0); + RNA_def_property_update(prop, NC_IMAGE|ND_DISPLAY, "rna_SpaceImageEditor_paint_update"); /* grease pencil */ prop= RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE); @@ -597,24 +686,40 @@ static void rna_def_space_image(BlenderRNA *brna) /* update */ prop= RNA_def_property(srna, "update_automatically", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "lock", 0); + RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1); RNA_def_property_ui_text(prop, "Update Automatically", "Update other affected window spaces automatically to reflect changes during interactive operations such as transform."); + /* state */ + prop= RNA_def_property(srna, "show_render", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_SpaceImageEditor_show_render_get", NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Show Render", "Show render related properties."); + + prop= RNA_def_property(srna, "show_paint", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_SpaceImageEditor_show_paint_get", NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Show Paint", "Show paint related properties."); + + prop= RNA_def_property(srna, "show_uvedit", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_SpaceImageEditor_show_uvedit_get", NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Show UV Editor", "Show uv editing related properties."); + rna_def_space_image_uv(brna); } - static void rna_def_space_sequencer(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem display_mode_items[] = { - {SEQ_DRAW_SEQUENCE, "SEQUENCER", "Sequencer", ""}, - {SEQ_DRAW_IMG_IMBUF, "IMAGE", "Image Preview", ""}, - {SEQ_DRAW_IMG_WAVEFORM, "WAVEFORM", "Luma Waveform", ""}, - {SEQ_DRAW_IMG_VECTORSCOPE, "VECTOR_SCOPE", "Chroma Vectorscope", ""}, - {SEQ_DRAW_IMG_HISTOGRAM, "HISTOGRAM", "Histogram", ""}, - {0, NULL, NULL, NULL}}; + {SEQ_DRAW_SEQUENCE, "SEQUENCER", 0, "Sequencer", ""}, + {SEQ_DRAW_IMG_IMBUF, "IMAGE", 0, "Image Preview", ""}, + {SEQ_DRAW_IMG_WAVEFORM, "WAVEFORM", 0, "Luma Waveform", ""}, + {SEQ_DRAW_IMG_VECTORSCOPE, "VECTOR_SCOPE", 0, "Chroma Vectorscope", ""}, + {SEQ_DRAW_IMG_HISTOGRAM, "HISTOGRAM", 0, "Histogram", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "SpaceSequenceEditor", "Space"); RNA_def_struct_sdna(srna, "SpaceSeq"); @@ -691,9 +796,9 @@ static void rna_def_space_text(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem font_size_items[] = { - {12, "SCREEN_12", "Screen 12", ""}, - {15, "SCREEN_15", "Screen 15", ""}, - {0, NULL, NULL, NULL}}; + {12, "SCREEN_12", 0, "Screen 12", ""}, + {15, "SCREEN_15", 0, "Screen 15", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "SpaceTextEditor", "Space"); RNA_def_struct_sdna(srna, "SpaceText"); @@ -710,22 +815,28 @@ static void rna_def_space_text(BlenderRNA *brna) prop= RNA_def_property(srna, "syntax_highlight", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "showsyntax", 0); RNA_def_property_ui_text(prop, "Syntax Highlight", "Syntax highlight for scripting."); + RNA_def_property_ui_icon(prop, ICON_SYNTAX_OFF, 1); RNA_def_property_update(prop, NC_TEXT|ND_DISPLAY, NULL); prop= RNA_def_property(srna, "word_wrap", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "wordwrap", 0); RNA_def_property_boolean_funcs(prop, NULL, "rna_SpaceTextEditor_word_wrap_set"); RNA_def_property_ui_text(prop, "Word Wrap", "Wrap words if there is not enough horizontal space."); + RNA_def_property_ui_icon(prop, ICON_WORDWRAP_OFF, 1); RNA_def_property_update(prop, NC_TEXT|ND_DISPLAY, NULL); prop= RNA_def_property(srna, "line_numbers", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "showlinenrs", 0); RNA_def_property_ui_text(prop, "Line Numbers", "Show line numbers next to the text."); + RNA_def_property_ui_icon(prop, ICON_LINENUMBERS_OFF, 1); RNA_def_property_update(prop, NC_TEXT|ND_DISPLAY, NULL); prop= RNA_def_property(srna, "overwrite", PROP_BOOLEAN, PROP_NONE); RNA_def_property_ui_text(prop, "Overwrite", "Overwrite characters when typing rather than inserting them."); RNA_def_property_update(prop, NC_TEXT|ND_DISPLAY, NULL); + + prop= RNA_def_property(srna, "live_edit", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_ui_text(prop, "Live Edit", "Run python while editing."); prop= RNA_def_property(srna, "tab_width", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "tabnumber"); diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index 360a0938bb2..2a7f65e2d90 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -127,12 +127,12 @@ static void rna_def_color_ramp(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_interpolation_items[] = { - {1, "EASE", "Ease", ""}, - {3, "CARDINAL", "Cardinal", ""}, - {0, "LINEAR", "Linear", ""}, - {2, "B_SPLINE", "B-Spline", ""}, - {4, "CONSTANT", "Constant", ""}, - {0, NULL, NULL, NULL}}; + {1, "EASE", 0, "Ease", ""}, + {3, "CARDINAL", 0, "Cardinal", ""}, + {0, "LINEAR", 0, "Linear", ""}, + {2, "B_SPLINE", 0, "B-Spline", ""}, + {4, "CONSTANT", 0, "Constant", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "ColorRamp", NULL); RNA_def_struct_sdna(srna, "ColorBand"); @@ -201,21 +201,21 @@ static void rna_def_mtex(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_blend_type_items[] = { - {MTEX_BLEND, "MIX", "Mix", ""}, - {MTEX_ADD, "ADD", "Add", ""}, - {MTEX_SUB, "SUBTRACT", "Subtract", ""}, - {MTEX_MUL, "MULTIPLY", "Multiply", ""}, - {MTEX_SCREEN, "SCREEN", "Screen", ""}, - {MTEX_OVERLAY, "OVERLAY", "Overlay", ""}, - {MTEX_DIFF, "DIFFERENCE", "Difference", ""}, - {MTEX_DIV, "DIVIDE", "Divide", ""}, - {MTEX_DARK, "DARKEN", "Darken", ""}, - {MTEX_LIGHT, "LIGHTEN", "Lighten", ""}, - {MTEX_BLEND_HUE, "HUE", "Hue", ""}, - {MTEX_BLEND_SAT, "SATURATION", "Saturation", ""}, - {MTEX_BLEND_VAL, "VALUE", "Value", ""}, - {MTEX_BLEND_COLOR, "COLOR", "Color", ""}, - {0, NULL, NULL, NULL}}; + {MTEX_BLEND, "MIX", 0, "Mix", ""}, + {MTEX_ADD, "ADD", 0, "Add", ""}, + {MTEX_SUB, "SUBTRACT", 0, "Subtract", ""}, + {MTEX_MUL, "MULTIPLY", 0, "Multiply", ""}, + {MTEX_SCREEN, "SCREEN", 0, "Screen", ""}, + {MTEX_OVERLAY, "OVERLAY", 0, "Overlay", ""}, + {MTEX_DIFF, "DIFFERENCE", 0, "Difference", ""}, + {MTEX_DIV, "DIVIDE", 0, "Divide", ""}, + {MTEX_DARK, "DARKEN", 0, "Darken", ""}, + {MTEX_LIGHT, "LIGHTEN", 0, "Lighten", ""}, + {MTEX_BLEND_HUE, "HUE", 0, "Hue", ""}, + {MTEX_BLEND_SAT, "SATURATION", 0, "Saturation", ""}, + {MTEX_BLEND_VAL, "VALUE", 0, "Value", ""}, + {MTEX_BLEND_COLOR, "COLOR", 0, "Color", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "TextureSlot", NULL); RNA_def_struct_sdna(srna, "MTex"); @@ -323,10 +323,10 @@ static void rna_def_environment_map_common(StructRNA *srna) PropertyRNA *prop; static EnumPropertyItem prop_source_items[] = { - {ENV_STATIC, "STATIC", "Static", "Calculates environment map only once"}, - {ENV_ANIM, "ANIMATED", "Animated", "Calculates environment map at each rendering"}, - {ENV_LOAD, "LOADED", "Loaded", "Loads saved environment map from disk"}, - {0, NULL, NULL, NULL}}; + {ENV_STATIC, "STATIC", 0, "Static", "Calculates environment map only once"}, + {ENV_ANIM, "ANIMATED", 0, "Animated", "Calculates environment map at each rendering"}, + {ENV_LOAD, "LOADED", 0, "Loaded", "Loads saved environment map from disk"}, + {0, NULL, 0, NULL, NULL}}; prop= RNA_def_property(srna, "source", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "stype"); @@ -348,9 +348,9 @@ static void rna_def_environment_map(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_type_items[] = { - {ENV_CUBE, "CUBE", "Cube", "Use environment map with six cube sides."}, - {ENV_PLANE, "PLANE", "Plane", "Only one side is rendered, with Z axis pointing in direction of image."}, - {0, NULL, NULL, NULL}}; + {ENV_CUBE, "CUBE", 0, "Cube", "Use environment map with six cube sides."}, + {ENV_PLANE, "PLANE", 0, "Plane", "Only one side is rendered, with Z axis pointing in direction of image."}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "EnvironmentMap", NULL); RNA_def_struct_sdna(srna, "EnvMap"); @@ -400,22 +400,22 @@ static void rna_def_environment_map(BlenderRNA *brna) } static EnumPropertyItem prop_noise_basis_items[] = { - {TEX_BLENDER, "BLENDER_ORIGINAL", "Blender Original", ""}, - {TEX_STDPERLIN, "ORIGINAL_PERLIN", "Original Perlin", ""}, - {TEX_NEWPERLIN, "IMPROVED_PERLIN", "Improved Perlin", ""}, - {TEX_VORONOI_F1, "VORONOI_F1", "Voronoi F1", ""}, - {TEX_VORONOI_F2, "VORONOI_F2", "Voronoi F2", ""}, - {TEX_VORONOI_F3, "VORONOI_F3", "Voronoi F3", ""}, - {TEX_VORONOI_F4, "VORONOI_F4", "Voronoi F4", ""}, - {TEX_VORONOI_F2F1, "VORONOI_F2_F1", "Voronoi F2-F1", ""}, - {TEX_VORONOI_CRACKLE, "VORONOI_CRACKLE", "Voronoi Crackle", ""}, - {TEX_CELLNOISE, "CELL_NOISE", "Cell Noise", ""}, - {0, NULL, NULL, NULL}}; + {TEX_BLENDER, "BLENDER_ORIGINAL", 0, "Blender Original", ""}, + {TEX_STDPERLIN, "ORIGINAL_PERLIN", 0, "Original Perlin", ""}, + {TEX_NEWPERLIN, "IMPROVED_PERLIN", 0, "Improved Perlin", ""}, + {TEX_VORONOI_F1, "VORONOI_F1", 0, "Voronoi F1", ""}, + {TEX_VORONOI_F2, "VORONOI_F2", 0, "Voronoi F2", ""}, + {TEX_VORONOI_F3, "VORONOI_F3", 0, "Voronoi F3", ""}, + {TEX_VORONOI_F4, "VORONOI_F4", 0, "Voronoi F4", ""}, + {TEX_VORONOI_F2F1, "VORONOI_F2_F1", 0, "Voronoi F2-F1", ""}, + {TEX_VORONOI_CRACKLE, "VORONOI_CRACKLE", 0, "Voronoi Crackle", ""}, + {TEX_CELLNOISE, "CELL_NOISE", 0, "Cell Noise", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_noise_type[] = { - {TEX_NOISESOFT, "SOFT_NOISE", "Soft", ""}, - {TEX_NOISEPERL, "HARD_NOISE", "Hard", ""}, - {0, NULL, NULL, NULL}}; + {TEX_NOISESOFT, "SOFT_NOISE", 0, "Soft", ""}, + {TEX_NOISEPERL, "HARD_NOISE", 0, "Hard", ""}, + {0, NULL, 0, NULL, NULL}}; static void rna_def_texture_clouds(BlenderRNA *brna) @@ -424,9 +424,9 @@ static void rna_def_texture_clouds(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_clouds_stype[] = { - {TEX_DEFAULT, "GREYSCALE", "Greyscale", ""}, - {TEX_COLOR, "COLOR", "Color", ""}, - {0, NULL, NULL, NULL}}; + {TEX_DEFAULT, "GREYSCALE", 0, "Greyscale", ""}, + {TEX_COLOR, "COLOR", 0, "Color", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "CloudsTexture", "Texture"); RNA_def_struct_ui_text(srna, "Clouds Texture", "Procedural noise texture."); @@ -477,17 +477,17 @@ static void rna_def_texture_wood(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_wood_stype[] = { - {TEX_BAND, "BANDS", "Bands", "Uses standard wood texture in bands"}, - {TEX_RING, "RINGS", "Rings", "Uses wood texture in rings"}, - {TEX_BANDNOISE, "BANDNOISE", "Band Noise", "Adds noise to standard wood"}, - {TEX_RINGNOISE, "RINGNOISE", "Ring Noise", "Adds noise to rings"}, - {0, NULL, NULL, NULL}}; + {TEX_BAND, "BANDS", 0, "Bands", "Uses standard wood texture in bands"}, + {TEX_RING, "RINGS", 0, "Rings", "Uses wood texture in rings"}, + {TEX_BANDNOISE, "BANDNOISE", 0, "Band Noise", "Adds noise to standard wood"}, + {TEX_RINGNOISE, "RINGNOISE", 0, "Ring Noise", "Adds noise to rings"}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_wood_noisebasis2[] = { - {TEX_SIN, "SIN", "Sine", "Uses a sine wave to produce bands"}, - {TEX_SAW, "SAW", "Saw", "Uses a saw wave to produce bands"}, - {TEX_TRI, "TRI", "Tri", "Uses a triangle wave to produce bands"}, - {0, NULL, NULL, NULL}}; + {TEX_SIN, "SIN", 0, "Sine", "Uses a sine wave to produce bands"}, + {TEX_SAW, "SAW", 0, "Saw", "Uses a saw wave to produce bands"}, + {TEX_TRI, "TRI", 0, "Tri", "Uses a triangle wave to produce bands"}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "WoodTexture", "Texture"); RNA_def_struct_ui_text(srna, "Wood Texture", "Procedural noise texture."); @@ -545,16 +545,16 @@ static void rna_def_texture_marble(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_marble_stype[] = { - {TEX_SOFT, "SOFT", "Soft", "Uses soft marble"}, - {TEX_SHARP, "SHARP", "Sharp", "Uses more clearly defined marble"}, - {TEX_SHARPER, "SHARPER", "Sharper", "Uses very clearly defined marble"}, - {0, NULL, NULL, NULL}}; + {TEX_SOFT, "SOFT", 0, "Soft", "Uses soft marble"}, + {TEX_SHARP, "SHARP", 0, "Sharp", "Uses more clearly defined marble"}, + {TEX_SHARPER, "SHARPER", 0, "Sharper", "Uses very clearly defined marble"}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_marble_noisebasis2[] = { - {TEX_SIN, "SIN", "Sin", "Uses a sine wave to produce bands"}, - {TEX_SAW, "SAW", "Saw", "Uses a saw wave to produce bands"}, - {TEX_TRI, "TRI", "Tri", "Uses a triangle wave to produce bands"}, - {0, NULL, NULL, NULL}}; + {TEX_SIN, "SIN", 0, "Sin", "Uses a sine wave to produce bands"}, + {TEX_SAW, "SAW", 0, "Saw", "Uses a saw wave to produce bands"}, + {TEX_TRI, "TRI", 0, "Tri", "Uses a triangle wave to produce bands"}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "MarbleTexture", "Texture"); RNA_def_struct_ui_text(srna, "Marble Texture", "Procedural noise texture."); @@ -643,14 +643,14 @@ static void rna_def_texture_blend(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_blend_progression[] = { - {TEX_LIN, "LINEAR", "Linear", "Creates a linear progression"}, - {TEX_QUAD, "QUADRATIC", "Quadratic", "Creates a quadratic progression"}, - {TEX_EASE, "EASING", "Easing", "Creates a progression easing from one step to the next"}, - {TEX_DIAG, "DIAGONAL", "Diagonal", "Creates a diagonal progression"}, - {TEX_SPHERE, "SPHERICAL", "Spherical", "Creates a spherical progression"}, - {TEX_HALO, "QUADRATIC_SPHERE", "Quadratic sphere", "Creates a quadratic progression in the shape of a sphere"}, - {TEX_RAD, "RADIAL", "Radial", "Creates a radial progression"}, - {0, NULL, NULL, NULL}}; + {TEX_LIN, "LINEAR", 0, "Linear", "Creates a linear progression"}, + {TEX_QUAD, "QUADRATIC", 0, "Quadratic", "Creates a quadratic progression"}, + {TEX_EASE, "EASING", 0, "Easing", "Creates a progression easing from one step to the next"}, + {TEX_DIAG, "DIAGONAL", 0, "Diagonal", "Creates a diagonal progression"}, + {TEX_SPHERE, "SPHERICAL", 0, "Spherical", "Creates a spherical progression"}, + {TEX_HALO, "QUADRATIC_SPHERE", 0, "Quadratic sphere", "Creates a quadratic progression in the shape of a sphere"}, + {TEX_RAD, "RADIAL", 0, "Radial", "Creates a radial progression"}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "BlendTexture", "Texture"); RNA_def_struct_ui_text(srna, "Blend Texture", "Procedural color blending texture."); @@ -674,10 +674,10 @@ static void rna_def_texture_stucci(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_stucci_stype[] = { - {TEX_PLASTIC, "PLASTIC", "Plastic", "Uses standard stucci"}, - {TEX_WALLIN, "WALL_IN", "Wall in", "Creates Dimples"}, - {TEX_WALLOUT, "WALL_OUT", "Wall out", "Creates Ridges"}, - {0, NULL, NULL, NULL}}; + {TEX_PLASTIC, "PLASTIC", 0, "Plastic", "Uses standard stucci"}, + {TEX_WALLIN, "WALL_IN", 0, "Wall in", "Creates Dimples"}, + {TEX_WALLOUT, "WALL_OUT", 0, "Wall out", "Creates Ridges"}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "StucciTexture", "Texture"); RNA_def_struct_ui_text(srna, "Stucci Texture", "Procedural noise texture."); @@ -731,12 +731,12 @@ static void rna_def_texture_image(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_image_extension[] = { - {1, "EXTEND", "Extend", "Extends by repeating edge pixels of the image"}, - {2, "CLIP", "Clip", "Clips to image size and sets exterior pixels as transparent"}, - {4, "CLIP_CUBE", "Clip Cube", "Clips to cubic-shaped area around the image and sets exterior pixels as transparent"}, - {3, "REPEAT", "Repeat", "Causes the image to repeat horizontally and vertically"}, - {5, "CHECKER", "Checker", "Causes the image to repeat in checker board pattern"}, - {0, NULL, NULL, NULL}}; + {1, "EXTEND", 0, "Extend", "Extends by repeating edge pixels of the image"}, + {2, "CLIP", 0, "Clip", "Clips to image size and sets exterior pixels as transparent"}, + {4, "CLIP_CUBE", 0, "Clip Cube", "Clips to cubic-shaped area around the image and sets exterior pixels as transparent"}, + {3, "REPEAT", 0, "Repeat", "Causes the image to repeat horizontally and vertically"}, + {5, "CHECKER", 0, "Checker", "Causes the image to repeat in checker board pattern"}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "ImageTexture", "Texture"); RNA_def_struct_ui_text(srna, "Image Texture", ""); @@ -920,12 +920,12 @@ static void rna_def_texture_musgrave(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_musgrave_type[] = { - {TEX_MFRACTAL, "MULTIFRACTAL", "Multifractal", ""}, - {TEX_RIDGEDMF, "RIDGED_MULTIFRACTAL", "Ridged Multifractal", ""}, - {TEX_HYBRIDMF, "HYBRID_MULTIFRACTAL", "Hybrid Multifractal", ""}, - {TEX_FBM, "FBM", "fBM", ""}, - {TEX_HTERRAIN, "HETERO_TERRAIN", "Hetero Terrain", ""}, - {0, NULL, NULL, NULL}}; + {TEX_MFRACTAL, "MULTIFRACTAL", 0, "Multifractal", ""}, + {TEX_RIDGEDMF, "RIDGED_MULTIFRACTAL", 0, "Ridged Multifractal", ""}, + {TEX_HYBRIDMF, "HYBRID_MULTIFRACTAL", 0, "Hybrid Multifractal", ""}, + {TEX_FBM, "FBM", 0, "fBM", ""}, + {TEX_HTERRAIN, "HETERO_TERRAIN", 0, "Hetero Terrain", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "MusgraveTexture", "Texture"); RNA_def_struct_ui_text(srna, "Musgrave", "Procedural musgrave texture."); @@ -999,22 +999,22 @@ static void rna_def_texture_voronoi(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_distance_metric_items[] = { - {TEX_DISTANCE, "DISTANCE", "Actual Distance", ""}, - {TEX_DISTANCE_SQUARED, "DISTANCE_SQUARED", "Distance Squared", ""}, - {TEX_MANHATTAN, "MANHATTAN", "Manhattan", ""}, - {TEX_CHEBYCHEV, "CHEBYCHEV", "Chebychev", ""}, - {TEX_MINKOVSKY_HALF, "MINKOVSKY_HALF", "Minkovsky 1/2", ""}, - {TEX_MINKOVSKY_FOUR, "MINKOVSKY_FOUR", "Minkovsky 4", ""}, - {TEX_MINKOVSKY, "MINKOVSKY", "Minkovsky", ""}, - {0, NULL, NULL, NULL}}; + {TEX_DISTANCE, "DISTANCE", 0, "Actual Distance", ""}, + {TEX_DISTANCE_SQUARED, "DISTANCE_SQUARED", 0, "Distance Squared", ""}, + {TEX_MANHATTAN, "MANHATTAN", 0, "Manhattan", ""}, + {TEX_CHEBYCHEV, "CHEBYCHEV", 0, "Chebychev", ""}, + {TEX_MINKOVSKY_HALF, "MINKOVSKY_HALF", 0, "Minkovsky 1/2", ""}, + {TEX_MINKOVSKY_FOUR, "MINKOVSKY_FOUR", 0, "Minkovsky 4", ""}, + {TEX_MINKOVSKY, "MINKOVSKY", 0, "Minkovsky", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_coloring_items[] = { /* XXX: OK names / descriptions? */ - {TEX_INTENSITY, "INTENSITY", "Intensity", "Only calculate intensity."}, - {TEX_COL1, "POSITION", "Position", "Color cells by position."}, - {TEX_COL2, "POSITION_OUTLINE", "Position and Outline", "Use position plus an outline based on F2-F.1"}, - {TEX_COL3, "POSITION_OUTLINE_INTENSITY", "Position, Outline, and Intensity", "Multiply position and outline by intensity."}, - {0, NULL, NULL, NULL}}; + {TEX_INTENSITY, "INTENSITY", 0, "Intensity", "Only calculate intensity."}, + {TEX_COL1, "POSITION", 0, "Position", "Color cells by position."}, + {TEX_COL2, "POSITION_OUTLINE", 0, "Position and Outline", "Use position plus an outline based on F2-F.1"}, + {TEX_COL3, "POSITION_OUTLINE_INTENSITY", 0, "Position, Outline, and Intensity", "Multiply position and outline by intensity."}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "VoronoiTexture", "Texture"); RNA_def_struct_ui_text(srna, "Voronoi", "Procedural voronoi texture."); @@ -1112,21 +1112,21 @@ static void rna_def_texture(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem prop_type_items[] = { - {0, "NONE", "None", ""}, - {TEX_CLOUDS, "CLOUDS", "Clouds", ""}, - {TEX_WOOD, "WOOD", "Wood", ""}, - {TEX_MARBLE, "MARBLE", "Marble", ""}, - {TEX_MAGIC, "MAGIC", "Magic", ""}, - {TEX_BLEND, "BLEND", "Blend", ""}, - {TEX_STUCCI, "STUCCI", "Stucci", ""}, - {TEX_NOISE, "NOISE", "Noise", ""}, - {TEX_IMAGE, "IMAGE", "Image", ""}, - {TEX_PLUGIN, "PLUGIN", "Plugin", ""}, - {TEX_ENVMAP, "ENVIRONMENT_MAP", "Environment Map", ""}, - {TEX_MUSGRAVE, "MUSGRAVE", "Musgrave", ""}, - {TEX_VORONOI, "VORONOI", "Voronoi", ""}, - {TEX_DISTNOISE, "DISTORTED_NOISE", "Distorted Noise", ""}, - {0, NULL, NULL, NULL}}; + {0, "NONE", 0, "None", ""}, + {TEX_CLOUDS, "CLOUDS", 0, "Clouds", ""}, + {TEX_WOOD, "WOOD", 0, "Wood", ""}, + {TEX_MARBLE, "MARBLE", 0, "Marble", ""}, + {TEX_MAGIC, "MAGIC", 0, "Magic", ""}, + {TEX_BLEND, "BLEND", 0, "Blend", ""}, + {TEX_STUCCI, "STUCCI", 0, "Stucci", ""}, + {TEX_NOISE, "NOISE", 0, "Noise", ""}, + {TEX_IMAGE, "IMAGE", 0, "Image/Movie", ""}, + {TEX_PLUGIN, "PLUGIN", 0, "Plugin", ""}, + {TEX_ENVMAP, "ENVIRONMENT_MAP", 0, "Environment Map", ""}, + {TEX_MUSGRAVE, "MUSGRAVE", 0, "Musgrave", ""}, + {TEX_VORONOI, "VORONOI", 0, "Voronoi", ""}, + {TEX_DISTNOISE, "DISTORTED_NOISE", 0, "Distorted Noise", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "Texture", "ID"); RNA_def_struct_sdna(srna, "Tex"); diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index b6912c44fb7..825b3711b97 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -24,6 +24,8 @@ #include <stdlib.h> +#include "DNA_screen_types.h" + #include "RNA_define.h" #include "RNA_types.h" @@ -40,8 +42,6 @@ #include "RNA_access.h" -#include "DNA_screen_types.h" - #include "BLI_dynstr.h" #include "BKE_context.h" @@ -497,23 +497,23 @@ static void rna_def_ui_layout(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem alignment_items[] = { - {UI_LAYOUT_ALIGN_EXPAND, "EXPAND", "Expand", ""}, - {UI_LAYOUT_ALIGN_LEFT, "LEFT", "Left", ""}, - {UI_LAYOUT_ALIGN_CENTER, "CENTER", "Center", ""}, - {UI_LAYOUT_ALIGN_RIGHT, "RIGHT", "RIght", ""}, - {0, NULL, NULL, NULL}}; + {UI_LAYOUT_ALIGN_EXPAND, "EXPAND", 0, "Expand", ""}, + {UI_LAYOUT_ALIGN_LEFT, "LEFT", 0, "Left", ""}, + {UI_LAYOUT_ALIGN_CENTER, "CENTER", 0, "Center", ""}, + {UI_LAYOUT_ALIGN_RIGHT, "RIGHT", 0, "RIght", ""}, + {0, NULL, 0, NULL, NULL}}; /* see WM_types.h */ static EnumPropertyItem operator_context_items[] = { - {WM_OP_INVOKE_DEFAULT, "INVOKE_DEFAULT", "Invoke Default", ""}, - {WM_OP_INVOKE_REGION_WIN, "INVOKE_REGION_WIN", "Invoke Region Window", ""}, - {WM_OP_INVOKE_AREA, "INVOKE_AREA", "Invoke Area", ""}, - {WM_OP_INVOKE_SCREEN, "INVOKE_SCREEN", "Invoke Screen", ""}, - {WM_OP_EXEC_DEFAULT, "EXEC_DEFAULT", "Exec Default", ""}, - {WM_OP_EXEC_REGION_WIN, "EXEC_REGION_WIN", "Exec Region Window", ""}, - {WM_OP_EXEC_AREA, "EXEC_AREA", "Exec Area", ""}, - {WM_OP_EXEC_SCREEN, "EXEC_SCREEN", "Exec Screen", ""}, - {0, NULL, NULL, NULL}}; + {WM_OP_INVOKE_DEFAULT, "INVOKE_DEFAULT", 0, "Invoke Default", ""}, + {WM_OP_INVOKE_REGION_WIN, "INVOKE_REGION_WIN", 0, "Invoke Region Window", ""}, + {WM_OP_INVOKE_AREA, "INVOKE_AREA", 0, "Invoke Area", ""}, + {WM_OP_INVOKE_SCREEN, "INVOKE_SCREEN", 0, "Invoke Screen", ""}, + {WM_OP_EXEC_DEFAULT, "EXEC_DEFAULT", 0, "Exec Default", ""}, + {WM_OP_EXEC_REGION_WIN, "EXEC_REGION_WIN", 0, "Exec Region Window", ""}, + {WM_OP_EXEC_AREA, "EXEC_AREA", 0, "Exec Area", ""}, + {WM_OP_EXEC_SCREEN, "EXEC_SCREEN", 0, "Exec Screen", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "UILayout", NULL); RNA_def_struct_sdna(srna, "uiLayout"); @@ -603,6 +603,10 @@ static void rna_def_panel(BlenderRNA *brna) prop= RNA_def_property(srna, "context", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "type->context"); RNA_def_property_flag(prop, PROP_REGISTER); + + prop= RNA_def_property(srna, "default_closed", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "type->flag", PNL_DEFAULT_CLOSED); + RNA_def_property_flag(prop, PROP_REGISTER); } static void rna_def_header(BlenderRNA *brna) diff --git a/source/blender/editors/interface/interface_api.c b/source/blender/makesrna/intern/rna_ui_api.c index 60bfe4e79ad..d06d4d4406d 100644 --- a/source/blender/editors/interface/interface_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -33,11 +33,28 @@ #include "RNA_types.h" #include "UI_interface.h" +#include "UI_resources.h" + +#ifdef RNA_RUNTIME + +#else + +#define DEF_ICON(name) {name, #name, 0, #name, ""}, +static EnumPropertyItem icon_items[] = { +#include "UI_icons.h" + {0, NULL, 0, NULL, NULL}}; +#undef DEF_ICON static void api_ui_item_common(FunctionRNA *func) { + PropertyRNA *prop; + RNA_def_string(func, "text", "", 0, "", "Override automatic text of the item."); - RNA_def_int(func, "icon", 0, 0, INT_MAX, "", "Override automatic icon of the item.", 0, INT_MAX); + + prop= RNA_def_property(func, "icon", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, icon_items); + RNA_def_property_ui_text(prop, "Icon", "Override automatic icon of the item."); + } static void api_ui_item_op_common(FunctionRNA *func) @@ -49,16 +66,26 @@ static void api_ui_item_op_common(FunctionRNA *func) RNA_def_property_flag(parm, PROP_REQUIRED); } +static void api_ui_item_rna_common(FunctionRNA *func) +{ + PropertyRNA *parm; + + parm= RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property."); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR); + parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in data."); + RNA_def_property_flag(parm, PROP_REQUIRED); +} + void RNA_api_ui_layout(StructRNA *srna) { FunctionRNA *func; PropertyRNA *parm; static EnumPropertyItem curve_type_items[] = { - {0, "NONE", "None", ""}, - {'v', "VECTOR", "Vector", ""}, - {'c', "COLOR", "Color", ""}, - {0, NULL, NULL, NULL}}; + {0, "NONE", 0, "None", ""}, + {'v', "VECTOR", 0, "Vector", ""}, + {'c', "COLOR", 0, "Color", ""}, + {0, NULL, 0, NULL, NULL}}; /* simple layout specifiers */ func= RNA_def_function(srna, "row", "uiLayoutRow"); @@ -91,33 +118,21 @@ void RNA_api_ui_layout(StructRNA *srna) /* items */ func= RNA_def_function(srna, "itemR", "uiItemR"); api_ui_item_common(func); - parm= RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property."); - RNA_def_property_flag(parm, PROP_REQUIRED); - parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in data."); - RNA_def_property_flag(parm, PROP_REQUIRED); + api_ui_item_rna_common(func); RNA_def_boolean(func, "expand", 0, "", "Expand button to show more detail."); RNA_def_boolean(func, "slider", 0, "", "Use slider widget for numeric values."); RNA_def_boolean(func, "toggle", 0, "", "Use toggle widget for boolean values."); func= RNA_def_function(srna, "items_enumR", "uiItemsEnumR"); - parm= RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property."); - RNA_def_property_flag(parm, PROP_REQUIRED); - parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in data."); - RNA_def_property_flag(parm, PROP_REQUIRED); + api_ui_item_rna_common(func); func= RNA_def_function(srna, "item_menu_enumR", "uiItemMenuEnumR"); api_ui_item_common(func); - parm= RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property."); - RNA_def_property_flag(parm, PROP_REQUIRED); - parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in data."); - RNA_def_property_flag(parm, PROP_REQUIRED); + api_ui_item_rna_common(func); /*func= RNA_def_function(srna, "item_enumR", "uiItemEnumR"); api_ui_item_common(func); - parm= RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property."); - RNA_def_property_flag(parm, PROP_REQUIRED); - parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in data."); - RNA_def_property_flag(parm, PROP_REQUIRED); + api_ui_item_rna_common(func); parm= RNA_def_string(func, "value", "", 0, "", "Enum property value."); RNA_def_property_flag(parm, PROP_REQUIRED);*/ @@ -187,7 +202,7 @@ void RNA_api_ui_layout(StructRNA *srna) parm= RNA_def_string(func, "name", "", 0, "Name", "Name of entry in the context."); RNA_def_property_flag(parm, PROP_REQUIRED); parm= RNA_def_pointer(func, "data", "AnyType", "", "Pointer to put in context."); - RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR); /* templates */ func= RNA_def_function(srna, "template_header", "uiTemplateHeader"); @@ -197,23 +212,20 @@ void RNA_api_ui_layout(StructRNA *srna) func= RNA_def_function(srna, "template_ID", "uiTemplateID"); parm= RNA_def_pointer(func, "context", "Context", "", "Current context."); RNA_def_property_flag(parm, PROP_REQUIRED); - parm= RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property."); - RNA_def_property_flag(parm, PROP_REQUIRED); - parm= RNA_def_string(func, "property", "", 0, "", "Identifier of pointer property in data."); - RNA_def_property_flag(parm, PROP_REQUIRED); + api_ui_item_rna_common(func); RNA_def_string(func, "new", "", 0, "", "Operator identifier to create a new ID block."); RNA_def_string(func, "open", "", 0, "", "Operator identifier to open a new ID block."); RNA_def_string(func, "unlink", "", 0, "", "Operator identifier to unlink the ID block."); func= RNA_def_function(srna, "template_modifier", "uiTemplateModifier"); - parm= RNA_def_pointer(func, "data", "AnyType", "", "Modifier data."); - RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_pointer(func, "data", "Modifier", "", "Modifier data."); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR); parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in."); RNA_def_function_return(func, parm); func= RNA_def_function(srna, "template_constraint", "uiTemplateConstraint"); - parm= RNA_def_pointer(func, "data", "AnyType", "", "Constraint data."); - RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_pointer(func, "data", "Constraint", "", "Constraint data."); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR); parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in."); RNA_def_function_return(func, parm); @@ -230,5 +242,10 @@ void RNA_api_ui_layout(StructRNA *srna) parm= RNA_def_pointer(func, "ramp", "ColorRamp", "", "Color ramp pointer."); RNA_def_property_flag(parm, PROP_REQUIRED); RNA_def_boolean(func, "expand", 0, "", "Expand button to show more detail."); + + func= RNA_def_function(srna, "template_layers", "uiTemplateLayers"); + api_ui_item_rna_common(func); } +#endif + diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index e0d3201a5e7..65d83bec552 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -135,29 +135,39 @@ static void rna_def_userdef_theme_ui_font_style(BlenderRNA *brna) prop= RNA_def_property(srna, "points", PROP_INT, PROP_NONE); RNA_def_property_range(prop, 6, 48); RNA_def_property_ui_text(prop, "Points", ""); - + RNA_def_property_update(prop, NC_WINDOW, NULL); + + prop= RNA_def_property(srna, "kerning", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, -5.0, 5.0); + RNA_def_property_ui_text(prop, "Kerning", ""); + RNA_def_property_update(prop, NC_WINDOW, NULL); + prop= RNA_def_property(srna, "shadow", PROP_INT, PROP_NONE); RNA_def_property_range(prop, 0, 5); RNA_def_property_ui_text(prop, "Shadow Size", "Shadow size in pixels (0, 3 and 5 supported)"); + RNA_def_property_update(prop, NC_WINDOW, NULL); prop= RNA_def_property(srna, "shadx", PROP_INT, PROP_NONE); RNA_def_property_range(prop, -10, 10); RNA_def_property_ui_text(prop, "Shadow X Offset", "Shadow offset in pixels"); + RNA_def_property_update(prop, NC_WINDOW, NULL); prop= RNA_def_property(srna, "shady", PROP_INT, PROP_NONE); RNA_def_property_range(prop, -10, 10); RNA_def_property_ui_text(prop, "Shadow Y Offset", "Shadow offset in pixels"); + RNA_def_property_update(prop, NC_WINDOW, NULL); prop= RNA_def_property(srna, "shadowalpha", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Shadow Alpha", ""); + RNA_def_property_update(prop, NC_WINDOW, NULL); prop= RNA_def_property(srna, "shadowcolor", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Shadow Brightness", "Shadow color in grey value"); + RNA_def_property_update(prop, NC_WINDOW, NULL); } - static void rna_def_userdef_theme_ui_style(BlenderRNA *brna) { StructRNA *srna; @@ -173,21 +183,25 @@ static void rna_def_userdef_theme_ui_style(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "paneltitle"); RNA_def_property_struct_type(prop, "ThemeFontStyle"); RNA_def_property_ui_text(prop, "Panel Font", ""); + RNA_def_property_update(prop, NC_WINDOW, NULL); prop= RNA_def_property(srna, "grouplabel", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_pointer_sdna(prop, NULL, "grouplabel"); RNA_def_property_struct_type(prop, "ThemeFontStyle"); RNA_def_property_ui_text(prop, "Group Label Font", ""); + RNA_def_property_update(prop, NC_WINDOW, NULL); prop= RNA_def_property(srna, "widgetlabel", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_pointer_sdna(prop, NULL, "widgetlabel"); RNA_def_property_struct_type(prop, "ThemeFontStyle"); RNA_def_property_ui_text(prop, "Widget Label Font", ""); + RNA_def_property_update(prop, NC_WINDOW, NULL); prop= RNA_def_property(srna, "widget", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_pointer_sdna(prop, NULL, "widget"); RNA_def_property_struct_type(prop, "ThemeFontStyle"); RNA_def_property_ui_text(prop, "Widget Font", ""); + RNA_def_property_update(prop, NC_WINDOW, NULL); } @@ -203,38 +217,47 @@ static void rna_def_userdef_theme_ui_wcol(BlenderRNA *brna) prop= RNA_def_property(srna, "outline", PROP_FLOAT, PROP_COLOR); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Outline", ""); + RNA_def_property_update(prop, NC_WINDOW, NULL); prop= RNA_def_property(srna, "inner", PROP_FLOAT, PROP_COLOR); RNA_def_property_array(prop, 4); RNA_def_property_ui_text(prop, "Inner", ""); + RNA_def_property_update(prop, NC_WINDOW, NULL); prop= RNA_def_property(srna, "inner_sel", PROP_FLOAT, PROP_COLOR); RNA_def_property_array(prop, 4); RNA_def_property_ui_text(prop, "Inner Selected", ""); + RNA_def_property_update(prop, NC_WINDOW, NULL); prop= RNA_def_property(srna, "item", PROP_FLOAT, PROP_COLOR); RNA_def_property_array(prop, 4); RNA_def_property_ui_text(prop, "Item", ""); + RNA_def_property_update(prop, NC_WINDOW, NULL); prop= RNA_def_property(srna, "text", PROP_FLOAT, PROP_COLOR); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Text", ""); + RNA_def_property_update(prop, NC_WINDOW, NULL); prop= RNA_def_property(srna, "text_sel", PROP_FLOAT, PROP_COLOR); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Text Selected", ""); + RNA_def_property_update(prop, NC_WINDOW, NULL); prop= RNA_def_property(srna, "shaded", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "shaded", 1); RNA_def_property_ui_text(prop, "Shaded", ""); + RNA_def_property_update(prop, NC_WINDOW, NULL); prop= RNA_def_property(srna, "shadetop", PROP_INT, PROP_NONE); RNA_def_property_range(prop, -100, 100); RNA_def_property_ui_text(prop, "Shade Top", ""); + RNA_def_property_update(prop, NC_WINDOW, NULL); prop= RNA_def_property(srna, "shadedown", PROP_INT, PROP_NONE); RNA_def_property_range(prop, -100, 100); RNA_def_property_ui_text(prop, "Shade Down", ""); + RNA_def_property_update(prop, NC_WINDOW, NULL); } @@ -868,6 +891,26 @@ static void rna_def_userdef_theme_space_node(BlenderRNA *brna) RNA_def_property_update(prop, NC_WINDOW, NULL); } +static void rna_def_userdef_theme_space_logic(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + /* space_buts */ + + srna= RNA_def_struct(brna, "ThemeLogicEditor", NULL); + RNA_def_struct_sdna(srna, "ThemeSpace"); + RNA_def_struct_ui_text(srna, "Theme Logic Editor", "Theme settings for the Logic Editor."); + + rna_def_userdef_theme_spaces_main(srna, SPACE_LOGIC); + + prop= RNA_def_property(srna, "panel", PROP_FLOAT, PROP_COLOR); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Panel", ""); + RNA_def_property_update(prop, NC_WINDOW, NULL); +} + + static void rna_def_userdef_theme_space_buts(BlenderRNA *brna) { StructRNA *srna; @@ -1298,6 +1341,11 @@ static void rna_def_userdef_themes(BlenderRNA *brna) RNA_def_property_struct_type(prop, "ThemeNodeEditor"); RNA_def_property_ui_text(prop, "Node Editor", ""); + prop= RNA_def_property(srna, "logic_editor", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "tlogic"); + RNA_def_property_struct_type(prop, "ThemeLogicEditor"); + RNA_def_property_ui_text(prop, "Logic Editor", ""); + prop= RNA_def_property(srna, "outliner", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_pointer_sdna(prop, NULL, "toops"); RNA_def_property_struct_type(prop, "ThemeOutliner"); @@ -1334,6 +1382,7 @@ static void rna_def_userdef_dothemes(BlenderRNA *brna) rna_def_userdef_theme_space_outliner(brna); rna_def_userdef_theme_space_info(brna); rna_def_userdef_theme_space_sound(brna); + rna_def_userdef_theme_space_logic(brna); rna_def_userdef_theme_colorset(brna); rna_def_userdef_themes(brna); } @@ -1373,15 +1422,15 @@ static void rna_def_userdef_view(BlenderRNA *brna) StructRNA *srna; static EnumPropertyItem view_zoom_styles[] = { - {USER_ZOOM_CONT, "CONTINUE", "Continue", "Old style zoom, continues while moving mouse up or down."}, - {USER_ZOOM_DOLLY, "DOLLY", "Dolly", "Zooms in and out based on vertical mouse movement."}, - {USER_ZOOM_SCALE, "SCALE", "Scale", "Zooms in and out like scaling the view, mouse movements relative to center."}, - {0, NULL, NULL, NULL}}; + {USER_ZOOM_CONT, "CONTINUE", 0, "Continue", "Old style zoom, continues while moving mouse up or down."}, + {USER_ZOOM_DOLLY, "DOLLY", 0, "Dolly", "Zooms in and out based on vertical mouse movement."}, + {USER_ZOOM_SCALE, "SCALE", 0, "Scale", "Zooms in and out like scaling the view, mouse movements relative to center."}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem view_rotation_items[] = { - {0, "TURNTABLE", "Turntable", "Use turntable style rotation in the viewport."}, - {USER_TRACKBALL, "TRACKBALL", "Trackball", "Use trackball style rotation in the viewport."}, - {0, NULL, NULL, NULL}}; + {0, "TURNTABLE", 0, "Turntable", "Use turntable style rotation in the viewport."}, + {USER_TRACKBALL, "TRACKBALL", 0, "Trackball", "Use trackball style rotation in the viewport."}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "UserPreferencesView", NULL); @@ -1398,23 +1447,28 @@ static void rna_def_userdef_view(BlenderRNA *brna) prop= RNA_def_property(srna, "display_object_info", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_DRAWVIEWINFO); - RNA_def_property_ui_text(prop, "Display Object Info", "Display and objects name and frame number in 3d view."); + RNA_def_property_ui_text(prop, "Display Object Info", "Display objects name and frame number in 3d view."); + RNA_def_property_update(prop, NC_WINDOW, NULL); prop= RNA_def_property(srna, "global_scene", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_SCENEGLOBAL); RNA_def_property_ui_text(prop, "Global Scene", "Forces the current Scene to be displayed in all Screens."); + RNA_def_property_update(prop, NC_WINDOW, NULL); prop= RNA_def_property(srna, "use_large_cursors", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "curssize", 0); RNA_def_property_ui_text(prop, "Large Cursors", "Use large mouse cursors when available."); + RNA_def_property_update(prop, NC_WINDOW, NULL); prop= RNA_def_property(srna, "show_view_name", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_SHOW_VIEWPORTNAME); RNA_def_property_ui_text(prop, "Show View Name", "Show the name of the view's direction in each 3D View."); + RNA_def_property_update(prop, NC_WINDOW, NULL); prop= RNA_def_property(srna, "show_playback_fps", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_SHOW_FPS); RNA_def_property_ui_text(prop, "Show Playback FPS", "Show the frames per second screen refresh rate, while animation is played back."); + RNA_def_property_update(prop, NC_WINDOW, NULL); /* menus */ prop= RNA_def_property(srna, "open_mouse_over", PROP_BOOLEAN, PROP_NONE); @@ -1448,7 +1502,11 @@ static void rna_def_userdef_view(BlenderRNA *brna) prop= RNA_def_property(srna, "use_column_layout", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_PLAINMENUS); - RNA_def_property_ui_text(prop, "Toolbox Column Layout", "Use a column layout for toolbox and do not flip the contents of any menu."); + RNA_def_property_ui_text(prop, "Toolbox Column Layout", "Use a column layout for toolbox."); + + prop= RNA_def_property(srna, "directional_menus", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_DIRECTIONALORDER); + RNA_def_property_ui_text(prop, "Contents Follow Opening Direction", "Otherwise menus, etc will always be top to bottom, left to right, no matter opening direction."); /* snap to grid */ prop= RNA_def_property(srna, "snap_translate", PROP_BOOLEAN, PROP_NONE); @@ -1599,15 +1657,15 @@ static void rna_def_userdef_edit(BlenderRNA *brna) StructRNA *srna; static EnumPropertyItem auto_key_modes[] = { - {AUTOKEY_MODE_NORMAL, "ADD_REPLACE_KEYS", "Add/Replace Keys", ""}, - {AUTOKEY_MODE_EDITKEYS, "REPLACE_KEYS", "Replace Keys", ""}, - {0, NULL, NULL, NULL}}; + {AUTOKEY_MODE_NORMAL, "ADD_REPLACE_KEYS", 0, "Add/Replace Keys", ""}, + {AUTOKEY_MODE_EDITKEYS, "REPLACE_KEYS", 0, "Replace Keys", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem new_interpolation_types[] = { - {BEZT_IPO_CONST, "CONSTANT", "Constant", ""}, - {BEZT_IPO_LIN, "LINEAR", "Linear", ""}, - {BEZT_IPO_BEZ, "BEZIER", "Bezier", ""}, - {0, NULL, NULL, NULL}}; + {BEZT_IPO_CONST, "CONSTANT", 0, "Constant", ""}, + {BEZT_IPO_LIN, "LINEAR", 0, "Linear", ""}, + {BEZT_IPO_BEZ, "BEZIER", 0, "Bezier", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "UserPreferencesEdit", NULL); RNA_def_struct_sdna(srna, "UserDef"); @@ -1752,30 +1810,30 @@ static void rna_def_userdef_language(BlenderRNA *brna) /* hardcoded here, could become dynamic somehow */ static EnumPropertyItem language_items[] = { - {0, "ENGLISH", "English", ""}, - {1, "JAPANESE", "Japanese", ""}, - {2, "DUTCH", "Dutch", ""}, - {3, "ITALIAN", "Italian", ""}, - {4, "GERMAN", "German", ""}, - {5, "FINNISH", "Finnish", ""}, - {6, "SWEDISH", "Swedish", ""}, - {7, "FRENCH", "French", ""}, - {8, "SPANISH", "Spanish", ""}, - {9, "CATALAN", "Catalan", ""}, - {10, "CZECH", "Czech", ""}, - {11, "BRAZILIAN_PORTUGUESE", "Brazilian Portuguese", ""}, - {12, "SIMPLIFIED_CHINESE", "Simplified Chinese", ""}, - {13, "RUSSIAN", "Russian", ""}, - {14, "CROATIAN", "Croatian", ""}, - {15, "SERBIAN", "Serbian", ""}, - {16, "UKRAINIAN", "Ukrainian", ""}, - {17, "POLISH", "Polish", ""}, - {18, "ROMANIAN", "Romanian", ""}, - {19, "ARABIC", "Arabic", ""}, - {20, "BULGARIAN", "Bulgarian", ""}, - {21, "GREEK", "Greek", ""}, - {22, "KOREAN", "Korean", ""}, - {0, NULL, NULL, NULL}}; + {0, "ENGLISH", 0, "English", ""}, + {1, "JAPANESE", 0, "Japanese", ""}, + {2, "DUTCH", 0, "Dutch", ""}, + {3, "ITALIAN", 0, "Italian", ""}, + {4, "GERMAN", 0, "German", ""}, + {5, "FINNISH", 0, "Finnish", ""}, + {6, "SWEDISH", 0, "Swedish", ""}, + {7, "FRENCH", 0, "French", ""}, + {8, "SPANISH", 0, "Spanish", ""}, + {9, "CATALAN", 0, "Catalan", ""}, + {10, "CZECH", 0, "Czech", ""}, + {11, "BRAZILIAN_PORTUGUESE", 0, "Brazilian Portuguese", ""}, + {12, "SIMPLIFIED_CHINESE", 0, "Simplified Chinese", ""}, + {13, "RUSSIAN", 0, "Russian", ""}, + {14, "CROATIAN", 0, "Croatian", ""}, + {15, "SERBIAN", 0, "Serbian", ""}, + {16, "UKRAINIAN", 0, "Ukrainian", ""}, + {17, "POLISH", 0, "Polish", ""}, + {18, "ROMANIAN", 0, "Romanian", ""}, + {19, "ARABIC", 0, "Arabic", ""}, + {20, "BULGARIAN", 0, "Bulgarian", ""}, + {21, "GREEK", 0, "Greek", ""}, + {22, "KOREAN", 0, "Korean", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "UserPreferencesLanguage", NULL); RNA_def_struct_sdna(srna, "UserDef"); @@ -1785,33 +1843,40 @@ static void rna_def_userdef_language(BlenderRNA *brna) prop= RNA_def_property(srna, "international_fonts", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "transopts", USER_DOTRANSLATE); RNA_def_property_ui_text(prop, "International Fonts", "Use international fonts."); + RNA_def_property_update(prop, NC_WINDOW, NULL); prop= RNA_def_property(srna, "dpi", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "dpi"); RNA_def_property_range(prop, 48, 128); RNA_def_property_ui_text(prop, "DPI", "Font size and resolution for display."); + RNA_def_property_update(prop, NC_WINDOW, NULL); /* Language Selection */ prop= RNA_def_property(srna, "language", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, language_items); RNA_def_property_ui_text(prop, "Language", "Language use for translation."); + RNA_def_property_update(prop, NC_WINDOW, NULL); prop= RNA_def_property(srna, "translate_tooltips", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "transopts", USER_TR_TOOLTIPS); RNA_def_property_ui_text(prop, "Translate Tooltips", "Translate Tooltips."); + RNA_def_property_update(prop, NC_WINDOW, NULL); prop= RNA_def_property(srna, "translate_buttons", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "transopts", USER_TR_BUTTONS); RNA_def_property_ui_text(prop, "Translate Buttons", "Translate button labels."); + RNA_def_property_update(prop, NC_WINDOW, NULL); prop= RNA_def_property(srna, "translate_toolbox", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "transopts", USER_TR_MENUS); RNA_def_property_ui_text(prop, "Translate Toolbox", "Translate toolbox menu."); + RNA_def_property_update(prop, NC_WINDOW, NULL); prop= RNA_def_property(srna, "use_textured_fonts", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "transopts", USER_USETEXTUREFONT); RNA_def_property_ui_text(prop, "Textured Fonts", "Use textures for drawing international fonts."); + RNA_def_property_update(prop, NC_WINDOW, NULL); } static void rna_def_userdef_autosave(BlenderRNA *brna) @@ -1855,28 +1920,28 @@ static void rna_def_userdef_system(BlenderRNA *brna) StructRNA *srna; static EnumPropertyItem gl_texture_clamp_items[] = { - {0, "GL_CLAMP_OFF", "GL Texture Clamp Off", ""}, - {8192, "GL_CLAMP_8192", "GL Texture Clamp 8192", ""}, - {4096, "GL_CLAMP_4096", "GL Texture Clamp 4096", ""}, - {2048, "GL_CLAMP_2048", "GL Texture Clamp 2048", ""}, - {1024, "GL_CLAMP_1024", "GL Texture Clamp 1024", ""}, - {512, "GL_CLAMP_512", "GL Texture Clamp 512", ""}, - {256, "GL_CLAMP_256", "GL Texture Clamp 256", ""}, - {128, "GL_CLAMP_128", "GL Texture Clamp 128", ""}, - {0, NULL, NULL, NULL}}; + {0, "GL_CLAMP_OFF", 0, "GL Texture Clamp Off", ""}, + {8192, "GL_CLAMP_8192", 0, "GL Texture Clamp 8192", ""}, + {4096, "GL_CLAMP_4096", 0, "GL Texture Clamp 4096", ""}, + {2048, "GL_CLAMP_2048", 0, "GL Texture Clamp 2048", ""}, + {1024, "GL_CLAMP_1024", 0, "GL Texture Clamp 1024", ""}, + {512, "GL_CLAMP_512", 0, "GL Texture Clamp 512", ""}, + {256, "GL_CLAMP_256", 0, "GL Texture Clamp 256", ""}, + {128, "GL_CLAMP_128", 0, "GL Texture Clamp 128", ""}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem audio_mixing_samples_items[] = { - {256, "AUDIO_SAMPLES_256", "256", "Set audio mixing buffer size to 256 samples"}, - {512, "AUDIO_SAMPLES_512", "512", "Set audio mixing buffer size to 512 samples"}, - {1024, "AUDIO_SAMPLES_1024", "1024", "Set audio mixing buffer size to 1024 samples"}, - {2048, "AUDIO_SAMPLES_2048", "2048", "Set audio mixing buffer size to 2048 samples"}, - {0, NULL, NULL, NULL}}; + {256, "AUDIO_SAMPLES_256", 0, "256", "Set audio mixing buffer size to 256 samples"}, + {512, "AUDIO_SAMPLES_512", 0, "512", "Set audio mixing buffer size to 512 samples"}, + {1024, "AUDIO_SAMPLES_1024", 0, "1024", "Set audio mixing buffer size to 1024 samples"}, + {2048, "AUDIO_SAMPLES_2048", 0, "2048", "Set audio mixing buffer size to 2048 samples"}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem draw_method_items[] = { - {USER_DRAW_TRIPLE, "TRIPLE_BUFFER", "Triple Buffer", "Use a third buffer for minimal redraws at the cost of more memory."}, - {USER_DRAW_OVERLAP, "OVERLAP", "Overlap", "Redraw all overlapping regions, minimal memory usage but more redraws."}, - {USER_DRAW_FULL, "FULL", "Full", "Do a full redraw each time, slow, only use for reference or when all else fails."}, - {0, NULL, NULL, NULL}}; + {USER_DRAW_TRIPLE, "TRIPLE_BUFFER", 0, "Triple Buffer", "Use a third buffer for minimal redraws at the cost of more memory."}, + {USER_DRAW_OVERLAP, "OVERLAP", 0, "Overlap", "Redraw all overlapping regions, minimal memory usage but more redraws."}, + {USER_DRAW_FULL, "FULL", 0, "Full", "Do a full redraw each time, slow, only use for reference or when all else fails."}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "UserPreferencesSystem", NULL); RNA_def_struct_sdna(srna, "UserDef"); @@ -2001,10 +2066,6 @@ static void rna_def_userdef_filepaths(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_FILECOMPRESS); RNA_def_property_ui_text(prop, "Compress File", "Enable file compression when saving .blend files."); - prop= RNA_def_property(srna, "yafray_export_directory", PROP_STRING, PROP_DIRPATH); - RNA_def_property_string_sdna(prop, NULL, "yfexportdir"); - RNA_def_property_ui_text(prop, "Yafray Export Directory", "The default directory for yafray xml export (must exist!)."); - prop= RNA_def_property(srna, "fonts_directory", PROP_STRING, PROP_DIRPATH); RNA_def_property_string_sdna(prop, NULL, "fontdir"); RNA_def_property_ui_text(prop, "Fonts Directory", "The default directory to search for loading fonts."); @@ -2044,14 +2105,14 @@ void RNA_def_userdef(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem user_pref_sections[] = { - {0, "VIEW_CONTROLS", "View & Controls", ""}, - {1, "EDIT_METHODS", "Edit Methods", ""}, - {2, "LANGUAGE_COLORS", "Language & Colors", ""}, - {3, "AUTO_SAVE", "Auto Save", ""}, - {4, "SYSTEM_OPENGL", "System & OpenGL", ""}, - {5, "FILE_PATHS", "File Paths", ""}, - {6, "THEMES", "Themes", ""}, - {0, NULL, NULL, NULL}}; + {0, "VIEW_CONTROLS", 0, "View & Controls", ""}, + {1, "EDIT_METHODS", 0, "Edit Methods", ""}, + {2, "LANGUAGE_COLORS", 0, "Language & Colors", ""}, + {3, "AUTO_SAVE", 0, "Auto Save", ""}, + {4, "SYSTEM_OPENGL", 0, "System & OpenGL", ""}, + {5, "FILE_PATHS", 0, "File Paths", ""}, + {6, "THEMES", 0, "Themes", ""}, + {0, NULL, 0, NULL, NULL}}; rna_def_userdef_dothemes(brna); rna_def_userdef_solidlight(brna); @@ -2113,11 +2174,6 @@ void RNA_def_userdef(BlenderRNA *brna) rna_def_userdef_filepaths(brna); rna_def_userdef_system(brna); - - - - - } #endif diff --git a/source/blender/makesrna/intern/rna_vpaint.c b/source/blender/makesrna/intern/rna_vpaint.c index 44219f032e7..a34099dffb7 100644 --- a/source/blender/makesrna/intern/rna_vpaint.c +++ b/source/blender/makesrna/intern/rna_vpaint.c @@ -40,14 +40,14 @@ void RNA_def_vpaint(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; static EnumPropertyItem prop_mode_items[] = { - {0, "MIX", "Mix", "Use mix blending mode while painting."}, - {1, "ADD", "Add", "Use add blending mode while painting."}, - {2, "SUB", "Subtract", "Use subtract blending mode while painting."}, - {3, "MUL", "Multiply", "Use multiply blending mode while painting."}, - {4, "BLUR", "Blur", "Blur the color with surrounding values"}, - {5, "LIGHTEN", "Lighten", "Use lighten blending mode while painting."}, - {6, "DARKEN", "Darken", "Use darken blending mode while painting."}, - {0, NULL, NULL, NULL}}; + {0, "MIX", 0, "Mix", "Use mix blending mode while painting."}, + {1, "ADD", 0, "Add", "Use add blending mode while painting."}, + {2, "SUB", 0, "Subtract", "Use subtract blending mode while painting."}, + {3, "MUL", 0, "Multiply", "Use multiply blending mode while painting."}, + {4, "BLUR", 0, "Blur", "Blur the color with surrounding values"}, + {5, "LIGHTEN", 0, "Lighten", "Use lighten blending mode while painting."}, + {6, "DARKEN", 0, "Darken", "Use darken blending mode while painting."}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "VPaint", NULL); RNA_def_struct_ui_text(srna, "Vertex Paint", "Properties of the Vpaint tool."); diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 22ce207c6a9..df07e03850a 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -160,6 +160,8 @@ static void rna_def_windowmanager(BlenderRNA *brna) prop= RNA_def_property(srna, "operators", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "Operator"); RNA_def_property_ui_text(prop, "Operators", "Operator registry."); + + RNA_api_wm(srna); } void RNA_def_wm(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c new file mode 100644 index 00000000000..fd34d7c4d70 --- /dev/null +++ b/source/blender/makesrna/intern/rna_wm_api.c @@ -0,0 +1,56 @@ +/** + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2009 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include <stdlib.h> +#include <stdio.h> + +#include "RNA_define.h" +#include "RNA_types.h" + +#ifdef RNA_RUNTIME + +#include "BKE_context.h" + +#include "WM_api.h" + +#else + +void RNA_api_wm(StructRNA *srna) +{ + FunctionRNA *func; + PropertyRNA *prop; + + func= RNA_def_function(srna, "add_fileselect", "WM_event_add_fileselect"); + RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT); + RNA_def_function_ui_description(func, "Show up the file selector."); + prop= RNA_def_pointer(func, "operator", "Operator", "", "Operator to call."); + RNA_def_property_flag(prop, PROP_REQUIRED); +} + +#endif + diff --git a/source/blender/makesrna/intern/rna_world.c b/source/blender/makesrna/intern/rna_world.c index 46a7ef139d5..4dba61411f0 100644 --- a/source/blender/makesrna/intern/rna_world.c +++ b/source/blender/makesrna/intern/rna_world.c @@ -74,13 +74,13 @@ static void rna_def_world_mtex(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem texco_items[] = { - {TEXCO_VIEW, "VIEW", "View", "Uses view vector for the texture coordinates."}, - {TEXCO_GLOB, "GLOBAL", "Global", "Uses global coordinates for the texture coordinates (interior mist)."}, - {TEXCO_ANGMAP, "ANGMAP", "AngMap", "Uses 360 degree angular coordinates, e.g. for spherical light probes."}, - {TEXCO_H_SPHEREMAP, "SPHERE", "Sphere", "For 360 degree panorama sky, spherical mapped, only top half."}, - {TEXCO_H_TUBEMAP, "TUBE", "Tube", "For 360 degree panorama sky, cylindrical mapped, only top half."}, - {TEXCO_OBJECT, "OBJECT", "Object", "Uses linked object's coordinates for texture coordinates."}, - {0, NULL, NULL, NULL}}; + {TEXCO_VIEW, "VIEW", 0, "View", "Uses view vector for the texture coordinates."}, + {TEXCO_GLOB, "GLOBAL", 0, "Global", "Uses global coordinates for the texture coordinates (interior mist)."}, + {TEXCO_ANGMAP, "ANGMAP", 0, "AngMap", "Uses 360 degree angular coordinates, e.g. for spherical light probes."}, + {TEXCO_H_SPHEREMAP, "SPHERE", 0, "Sphere", "For 360 degree panorama sky, spherical mapped, only top half."}, + {TEXCO_H_TUBEMAP, "TUBE", 0, "Tube", "For 360 degree panorama sky, cylindrical mapped, only top half."}, + {TEXCO_OBJECT, "OBJECT", 0, "Object", "Uses linked object's coordinates for texture coordinates."}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "WorldTextureSlot", "TextureSlot"); RNA_def_struct_sdna(srna, "MTex"); @@ -89,19 +89,19 @@ static void rna_def_world_mtex(BlenderRNA *brna) /* map to */ prop= RNA_def_property(srna, "map_to_blend", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mapto", WOMAP_BLEND); - RNA_def_property_ui_text(prop, "Map To Blend", "Causes the texture to affect the color progression of the background."); + RNA_def_property_ui_text(prop, "Map To Blend", "Affect the color progression of the background."); prop= RNA_def_property(srna, "map_to_horizon", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mapto", WOMAP_HORIZ); - RNA_def_property_ui_text(prop, "Map To Horizon", "Causes the texture to affect the color of the horizon."); + RNA_def_property_ui_text(prop, "Map To Horizon", "Affect the color of the horizon."); prop= RNA_def_property(srna, "map_to_zenith_up", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mapto", WOMAP_ZENUP); - RNA_def_property_ui_text(prop, "Map To Zenith Up", "Causes the texture to affect the color of the zenith above."); + RNA_def_property_ui_text(prop, "Map To Zenith Up", "Affect the color of the zenith above."); prop= RNA_def_property(srna, "map_to_zenith_down", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mapto", WOMAP_ZENDOWN); - RNA_def_property_ui_text(prop, "Map To Zenith Down", "Causes the texture to affect the color of the zenith below."); + RNA_def_property_ui_text(prop, "Map To Zenith Down", "Affect the color of the zenith below."); /* unused prop= RNA_def_property(srna, "map_to_mist", PROP_BOOLEAN, PROP_NONE); @@ -111,7 +111,7 @@ static void rna_def_world_mtex(BlenderRNA *brna) prop= RNA_def_property(srna, "texture_coordinates", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "texco"); RNA_def_property_enum_items(prop, texco_items); - RNA_def_property_ui_text(prop, "Texture Coordinates", "Textures coordinates used to map the texture with."); + RNA_def_property_ui_text(prop, "Texture Coordinates", "Texture coordinates used to map the texture onto the background."); prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "object"); @@ -126,27 +126,27 @@ static void rna_def_ambient_occlusion(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem blend_mode_items[] = { - {WO_AOADD, "ADD", "Add", "Add light and shadow."}, - {WO_AOSUB, "SUBTRACT", "Subtract", "Subtract light and shadow (needs a normal light to make anything visible.)"}, - {WO_AOADDSUB, "BOTH", "Both", "Both lighten and darken."}, - {0, NULL, NULL, NULL}}; + {WO_AOADD, "ADD", 0, "Add", "Add light and shadow."}, + {WO_AOSUB, "SUBTRACT", 0, "Subtract", "Subtract light and shadow (needs a normal light to make anything visible.)"}, + {WO_AOADDSUB, "BOTH", 0, "Both", "Both lighten and darken."}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_color_items[] = { - {WO_AOPLAIN, "PLAIN", "White", "Plain diffuse energy (white.)"}, - {WO_AOSKYCOL, "SKY_COLOR", "Sky Color", "Use horizon and zenith color for diffuse energy."}, - {WO_AOSKYTEX, "SKY_TEXTURE", "Sky Texture", "Does full Sky texture render for diffuse energy."}, - {0, NULL, NULL, NULL}}; + {WO_AOPLAIN, "PLAIN", 0, "White", "Plain diffuse energy (white.)"}, + {WO_AOSKYCOL, "SKY_COLOR", 0, "Sky Color", "Use horizon and zenith color for diffuse energy."}, + {WO_AOSKYTEX, "SKY_TEXTURE", 0, "Sky Texture", "Does full Sky texture render for diffuse energy."}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_sample_method_items[] = { - {WO_AOSAMP_CONSTANT, "CONSTANT_JITTERED", "Constant Jittered", ""}, - {WO_AOSAMP_HALTON, "ADAPTIVE_QMC", "Adaptive QMC", "Fast in high-contrast areas."}, - {WO_AOSAMP_HAMMERSLEY, "CONSTANT_QMC", "Constant QMC", "Best quality."}, - {0, NULL, NULL, NULL}}; + {WO_AOSAMP_CONSTANT, "CONSTANT_JITTERED", 0, "Constant Jittered", ""}, + {WO_AOSAMP_HALTON, "ADAPTIVE_QMC", 0, "Adaptive QMC", "Fast in high-contrast areas."}, + {WO_AOSAMP_HAMMERSLEY, "CONSTANT_QMC", 0, "Constant QMC", "Best quality."}, + {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_gather_method_items[] = { - {WO_AOGATHER_RAYTRACE, "RAYTRACE", "Raytrace", "Accurate, but slow when noise-free results are required."}, - {WO_AOGATHER_APPROX, "APPROXIMATE", "Approximate", "Inaccurate, but faster and without noise."}, - {0, NULL, NULL, NULL}}; + {WO_AOGATHER_RAYTRACE, "RAYTRACE", 0, "Raytrace", "Accurate, but slow when noise-free results are required."}, + {WO_AOGATHER_APPROX, "APPROXIMATE", 0, "Approximate", "Inaccurate, but faster and without noise."}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "WorldAmbientOcclusion", NULL); RNA_def_struct_sdna(srna, "World"); @@ -155,7 +155,7 @@ static void rna_def_ambient_occlusion(BlenderRNA *brna) prop= RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", WO_AMB_OCC); - RNA_def_property_ui_text(prop, "Enabled", ""); + RNA_def_property_ui_text(prop, "Enabled", "Use Ambient Occlusion to add light based on distance between elements, creating the illusion of omnipresent light"); prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "aodist"); @@ -168,7 +168,7 @@ static void rna_def_ambient_occlusion(BlenderRNA *brna) prop= RNA_def_property(srna, "energy", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "aoenergy"); RNA_def_property_ui_range(prop, 0, 10, 0.1, 3); - RNA_def_property_ui_text(prop, "Energy", "Global energy scale for ambient occlusion."); + RNA_def_property_ui_text(prop, "Energy", "Amount of enerygy generated by ambient occlusion."); prop= RNA_def_property(srna, "bias", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "aobias"); @@ -207,17 +207,17 @@ static void rna_def_ambient_occlusion(BlenderRNA *brna) prop= RNA_def_property(srna, "samples", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "aosamp"); RNA_def_property_range(prop, 1, 32); - RNA_def_property_ui_text(prop, "Samples", ""); + RNA_def_property_ui_text(prop, "Samples", "Amount of ray samples. Higher values give smoother results and longer rendering times"); prop= RNA_def_property(srna, "blend_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "aomix"); RNA_def_property_enum_items(prop, blend_mode_items); - RNA_def_property_ui_text(prop, "Blend Mode", "Blending mode for how AO mixes with material shading."); + RNA_def_property_ui_text(prop, "Blend Mode", "Defines how AO mixes with material shading."); prop= RNA_def_property(srna, "color", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "aocolor"); RNA_def_property_enum_items(prop, prop_color_items); - RNA_def_property_ui_text(prop, "Color", ""); + RNA_def_property_ui_text(prop, "Color", "Defines the color of the AO light"); prop= RNA_def_property(srna, "sample_method", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "ao_samp_method"); @@ -241,10 +241,10 @@ static void rna_def_world_mist(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem falloff_items[] = { - {0, "QUADRATIC", "Quadratic", "Mist uses quadratic progression."}, - {1, "LINEAR", "Linear", "Mist uses linear progression."}, - {2, "INVERSE_QUADRATIC", "Inverse Quadratic", "Mist uses inverse quadratic progression."}, - {0, NULL, NULL, NULL}}; + {0, "QUADRATIC", 0, "Quadratic", "Mist uses quadratic progression."}, + {1, "LINEAR", 0, "Linear", "Mist uses linear progression."}, + {2, "INVERSE_QUADRATIC", 0, "Inverse Quadratic", "Mist uses inverse quadratic progression."}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "WorldMistSettings", NULL); RNA_def_struct_sdna(srna, "World"); @@ -253,34 +253,34 @@ static void rna_def_world_mist(BlenderRNA *brna) prop= RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", WO_MIST); - RNA_def_property_ui_text(prop, "Enabled", "Enable mist, occluding objects with the environment color as they are further away."); + RNA_def_property_ui_text(prop, "Enabled", "Occlude objects with the environment color as they are further away."); prop= RNA_def_property(srna, "intensity", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "misi"); RNA_def_property_range(prop, 0, 1); - RNA_def_property_ui_text(prop, "Intensity", "Intensity of the mist."); + RNA_def_property_ui_text(prop, "Intensity", "Intensity of the mist effect."); prop= RNA_def_property(srna, "start", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "miststa"); RNA_def_property_range(prop, 0, FLT_MAX); RNA_def_property_ui_range(prop, 0, 10000, 10, 2); - RNA_def_property_ui_text(prop, "Start", "Starting distance of the mist."); + RNA_def_property_ui_text(prop, "Start", "Starting distance of the mist, measured from the camera"); prop= RNA_def_property(srna, "depth", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "mistdist"); RNA_def_property_range(prop, 0, FLT_MAX); RNA_def_property_ui_range(prop, 0, 10000, 10, 2); - RNA_def_property_ui_text(prop, "Depth", "Depth of the mist."); + RNA_def_property_ui_text(prop, "Depth", "The distance over which the mist effect fades in"); prop= RNA_def_property(srna, "height", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "misthi"); RNA_def_property_range(prop, 0, 100); - RNA_def_property_ui_text(prop, "Height", "Factor for a less dense mist with increasing height."); + RNA_def_property_ui_text(prop, "Height", "Control how much mist density decreases with height"); prop= RNA_def_property(srna, "falloff", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "mistype"); RNA_def_property_enum_items(prop, falloff_items); - RNA_def_property_ui_text(prop, "Falloff", "Falloff method for mist."); + RNA_def_property_ui_text(prop, "Falloff", "Type of transition used to fade mist"); } static void rna_def_world_stars(BlenderRNA *brna) @@ -319,7 +319,7 @@ static void rna_def_world_stars(BlenderRNA *brna) prop= RNA_def_property(srna, "color_randomization", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "starcolnoise"); RNA_def_property_range(prop, 0, 1); - RNA_def_property_ui_text(prop, "Color Randomization", "Randomizes star color."); + RNA_def_property_ui_text(prop, "Color Randomization", "Randomize star colors."); RNA_def_property_update(prop, NC_WORLD, NULL); /* unused @@ -335,13 +335,13 @@ void RNA_def_world(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem physics_engine_items[] = { - {WOPHY_NONE, "NONE", "None", ""}, - //{WOPHY_ENJI, "ENJI", "Enji", ""}, - {WOPHY_SUMO, "SUMO", "Sumo (Deprecated)", ""}, - //{WOPHY_DYNAMO, "DYNAMO", "Dynamo", ""}, - //{WOPHY_ODE, "ODE", "ODE", ""}, - {WOPHY_BULLET, "BULLET", "Bullet", ""}, - {0, NULL, NULL, NULL}}; + {WOPHY_NONE, "NONE", 0, "None", ""}, + //{WOPHY_ENJI, "ENJI", 0, "Enji", ""}, + {WOPHY_SUMO, "SUMO", 0, "Sumo (Deprecated)", ""}, + //{WOPHY_DYNAMO, "DYNAMO", 0, "Dynamo", ""}, + //{WOPHY_ODE, "ODE", 0, "ODE", ""}, + {WOPHY_BULLET, "BULLET", 0, "Bullet", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "World", "ID"); RNA_def_struct_ui_text(srna, "World", "World datablock describing the environment and ambient lighting of a scene."); @@ -377,22 +377,22 @@ void RNA_def_world(BlenderRNA *brna) prop= RNA_def_property(srna, "range", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "range"); RNA_def_property_range(prop, 0.2, 5.0); - RNA_def_property_ui_text(prop, "Range", "The color amount that will be mapped on color 1.0."); + RNA_def_property_ui_text(prop, "Range", "The color rage that will be mapped to 0-1"); /* sky type */ prop= RNA_def_property(srna, "blend_sky", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "skytype", WO_SKYBLEND); - RNA_def_property_ui_text(prop, "Blend Sky", "Renders background with natural progression from horizon to zenith."); + RNA_def_property_ui_text(prop, "Blend Sky", "Render background with natural progression from horizon to zenith."); RNA_def_property_update(prop, NC_WORLD, NULL); prop= RNA_def_property(srna, "paper_sky", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "skytype", WO_SKYPAPER); - RNA_def_property_ui_text(prop, "Paper Sky", "Flattens blend or texture coordinates."); + RNA_def_property_ui_text(prop, "Paper Sky", "Flatten blend or texture coordinates."); RNA_def_property_update(prop, NC_WORLD, NULL); prop= RNA_def_property(srna, "real_sky", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "skytype", WO_SKYREAL); - RNA_def_property_ui_text(prop, "Real Sky", "Renders background with a real horizon."); + RNA_def_property_ui_text(prop, "Real Sky", "Render background with a real horizon, relative to the camera angle."); RNA_def_property_update(prop, NC_WORLD, NULL); /* physics */ diff --git a/source/blender/nodes/TEX_node.h b/source/blender/nodes/TEX_node.h index d298f062143..f58d0312961 100644 --- a/source/blender/nodes/TEX_node.h +++ b/source/blender/nodes/TEX_node.h @@ -59,6 +59,7 @@ extern bNodeType tex_node_distance; extern bNodeType tex_node_rotate; extern bNodeType tex_node_translate; extern bNodeType tex_node_scale; +extern bNodeType tex_node_at; extern bNodeType tex_node_compose; extern bNodeType tex_node_decompose; diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_at.c b/source/blender/nodes/intern/TEX_nodes/TEX_at.c new file mode 100644 index 00000000000..80f232ccd0c --- /dev/null +++ b/source/blender/nodes/intern/TEX_nodes/TEX_at.c @@ -0,0 +1,70 @@ +/** + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2005 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): R Allen + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "../TEX_util.h" + +static bNodeSocketType inputs[]= { + { SOCK_RGBA, 1, "Texture", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f }, + { SOCK_VECTOR, 1, "Coordinates", 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f }, + { -1, 0, "" } +}; +static bNodeSocketType outputs[]= { + { SOCK_RGBA, 0, "Texture", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f }, + { -1, 0, "" } +}; + +static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread) +{ + float new_coord[3]; + + tex_input_vec(new_coord, in[1], coord, thread); + tex_input_rgba(out, in[0], new_coord, thread); +} + +static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) +{ + tex_output(node, in, out[0], &colorfn); +} + +bNodeType tex_node_at = { + /* *next,*prev */ NULL, NULL, + /* type code */ TEX_NODE_AT, + /* name */ "At", + /* width+range */ 100, 60, 150, + /* class+opts */ NODE_CLASS_DISTORT, 0, + /* input sock */ inputs, + /* output sock */ outputs, + /* storage */ "", + /* execfunc */ exec, + /* butfunc */ NULL, + /* initfunc */ NULL, + /* freestoragefunc */ NULL, + /* copystoragefunc */ NULL, + /* id */ NULL + +}; diff --git a/source/blender/python/BPY_extern.h b/source/blender/python/BPY_extern.h index ff3e89a6e25..855fdde50c5 100644 --- a/source/blender/python/BPY_extern.h +++ b/source/blender/python/BPY_extern.h @@ -97,7 +97,7 @@ extern "C" { int BPY_menu_invoke( struct BPyMenu *pym, short menutype ); /* 2.5 UI Scripts */ - int BPY_run_python_script( struct bContext *C, const char *filename, struct Text *text ); // 2.5 working + int BPY_run_python_script( struct bContext *C, const char *filename, struct Text *text, struct ReportList *reports ); // 2.5 working int BPY_run_script_space_draw(struct bContext *C, struct SpaceScript * sc); // 2.5 working void BPY_run_ui_scripts(struct bContext *C, int reload); // int BPY_run_script_space_listener(struct bContext *C, struct SpaceScript * sc, struct ARegion *ar, struct wmNotifier *wmn); // 2.5 working diff --git a/source/blender/python/CMakeLists.txt b/source/blender/python/CMakeLists.txt index d15970e1df4..7700e6bc2aa 100644 --- a/source/blender/python/CMakeLists.txt +++ b/source/blender/python/CMakeLists.txt @@ -24,10 +24,12 @@ # ***** END GPL LICENSE BLOCK ***** FILE(GLOB SRC intern/*.c) +FILE(GLOB GENSRC generic/*.c) SET(INC . ../../../intern/guardedalloc ../blenlib ../makesdna ../makesrna ../blenkernel ../editors/include ../windowmanager ${PYTHON_INC} + ../../../extern/glew/include ) IF(WITH_OPENEXR) @@ -47,3 +49,5 @@ ENDIF(WITH_FFMPEG) ADD_DEFINITIONS(-DWITH_CCGSUBSURF) BLENDERLIB(bf_python "${SRC}" "${INC}") +BLENDERLIB(bf_gen_python "${GENSRC}" "${INC}") + diff --git a/source/blender/python/Makefile b/source/blender/python/Makefile index c830fbb3ccf..0c4b9ab6578 100644 --- a/source/blender/python/Makefile +++ b/source/blender/python/Makefile @@ -29,6 +29,6 @@ # Bounces make to subdirectories. SOURCEDIR = source/blender/python -DIRS = intern +DIRS = intern generic include nan_subdirs.mk diff --git a/source/blender/python/SConscript b/source/blender/python/SConscript index 9d7fcf6a9cf..73dc171fc3e 100644 --- a/source/blender/python/SConscript +++ b/source/blender/python/SConscript @@ -5,7 +5,7 @@ sources = env.Glob('intern/*.c') incs = '. ../editors/include ../makesdna ../makesrna ../blenlib ../blenkernel ../nodes' incs += ' ../imbuf ../blenloader ../render/extern/include ../windowmanager' -incs += ' #intern/guardedalloc #intern/memutil' +incs += ' #intern/guardedalloc #intern/memutil #extern/glew/include' incs += ' ' + env['BF_PYTHON_INC'] defs = [] @@ -15,3 +15,7 @@ if env['OURPLATFORM'] in ('win32-mingw', 'win32-vc') and env['BF_DEBUG']: env.BlenderLib( libname = 'bf_python', sources = Split(sources), includes = Split(incs), defines = defs, libtype = ['core'], priority = [140]) + +# generic +sources = env.Glob('generic/*.c') +env.BlenderLib( libname = 'bf_gen_python', sources = Split(sources), includes = Split(incs), defines = defs, libtype = ['core'], priority = [361]) # ketsji is 360 diff --git a/source/blender/python/generic/BGL.c b/source/blender/python/generic/BGL.c new file mode 100644 index 00000000000..f1a72270ea1 --- /dev/null +++ b/source/blender/python/generic/BGL.c @@ -0,0 +1,1605 @@ +/* + * $Id: BGL.c 20922 2009-06-16 07:16:51Z campbellbarton $ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * This is a new part of Blender. + * + * Contributor(s): Willian P. Germano + * + * ***** END GPL LICENSE BLOCK ***** +*/ + +/* This file is the Blender.BGL part of opy_draw.c, from the old + * bpython/intern dir, with minor changes to adapt it to the new Python + * implementation. The BGL submodule "wraps" OpenGL functions and constants, + * allowing script writers to make OpenGL calls in their Python scripts. */ + +#include "BGL.h" /*This must come first */ + +#include "MEM_guardedalloc.h" + +static int type_size( int type ); +static Buffer *make_buffer( int type, int ndimensions, int *dimensions ); + +static char Method_Buffer_doc[] = + "(type, dimensions, [template]) - Create a new Buffer object\n\n\ +(type) - The format to store data in\n\ +(dimensions) - An int or sequence specifying the dimensions of the buffer\n\ +[template] - A sequence of matching dimensions to the buffer to be created\n\ + which will be used to initialize the Buffer.\n\n\ +If a template is not passed in all fields will be initialized to 0.\n\n\ +The type should be one of GL_BYTE, GL_SHORT, GL_INT, GL_FLOAT, or GL_DOUBLE.\n\ +If the dimensions are specified as an int a linear buffer will be\n\ +created. If a sequence is passed for the dimensions the buffer\n\ +will have len(sequence) dimensions, where the size for each dimension\n\ +is determined by the value in the sequence at that index.\n\n\ +For example, passing [100, 100] will create a 2 dimensional\n\ +square buffer. Passing [16, 16, 32] will create a 3 dimensional\n\ +buffer which is twice as deep as it is wide or high."; + +static PyObject *Method_Buffer( PyObject * self, PyObject * args ); + +/* Buffer sequence methods */ + +static int Buffer_len( PyObject * self ); +static PyObject *Buffer_item( PyObject * self, int i ); +static PyObject *Buffer_slice( PyObject * self, int begin, int end ); +static int Buffer_ass_item( PyObject * self, int i, PyObject * v ); +static int Buffer_ass_slice( PyObject * self, int begin, int end, + PyObject * seq ); + +static PySequenceMethods Buffer_SeqMethods = { + ( inquiry ) Buffer_len, /*sq_length */ + ( binaryfunc ) 0, /*sq_concat */ + ( ssizeargfunc ) 0, /*sq_repeat */ + ( ssizeargfunc ) Buffer_item, /*sq_item */ + ( ssizessizeargfunc ) Buffer_slice, /*sq_slice */ + ( ssizeobjargproc ) Buffer_ass_item, /*sq_ass_item */ + ( ssizessizeobjargproc ) Buffer_ass_slice, /*sq_ass_slice */ +}; + +static void Buffer_dealloc( PyObject * self ); +static PyObject *Buffer_tolist( PyObject * self ); +static PyObject *Buffer_dimensions( PyObject * self ); +static PyObject *Buffer_getattr( PyObject * self, char *name ); +static PyObject *Buffer_repr( PyObject * self ); + +PyTypeObject buffer_Type = { + PyObject_HEAD_INIT( NULL ) /* required python macro */ + 0, /*ob_size */ + "buffer", /*tp_name */ + sizeof( Buffer ), /*tp_basicsize */ + 0, /*tp_itemsize */ + ( destructor ) Buffer_dealloc, /*tp_dealloc */ + ( printfunc ) 0, /*tp_print */ + ( getattrfunc ) Buffer_getattr, /*tp_getattr */ + ( setattrfunc ) 0, /*tp_setattr */ + 0, /*tp_compare */ + ( reprfunc ) Buffer_repr, /*tp_repr */ + 0, /*tp_as_number */ + &Buffer_SeqMethods, /*tp_as_sequence */ +}; + +/* #ifndef __APPLE__ */ + +#define BGL_Wrap(nargs, funcname, ret, arg_list) \ +static PyObject *Method_##funcname (PyObject *self, PyObject *args) {\ + arg_def##nargs arg_list; \ + ret_def_##ret; \ + if(!PyArg_ParseTuple(args, arg_str##nargs arg_list, arg_ref##nargs arg_list)) return NULL;\ + ret_set_##ret gl##funcname (arg_var##nargs arg_list);\ + ret_ret_##ret; \ +} + +#define BGLU_Wrap(nargs, funcname, ret, arg_list) \ +static PyObject *Method_##funcname (PyObject *self, PyObject *args) {\ + arg_def##nargs arg_list; \ + ret_def_##ret; \ + if(!PyArg_ParseTuple(args, arg_str##nargs arg_list, arg_ref##nargs arg_list)) return NULL;\ + ret_set_##ret glu##funcname (arg_var##nargs arg_list);\ + ret_ret_##ret; \ +} + +/* #endif */ + +/********/ +static int type_size(int type) +{ + switch (type) { + case GL_BYTE: + return sizeof(char); + case GL_SHORT: + return sizeof(short); + case GL_INT: + return sizeof(int); + case GL_FLOAT: + return sizeof(float); + case GL_DOUBLE: + return sizeof(double); + } + return -1; +} + +static Buffer *make_buffer(int type, int ndimensions, int *dimensions) +{ + Buffer *buffer; + void *buf= NULL; + int i, size, length; + + length= 1; + for (i=0; i<ndimensions; i++) + length*= dimensions[i]; + + size= type_size(type); + + buf= MEM_mallocN(length*size, "Buffer buffer"); + + buffer= (Buffer *) PyObject_NEW(Buffer, &buffer_Type); + buffer->parent= NULL; + buffer->ndimensions= ndimensions; + buffer->dimensions= dimensions; + buffer->type= type; + buffer->buf.asvoid= buf; + + for (i= 0; i<length; i++) { + if (type==GL_BYTE) + buffer->buf.asbyte[i]= 0; + else if (type==GL_SHORT) + buffer->buf.asshort[i]= 0; + else if (type==GL_INT) + buffer->buf.asint[i]= 0; + else if (type==GL_FLOAT) + buffer->buf.asfloat[i]= 0.0f; + else if (type==GL_DOUBLE) + buffer->buf.asdouble[i]= 0.0; + } + return buffer; +} + +static PyObject *Method_Buffer (PyObject *self, PyObject *args) +{ + PyObject *length_ob= NULL, *template= NULL; + Buffer *buffer; + + int i, type; + int *dimensions = 0, ndimensions = 0; + + if (!PyArg_ParseTuple(args, "iO|O", &type, &length_ob, &template)) { + PyErr_SetString(PyExc_AttributeError, "expected an int and one or two PyObjects"); + return NULL; + } + if (type!=GL_BYTE && type!=GL_SHORT && type!=GL_INT && type!=GL_FLOAT && type!=GL_DOUBLE) { + PyErr_SetString(PyExc_AttributeError, "invalid first argument type, should be one of GL_BYTE, GL_SHORT, GL_INT, GL_FLOAT or GL_DOUBLE"); + return NULL; + } + + if (PyNumber_Check(length_ob)) { + ndimensions= 1; + dimensions= MEM_mallocN(ndimensions*sizeof(int), "Buffer dimensions"); + dimensions[0]= PyLong_AsLong(length_ob); + } else if (PySequence_Check(length_ob)) { + ndimensions= PySequence_Length(length_ob); + dimensions= MEM_mallocN(ndimensions*sizeof(int), "Buffer dimensions"); + for (i=0; i<ndimensions; i++) { + PyObject *ob= PySequence_GetItem(length_ob, i); + + if (!PyNumber_Check(ob)) dimensions[i]= 1; + else dimensions[i]= PyLong_AsLong(ob); + Py_DECREF(ob); + } + } + + buffer= make_buffer(type, ndimensions, dimensions); + if (template && ndimensions) { + if (Buffer_ass_slice((PyObject *) buffer, 0, dimensions[0], template)) { + Py_DECREF(buffer); + return NULL; + } + } + + return (PyObject *) buffer; +} + +/*@ Buffer sequence methods */ + +static int Buffer_len(PyObject *self) +{ + Buffer *buf= (Buffer *) self; + return buf->dimensions[0]; +} + +static PyObject *Buffer_item(PyObject *self, int i) +{ + Buffer *buf= (Buffer *) self; + + if (i >= buf->dimensions[0]) { + PyErr_SetString(PyExc_IndexError, "array index out of range"); + return NULL; + } + + if (buf->ndimensions==1) { + switch (buf->type) { + case GL_BYTE: return Py_BuildValue("b", buf->buf.asbyte[i]); + case GL_SHORT: return Py_BuildValue("h", buf->buf.asshort[i]); + case GL_INT: return Py_BuildValue("i", buf->buf.asint[i]); + case GL_FLOAT: return PyFloat_FromDouble(buf->buf.asfloat[i]); + case GL_DOUBLE: return Py_BuildValue("d", buf->buf.asdouble[i]); + } + } else { + Buffer *newbuf; + int j, length, size; + + length= 1; + for (j=1; j<buf->ndimensions; j++) { + length*= buf->dimensions[j]; + } + size= type_size(buf->type); + + newbuf= (Buffer *) PyObject_NEW(Buffer, &buffer_Type); + + Py_INCREF(self); + newbuf->parent= self; + + newbuf->ndimensions= buf->ndimensions-1; + newbuf->type= buf->type; + newbuf->buf.asvoid= buf->buf.asbyte + i*length*size; + newbuf->dimensions= MEM_mallocN(newbuf->ndimensions*sizeof(int), + "Buffer dimensions"); + memcpy(newbuf->dimensions, buf->dimensions+1, + newbuf->ndimensions*sizeof(int)); + + return (PyObject *) newbuf; + } + + return NULL; +} + +static PyObject *Buffer_slice(PyObject *self, int begin, int end) +{ + Buffer *buf= (Buffer *) self; + PyObject *list; + int count; + + if (begin<0) begin= 0; + if (end>buf->dimensions[0]) + end= buf->dimensions[0]; + if (begin>end) begin= end; + + list= PyList_New(end-begin); + + for (count= begin; count<end; count++) + PyList_SetItem(list, count-begin, Buffer_item(self, count)); + + return list; +} + +static int Buffer_ass_item(PyObject *self, int i, PyObject *v) +{ + Buffer *buf= (Buffer *) self; + + if (i >= buf->dimensions[0]) { + PyErr_SetString(PyExc_IndexError, "array assignment index out of range"); + return -1; + } + + if (buf->ndimensions!=1) { + PyObject *row= Buffer_item(self, i); + int ret; + + if (!row) return -1; + ret= Buffer_ass_slice(row, 0, buf->dimensions[1], v); + Py_DECREF(row); + return ret; + } + + if (buf->type==GL_BYTE) { + if (!PyArg_Parse(v, "b;Coordinates must be ints", &buf->buf.asbyte[i])) + return -1; + } else if (buf->type==GL_SHORT) { + if (!PyArg_Parse(v, "h;Coordinates must be ints", &buf->buf.asshort[i])) + return -1; + + } else if (buf->type==GL_INT) { + if (!PyArg_Parse(v, "i;Coordinates must be ints", &buf->buf.asint[i])) + return -1; + } else if (buf->type==GL_FLOAT) { + if (!PyArg_Parse(v, "f;Coordinates must be floats", &buf->buf.asfloat[i])) + return -1; + } else if (buf->type==GL_DOUBLE) { + if (!PyArg_Parse(v, "d;Coordinates must be floats", &buf->buf.asdouble[i])) + return -1; + } + return 0; +} + +static int Buffer_ass_slice(PyObject *self, int begin, int end, PyObject *seq) +{ + Buffer *buf= (Buffer *) self; + PyObject *item; + int count, err=0; + + if (begin<0) begin= 0; + if (end>buf->dimensions[0]) end= buf->dimensions[0]; + if (begin>end) begin= end; + + if (!PySequence_Check(seq)) { + PyErr_SetString(PyExc_TypeError, + "illegal argument type for built-in operation"); + return -1; + } + + if (PySequence_Length(seq)!=(end-begin)) { + PyErr_SetString(PyExc_TypeError, "size mismatch in assignment"); + return -1; + } + + for (count= begin; count<end; count++) { + item= PySequence_GetItem(seq, count-begin); + err= Buffer_ass_item(self, count, item); + Py_DECREF(item); + if (err) break; + } + return err; +} + +static void Buffer_dealloc(PyObject *self) +{ + Buffer *buf = (Buffer *)self; + + if (buf->parent) Py_DECREF (buf->parent); + else MEM_freeN (buf->buf.asvoid); + + MEM_freeN (buf->dimensions); + + PyObject_DEL (self); +} + +static PyObject *Buffer_tolist(PyObject *self) +{ + int i, len= ((Buffer *)self)->dimensions[0]; + PyObject *list= PyList_New(len); + + for (i=0; i<len; i++) { + PyList_SetItem(list, i, Buffer_item(self, i)); + } + + return list; +} + +static PyObject *Buffer_dimensions(PyObject *self) +{ + Buffer *buffer= (Buffer *) self; + PyObject *list= PyList_New(buffer->ndimensions); + int i; + + for (i= 0; i<buffer->ndimensions; i++) { + PyList_SetItem(list, i, PyLong_FromLong(buffer->dimensions[i])); + } + + return list; +} + +static PyObject *Buffer_getattr(PyObject *self, char *name) +{ + if (strcmp(name, "list")==0) return Buffer_tolist(self); + else if (strcmp(name, "dimensions")==0) return Buffer_dimensions(self); + + PyErr_SetString(PyExc_AttributeError, name); + return NULL; +} + +static PyObject *Buffer_repr(PyObject *self) +{ + PyObject *list= Buffer_tolist(self); + PyObject *repr= PyObject_Repr(list); + Py_DECREF(list); + + return repr; +} + + +BGL_Wrap(2, Accum, void, (GLenum, GLfloat)) +BGL_Wrap(2, AlphaFunc, void, (GLenum, GLclampf)) +BGL_Wrap(3, AreTexturesResident, GLboolean, (GLsizei, GLuintP, GLbooleanP)) +BGL_Wrap(1, Begin, void, (GLenum)) +BGL_Wrap(2, BindTexture, void, (GLenum, GLuint)) +BGL_Wrap(7, Bitmap, void, (GLsizei, GLsizei, GLfloat, + GLfloat, GLfloat, GLfloat, GLubyteP)) +BGL_Wrap(2, BlendFunc, void, (GLenum, GLenum)) +BGL_Wrap(1, CallList, void, (GLuint)) +BGL_Wrap(3, CallLists, void, (GLsizei, GLenum, GLvoidP)) +BGL_Wrap(1, Clear, void, (GLbitfield)) +BGL_Wrap(4, ClearAccum, void, (GLfloat, GLfloat, GLfloat, GLfloat)) +BGL_Wrap(4, ClearColor, void, (GLclampf, GLclampf, GLclampf, GLclampf)) +BGL_Wrap(1, ClearDepth, void, (GLclampd)) +BGL_Wrap(1, ClearIndex, void, (GLfloat)) +BGL_Wrap(1, ClearStencil, void, (GLint)) +BGL_Wrap(2, ClipPlane, void, (GLenum, GLdoubleP)) +BGL_Wrap(3, Color3b, void, (GLbyte, GLbyte, GLbyte)) +BGL_Wrap(1, Color3bv, void, (GLbyteP)) +BGL_Wrap(3, Color3d, void, (GLdouble, GLdouble, GLdouble)) +BGL_Wrap(1, Color3dv, void, (GLdoubleP)) +BGL_Wrap(3, Color3f, void, (GLfloat, GLfloat, GLfloat)) +BGL_Wrap(1, Color3fv, void, (GLfloatP)) +BGL_Wrap(3, Color3i, void, (GLint, GLint, GLint)) +BGL_Wrap(1, Color3iv, void, (GLintP)) +BGL_Wrap(3, Color3s, void, (GLshort, GLshort, GLshort)) +BGL_Wrap(1, Color3sv, void, (GLshortP)) +BGL_Wrap(3, Color3ub, void, (GLubyte, GLubyte, GLubyte)) +BGL_Wrap(1, Color3ubv, void, (GLubyteP)) +BGL_Wrap(3, Color3ui, void, (GLuint, GLuint, GLuint)) +BGL_Wrap(1, Color3uiv, void, (GLuintP)) +BGL_Wrap(3, Color3us, void, (GLushort, GLushort, GLushort)) +BGL_Wrap(1, Color3usv, void, (GLushortP)) +BGL_Wrap(4, Color4b, void, (GLbyte, GLbyte, GLbyte, GLbyte)) +BGL_Wrap(1, Color4bv, void, (GLbyteP)) +BGL_Wrap(4, Color4d, void, (GLdouble, GLdouble, GLdouble, GLdouble)) +BGL_Wrap(1, Color4dv, void, (GLdoubleP)) +BGL_Wrap(4, Color4f, void, (GLfloat, GLfloat, GLfloat, GLfloat)) +BGL_Wrap(1, Color4fv, void, (GLfloatP)) +BGL_Wrap(4, Color4i, void, (GLint, GLint, GLint, GLint)) +BGL_Wrap(1, Color4iv, void, (GLintP)) +BGL_Wrap(4, Color4s, void, (GLshort, GLshort, GLshort, GLshort)) +BGL_Wrap(1, Color4sv, void, (GLshortP)) +BGL_Wrap(4, Color4ub, void, (GLubyte, GLubyte, GLubyte, GLubyte)) +BGL_Wrap(1, Color4ubv, void, (GLubyteP)) +BGL_Wrap(4, Color4ui, void, (GLuint, GLuint, GLuint, GLuint)) +BGL_Wrap(1, Color4uiv, void, (GLuintP)) +BGL_Wrap(4, Color4us, void, (GLushort, GLushort, GLushort, GLushort)) +BGL_Wrap(1, Color4usv, void, (GLushortP)) +BGL_Wrap(4, ColorMask, void, (GLboolean, GLboolean, GLboolean, GLboolean)) +BGL_Wrap(2, ColorMaterial, void, (GLenum, GLenum)) +BGL_Wrap(5, CopyPixels, void, (GLint, GLint, GLsizei, GLsizei, GLenum)) +BGL_Wrap(1, CullFace, void, (GLenum)) +BGL_Wrap(2, DeleteLists, void, (GLuint, GLsizei)) +BGL_Wrap(2, DeleteTextures, void, (GLsizei, GLuintP)) +BGL_Wrap(1, DepthFunc, void, (GLenum)) +BGL_Wrap(1, DepthMask, void, (GLboolean)) +BGL_Wrap(2, DepthRange, void, (GLclampd, GLclampd)) +BGL_Wrap(1, Disable, void, (GLenum)) +BGL_Wrap(1, DrawBuffer, void, (GLenum)) +BGL_Wrap(5, DrawPixels, void, (GLsizei, GLsizei, GLenum, GLenum, GLvoidP)) +BGL_Wrap(1, EdgeFlag, void, (GLboolean)) +BGL_Wrap(1, EdgeFlagv, void, (GLbooleanP)) +BGL_Wrap(1, Enable, void, (GLenum)) +BGL_Wrap(1, End, void, (void)) +BGL_Wrap(1, EndList, void, (void)) +BGL_Wrap(1, EvalCoord1d, void, (GLdouble)) +BGL_Wrap(1, EvalCoord1dv, void, (GLdoubleP)) +BGL_Wrap(1, EvalCoord1f, void, (GLfloat)) +BGL_Wrap(1, EvalCoord1fv, void, (GLfloatP)) +BGL_Wrap(2, EvalCoord2d, void, (GLdouble, GLdouble)) +BGL_Wrap(1, EvalCoord2dv, void, (GLdoubleP)) +BGL_Wrap(2, EvalCoord2f, void, (GLfloat, GLfloat)) +BGL_Wrap(1, EvalCoord2fv, void, (GLfloatP)) +BGL_Wrap(3, EvalMesh1, void, (GLenum, GLint, GLint)) +BGL_Wrap(5, EvalMesh2, void, (GLenum, GLint, GLint, GLint, GLint)) +BGL_Wrap(1, EvalPoint1, void, (GLint)) +BGL_Wrap(2, EvalPoint2, void, (GLint, GLint)) +BGL_Wrap(3, FeedbackBuffer, void, (GLsizei, GLenum, GLfloatP)) +BGL_Wrap(1, Finish, void, (void)) +BGL_Wrap(1, Flush, void, (void)) +BGL_Wrap(2, Fogf, void, (GLenum, GLfloat)) +BGL_Wrap(2, Fogfv, void, (GLenum, GLfloatP)) +BGL_Wrap(2, Fogi, void, (GLenum, GLint)) +BGL_Wrap(2, Fogiv, void, (GLenum, GLintP)) +BGL_Wrap(1, FrontFace, void, (GLenum)) +BGL_Wrap(6, Frustum, void, (GLdouble, GLdouble, + GLdouble, GLdouble, GLdouble, GLdouble)) +BGL_Wrap(1, GenLists, GLuint, (GLsizei)) +BGL_Wrap(2, GenTextures, void, (GLsizei, GLuintP)) +BGL_Wrap(2, GetBooleanv, void, (GLenum, GLbooleanP)) +BGL_Wrap(2, GetClipPlane, void, (GLenum, GLdoubleP)) +BGL_Wrap(2, GetDoublev, void, (GLenum, GLdoubleP)) +BGL_Wrap(1, GetError, GLenum, (void)) +BGL_Wrap(2, GetFloatv, void, (GLenum, GLfloatP)) +BGL_Wrap(2, GetIntegerv, void, (GLenum, GLintP)) +BGL_Wrap(3, GetLightfv, void, (GLenum, GLenum, GLfloatP)) +BGL_Wrap(3, GetLightiv, void, (GLenum, GLenum, GLintP)) +BGL_Wrap(3, GetMapdv, void, (GLenum, GLenum, GLdoubleP)) +BGL_Wrap(3, GetMapfv, void, (GLenum, GLenum, GLfloatP)) +BGL_Wrap(3, GetMapiv, void, (GLenum, GLenum, GLintP)) +BGL_Wrap(3, GetMaterialfv, void, (GLenum, GLenum, GLfloatP)) +BGL_Wrap(3, GetMaterialiv, void, (GLenum, GLenum, GLintP)) +BGL_Wrap(2, GetPixelMapfv, void, (GLenum, GLfloatP)) +BGL_Wrap(2, GetPixelMapuiv, void, (GLenum, GLuintP)) +BGL_Wrap(2, GetPixelMapusv, void, (GLenum, GLushortP)) +BGL_Wrap(1, GetPolygonStipple,void, (GLubyteP)) +BGL_Wrap(1, GetString, GLstring, (GLenum)) +BGL_Wrap(3, GetTexEnvfv, void, (GLenum, GLenum, GLfloatP)) +BGL_Wrap(3, GetTexEnviv, void, (GLenum, GLenum, GLintP)) +BGL_Wrap(3, GetTexGendv, void, (GLenum, GLenum, GLdoubleP)) +BGL_Wrap(3, GetTexGenfv, void, (GLenum, GLenum, GLfloatP)) +BGL_Wrap(3, GetTexGeniv, void, (GLenum, GLenum, GLintP)) +BGL_Wrap(5, GetTexImage, void, (GLenum, GLint, GLenum, GLenum, GLvoidP)) +BGL_Wrap(4, GetTexLevelParameterfv, void, (GLenum, GLint, GLenum, GLfloatP)) +BGL_Wrap(4, GetTexLevelParameteriv, void, (GLenum, GLint, GLenum, GLintP)) +BGL_Wrap(3, GetTexParameterfv, void, (GLenum, GLenum, GLfloatP)) +BGL_Wrap(3, GetTexParameteriv, void, (GLenum, GLenum, GLintP)) +BGL_Wrap(2, Hint, void, (GLenum, GLenum)) +BGL_Wrap(1, IndexMask, void, (GLuint)) +BGL_Wrap(1, Indexd, void, (GLdouble)) +BGL_Wrap(1, Indexdv, void, (GLdoubleP)) +BGL_Wrap(1, Indexf, void, (GLfloat)) +BGL_Wrap(1, Indexfv, void, (GLfloatP)) +BGL_Wrap(1, Indexi, void, (GLint)) +BGL_Wrap(1, Indexiv, void, (GLintP)) +BGL_Wrap(1, Indexs, void, (GLshort)) +BGL_Wrap(1, Indexsv, void, (GLshortP)) +BGL_Wrap(1, InitNames, void, (void)) +BGL_Wrap(1, IsEnabled, GLboolean, (GLenum)) +BGL_Wrap(1, IsList, GLboolean, (GLuint)) +BGL_Wrap(1, IsTexture, GLboolean, (GLuint)) +BGL_Wrap(2, LightModelf, void, (GLenum, GLfloat)) +BGL_Wrap(2, LightModelfv, void, (GLenum, GLfloatP)) +BGL_Wrap(2, LightModeli, void, (GLenum, GLint)) +BGL_Wrap(2, LightModeliv, void, (GLenum, GLintP)) +BGL_Wrap(3, Lightf, void, (GLenum, GLenum, GLfloat)) +BGL_Wrap(3, Lightfv, void, (GLenum, GLenum, GLfloatP)) +BGL_Wrap(3, Lighti, void, (GLenum, GLenum, GLint)) +BGL_Wrap(3, Lightiv, void, (GLenum, GLenum, GLintP)) +BGL_Wrap(2, LineStipple, void, (GLint, GLushort)) +BGL_Wrap(1, LineWidth, void, (GLfloat)) +BGL_Wrap(1, ListBase, void, (GLuint)) +BGL_Wrap(1, LoadIdentity, void, (void)) +BGL_Wrap(1, LoadMatrixd, void, (GLdoubleP)) +BGL_Wrap(1, LoadMatrixf, void, (GLfloatP)) +BGL_Wrap(1, LoadName, void, (GLuint)) +BGL_Wrap(1, LogicOp, void, (GLenum)) +BGL_Wrap(6, Map1d, void, (GLenum, GLdouble, GLdouble, + GLint, GLint, GLdoubleP)) +BGL_Wrap(6, Map1f, void, (GLenum, GLfloat, GLfloat, + GLint, GLint, GLfloatP)) +BGL_Wrap(10, Map2d, void, (GLenum, GLdouble, GLdouble, + GLint, GLint, GLdouble, GLdouble, GLint, GLint, GLdoubleP)) +BGL_Wrap(10, Map2f, void, (GLenum, GLfloat, GLfloat, + GLint, GLint, GLfloat, GLfloat, GLint, GLint, GLfloatP)) +BGL_Wrap(3, MapGrid1d, void, (GLint, GLdouble, GLdouble)) +BGL_Wrap(3, MapGrid1f, void, (GLint, GLfloat, GLfloat)) +BGL_Wrap(6, MapGrid2d, void, (GLint, GLdouble, GLdouble, + GLint, GLdouble, GLdouble)) +BGL_Wrap(6, MapGrid2f, void, (GLint, GLfloat, GLfloat, + GLint, GLfloat, GLfloat)) +BGL_Wrap(3, Materialf, void, (GLenum, GLenum, GLfloat)) +BGL_Wrap(3, Materialfv, void, (GLenum, GLenum, GLfloatP)) +BGL_Wrap(3, Materiali, void, (GLenum, GLenum, GLint)) +BGL_Wrap(3, Materialiv, void, (GLenum, GLenum, GLintP)) +BGL_Wrap(1, MatrixMode, void, (GLenum)) +BGL_Wrap(1, MultMatrixd, void, (GLdoubleP)) +BGL_Wrap(1, MultMatrixf, void, (GLfloatP)) +BGL_Wrap(2, NewList, void, (GLuint, GLenum)) +BGL_Wrap(3, Normal3b, void, (GLbyte, GLbyte, GLbyte)) +BGL_Wrap(1, Normal3bv, void, (GLbyteP)) +BGL_Wrap(3, Normal3d, void, (GLdouble, GLdouble, GLdouble)) +BGL_Wrap(1, Normal3dv, void, (GLdoubleP)) +BGL_Wrap(3, Normal3f, void, (GLfloat, GLfloat, GLfloat)) +BGL_Wrap(1, Normal3fv, void, (GLfloatP)) +BGL_Wrap(3, Normal3i, void, (GLint, GLint, GLint)) +BGL_Wrap(1, Normal3iv, void, (GLintP)) +BGL_Wrap(3, Normal3s, void, (GLshort, GLshort, GLshort)) +BGL_Wrap(1, Normal3sv, void, (GLshortP)) +BGL_Wrap(6, Ortho, void, (GLdouble, GLdouble, + GLdouble, GLdouble, GLdouble, GLdouble)) +BGL_Wrap(1, PassThrough, void, (GLfloat)) +BGL_Wrap(3, PixelMapfv, void, (GLenum, GLint, GLfloatP)) +BGL_Wrap(3, PixelMapuiv, void, (GLenum, GLint, GLuintP)) +BGL_Wrap(3, PixelMapusv, void, (GLenum, GLint, GLushortP)) +BGL_Wrap(2, PixelStoref, void, (GLenum, GLfloat)) +BGL_Wrap(2, PixelStorei, void, (GLenum, GLint)) +BGL_Wrap(2, PixelTransferf, void, (GLenum, GLfloat)) +BGL_Wrap(2, PixelTransferi, void, (GLenum, GLint)) +BGL_Wrap(2, PixelZoom, void, (GLfloat, GLfloat)) +BGL_Wrap(1, PointSize, void, (GLfloat)) +BGL_Wrap(2, PolygonMode, void, (GLenum, GLenum)) +BGL_Wrap(2, PolygonOffset, void, (GLfloat, GLfloat)) +BGL_Wrap(1, PolygonStipple, void, (GLubyteP)) +BGL_Wrap(1, PopAttrib, void, (void)) +BGL_Wrap(1, PopClientAttrib, void, (void)) +BGL_Wrap(1, PopMatrix, void, (void)) +BGL_Wrap(1, PopName, void, (void)) +BGL_Wrap(3, PrioritizeTextures, void, (GLsizei, GLuintP, GLclampfP)) +BGL_Wrap(1, PushAttrib, void, (GLbitfield)) +BGL_Wrap(1, PushClientAttrib, void, (GLbitfield)) +BGL_Wrap(1, PushMatrix, void, (void)) +BGL_Wrap(1, PushName, void, (GLuint)) +BGL_Wrap(2, RasterPos2d, void, (GLdouble, GLdouble)) +BGL_Wrap(1, RasterPos2dv, void, (GLdoubleP)) +BGL_Wrap(2, RasterPos2f, void, (GLfloat, GLfloat)) +BGL_Wrap(1, RasterPos2fv, void, (GLfloatP)) +BGL_Wrap(2, RasterPos2i, void, (GLint, GLint)) +BGL_Wrap(1, RasterPos2iv, void, (GLintP)) +BGL_Wrap(2, RasterPos2s, void, (GLshort, GLshort)) +BGL_Wrap(1, RasterPos2sv, void, (GLshortP)) +BGL_Wrap(3, RasterPos3d, void, (GLdouble, GLdouble, GLdouble)) +BGL_Wrap(1, RasterPos3dv, void, (GLdoubleP)) +BGL_Wrap(3, RasterPos3f, void, (GLfloat, GLfloat, GLfloat)) +BGL_Wrap(1, RasterPos3fv, void, (GLfloatP)) +BGL_Wrap(3, RasterPos3i, void, (GLint, GLint, GLint)) +BGL_Wrap(1, RasterPos3iv, void, (GLintP)) +BGL_Wrap(3, RasterPos3s, void, (GLshort, GLshort, GLshort)) +BGL_Wrap(1, RasterPos3sv, void, (GLshortP)) +BGL_Wrap(4, RasterPos4d, void, (GLdouble, GLdouble, GLdouble, GLdouble)) +BGL_Wrap(1, RasterPos4dv, void, (GLdoubleP)) +BGL_Wrap(4, RasterPos4f, void, (GLfloat, GLfloat, GLfloat, GLfloat)) +BGL_Wrap(1, RasterPos4fv, void, (GLfloatP)) +BGL_Wrap(4, RasterPos4i, void, (GLint, GLint, GLint, GLint)) +BGL_Wrap(1, RasterPos4iv, void, (GLintP)) +BGL_Wrap(4, RasterPos4s, void, (GLshort, GLshort, GLshort, GLshort)) +BGL_Wrap(1, RasterPos4sv, void, (GLshortP)) +BGL_Wrap(1, ReadBuffer, void, (GLenum)) +BGL_Wrap(7, ReadPixels, void, (GLint, GLint, GLsizei, + GLsizei, GLenum, GLenum, GLvoidP)) +BGL_Wrap(4, Rectd, void, (GLdouble, GLdouble, GLdouble, GLdouble)) +BGL_Wrap(2, Rectdv, void, (GLdoubleP, GLdoubleP)) +BGL_Wrap(4, Rectf, void, (GLfloat, GLfloat, GLfloat, GLfloat)) +BGL_Wrap(2, Rectfv, void, (GLfloatP, GLfloatP)) +BGL_Wrap(4, Recti, void, (GLint, GLint, GLint, GLint)) +BGL_Wrap(2, Rectiv, void, (GLintP, GLintP)) +BGL_Wrap(4, Rects, void, (GLshort, GLshort, GLshort, GLshort)) +BGL_Wrap(2, Rectsv, void, (GLshortP, GLshortP)) +BGL_Wrap(1, RenderMode, GLint, (GLenum)) +BGL_Wrap(4, Rotated, void, (GLdouble, GLdouble, GLdouble, GLdouble)) +BGL_Wrap(4, Rotatef, void, (GLfloat, GLfloat, GLfloat, GLfloat)) +BGL_Wrap(3, Scaled, void, (GLdouble, GLdouble, GLdouble)) +BGL_Wrap(3, Scalef, void, (GLfloat, GLfloat, GLfloat)) +BGL_Wrap(4, Scissor, void, (GLint, GLint, GLsizei, GLsizei)) +BGL_Wrap(2, SelectBuffer, void, (GLsizei, GLuintP)) +BGL_Wrap(1, ShadeModel, void, (GLenum)) +BGL_Wrap(3, StencilFunc, void, (GLenum, GLint, GLuint)) +BGL_Wrap(1, StencilMask, void, (GLuint)) +BGL_Wrap(3, StencilOp, void, (GLenum, GLenum, GLenum)) +BGL_Wrap(1, TexCoord1d, void, (GLdouble)) +BGL_Wrap(1, TexCoord1dv, void, (GLdoubleP)) +BGL_Wrap(1, TexCoord1f, void, (GLfloat)) +BGL_Wrap(1, TexCoord1fv, void, (GLfloatP)) +BGL_Wrap(1, TexCoord1i, void, (GLint)) +BGL_Wrap(1, TexCoord1iv, void, (GLintP)) +BGL_Wrap(1, TexCoord1s, void, (GLshort)) +BGL_Wrap(1, TexCoord1sv, void, (GLshortP)) +BGL_Wrap(2, TexCoord2d, void, (GLdouble, GLdouble)) +BGL_Wrap(1, TexCoord2dv, void, (GLdoubleP)) +BGL_Wrap(2, TexCoord2f, void, (GLfloat, GLfloat)) +BGL_Wrap(1, TexCoord2fv, void, (GLfloatP)) +BGL_Wrap(2, TexCoord2i, void, (GLint, GLint)) +BGL_Wrap(1, TexCoord2iv, void, (GLintP)) +BGL_Wrap(2, TexCoord2s, void, (GLshort, GLshort)) +BGL_Wrap(1, TexCoord2sv, void, (GLshortP)) +BGL_Wrap(3, TexCoord3d, void, (GLdouble, GLdouble, GLdouble)) +BGL_Wrap(1, TexCoord3dv, void, (GLdoubleP)) +BGL_Wrap(3, TexCoord3f, void, (GLfloat, GLfloat, GLfloat)) +BGL_Wrap(1, TexCoord3fv, void, (GLfloatP)) +BGL_Wrap(3, TexCoord3i, void, (GLint, GLint, GLint)) +BGL_Wrap(1, TexCoord3iv, void, (GLintP)) +BGL_Wrap(3, TexCoord3s, void, (GLshort, GLshort, GLshort)) +BGL_Wrap(1, TexCoord3sv, void, (GLshortP)) +BGL_Wrap(4, TexCoord4d, void, (GLdouble, GLdouble, GLdouble, GLdouble)) +BGL_Wrap(1, TexCoord4dv, void, (GLdoubleP)) +BGL_Wrap(4, TexCoord4f, void, (GLfloat, GLfloat, GLfloat, GLfloat)) +BGL_Wrap(1, TexCoord4fv, void, (GLfloatP)) +BGL_Wrap(4, TexCoord4i, void, (GLint, GLint, GLint, GLint)) +BGL_Wrap(1, TexCoord4iv, void, (GLintP)) +BGL_Wrap(4, TexCoord4s, void, (GLshort, GLshort, GLshort, GLshort)) +BGL_Wrap(1, TexCoord4sv, void, (GLshortP)) +BGL_Wrap(3, TexEnvf, void, (GLenum, GLenum, GLfloat)) +BGL_Wrap(3, TexEnvfv, void, (GLenum, GLenum, GLfloatP)) +BGL_Wrap(3, TexEnvi, void, (GLenum, GLenum, GLint)) +BGL_Wrap(3, TexEnviv, void, (GLenum, GLenum, GLintP)) +BGL_Wrap(3, TexGend, void, (GLenum, GLenum, GLdouble)) +BGL_Wrap(3, TexGendv, void, (GLenum, GLenum, GLdoubleP)) +BGL_Wrap(3, TexGenf, void, (GLenum, GLenum, GLfloat)) +BGL_Wrap(3, TexGenfv, void, (GLenum, GLenum, GLfloatP)) +BGL_Wrap(3, TexGeni, void, (GLenum, GLenum, GLint)) +BGL_Wrap(3, TexGeniv, void, (GLenum, GLenum, GLintP)) +BGL_Wrap(8, TexImage1D, void, (GLenum, GLint, GLint, + GLsizei, GLint, GLenum, GLenum, GLvoidP)) +BGL_Wrap(9, TexImage2D, void, (GLenum, GLint, GLint, + GLsizei, GLsizei, GLint, GLenum, GLenum, GLvoidP)) +BGL_Wrap(3, TexParameterf, void, (GLenum, GLenum, GLfloat)) +BGL_Wrap(3, TexParameterfv, void, (GLenum, GLenum, GLfloatP)) +BGL_Wrap(3, TexParameteri, void, (GLenum, GLenum, GLint)) +BGL_Wrap(3, TexParameteriv, void, (GLenum, GLenum, GLintP)) +BGL_Wrap(3, Translated, void, (GLdouble, GLdouble, GLdouble)) +BGL_Wrap(3, Translatef, void, (GLfloat, GLfloat, GLfloat)) +BGL_Wrap(2, Vertex2d, void, (GLdouble, GLdouble)) +BGL_Wrap(1, Vertex2dv, void, (GLdoubleP)) +BGL_Wrap(2, Vertex2f, void, (GLfloat, GLfloat)) +BGL_Wrap(1, Vertex2fv, void, (GLfloatP)) +BGL_Wrap(2, Vertex2i, void, (GLint, GLint)) +BGL_Wrap(1, Vertex2iv, void, (GLintP)) +BGL_Wrap(2, Vertex2s, void, (GLshort, GLshort)) +BGL_Wrap(1, Vertex2sv, void, (GLshortP)) +BGL_Wrap(3, Vertex3d, void, (GLdouble, GLdouble, GLdouble)) +BGL_Wrap(1, Vertex3dv, void, (GLdoubleP)) +BGL_Wrap(3, Vertex3f, void, (GLfloat, GLfloat, GLfloat)) +BGL_Wrap(1, Vertex3fv, void, (GLfloatP)) +BGL_Wrap(3, Vertex3i, void, (GLint, GLint, GLint)) +BGL_Wrap(1, Vertex3iv, void, (GLintP)) +BGL_Wrap(3, Vertex3s, void, (GLshort, GLshort, GLshort)) +BGL_Wrap(1, Vertex3sv, void, (GLshortP)) +BGL_Wrap(4, Vertex4d, void, (GLdouble, GLdouble, GLdouble, GLdouble)) +BGL_Wrap(1, Vertex4dv, void, (GLdoubleP)) +BGL_Wrap(4, Vertex4f, void, (GLfloat, GLfloat, GLfloat, GLfloat)) +BGL_Wrap(1, Vertex4fv, void, (GLfloatP)) +BGL_Wrap(4, Vertex4i, void, (GLint, GLint, GLint, GLint)) +BGL_Wrap(1, Vertex4iv, void, (GLintP)) +BGL_Wrap(4, Vertex4s, void, (GLshort, GLshort, GLshort, GLshort)) +BGL_Wrap(1, Vertex4sv, void, (GLshortP)) +BGL_Wrap(4, Viewport, void, (GLint, GLint, GLsizei, GLsizei)) +BGLU_Wrap(4, Perspective, void, (GLdouble, GLdouble, GLdouble, GLdouble)) +BGLU_Wrap(9, LookAt, void, (GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble)) +BGLU_Wrap(4, Ortho2D, void, (GLdouble, GLdouble, GLdouble, GLdouble)) +BGLU_Wrap(5, PickMatrix, void, (GLdouble, GLdouble, GLdouble, GLdouble, GLintP)) +BGLU_Wrap(9, Project, GLint, (GLdouble, GLdouble, GLdouble, GLdoubleP, GLdoubleP, GLintP, GLdoubleP, GLdoubleP, GLdoubleP)) +BGLU_Wrap(9, UnProject, GLint, (GLdouble, GLdouble, GLdouble, GLdoubleP, GLdoubleP, GLintP, GLdoubleP, GLdoubleP, GLdoubleP)) + +#undef MethodDef +#define MethodDef(func) {"gl"#func, Method_##func, METH_VARARGS, "no string"} +#define MethodDefu(func) {"glu"#func, Method_##func, METH_VARARGS, "no string"} +/* So that MethodDef(Accum) becomes: + * {"glAccum", Method_Accumfunc, METH_VARARGS} */ + +static struct PyMethodDef BGL_methods[] = { + {"Buffer", Method_Buffer, METH_VARARGS, Method_Buffer_doc}, + +/* #ifndef __APPLE__ */ + MethodDef(Accum), + MethodDef(AlphaFunc), + MethodDef(AreTexturesResident), + MethodDef(Begin), + MethodDef(BindTexture), + MethodDef(Bitmap), + MethodDef(BlendFunc), + MethodDef(CallList), + MethodDef(CallLists), + MethodDef(Clear), + MethodDef(ClearAccum), + MethodDef(ClearColor), + MethodDef(ClearDepth), + MethodDef(ClearIndex), + MethodDef(ClearStencil), + MethodDef(ClipPlane), + MethodDef(Color3b), + MethodDef(Color3bv), + MethodDef(Color3d), + MethodDef(Color3dv), + MethodDef(Color3f), + MethodDef(Color3fv), + MethodDef(Color3i), + MethodDef(Color3iv), + MethodDef(Color3s), + MethodDef(Color3sv), + MethodDef(Color3ub), + MethodDef(Color3ubv), + MethodDef(Color3ui), + MethodDef(Color3uiv), + MethodDef(Color3us), + MethodDef(Color3usv), + MethodDef(Color4b), + MethodDef(Color4bv), + MethodDef(Color4d), + MethodDef(Color4dv), + MethodDef(Color4f), + MethodDef(Color4fv), + MethodDef(Color4i), + MethodDef(Color4iv), + MethodDef(Color4s), + MethodDef(Color4sv), + MethodDef(Color4ub), + MethodDef(Color4ubv), + MethodDef(Color4ui), + MethodDef(Color4uiv), + MethodDef(Color4us), + MethodDef(Color4usv), + MethodDef(ColorMask), + MethodDef(ColorMaterial), + MethodDef(CopyPixels), + MethodDef(CullFace), + MethodDef(DeleteLists), + MethodDef(DeleteTextures), + MethodDef(DepthFunc), + MethodDef(DepthMask), + MethodDef(DepthRange), + MethodDef(Disable), + MethodDef(DrawBuffer), + MethodDef(DrawPixels), + MethodDef(EdgeFlag), + MethodDef(EdgeFlagv), + MethodDef(Enable), + MethodDef(End), + MethodDef(EndList), + MethodDef(EvalCoord1d), + MethodDef(EvalCoord1dv), + MethodDef(EvalCoord1f), + MethodDef(EvalCoord1fv), + MethodDef(EvalCoord2d), + MethodDef(EvalCoord2dv), + MethodDef(EvalCoord2f), + MethodDef(EvalCoord2fv), + MethodDef(EvalMesh1), + MethodDef(EvalMesh2), + MethodDef(EvalPoint1), + MethodDef(EvalPoint2), + MethodDef(FeedbackBuffer), + MethodDef(Finish), + MethodDef(Flush), + MethodDef(Fogf), + MethodDef(Fogfv), + MethodDef(Fogi), + MethodDef(Fogiv), + MethodDef(FrontFace), + MethodDef(Frustum), + MethodDef(GenLists), + MethodDef(GenTextures), + MethodDef(GetBooleanv), + MethodDef(GetClipPlane), + MethodDef(GetDoublev), + MethodDef(GetError), + MethodDef(GetFloatv), + MethodDef(GetIntegerv), + MethodDef(GetLightfv), + MethodDef(GetLightiv), + MethodDef(GetMapdv), + MethodDef(GetMapfv), + MethodDef(GetMapiv), + MethodDef(GetMaterialfv), + MethodDef(GetMaterialiv), + MethodDef(GetPixelMapfv), + MethodDef(GetPixelMapuiv), + MethodDef(GetPixelMapusv), + MethodDef(GetPolygonStipple), + MethodDef(GetString), + MethodDef(GetTexEnvfv), + MethodDef(GetTexEnviv), + MethodDef(GetTexGendv), + MethodDef(GetTexGenfv), + MethodDef(GetTexGeniv), + MethodDef(GetTexImage), + MethodDef(GetTexLevelParameterfv), + MethodDef(GetTexLevelParameteriv), + MethodDef(GetTexParameterfv), + MethodDef(GetTexParameteriv), + MethodDef(Hint), + MethodDef(IndexMask), + MethodDef(Indexd), + MethodDef(Indexdv), + MethodDef(Indexf), + MethodDef(Indexfv), + MethodDef(Indexi), + MethodDef(Indexiv), + MethodDef(Indexs), + MethodDef(Indexsv), + MethodDef(InitNames), + MethodDef(IsEnabled), + MethodDef(IsList), + MethodDef(IsTexture), + MethodDef(LightModelf), + MethodDef(LightModelfv), + MethodDef(LightModeli), + MethodDef(LightModeliv), + MethodDef(Lightf), + MethodDef(Lightfv), + MethodDef(Lighti), + MethodDef(Lightiv), + MethodDef(LineStipple), + MethodDef(LineWidth), + MethodDef(ListBase), + MethodDef(LoadIdentity), + MethodDef(LoadMatrixd), + MethodDef(LoadMatrixf), + MethodDef(LoadName), + MethodDef(LogicOp), + MethodDef(Map1d), + MethodDef(Map1f), + MethodDef(Map2d), + MethodDef(Map2f), + MethodDef(MapGrid1d), + MethodDef(MapGrid1f), + MethodDef(MapGrid2d), + MethodDef(MapGrid2f), + MethodDef(Materialf), + MethodDef(Materialfv), + MethodDef(Materiali), + MethodDef(Materialiv), + MethodDef(MatrixMode), + MethodDef(MultMatrixd), + MethodDef(MultMatrixf), + MethodDef(NewList), + MethodDef(Normal3b), + MethodDef(Normal3bv), + MethodDef(Normal3d), + MethodDef(Normal3dv), + MethodDef(Normal3f), + MethodDef(Normal3fv), + MethodDef(Normal3i), + MethodDef(Normal3iv), + MethodDef(Normal3s), + MethodDef(Normal3sv), + MethodDef(Ortho), + MethodDef(PassThrough), + MethodDef(PixelMapfv), + MethodDef(PixelMapuiv), + MethodDef(PixelMapusv), + MethodDef(PixelStoref), + MethodDef(PixelStorei), + MethodDef(PixelTransferf), + MethodDef(PixelTransferi), + MethodDef(PixelZoom), + MethodDef(PointSize), + MethodDef(PolygonMode), + MethodDef(PolygonOffset), + MethodDef(PolygonStipple), + MethodDef(PopAttrib), + MethodDef(PopClientAttrib), + MethodDef(PopMatrix), + MethodDef(PopName), + MethodDef(PrioritizeTextures), + MethodDef(PushAttrib), + MethodDef(PushClientAttrib), + MethodDef(PushMatrix), + MethodDef(PushName), + MethodDef(RasterPos2d), + MethodDef(RasterPos2dv), + MethodDef(RasterPos2f), + MethodDef(RasterPos2fv), + MethodDef(RasterPos2i), + MethodDef(RasterPos2iv), + MethodDef(RasterPos2s), + MethodDef(RasterPos2sv), + MethodDef(RasterPos3d), + MethodDef(RasterPos3dv), + MethodDef(RasterPos3f), + MethodDef(RasterPos3fv), + MethodDef(RasterPos3i), + MethodDef(RasterPos3iv), + MethodDef(RasterPos3s), + MethodDef(RasterPos3sv), + MethodDef(RasterPos4d), + MethodDef(RasterPos4dv), + MethodDef(RasterPos4f), + MethodDef(RasterPos4fv), + MethodDef(RasterPos4i), + MethodDef(RasterPos4iv), + MethodDef(RasterPos4s), + MethodDef(RasterPos4sv), + MethodDef(ReadBuffer), + MethodDef(ReadPixels), + MethodDef(Rectd), + MethodDef(Rectdv), + MethodDef(Rectf), + MethodDef(Rectfv), + MethodDef(Recti), + MethodDef(Rectiv), + MethodDef(Rects), + MethodDef(Rectsv), + MethodDef(RenderMode), + MethodDef(Rotated), + MethodDef(Rotatef), + MethodDef(Scaled), + MethodDef(Scalef), + MethodDef(Scissor), + MethodDef(SelectBuffer), + MethodDef(ShadeModel), + MethodDef(StencilFunc), + MethodDef(StencilMask), + MethodDef(StencilOp), + MethodDef(TexCoord1d), + MethodDef(TexCoord1dv), + MethodDef(TexCoord1f), + MethodDef(TexCoord1fv), + MethodDef(TexCoord1i), + MethodDef(TexCoord1iv), + MethodDef(TexCoord1s), + MethodDef(TexCoord1sv), + MethodDef(TexCoord2d), + MethodDef(TexCoord2dv), + MethodDef(TexCoord2f), + MethodDef(TexCoord2fv), + MethodDef(TexCoord2i), + MethodDef(TexCoord2iv), + MethodDef(TexCoord2s), + MethodDef(TexCoord2sv), + MethodDef(TexCoord3d), + MethodDef(TexCoord3dv), + MethodDef(TexCoord3f), + MethodDef(TexCoord3fv), + MethodDef(TexCoord3i), + MethodDef(TexCoord3iv), + MethodDef(TexCoord3s), + MethodDef(TexCoord3sv), + MethodDef(TexCoord4d), + MethodDef(TexCoord4dv), + MethodDef(TexCoord4f), + MethodDef(TexCoord4fv), + MethodDef(TexCoord4i), + MethodDef(TexCoord4iv), + MethodDef(TexCoord4s), + MethodDef(TexCoord4sv), + MethodDef(TexEnvf), + MethodDef(TexEnvfv), + MethodDef(TexEnvi), + MethodDef(TexEnviv), + MethodDef(TexGend), + MethodDef(TexGendv), + MethodDef(TexGenf), + MethodDef(TexGenfv), + MethodDef(TexGeni), + MethodDef(TexGeniv), + MethodDef(TexImage1D), + MethodDef(TexImage2D), + MethodDef(TexParameterf), + MethodDef(TexParameterfv), + MethodDef(TexParameteri), + MethodDef(TexParameteriv), + MethodDef(Translated), + MethodDef(Translatef), + MethodDef(Vertex2d), + MethodDef(Vertex2dv), + MethodDef(Vertex2f), + MethodDef(Vertex2fv), + MethodDef(Vertex2i), + MethodDef(Vertex2iv), + MethodDef(Vertex2s), + MethodDef(Vertex2sv), + MethodDef(Vertex3d), + MethodDef(Vertex3dv), + MethodDef(Vertex3f), + MethodDef(Vertex3fv), + MethodDef(Vertex3i), + MethodDef(Vertex3iv), + MethodDef(Vertex3s), + MethodDef(Vertex3sv), + MethodDef(Vertex4d), + MethodDef(Vertex4dv), + MethodDef(Vertex4f), + MethodDef(Vertex4fv), + MethodDef(Vertex4i), + MethodDef(Vertex4iv), + MethodDef(Vertex4s), + MethodDef(Vertex4sv), + MethodDef(Viewport), + MethodDefu(Perspective), + MethodDefu(LookAt), + MethodDefu(Ortho2D), + MethodDefu(PickMatrix), + MethodDefu(Project), + MethodDefu(UnProject), +/* #endif */ + {NULL, NULL, 0, NULL} +}; + +#if (PY_VERSION_HEX >= 0x03000000) +static struct PyModuleDef BGL_module_def = { + {}, /* m_base */ + "BGL", /* m_name */ + 0, /* m_doc */ + 0, /* m_size */ + BGL_methods, /* m_methods */ + 0, /* m_reload */ + 0, /* m_traverse */ + 0, /* m_clear */ + 0, /* m_free */ +}; +#endif + +PyObject *BGL_Init(const char *from) +{ + PyObject *mod, *dict, *item; +#if (PY_VERSION_HEX >= 0x03000000) + mod = PyModule_Create(&BGL_module_def); + PyDict_SetItemString(PySys_GetObject("modules"), BGL_module_def.m_name, mod); +#else + mod= Py_InitModule(from, BGL_methods); +#endif + dict= PyModule_GetDict(mod); + + if( PyType_Ready( &buffer_Type) < 0) + return NULL; /* should never happen */ + +#define EXPP_ADDCONST(x) PyDict_SetItemString(dict, #x, item=PyLong_FromLong((int)x)); Py_DECREF(item) + +/* So, for example: + * EXPP_ADDCONST(GL_CURRENT_BIT) becomes + * PyDict_SetItemString(dict, "GL_CURRENT_BIT", item=PyLong_FromLong(GL_CURRENT_BIT)); Py_DECREF(item) */ + + EXPP_ADDCONST(GL_CURRENT_BIT); + EXPP_ADDCONST(GL_POINT_BIT); + EXPP_ADDCONST(GL_LINE_BIT); + EXPP_ADDCONST(GL_POLYGON_BIT); + EXPP_ADDCONST(GL_POLYGON_STIPPLE_BIT); + EXPP_ADDCONST(GL_PIXEL_MODE_BIT); + EXPP_ADDCONST(GL_LIGHTING_BIT); + EXPP_ADDCONST(GL_FOG_BIT); + EXPP_ADDCONST(GL_DEPTH_BUFFER_BIT); + EXPP_ADDCONST(GL_ACCUM_BUFFER_BIT); + EXPP_ADDCONST(GL_STENCIL_BUFFER_BIT); + EXPP_ADDCONST(GL_VIEWPORT_BIT); + EXPP_ADDCONST(GL_TRANSFORM_BIT); + EXPP_ADDCONST(GL_ENABLE_BIT); + EXPP_ADDCONST(GL_COLOR_BUFFER_BIT); + EXPP_ADDCONST(GL_HINT_BIT); + EXPP_ADDCONST(GL_EVAL_BIT); + EXPP_ADDCONST(GL_LIST_BIT); + EXPP_ADDCONST(GL_TEXTURE_BIT); + EXPP_ADDCONST(GL_SCISSOR_BIT); + EXPP_ADDCONST(GL_ALL_ATTRIB_BITS); + EXPP_ADDCONST(GL_CLIENT_ALL_ATTRIB_BITS); + + EXPP_ADDCONST(GL_FALSE); + EXPP_ADDCONST(GL_TRUE); + + EXPP_ADDCONST(GL_POINTS); + EXPP_ADDCONST(GL_LINES); + EXPP_ADDCONST(GL_LINE_LOOP); + EXPP_ADDCONST(GL_LINE_STRIP); + EXPP_ADDCONST(GL_TRIANGLES); + EXPP_ADDCONST(GL_TRIANGLE_STRIP); + EXPP_ADDCONST(GL_TRIANGLE_FAN); + EXPP_ADDCONST(GL_QUADS); + EXPP_ADDCONST(GL_QUAD_STRIP); + EXPP_ADDCONST(GL_POLYGON); + + EXPP_ADDCONST(GL_ACCUM); + EXPP_ADDCONST(GL_LOAD); + EXPP_ADDCONST(GL_RETURN); + EXPP_ADDCONST(GL_MULT); + EXPP_ADDCONST(GL_ADD); + + EXPP_ADDCONST(GL_NEVER); + EXPP_ADDCONST(GL_LESS); + EXPP_ADDCONST(GL_EQUAL); + EXPP_ADDCONST(GL_LEQUAL); + EXPP_ADDCONST(GL_GREATER); + EXPP_ADDCONST(GL_NOTEQUAL); + EXPP_ADDCONST(GL_GEQUAL); + EXPP_ADDCONST(GL_ALWAYS); + + EXPP_ADDCONST(GL_ZERO); + EXPP_ADDCONST(GL_ONE); + EXPP_ADDCONST(GL_SRC_COLOR); + EXPP_ADDCONST(GL_ONE_MINUS_SRC_COLOR); + EXPP_ADDCONST(GL_SRC_ALPHA); + EXPP_ADDCONST(GL_ONE_MINUS_SRC_ALPHA); + EXPP_ADDCONST(GL_DST_ALPHA); + EXPP_ADDCONST(GL_ONE_MINUS_DST_ALPHA); + + EXPP_ADDCONST(GL_DST_COLOR); + EXPP_ADDCONST(GL_ONE_MINUS_DST_COLOR); + EXPP_ADDCONST(GL_SRC_ALPHA_SATURATE); + + EXPP_ADDCONST(GL_NONE); + EXPP_ADDCONST(GL_FRONT_LEFT); + EXPP_ADDCONST(GL_FRONT_RIGHT); + EXPP_ADDCONST(GL_BACK_LEFT); + EXPP_ADDCONST(GL_BACK_RIGHT); + EXPP_ADDCONST(GL_FRONT); + EXPP_ADDCONST(GL_BACK); + EXPP_ADDCONST(GL_LEFT); + EXPP_ADDCONST(GL_RIGHT); + EXPP_ADDCONST(GL_FRONT_AND_BACK); + EXPP_ADDCONST(GL_AUX0); + EXPP_ADDCONST(GL_AUX1); + EXPP_ADDCONST(GL_AUX2); + EXPP_ADDCONST(GL_AUX3); + + EXPP_ADDCONST(GL_NO_ERROR); + EXPP_ADDCONST(GL_INVALID_ENUM); + EXPP_ADDCONST(GL_INVALID_VALUE); + EXPP_ADDCONST(GL_INVALID_OPERATION); + EXPP_ADDCONST(GL_STACK_OVERFLOW); + EXPP_ADDCONST(GL_STACK_UNDERFLOW); + EXPP_ADDCONST(GL_OUT_OF_MEMORY); + + EXPP_ADDCONST(GL_2D); + EXPP_ADDCONST(GL_3D); + EXPP_ADDCONST(GL_3D_COLOR); + EXPP_ADDCONST(GL_3D_COLOR_TEXTURE); + EXPP_ADDCONST(GL_4D_COLOR_TEXTURE); + + EXPP_ADDCONST(GL_PASS_THROUGH_TOKEN); + EXPP_ADDCONST(GL_POINT_TOKEN); + EXPP_ADDCONST(GL_LINE_TOKEN); + EXPP_ADDCONST(GL_POLYGON_TOKEN); + EXPP_ADDCONST(GL_BITMAP_TOKEN); + EXPP_ADDCONST(GL_DRAW_PIXEL_TOKEN); + EXPP_ADDCONST(GL_COPY_PIXEL_TOKEN); + EXPP_ADDCONST(GL_LINE_RESET_TOKEN); + + EXPP_ADDCONST(GL_EXP); + EXPP_ADDCONST(GL_EXP2); + + EXPP_ADDCONST(GL_CW); + EXPP_ADDCONST(GL_CCW); + + EXPP_ADDCONST(GL_COEFF); + EXPP_ADDCONST(GL_ORDER); + EXPP_ADDCONST(GL_DOMAIN); + + EXPP_ADDCONST(GL_PIXEL_MAP_I_TO_I); + EXPP_ADDCONST(GL_PIXEL_MAP_S_TO_S); + EXPP_ADDCONST(GL_PIXEL_MAP_I_TO_R); + EXPP_ADDCONST(GL_PIXEL_MAP_I_TO_G); + EXPP_ADDCONST(GL_PIXEL_MAP_I_TO_B); + EXPP_ADDCONST(GL_PIXEL_MAP_I_TO_A); + EXPP_ADDCONST(GL_PIXEL_MAP_R_TO_R); + EXPP_ADDCONST(GL_PIXEL_MAP_G_TO_G); + EXPP_ADDCONST(GL_PIXEL_MAP_B_TO_B); + EXPP_ADDCONST(GL_PIXEL_MAP_A_TO_A); + + EXPP_ADDCONST(GL_CURRENT_COLOR); + EXPP_ADDCONST(GL_CURRENT_INDEX); + EXPP_ADDCONST(GL_CURRENT_NORMAL); + EXPP_ADDCONST(GL_CURRENT_TEXTURE_COORDS); + EXPP_ADDCONST(GL_CURRENT_RASTER_COLOR); + EXPP_ADDCONST(GL_CURRENT_RASTER_INDEX); + EXPP_ADDCONST(GL_CURRENT_RASTER_TEXTURE_COORDS); + EXPP_ADDCONST(GL_CURRENT_RASTER_POSITION); + EXPP_ADDCONST(GL_CURRENT_RASTER_POSITION_VALID); + EXPP_ADDCONST(GL_CURRENT_RASTER_DISTANCE); + EXPP_ADDCONST(GL_POINT_SMOOTH); + EXPP_ADDCONST(GL_POINT_SIZE); + EXPP_ADDCONST(GL_POINT_SIZE_RANGE); + EXPP_ADDCONST(GL_POINT_SIZE_GRANULARITY); + EXPP_ADDCONST(GL_LINE_SMOOTH); + EXPP_ADDCONST(GL_LINE_WIDTH); + EXPP_ADDCONST(GL_LINE_WIDTH_RANGE); + EXPP_ADDCONST(GL_LINE_WIDTH_GRANULARITY); + EXPP_ADDCONST(GL_LINE_STIPPLE); + EXPP_ADDCONST(GL_LINE_STIPPLE_PATTERN); + EXPP_ADDCONST(GL_LINE_STIPPLE_REPEAT); + EXPP_ADDCONST(GL_LIST_MODE); + EXPP_ADDCONST(GL_MAX_LIST_NESTING); + EXPP_ADDCONST(GL_LIST_BASE); + EXPP_ADDCONST(GL_LIST_INDEX); + EXPP_ADDCONST(GL_POLYGON_MODE); + EXPP_ADDCONST(GL_POLYGON_SMOOTH); + EXPP_ADDCONST(GL_POLYGON_STIPPLE); + EXPP_ADDCONST(GL_EDGE_FLAG); + EXPP_ADDCONST(GL_CULL_FACE); + EXPP_ADDCONST(GL_CULL_FACE_MODE); + EXPP_ADDCONST(GL_FRONT_FACE); + EXPP_ADDCONST(GL_LIGHTING); + EXPP_ADDCONST(GL_LIGHT_MODEL_LOCAL_VIEWER); + EXPP_ADDCONST(GL_LIGHT_MODEL_TWO_SIDE); + EXPP_ADDCONST(GL_LIGHT_MODEL_AMBIENT); + EXPP_ADDCONST(GL_SHADE_MODEL); + EXPP_ADDCONST(GL_COLOR_MATERIAL_FACE); + EXPP_ADDCONST(GL_COLOR_MATERIAL_PARAMETER); + EXPP_ADDCONST(GL_COLOR_MATERIAL); + EXPP_ADDCONST(GL_FOG); + EXPP_ADDCONST(GL_FOG_INDEX); + EXPP_ADDCONST(GL_FOG_DENSITY); + EXPP_ADDCONST(GL_FOG_START); + EXPP_ADDCONST(GL_FOG_END); + EXPP_ADDCONST(GL_FOG_MODE); + EXPP_ADDCONST(GL_FOG_COLOR); + EXPP_ADDCONST(GL_DEPTH_RANGE); + EXPP_ADDCONST(GL_DEPTH_TEST); + EXPP_ADDCONST(GL_DEPTH_WRITEMASK); + EXPP_ADDCONST(GL_DEPTH_CLEAR_VALUE); + EXPP_ADDCONST(GL_DEPTH_FUNC); + EXPP_ADDCONST(GL_ACCUM_CLEAR_VALUE); + EXPP_ADDCONST(GL_STENCIL_TEST); + EXPP_ADDCONST(GL_STENCIL_CLEAR_VALUE); + EXPP_ADDCONST(GL_STENCIL_FUNC); + EXPP_ADDCONST(GL_STENCIL_VALUE_MASK); + EXPP_ADDCONST(GL_STENCIL_FAIL); + EXPP_ADDCONST(GL_STENCIL_PASS_DEPTH_FAIL); + EXPP_ADDCONST(GL_STENCIL_PASS_DEPTH_PASS); + EXPP_ADDCONST(GL_STENCIL_REF); + EXPP_ADDCONST(GL_STENCIL_WRITEMASK); + EXPP_ADDCONST(GL_MATRIX_MODE); + EXPP_ADDCONST(GL_NORMALIZE); + EXPP_ADDCONST(GL_VIEWPORT); + EXPP_ADDCONST(GL_MODELVIEW_STACK_DEPTH); + EXPP_ADDCONST(GL_PROJECTION_STACK_DEPTH); + EXPP_ADDCONST(GL_TEXTURE_STACK_DEPTH); + EXPP_ADDCONST(GL_MODELVIEW_MATRIX); + EXPP_ADDCONST(GL_PROJECTION_MATRIX); + EXPP_ADDCONST(GL_TEXTURE_MATRIX); + EXPP_ADDCONST(GL_ATTRIB_STACK_DEPTH); + EXPP_ADDCONST(GL_ALPHA_TEST); + EXPP_ADDCONST(GL_ALPHA_TEST_FUNC); + EXPP_ADDCONST(GL_ALPHA_TEST_REF); + EXPP_ADDCONST(GL_DITHER); + EXPP_ADDCONST(GL_BLEND_DST); + EXPP_ADDCONST(GL_BLEND_SRC); + EXPP_ADDCONST(GL_BLEND); + EXPP_ADDCONST(GL_LOGIC_OP_MODE); + EXPP_ADDCONST(GL_LOGIC_OP); + EXPP_ADDCONST(GL_AUX_BUFFERS); + EXPP_ADDCONST(GL_DRAW_BUFFER); + EXPP_ADDCONST(GL_READ_BUFFER); + EXPP_ADDCONST(GL_SCISSOR_BOX); + EXPP_ADDCONST(GL_SCISSOR_TEST); + EXPP_ADDCONST(GL_INDEX_CLEAR_VALUE); + EXPP_ADDCONST(GL_INDEX_WRITEMASK); + EXPP_ADDCONST(GL_COLOR_CLEAR_VALUE); + EXPP_ADDCONST(GL_COLOR_WRITEMASK); + EXPP_ADDCONST(GL_INDEX_MODE); + EXPP_ADDCONST(GL_RGBA_MODE); + EXPP_ADDCONST(GL_DOUBLEBUFFER); + EXPP_ADDCONST(GL_STEREO); + EXPP_ADDCONST(GL_RENDER_MODE); + EXPP_ADDCONST(GL_PERSPECTIVE_CORRECTION_HINT); + EXPP_ADDCONST(GL_POINT_SMOOTH_HINT); + EXPP_ADDCONST(GL_LINE_SMOOTH_HINT); + EXPP_ADDCONST(GL_POLYGON_SMOOTH_HINT); + EXPP_ADDCONST(GL_FOG_HINT); + EXPP_ADDCONST(GL_TEXTURE_GEN_S); + EXPP_ADDCONST(GL_TEXTURE_GEN_T); + EXPP_ADDCONST(GL_TEXTURE_GEN_R); + EXPP_ADDCONST(GL_TEXTURE_GEN_Q); + EXPP_ADDCONST(GL_PIXEL_MAP_I_TO_I_SIZE); + EXPP_ADDCONST(GL_PIXEL_MAP_S_TO_S_SIZE); + EXPP_ADDCONST(GL_PIXEL_MAP_I_TO_R_SIZE); + EXPP_ADDCONST(GL_PIXEL_MAP_I_TO_G_SIZE); + EXPP_ADDCONST(GL_PIXEL_MAP_I_TO_B_SIZE); + EXPP_ADDCONST(GL_PIXEL_MAP_I_TO_A_SIZE); + EXPP_ADDCONST(GL_PIXEL_MAP_R_TO_R_SIZE); + EXPP_ADDCONST(GL_PIXEL_MAP_G_TO_G_SIZE); + EXPP_ADDCONST(GL_PIXEL_MAP_B_TO_B_SIZE); + EXPP_ADDCONST(GL_PIXEL_MAP_A_TO_A_SIZE); + EXPP_ADDCONST(GL_UNPACK_SWAP_BYTES); + EXPP_ADDCONST(GL_UNPACK_LSB_FIRST); + EXPP_ADDCONST(GL_UNPACK_ROW_LENGTH); + EXPP_ADDCONST(GL_UNPACK_SKIP_ROWS); + EXPP_ADDCONST(GL_UNPACK_SKIP_PIXELS); + EXPP_ADDCONST(GL_UNPACK_ALIGNMENT); + EXPP_ADDCONST(GL_PACK_SWAP_BYTES); + EXPP_ADDCONST(GL_PACK_LSB_FIRST); + EXPP_ADDCONST(GL_PACK_ROW_LENGTH); + EXPP_ADDCONST(GL_PACK_SKIP_ROWS); + EXPP_ADDCONST(GL_PACK_SKIP_PIXELS); + EXPP_ADDCONST(GL_PACK_ALIGNMENT); + EXPP_ADDCONST(GL_MAP_COLOR); + EXPP_ADDCONST(GL_MAP_STENCIL); + EXPP_ADDCONST(GL_INDEX_SHIFT); + EXPP_ADDCONST(GL_INDEX_OFFSET); + EXPP_ADDCONST(GL_RED_SCALE); + EXPP_ADDCONST(GL_RED_BIAS); + EXPP_ADDCONST(GL_ZOOM_X); + EXPP_ADDCONST(GL_ZOOM_Y); + EXPP_ADDCONST(GL_GREEN_SCALE); + EXPP_ADDCONST(GL_GREEN_BIAS); + EXPP_ADDCONST(GL_BLUE_SCALE); + EXPP_ADDCONST(GL_BLUE_BIAS); + EXPP_ADDCONST(GL_ALPHA_SCALE); + EXPP_ADDCONST(GL_ALPHA_BIAS); + EXPP_ADDCONST(GL_DEPTH_SCALE); + EXPP_ADDCONST(GL_DEPTH_BIAS); + EXPP_ADDCONST(GL_MAX_EVAL_ORDER); + EXPP_ADDCONST(GL_MAX_LIGHTS); + EXPP_ADDCONST(GL_MAX_CLIP_PLANES); + EXPP_ADDCONST(GL_MAX_TEXTURE_SIZE); + EXPP_ADDCONST(GL_MAX_PIXEL_MAP_TABLE); + EXPP_ADDCONST(GL_MAX_ATTRIB_STACK_DEPTH); + EXPP_ADDCONST(GL_MAX_MODELVIEW_STACK_DEPTH); + EXPP_ADDCONST(GL_MAX_NAME_STACK_DEPTH); + EXPP_ADDCONST(GL_MAX_PROJECTION_STACK_DEPTH); + EXPP_ADDCONST(GL_MAX_TEXTURE_STACK_DEPTH); + EXPP_ADDCONST(GL_MAX_VIEWPORT_DIMS); + EXPP_ADDCONST(GL_SUBPIXEL_BITS); + EXPP_ADDCONST(GL_INDEX_BITS); + EXPP_ADDCONST(GL_RED_BITS); + EXPP_ADDCONST(GL_GREEN_BITS); + EXPP_ADDCONST(GL_BLUE_BITS); + EXPP_ADDCONST(GL_ALPHA_BITS); + EXPP_ADDCONST(GL_DEPTH_BITS); + EXPP_ADDCONST(GL_STENCIL_BITS); + EXPP_ADDCONST(GL_ACCUM_RED_BITS); + EXPP_ADDCONST(GL_ACCUM_GREEN_BITS); + EXPP_ADDCONST(GL_ACCUM_BLUE_BITS); + EXPP_ADDCONST(GL_ACCUM_ALPHA_BITS); + EXPP_ADDCONST(GL_NAME_STACK_DEPTH); + EXPP_ADDCONST(GL_AUTO_NORMAL); + EXPP_ADDCONST(GL_MAP1_COLOR_4); + EXPP_ADDCONST(GL_MAP1_INDEX); + EXPP_ADDCONST(GL_MAP1_NORMAL); + EXPP_ADDCONST(GL_MAP1_TEXTURE_COORD_1); + EXPP_ADDCONST(GL_MAP1_TEXTURE_COORD_2); + EXPP_ADDCONST(GL_MAP1_TEXTURE_COORD_3); + EXPP_ADDCONST(GL_MAP1_TEXTURE_COORD_4); + EXPP_ADDCONST(GL_MAP1_VERTEX_3); + EXPP_ADDCONST(GL_MAP1_VERTEX_4); + EXPP_ADDCONST(GL_MAP2_COLOR_4); + EXPP_ADDCONST(GL_MAP2_INDEX); + EXPP_ADDCONST(GL_MAP2_NORMAL); + EXPP_ADDCONST(GL_MAP2_TEXTURE_COORD_1); + EXPP_ADDCONST(GL_MAP2_TEXTURE_COORD_2); + EXPP_ADDCONST(GL_MAP2_TEXTURE_COORD_3); + EXPP_ADDCONST(GL_MAP2_TEXTURE_COORD_4); + EXPP_ADDCONST(GL_MAP2_VERTEX_3); + EXPP_ADDCONST(GL_MAP2_VERTEX_4); + EXPP_ADDCONST(GL_MAP1_GRID_DOMAIN); + EXPP_ADDCONST(GL_MAP1_GRID_SEGMENTS); + EXPP_ADDCONST(GL_MAP2_GRID_DOMAIN); + EXPP_ADDCONST(GL_MAP2_GRID_SEGMENTS); + EXPP_ADDCONST(GL_TEXTURE_1D); + EXPP_ADDCONST(GL_TEXTURE_2D); + + EXPP_ADDCONST(GL_TEXTURE_WIDTH); + EXPP_ADDCONST(GL_TEXTURE_HEIGHT); + EXPP_ADDCONST(GL_TEXTURE_COMPONENTS); + EXPP_ADDCONST(GL_TEXTURE_BORDER_COLOR); + EXPP_ADDCONST(GL_TEXTURE_BORDER); + + EXPP_ADDCONST(GL_DONT_CARE); + EXPP_ADDCONST(GL_FASTEST); + EXPP_ADDCONST(GL_NICEST); + + EXPP_ADDCONST(GL_AMBIENT); + EXPP_ADDCONST(GL_DIFFUSE); + EXPP_ADDCONST(GL_SPECULAR); + EXPP_ADDCONST(GL_POSITION); + EXPP_ADDCONST(GL_SPOT_DIRECTION); + EXPP_ADDCONST(GL_SPOT_EXPONENT); + EXPP_ADDCONST(GL_SPOT_CUTOFF); + EXPP_ADDCONST(GL_CONSTANT_ATTENUATION); + EXPP_ADDCONST(GL_LINEAR_ATTENUATION); + EXPP_ADDCONST(GL_QUADRATIC_ATTENUATION); + + EXPP_ADDCONST(GL_COMPILE); + EXPP_ADDCONST(GL_COMPILE_AND_EXECUTE); + + EXPP_ADDCONST(GL_BYTE); + EXPP_ADDCONST(GL_UNSIGNED_BYTE); + EXPP_ADDCONST(GL_SHORT); + EXPP_ADDCONST(GL_UNSIGNED_SHORT); + EXPP_ADDCONST(GL_INT); + EXPP_ADDCONST(GL_UNSIGNED_INT); + EXPP_ADDCONST(GL_FLOAT); + EXPP_ADDCONST(GL_DOUBLE); + EXPP_ADDCONST(GL_2_BYTES); + EXPP_ADDCONST(GL_3_BYTES); + EXPP_ADDCONST(GL_4_BYTES); + + EXPP_ADDCONST(GL_CLEAR); + EXPP_ADDCONST(GL_AND); + EXPP_ADDCONST(GL_AND_REVERSE); + EXPP_ADDCONST(GL_COPY); + EXPP_ADDCONST(GL_AND_INVERTED); + EXPP_ADDCONST(GL_NOOP); + EXPP_ADDCONST(GL_XOR); + EXPP_ADDCONST(GL_OR); + EXPP_ADDCONST(GL_NOR); + EXPP_ADDCONST(GL_EQUIV); + EXPP_ADDCONST(GL_INVERT); + EXPP_ADDCONST(GL_OR_REVERSE); + EXPP_ADDCONST(GL_COPY_INVERTED); + EXPP_ADDCONST(GL_OR_INVERTED); + EXPP_ADDCONST(GL_NAND); + EXPP_ADDCONST(GL_SET); + + EXPP_ADDCONST(GL_EMISSION); + EXPP_ADDCONST(GL_SHININESS); + EXPP_ADDCONST(GL_AMBIENT_AND_DIFFUSE); + EXPP_ADDCONST(GL_COLOR_INDEXES); + + EXPP_ADDCONST(GL_MODELVIEW); + EXPP_ADDCONST(GL_PROJECTION); + EXPP_ADDCONST(GL_TEXTURE); + + EXPP_ADDCONST(GL_COLOR); + EXPP_ADDCONST(GL_DEPTH); + EXPP_ADDCONST(GL_STENCIL); + + EXPP_ADDCONST(GL_COLOR_INDEX); + EXPP_ADDCONST(GL_STENCIL_INDEX); + EXPP_ADDCONST(GL_DEPTH_COMPONENT); + EXPP_ADDCONST(GL_RED); + EXPP_ADDCONST(GL_GREEN); + EXPP_ADDCONST(GL_BLUE); + EXPP_ADDCONST(GL_ALPHA); + EXPP_ADDCONST(GL_RGB); + EXPP_ADDCONST(GL_RGBA); + EXPP_ADDCONST(GL_LUMINANCE); + EXPP_ADDCONST(GL_LUMINANCE_ALPHA); + + EXPP_ADDCONST(GL_BITMAP); + + EXPP_ADDCONST(GL_POINT); + EXPP_ADDCONST(GL_LINE); + EXPP_ADDCONST(GL_FILL); + + EXPP_ADDCONST(GL_RENDER); + EXPP_ADDCONST(GL_FEEDBACK); + EXPP_ADDCONST(GL_SELECT); + + EXPP_ADDCONST(GL_FLAT); + EXPP_ADDCONST(GL_SMOOTH); + + EXPP_ADDCONST(GL_KEEP); + EXPP_ADDCONST(GL_REPLACE); + EXPP_ADDCONST(GL_INCR); + EXPP_ADDCONST(GL_DECR); + + EXPP_ADDCONST(GL_VENDOR); + EXPP_ADDCONST(GL_RENDERER); + EXPP_ADDCONST(GL_VERSION); + EXPP_ADDCONST(GL_EXTENSIONS); + + EXPP_ADDCONST(GL_S); + EXPP_ADDCONST(GL_T); + EXPP_ADDCONST(GL_R); + EXPP_ADDCONST(GL_Q); + + EXPP_ADDCONST(GL_MODULATE); + EXPP_ADDCONST(GL_DECAL); + + EXPP_ADDCONST(GL_TEXTURE_ENV_MODE); + EXPP_ADDCONST(GL_TEXTURE_ENV_COLOR); + + EXPP_ADDCONST(GL_TEXTURE_ENV); + + EXPP_ADDCONST(GL_EYE_LINEAR); + EXPP_ADDCONST(GL_OBJECT_LINEAR); + EXPP_ADDCONST(GL_SPHERE_MAP); + + EXPP_ADDCONST(GL_TEXTURE_GEN_MODE); + EXPP_ADDCONST(GL_OBJECT_PLANE); + EXPP_ADDCONST(GL_EYE_PLANE); + + EXPP_ADDCONST(GL_NEAREST); + EXPP_ADDCONST(GL_LINEAR); + + EXPP_ADDCONST(GL_NEAREST_MIPMAP_NEAREST); + EXPP_ADDCONST(GL_LINEAR_MIPMAP_NEAREST); + EXPP_ADDCONST(GL_NEAREST_MIPMAP_LINEAR); + EXPP_ADDCONST(GL_LINEAR_MIPMAP_LINEAR); + + EXPP_ADDCONST(GL_TEXTURE_MAG_FILTER); + EXPP_ADDCONST(GL_TEXTURE_MIN_FILTER); + EXPP_ADDCONST(GL_TEXTURE_WRAP_S); + EXPP_ADDCONST(GL_TEXTURE_WRAP_T); + + EXPP_ADDCONST(GL_CLAMP); + EXPP_ADDCONST(GL_REPEAT); + + EXPP_ADDCONST(GL_CLIP_PLANE0); + EXPP_ADDCONST(GL_CLIP_PLANE1); + EXPP_ADDCONST(GL_CLIP_PLANE2); + EXPP_ADDCONST(GL_CLIP_PLANE3); + EXPP_ADDCONST(GL_CLIP_PLANE4); + EXPP_ADDCONST(GL_CLIP_PLANE5); + + EXPP_ADDCONST(GL_LIGHT0); + EXPP_ADDCONST(GL_LIGHT1); + EXPP_ADDCONST(GL_LIGHT2); + EXPP_ADDCONST(GL_LIGHT3); + EXPP_ADDCONST(GL_LIGHT4); + EXPP_ADDCONST(GL_LIGHT5); + EXPP_ADDCONST(GL_LIGHT6); + EXPP_ADDCONST(GL_LIGHT7); + + EXPP_ADDCONST(GL_POLYGON_OFFSET_UNITS); + EXPP_ADDCONST(GL_POLYGON_OFFSET_POINT); + EXPP_ADDCONST(GL_POLYGON_OFFSET_LINE); + EXPP_ADDCONST(GL_POLYGON_OFFSET_FILL); + EXPP_ADDCONST(GL_POLYGON_OFFSET_FACTOR); + + EXPP_ADDCONST(GL_TEXTURE_PRIORITY); + EXPP_ADDCONST(GL_TEXTURE_RESIDENT); + EXPP_ADDCONST(GL_TEXTURE_BINDING_1D); + EXPP_ADDCONST(GL_TEXTURE_BINDING_2D); + + return mod; +} + diff --git a/source/blender/python/generic/BGL.h b/source/blender/python/generic/BGL.h new file mode 100755 index 00000000000..e2d1b0bb495 --- /dev/null +++ b/source/blender/python/generic/BGL.h @@ -0,0 +1,338 @@ +/* + * $Id: BGL.h 19717 2009-04-14 17:19:09Z campbellbarton $ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * This is a new part of Blender. + * + * Contributor(s): Willian P. Germano + * + * ***** END GPL LICENSE BLOCK ***** +*/ + +/* This is the Blender.BGL part of opy_draw.c, from the old bpython/intern + * dir, with minor changes to adapt it to the new Python implementation. + * The BGL submodule "wraps" OpenGL functions and constants, allowing script + * writers to make OpenGL calls in their Python scripts for Blender. The + * more important original comments are marked with an @ symbol. */ + +#ifndef EXPP_BGL_H +#define EXPP_BGL_H + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <Python.h> +#include <GL/glew.h> +#include "../intern/bpy_compat.h" + +PyObject *BGL_Init( const char *from ); + +/*@ Buffer Object */ +/*@ For Python access to OpenGL functions requiring a pointer. */ + +typedef struct _Buffer { + PyObject_VAR_HEAD + PyObject * parent; + + int type; /* GL_BYTE, GL_SHORT, GL_INT, GL_FLOAT */ + int ndimensions; + int *dimensions; + + union { + char *asbyte; + short *asshort; + int *asint; + float *asfloat; + double *asdouble; + + void *asvoid; + } buf; +} Buffer; + + +/*@ By golly George! It looks like fancy pants macro time!!! */ + +/* +#define int_str "i" +#define int_var(number) bgl_int##number +#define int_ref(number) &bgl_int##number +#define int_def(number) int int_var(number) + +#define float_str "f" +#define float_var(number) bgl_float##number +#define float_ref(number) &bgl_float##number +#define float_def(number) float float_var(number) +*/ + +/* TYPE_str is the string to pass to Py_ArgParse (for the format) */ +/* TYPE_var is the name to pass to the GL function */ +/* TYPE_ref is the pointer to pass to Py_ArgParse (to store in) */ +/* TYPE_def is the C initialization of the variable */ + +#define void_str "" +#define void_var(num) +#define void_ref(num) &bgl_var##num +#define void_def(num) char bgl_var##num + +#define buffer_str "O!" +#define buffer_var(number) (bgl_buffer##number)->buf.asvoid +#define buffer_ref(number) &buffer_Type, &bgl_buffer##number +#define buffer_def(number) Buffer *bgl_buffer##number + +/* GL Pointer fields, handled by buffer type */ +/* GLdoubleP, GLfloatP, GLintP, GLuintP, GLshortP */ + +#define GLbooleanP_str "O!" +#define GLbooleanP_var(number) (bgl_buffer##number)->buf.asvoid +#define GLbooleanP_ref(number) &buffer_Type, &bgl_buffer##number +#define GLbooleanP_def(number) Buffer *bgl_buffer##number + +#define GLbyteP_str "O!" +#define GLbyteP_var(number) (bgl_buffer##number)->buf.asvoid +#define GLbyteP_ref(number) &buffer_Type, &bgl_buffer##number +#define GLbyteP_def(number) Buffer *bgl_buffer##number + +#define GLubyteP_str "O!" +#define GLubyteP_var(number) (bgl_buffer##number)->buf.asvoid +#define GLubyteP_ref(number) &buffer_Type, &bgl_buffer##number +#define GLubyteP_def(number) Buffer *bgl_buffer##number + +#define GLintP_str "O!" +#define GLintP_var(number) (bgl_buffer##number)->buf.asvoid +#define GLintP_ref(number) &buffer_Type, &bgl_buffer##number +#define GLintP_def(number) Buffer *bgl_buffer##number + +#define GLuintP_str "O!" +#define GLuintP_var(number) (bgl_buffer##number)->buf.asvoid +#define GLuintP_ref(number) &buffer_Type, &bgl_buffer##number +#define GLuintP_def(number) Buffer *bgl_buffer##number + +#define GLshortP_str "O!" +#define GLshortP_var(number) (bgl_buffer##number)->buf.asvoid +#define GLshortP_ref(number) &buffer_Type, &bgl_buffer##number +#define GLshortP_def(number) Buffer *bgl_buffer##number + +#define GLushortP_str "O!" +#define GLushortP_var(number) (bgl_buffer##number)->buf.asvoid +#define GLushortP_ref(number) &buffer_Type, &bgl_buffer##number +#define GLushortP_def(number) Buffer *bgl_buffer##number + +#define GLfloatP_str "O!" +#define GLfloatP_var(number) (bgl_buffer##number)->buf.asvoid +#define GLfloatP_ref(number) &buffer_Type, &bgl_buffer##number +#define GLfloatP_def(number) Buffer *bgl_buffer##number + +#define GLdoubleP_str "O!" +#define GLdoubleP_var(number) (bgl_buffer##number)->buf.asvoid +#define GLdoubleP_ref(number) &buffer_Type, &bgl_buffer##number +#define GLdoubleP_def(number) Buffer *bgl_buffer##number + +#define GLclampfP_str "O!" +#define GLclampfP_var(number) (bgl_buffer##number)->buf.asvoid +#define GLclampfP_ref(number) &buffer_Type, &bgl_buffer##number +#define GLclampfP_def(number) Buffer *bgl_buffer##number + +#define GLvoidP_str "O!" +#define GLvoidP_var(number) (bgl_buffer##number)->buf.asvoid +#define GLvoidP_ref(number) &buffer_Type, &bgl_buffer##number +#define GLvoidP_def(number) Buffer *bgl_buffer##number + +#define buffer_str "O!" +#define buffer_var(number) (bgl_buffer##number)->buf.asvoid +#define buffer_ref(number) &buffer_Type, &bgl_buffer##number +#define buffer_def(number) Buffer *bgl_buffer##number + +/*@The standard GL typedefs are used as prototypes, we can't + * use the GL type directly because Py_ArgParse expects normal + * C types. + * + * Py_ArgParse doesn't grok writing into unsigned variables, + * so we use signed everything (even stuff that should be unsigned. + */ + +/* typedef unsigned int GLenum; */ +#define GLenum_str "i" +#define GLenum_var(num) bgl_var##num +#define GLenum_ref(num) &bgl_var##num +#define GLenum_def(num) /* unsigned */ int GLenum_var(num) + +/* typedef unsigned int GLboolean; */ +#define GLboolean_str "b" +#define GLboolean_var(num) bgl_var##num +#define GLboolean_ref(num) &bgl_var##num +#define GLboolean_def(num) /* unsigned */ char GLboolean_var(num) + +/* typedef unsigned int GLbitfield; */ +#define GLbitfield_str "i" +#define GLbitfield_var(num) bgl_var##num +#define GLbitfield_ref(num) &bgl_var##num +#define GLbitfield_def(num) /* unsigned */ int GLbitfield_var(num) + +/* typedef signed char GLbyte; */ +#define GLbyte_str "b" +#define GLbyte_var(num) bgl_var##num +#define GLbyte_ref(num) &bgl_var##num +#define GLbyte_def(num) signed char GLbyte_var(num) + +/* typedef short GLshort; */ +#define GLshort_str "h" +#define GLshort_var(num) bgl_var##num +#define GLshort_ref(num) &bgl_var##num +#define GLshort_def(num) short GLshort_var(num) + +/* typedef int GLint; */ +#define GLint_str "i" +#define GLint_var(num) bgl_var##num +#define GLint_ref(num) &bgl_var##num +#define GLint_def(num) int GLint_var(num) + +/* typedef int GLsizei; */ +#define GLsizei_str "i" +#define GLsizei_var(num) bgl_var##num +#define GLsizei_ref(num) &bgl_var##num +#define GLsizei_def(num) int GLsizei_var(num) + +/* typedef unsigned char GLubyte; */ +#define GLubyte_str "b" +#define GLubyte_var(num) bgl_var##num +#define GLubyte_ref(num) &bgl_var##num +#define GLubyte_def(num) /* unsigned */ char GLubyte_var(num) + +/* typedef unsigned short GLushort; */ +#define GLushort_str "h" +#define GLushort_var(num) bgl_var##num +#define GLushort_ref(num) &bgl_var##num +#define GLushort_def(num) /* unsigned */ short GLushort_var(num) + +/* typedef unsigned int GLuint; */ +#define GLuint_str "i" +#define GLuint_var(num) bgl_var##num +#define GLuint_ref(num) &bgl_var##num +#define GLuint_def(num) /* unsigned */ int GLuint_var(num) + +/* typedef float GLfloat; */ +#define GLfloat_str "f" +#define GLfloat_var(num) bgl_var##num +#define GLfloat_ref(num) &bgl_var##num +#define GLfloat_def(num) float GLfloat_var(num) + +/* typedef float GLclampf; */ +#define GLclampf_str "f" +#define GLclampf_var(num) bgl_var##num +#define GLclampf_ref(num) &bgl_var##num +#define GLclampf_def(num) float GLclampf_var(num) + +/* typedef double GLdouble; */ +#define GLdouble_str "d" +#define GLdouble_var(num) bgl_var##num +#define GLdouble_ref(num) &bgl_var##num +#define GLdouble_def(num) double GLdouble_var(num) + +/* typedef double GLclampd; */ +#define GLclampd_str "d" +#define GLclampd_var(num) bgl_var##num +#define GLclampd_ref(num) &bgl_var##num +#define GLclampd_def(num) double GLclampd_var(num) + +/* typedef void GLvoid; */ +/* #define GLvoid_str "" */ +/* #define GLvoid_var(num) bgl_var##num */ +/* #define GLvoid_ref(num) &bgl_var##num */ +/* #define GLvoid_def(num) char bgl_var##num */ + +#define arg_def1(a1) a1##_def(1) +#define arg_def2(a1, a2) arg_def1(a1); a2##_def(2) +#define arg_def3(a1, a2, a3) arg_def2(a1, a2); a3##_def(3) +#define arg_def4(a1, a2, a3, a4) arg_def3(a1, a2, a3); a4##_def(4) +#define arg_def5(a1, a2, a3, a4, a5) arg_def4(a1, a2, a3, a4); a5##_def(5) +#define arg_def6(a1, a2, a3, a4, a5, a6)arg_def5(a1, a2, a3, a4, a5); a6##_def(6) +#define arg_def7(a1, a2, a3, a4, a5, a6, a7)arg_def6(a1, a2, a3, a4, a5, a6); a7##_def(7) +#define arg_def8(a1, a2, a3, a4, a5, a6, a7, a8)arg_def7(a1, a2, a3, a4, a5, a6, a7); a8##_def(8) +#define arg_def9(a1, a2, a3, a4, a5, a6, a7, a8, a9)arg_def8(a1, a2, a3, a4, a5, a6, a7, a8); a9##_def(9) +#define arg_def10(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)arg_def9(a1, a2, a3, a4, a5, a6, a7, a8, a9); a10##_def(10) + +#define arg_var1(a1) a1##_var(1) +#define arg_var2(a1, a2) arg_var1(a1), a2##_var(2) +#define arg_var3(a1, a2, a3) arg_var2(a1, a2), a3##_var(3) +#define arg_var4(a1, a2, a3, a4) arg_var3(a1, a2, a3), a4##_var(4) +#define arg_var5(a1, a2, a3, a4, a5) arg_var4(a1, a2, a3, a4), a5##_var(5) +#define arg_var6(a1, a2, a3, a4, a5, a6)arg_var5(a1, a2, a3, a4, a5), a6##_var(6) +#define arg_var7(a1, a2, a3, a4, a5, a6, a7)arg_var6(a1, a2, a3, a4, a5, a6), a7##_var(7) +#define arg_var8(a1, a2, a3, a4, a5, a6, a7, a8)arg_var7(a1, a2, a3, a4, a5, a6, a7), a8##_var(8) +#define arg_var9(a1, a2, a3, a4, a5, a6, a7, a8, a9)arg_var8(a1, a2, a3, a4, a5, a6, a7, a8), a9##_var(9) +#define arg_var10(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)arg_var9(a1, a2, a3, a4, a5, a6, a7, a8, a9), a10##_var(10) + +#define arg_ref1(a1) a1##_ref(1) +#define arg_ref2(a1, a2) arg_ref1(a1), a2##_ref(2) +#define arg_ref3(a1, a2, a3) arg_ref2(a1, a2), a3##_ref(3) +#define arg_ref4(a1, a2, a3, a4) arg_ref3(a1, a2, a3), a4##_ref(4) +#define arg_ref5(a1, a2, a3, a4, a5) arg_ref4(a1, a2, a3, a4), a5##_ref(5) +#define arg_ref6(a1, a2, a3, a4, a5, a6)arg_ref5(a1, a2, a3, a4, a5), a6##_ref(6) +#define arg_ref7(a1, a2, a3, a4, a5, a6, a7)arg_ref6(a1, a2, a3, a4, a5, a6), a7##_ref(7) +#define arg_ref8(a1, a2, a3, a4, a5, a6, a7, a8)arg_ref7(a1, a2, a3, a4, a5, a6, a7), a8##_ref(8) +#define arg_ref9(a1, a2, a3, a4, a5, a6, a7, a8, a9)arg_ref8(a1, a2, a3, a4, a5, a6, a7, a8), a9##_ref(9) +#define arg_ref10(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)arg_ref9(a1, a2, a3, a4, a5, a6, a7, a8, a9), a10##_ref(10) + +#define arg_str1(a1) a1##_str +#define arg_str2(a1, a2) arg_str1(a1) a2##_str +#define arg_str3(a1, a2, a3) arg_str2(a1, a2) a3##_str +#define arg_str4(a1, a2, a3, a4) arg_str3(a1, a2, a3) a4##_str +#define arg_str5(a1, a2, a3, a4, a5) arg_str4(a1, a2, a3, a4) a5##_str +#define arg_str6(a1, a2, a3, a4, a5, a6)arg_str5(a1, a2, a3, a4, a5) a6##_str +#define arg_str7(a1, a2, a3, a4, a5, a6, a7)arg_str6(a1, a2, a3, a4, a5, a6) a7##_str +#define arg_str8(a1, a2, a3, a4, a5, a6, a7, a8)arg_str7(a1, a2, a3, a4, a5, a6, a7) a8##_str +#define arg_str9(a1, a2, a3, a4, a5, a6, a7, a8, a9)arg_str8(a1, a2, a3, a4, a5, a6, a7, a8) a9##_str +#define arg_str10(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)arg_str9(a1, a2, a3, a4, a5, a6, a7, a8, a9) a10##_str + +#define ret_def_void +#define ret_set_void +/* would use Py_RETURN_NONE - except for py 2.3 doesnt have it */ +#define ret_ret_void { Py_INCREF(Py_None); return Py_None; } + +#define ret_def_GLint int ret_int +#define ret_set_GLint ret_int= +#define ret_ret_GLint return PyLong_FromLong(ret_int); + +#define ret_def_GLuint unsigned int ret_uint +#define ret_set_GLuint ret_uint= +#define ret_ret_GLuint return PyLong_FromLong((long) ret_uint); + +#define ret_def_GLenum unsigned int ret_uint +#define ret_set_GLenum ret_uint= +#define ret_ret_GLenum return PyLong_FromLong((long) ret_uint); + +#define ret_def_GLboolean unsigned char ret_bool +#define ret_set_GLboolean ret_bool= +#define ret_ret_GLboolean return PyLong_FromLong((long) ret_bool); + +#define ret_def_GLstring const unsigned char *ret_str; +#define ret_set_GLstring ret_str= + +#define ret_ret_GLstring \ + if (ret_str) {\ + return PyUnicode_FromString(ret_str);\ + } else {\ + PyErr_SetString(PyExc_AttributeError, "could not get opengl string");\ + return NULL;\ + } + +#endif /* EXPP_BGL_H */ diff --git a/source/blender/python/generic/Geometry.c b/source/blender/python/generic/Geometry.c new file mode 100644 index 00000000000..d1e8b471f75 --- /dev/null +++ b/source/blender/python/generic/Geometry.c @@ -0,0 +1,522 @@ +/* + * $Id: Geometry.c 20922 2009-06-16 07:16:51Z campbellbarton $ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * This is a new part of Blender. + * + * Contributor(s): Joseph Gilbert, Campbell Barton + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "Geometry.h" + +/* - Not needed for now though other geometry functions will probably need them +#include "BLI_arithb.h" +#include "BKE_utildefines.h" +*/ + +/* Used for PolyFill */ +#include "BKE_displist.h" +#include "MEM_guardedalloc.h" +#include "BLI_blenlib.h" + +#include "BKE_utildefines.h" +#include "BKE_curve.h" +#include "BLI_boxpack2d.h" +#include "BLI_arithb.h" + +#define SWAP_FLOAT(a,b,tmp) tmp=a; a=b; b=tmp +#define eul 0.000001 + +/*-- forward declarations -- */ +static PyObject *M_Geometry_PolyFill( PyObject * self, PyObject * polyLineSeq ); +static PyObject *M_Geometry_LineIntersect2D( PyObject * self, PyObject * args ); +static PyObject *M_Geometry_ClosestPointOnLine( PyObject * self, PyObject * args ); +static PyObject *M_Geometry_PointInTriangle2D( PyObject * self, PyObject * args ); +static PyObject *M_Geometry_PointInQuad2D( PyObject * self, PyObject * args ); +static PyObject *M_Geometry_BoxPack2D( PyObject * self, PyObject * args ); +static PyObject *M_Geometry_BezierInterp( PyObject * self, PyObject * args ); + + +/*-------------------------DOC STRINGS ---------------------------*/ +static char M_Geometry_doc[] = "The Blender Geometry module\n\n"; +static char M_Geometry_PolyFill_doc[] = "(veclist_list) - takes a list of polylines (each point a vector) and returns the point indicies for a polyline filled with triangles"; +static char M_Geometry_LineIntersect2D_doc[] = "(lineA_p1, lineA_p2, lineB_p1, lineB_p2) - takes 2 lines (as 4 vectors) and returns a vector for their point of intersection or None"; +static char M_Geometry_ClosestPointOnLine_doc[] = "(pt, line_p1, line_p2) - takes a point and a line and returns a (Vector, float) for the point on the line, and the bool so you can know if the point was between the 2 points"; +static char M_Geometry_PointInTriangle2D_doc[] = "(pt, tri_p1, tri_p2, tri_p3) - takes 4 vectors, one is the point and the next 3 define the triangle, only the x and y are used from the vectors"; +static char M_Geometry_PointInQuad2D_doc[] = "(pt, quad_p1, quad_p2, quad_p3, quad_p4) - takes 5 vectors, one is the point and the next 4 define the quad, only the x and y are used from the vectors"; +static char M_Geometry_BoxPack2D_doc[] = ""; +static char M_Geometry_BezierInterp_doc[] = ""; +/*-----------------------METHOD DEFINITIONS ----------------------*/ +struct PyMethodDef M_Geometry_methods[] = { + {"PolyFill", ( PyCFunction ) M_Geometry_PolyFill, METH_O, M_Geometry_PolyFill_doc}, + {"LineIntersect2D", ( PyCFunction ) M_Geometry_LineIntersect2D, METH_VARARGS, M_Geometry_LineIntersect2D_doc}, + {"ClosestPointOnLine", ( PyCFunction ) M_Geometry_ClosestPointOnLine, METH_VARARGS, M_Geometry_ClosestPointOnLine_doc}, + {"PointInTriangle2D", ( PyCFunction ) M_Geometry_PointInTriangle2D, METH_VARARGS, M_Geometry_PointInTriangle2D_doc}, + {"PointInQuad2D", ( PyCFunction ) M_Geometry_PointInQuad2D, METH_VARARGS, M_Geometry_PointInQuad2D_doc}, + {"BoxPack2D", ( PyCFunction ) M_Geometry_BoxPack2D, METH_O, M_Geometry_BoxPack2D_doc}, + {"BezierInterp", ( PyCFunction ) M_Geometry_BezierInterp, METH_VARARGS, M_Geometry_BezierInterp_doc}, + {NULL, NULL, 0, NULL} +}; + +#if (PY_VERSION_HEX >= 0x03000000) +static struct PyModuleDef M_Geometry_module_def = { + {}, /* m_base */ + "Geometry", /* m_name */ + M_Geometry_doc, /* m_doc */ + 0, /* m_size */ + M_Geometry_methods, /* m_methods */ + 0, /* m_reload */ + 0, /* m_traverse */ + 0, /* m_clear */ + 0, /* m_free */ +}; +#endif + +/*----------------------------MODULE INIT-------------------------*/ +PyObject *Geometry_Init(const char *from) +{ + PyObject *submodule; + +#if (PY_VERSION_HEX >= 0x03000000) + submodule = PyModule_Create(&M_Geometry_module_def); + PyDict_SetItemString(PySys_GetObject("modules"), M_Geometry_module_def.m_name, submodule); +#else + submodule = Py_InitModule3(from, M_Geometry_methods, M_Geometry_doc); +#endif + + return (submodule); +} + +/*----------------------------------Geometry.PolyFill() -------------------*/ +/* PolyFill function, uses Blenders scanfill to fill multiple poly lines */ +static PyObject *M_Geometry_PolyFill( PyObject * self, PyObject * polyLineSeq ) +{ + PyObject *tri_list; /*return this list of tri's */ + PyObject *polyLine, *polyVec; + int i, len_polylines, len_polypoints, ls_error = 0; + + /* display listbase */ + ListBase dispbase={NULL, NULL}; + DispList *dl; + float *fp; /*pointer to the array of malloced dl->verts to set the points from the vectors */ + int index, *dl_face, totpoints=0; + + + dispbase.first= dispbase.last= NULL; + + + if(!PySequence_Check(polyLineSeq)) { + PyErr_SetString( PyExc_TypeError, "expected a sequence of poly lines" ); + return NULL; + } + + len_polylines = PySequence_Size( polyLineSeq ); + + for( i = 0; i < len_polylines; ++i ) { + polyLine= PySequence_GetItem( polyLineSeq, i ); + if (!PySequence_Check(polyLine)) { + freedisplist(&dispbase); + Py_XDECREF(polyLine); /* may be null so use Py_XDECREF*/ + PyErr_SetString( PyExc_TypeError, "One or more of the polylines is not a sequence of Mathutils.Vector's" ); + return NULL; + } + + len_polypoints= PySequence_Size( polyLine ); + if (len_polypoints>0) { /* dont bother adding edges as polylines */ +#if 0 + if (EXPP_check_sequence_consistency( polyLine, &vector_Type ) != 1) { + freedisplist(&dispbase); + Py_DECREF(polyLine); + PyErr_SetString( PyExc_TypeError, "A point in one of the polylines is not a Mathutils.Vector type" ); + return NULL; + } +#endif + dl= MEM_callocN(sizeof(DispList), "poly disp"); + BLI_addtail(&dispbase, dl); + dl->type= DL_INDEX3; + dl->nr= len_polypoints; + dl->type= DL_POLY; + dl->parts= 1; /* no faces, 1 edge loop */ + dl->col= 0; /* no material */ + dl->verts= fp= MEM_callocN( sizeof(float)*3*len_polypoints, "dl verts"); + dl->index= MEM_callocN(sizeof(int)*3*len_polypoints, "dl index"); + + for( index = 0; index<len_polypoints; ++index, fp+=3) { + polyVec= PySequence_GetItem( polyLine, index ); + if(VectorObject_Check(polyVec)) { + fp[0] = ((VectorObject *)polyVec)->vec[0]; + fp[1] = ((VectorObject *)polyVec)->vec[1]; + if( ((VectorObject *)polyVec)->size > 2 ) + fp[2] = ((VectorObject *)polyVec)->vec[2]; + else + fp[2]= 0.0f; /* if its a 2d vector then set the z to be zero */ + } + else { + ls_error= 1; + } + + totpoints++; + Py_DECREF(polyVec); + } + } + Py_DECREF(polyLine); + } + + if(ls_error) { + freedisplist(&dispbase); /* possible some dl was allocated */ + PyErr_SetString( PyExc_TypeError, "A point in one of the polylines is not a Mathutils.Vector type" ); + return NULL; + } + else if (totpoints) { + /* now make the list to return */ + filldisplist(&dispbase, &dispbase); + + /* The faces are stored in a new DisplayList + thats added to the head of the listbase */ + dl= dispbase.first; + + tri_list= PyList_New(dl->parts); + if( !tri_list ) { + freedisplist(&dispbase); + PyErr_SetString( PyExc_RuntimeError, "Geometry.PolyFill failed to make a new list" ); + return NULL; + } + + index= 0; + dl_face= dl->index; + while(index < dl->parts) { + PyList_SetItem(tri_list, index, Py_BuildValue("iii", dl_face[0], dl_face[1], dl_face[2]) ); + dl_face+= 3; + index++; + } + freedisplist(&dispbase); + } else { + /* no points, do this so scripts dont barf */ + freedisplist(&dispbase); /* possible some dl was allocated */ + tri_list= PyList_New(0); + } + + return tri_list; +} + + +static PyObject *M_Geometry_LineIntersect2D( PyObject * self, PyObject * args ) +{ + VectorObject *line_a1, *line_a2, *line_b1, *line_b2; + float a1x, a1y, a2x, a2y, b1x, b1y, b2x, b2y, xi, yi, a1,a2,b1,b2, newvec[2]; + if( !PyArg_ParseTuple ( args, "O!O!O!O!", + &vector_Type, &line_a1, + &vector_Type, &line_a2, + &vector_Type, &line_b1, + &vector_Type, &line_b2) + ) { + PyErr_SetString( PyExc_TypeError, "expected 4 vector types\n" ); + return NULL; + } + + a1x= line_a1->vec[0]; + a1y= line_a1->vec[1]; + a2x= line_a2->vec[0]; + a2y= line_a2->vec[1]; + + b1x= line_b1->vec[0]; + b1y= line_b1->vec[1]; + b2x= line_b2->vec[0]; + b2y= line_b2->vec[1]; + + if((MIN2(a1x, a2x) > MAX2(b1x, b2x)) || + (MAX2(a1x, a2x) < MIN2(b1x, b2x)) || + (MIN2(a1y, a2y) > MAX2(b1y, b2y)) || + (MAX2(a1y, a2y) < MIN2(b1y, b2y)) ) { + Py_RETURN_NONE; + } + /* Make sure the hoz/vert line comes first. */ + if (fabs(b1x - b2x) < eul || fabs(b1y - b2y) < eul) { + SWAP_FLOAT(a1x, b1x, xi); /*abuse xi*/ + SWAP_FLOAT(a1y, b1y, xi); + SWAP_FLOAT(a2x, b2x, xi); + SWAP_FLOAT(a2y, b2y, xi); + } + + if (fabs(a1x-a2x) < eul) { /* verticle line */ + if (fabs(b1x-b2x) < eul){ /*verticle second line */ + Py_RETURN_NONE; /* 2 verticle lines dont intersect. */ + } + else if (fabs(b1y-b2y) < eul) { + /*X of vert, Y of hoz. no calculation needed */ + newvec[0]= a1x; + newvec[1]= b1y; + return newVectorObject(newvec, 2, Py_NEW); + } + + yi = (float)(((b1y / fabs(b1x - b2x)) * fabs(b2x - a1x)) + ((b2y / fabs(b1x - b2x)) * fabs(b1x - a1x))); + + if (yi > MAX2(a1y, a2y)) {/* New point above seg1's vert line */ + Py_RETURN_NONE; + } else if (yi < MIN2(a1y, a2y)) { /* New point below seg1's vert line */ + Py_RETURN_NONE; + } + newvec[0]= a1x; + newvec[1]= yi; + return newVectorObject(newvec, 2, Py_NEW); + } else if (fabs(a2y-a1y) < eul) { /* hoz line1 */ + if (fabs(b2y-b1y) < eul) { /*hoz line2*/ + Py_RETURN_NONE; /*2 hoz lines dont intersect*/ + } + + /* Can skip vert line check for seg 2 since its covered above. */ + xi = (float)(((b1x / fabs(b1y - b2y)) * fabs(b2y - a1y)) + ((b2x / fabs(b1y - b2y)) * fabs(b1y - a1y))); + if (xi > MAX2(a1x, a2x)) { /* New point right of hoz line1's */ + Py_RETURN_NONE; + } else if (xi < MIN2(a1x, a2x)) { /*New point left of seg1's hoz line */ + Py_RETURN_NONE; + } + newvec[0]= xi; + newvec[1]= a1y; + return newVectorObject(newvec, 2, Py_NEW); + } + + b1 = (a2y-a1y)/(a2x-a1x); + b2 = (b2y-b1y)/(b2x-b1x); + a1 = a1y-b1*a1x; + a2 = b1y-b2*b1x; + + if (b1 - b2 == 0.0) { + Py_RETURN_NONE; + } + + xi = - (a1-a2)/(b1-b2); + yi = a1+b1*xi; + if ((a1x-xi)*(xi-a2x) >= 0 && (b1x-xi)*(xi-b2x) >= 0 && (a1y-yi)*(yi-a2y) >= 0 && (b1y-yi)*(yi-b2y)>=0) { + newvec[0]= xi; + newvec[1]= yi; + return newVectorObject(newvec, 2, Py_NEW); + } + Py_RETURN_NONE; +} + +static PyObject *M_Geometry_ClosestPointOnLine( PyObject * self, PyObject * args ) +{ + VectorObject *pt, *line_1, *line_2; + float pt_in[3], pt_out[3], l1[3], l2[3]; + float lambda; + PyObject *ret; + + if( !PyArg_ParseTuple ( args, "O!O!O!", + &vector_Type, &pt, + &vector_Type, &line_1, + &vector_Type, &line_2) + ) { + PyErr_SetString( PyExc_TypeError, "expected 3 vector types\n" ); + return NULL; + } + /* accept 2d verts */ + if (pt->size==3) { VECCOPY(pt_in, pt->vec);} + else { pt_in[2]=0.0; VECCOPY2D(pt_in, pt->vec) } + + if (line_1->size==3) { VECCOPY(l1, line_1->vec);} + else { l1[2]=0.0; VECCOPY2D(l1, line_1->vec) } + + if (line_2->size==3) { VECCOPY(l2, line_2->vec);} + else { l2[2]=0.0; VECCOPY2D(l2, line_2->vec) } + + /* do the calculation */ + lambda = lambda_cp_line_ex(pt_in, l1, l2, pt_out); + + ret = PyTuple_New(2); + PyTuple_SET_ITEM( ret, 0, newVectorObject(pt_out, 3, Py_NEW) ); + PyTuple_SET_ITEM( ret, 1, PyFloat_FromDouble(lambda) ); + return ret; +} + +static PyObject *M_Geometry_PointInTriangle2D( PyObject * self, PyObject * args ) +{ + VectorObject *pt_vec, *tri_p1, *tri_p2, *tri_p3; + + if( !PyArg_ParseTuple ( args, "O!O!O!O!", + &vector_Type, &pt_vec, + &vector_Type, &tri_p1, + &vector_Type, &tri_p2, + &vector_Type, &tri_p3) + ) { + PyErr_SetString( PyExc_TypeError, "expected 4 vector types\n" ); + return NULL; + } + + return PyLong_FromLong(IsectPT2Df(pt_vec->vec, tri_p1->vec, tri_p2->vec, tri_p3->vec)); +} + +static PyObject *M_Geometry_PointInQuad2D( PyObject * self, PyObject * args ) +{ + VectorObject *pt_vec, *quad_p1, *quad_p2, *quad_p3, *quad_p4; + + if( !PyArg_ParseTuple ( args, "O!O!O!O!O!", + &vector_Type, &pt_vec, + &vector_Type, &quad_p1, + &vector_Type, &quad_p2, + &vector_Type, &quad_p3, + &vector_Type, &quad_p4) + ) { + PyErr_SetString( PyExc_TypeError, "expected 5 vector types\n" ); + return NULL; + } + + return PyLong_FromLong(IsectPQ2Df(pt_vec->vec, quad_p1->vec, quad_p2->vec, quad_p3->vec, quad_p4->vec)); +} + +static int boxPack_FromPyObject(PyObject * value, boxPack **boxarray ) +{ + int len, i; + PyObject *list_item, *item_1, *item_2; + boxPack *box; + + + /* Error checking must alredy be done */ + if( !PyList_Check( value ) ) { + PyErr_SetString( PyExc_TypeError, "can only back a list of [x,y,x,w]" ); + return -1; + } + + len = PyList_Size( value ); + + (*boxarray) = MEM_mallocN( len*sizeof(boxPack), "boxPack box"); + + + for( i = 0; i < len; i++ ) { + list_item = PyList_GET_ITEM( value, i ); + if( !PyList_Check( list_item ) || PyList_Size( list_item ) < 4 ) { + MEM_freeN(*boxarray); + PyErr_SetString( PyExc_TypeError, "can only back a list of [x,y,x,w]" ); + return -1; + } + + box = (*boxarray)+i; + + item_1 = PyList_GET_ITEM(list_item, 2); + item_2 = PyList_GET_ITEM(list_item, 3); + + if (!PyNumber_Check(item_1) || !PyNumber_Check(item_2)) { + MEM_freeN(*boxarray); + PyErr_SetString( PyExc_TypeError, "can only back a list of 2d boxes [x,y,x,w]" ); + return -1; + } + + box->w = (float)PyFloat_AsDouble( item_1 ); + box->h = (float)PyFloat_AsDouble( item_2 ); + box->index = i; + /* verts will be added later */ + } + return 0; +} + +static void boxPack_ToPyObject(PyObject * value, boxPack **boxarray) +{ + int len, i; + PyObject *list_item; + boxPack *box; + + len = PyList_Size( value ); + + for( i = 0; i < len; i++ ) { + box = (*boxarray)+i; + list_item = PyList_GET_ITEM( value, box->index ); + PyList_SET_ITEM( list_item, 0, PyFloat_FromDouble( box->x )); + PyList_SET_ITEM( list_item, 1, PyFloat_FromDouble( box->y )); + } + MEM_freeN(*boxarray); +} + + +static PyObject *M_Geometry_BoxPack2D( PyObject * self, PyObject * boxlist ) +{ + boxPack *boxarray = NULL; + float tot_width, tot_height; + int len; + int error; + + if(!PyList_Check(boxlist)) { + PyErr_SetString( PyExc_TypeError, "expected a sequence of boxes [[x,y,w,h], ... ]" ); + return NULL; + } + + len = PyList_Size( boxlist ); + + if (!len) + return Py_BuildValue( "ff", 0.0, 0.0); + + error = boxPack_FromPyObject(boxlist, &boxarray); + if (error!=0) return NULL; + + /* Non Python function */ + boxPack2D(boxarray, len, &tot_width, &tot_height); + + boxPack_ToPyObject(boxlist, &boxarray); + + return Py_BuildValue( "ff", tot_width, tot_height); +} + +static PyObject *M_Geometry_BezierInterp( PyObject * self, PyObject * args ) +{ + VectorObject *vec_k1, *vec_h1, *vec_k2, *vec_h2; + int resolu; + int dims; + int i; + float *coord_array, *fp; + PyObject *list; + + float k1[4] = {0.0, 0.0, 0.0, 0.0}; + float h1[4] = {0.0, 0.0, 0.0, 0.0}; + float k2[4] = {0.0, 0.0, 0.0, 0.0}; + float h2[4] = {0.0, 0.0, 0.0, 0.0}; + + + if( !PyArg_ParseTuple ( args, "O!O!O!O!i", + &vector_Type, &vec_k1, + &vector_Type, &vec_h1, + &vector_Type, &vec_h2, + &vector_Type, &vec_k2, &resolu) || (resolu<=1) + ) { + PyErr_SetString( PyExc_TypeError, "expected 4 vector types and an int greater then 1\n" ); + return NULL; + } + + dims= MAX4(vec_k1->size, vec_h1->size, vec_h2->size, vec_k2->size); + + for(i=0; i < vec_k1->size; i++) k1[i]= vec_k1->vec[i]; + for(i=0; i < vec_h1->size; i++) h1[i]= vec_h1->vec[i]; + for(i=0; i < vec_k2->size; i++) k2[i]= vec_k2->vec[i]; + for(i=0; i < vec_h2->size; i++) h2[i]= vec_h2->vec[i]; + + coord_array = MEM_callocN(dims * (resolu) * sizeof(float), "BezierInterp"); + for(i=0; i<dims; i++) { + forward_diff_bezier(k1[i], h1[i], h2[i], k2[i], coord_array+i, resolu-1, dims); + } + + list= PyList_New(resolu); + fp= coord_array; + for(i=0; i<resolu; i++, fp= fp+dims) { + PyList_SET_ITEM(list, i, newVectorObject(fp, dims, Py_NEW)); + } + MEM_freeN(coord_array); + return list; +} diff --git a/source/blender/python/generic/Geometry.h b/source/blender/python/generic/Geometry.h new file mode 100644 index 00000000000..d7292e31fac --- /dev/null +++ b/source/blender/python/generic/Geometry.h @@ -0,0 +1,39 @@ +/* + * $Id: Geometry.h 20007 2009-04-30 12:45:13Z campbellbarton $ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * This is a new part of Blender. + * + * Contributor(s): Joseph Gilbert + * + * ***** END GPL LICENSE BLOCK ***** +*/ +/*Include this file for access to vector, quat, matrix, euler, etc...*/ + +#ifndef EXPP_Geometry_H +#define EXPP_Geometry_H + +#include <Python.h> +#include "Mathutils.h" + +PyObject *Geometry_Init( const char *from ); + +#endif /* EXPP_Geometry_H */ diff --git a/source/blender/python/generic/Makefile b/source/blender/python/generic/Makefile new file mode 100644 index 00000000000..20cf7f19ec7 --- /dev/null +++ b/source/blender/python/generic/Makefile @@ -0,0 +1,66 @@ +# +# $Id: Makefile 11904 2007-08-31 16:16:33Z sirdude $ +# +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. +# All rights reserved. +# +# The Original Code is: all of this file. +# +# Contributor(s): none yet. +# +# ***** END GPL LICENSE BLOCK ***** +# +# + +LIBNAME = gen_python +DIR = $(OCGDIR)/blender/$(LIBNAME) + +include nan_compile.mk + +CFLAGS += $(LEVEL_1_C_WARNINGS) + +# OpenGL and Python +CPPFLAGS += -I$(NAN_GLEW)/include +CPPFLAGS += $(OGL_CPPFLAGS) +CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) + +# PreProcessor stuff + +CPPFLAGS += -I$(NAN_GHOST)/include +CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include $(NAN_SDLCFLAGS) + +# modules +CPPFLAGS += -I../../editors/include +CPPFLAGS += -I../../python +CPPFLAGS += -I../../makesdna +CPPFLAGS += -I../../makesrna +CPPFLAGS += -I../../blenlib +CPPFLAGS += -I../../blenkernel +CPPFLAGS += -I../../nodes +CPPFLAGS += -I../../imbuf +CPPFLAGS += -I../../blenloader +CPPFLAGS += -I../../windowmanager +CPPFLAGS += -I../../render/extern/include + +# path to the guarded memory allocator +CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include +CPPFLAGS += -I$(NAN_MEMUTIL)/include + +# path to our own headerfiles +CPPFLAGS += -I.. diff --git a/source/blender/python/generic/Mathutils.c b/source/blender/python/generic/Mathutils.c new file mode 100644 index 00000000000..3c34a369baf --- /dev/null +++ b/source/blender/python/generic/Mathutils.c @@ -0,0 +1,1170 @@ +/* + * $Id: Mathutils.c 20922 2009-06-16 07:16:51Z campbellbarton $ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * This is a new part of Blender. + * + * Contributor(s): Joseph Gilbert, Campbell Barton + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "Mathutils.h" + +#include "BLI_arithb.h" +#include "PIL_time.h" +#include "BLI_rand.h" +#include "BKE_utildefines.h" + +//-------------------------DOC STRINGS --------------------------- +static char M_Mathutils_doc[] = "The Blender Mathutils module\n\n"; +static char M_Mathutils_Rand_doc[] = "() - return a random number"; +static char M_Mathutils_AngleBetweenVecs_doc[] = "() - returns the angle between two vectors in degrees"; +static char M_Mathutils_MidpointVecs_doc[] = "() - return the vector to the midpoint between two vectors"; +static char M_Mathutils_ProjectVecs_doc[] = "() - returns the projection vector from the projection of vecA onto vecB"; +static char M_Mathutils_RotationMatrix_doc[] = "() - construct a rotation matrix from an angle and axis of rotation"; +static char M_Mathutils_ScaleMatrix_doc[] = "() - construct a scaling matrix from a scaling factor"; +static char M_Mathutils_OrthoProjectionMatrix_doc[] = "() - construct a orthographic projection matrix from a selected plane"; +static char M_Mathutils_ShearMatrix_doc[] = "() - construct a shearing matrix from a plane of shear and a shear factor"; +static char M_Mathutils_TranslationMatrix_doc[] = "(vec) - create a translation matrix from a vector"; +static char M_Mathutils_Slerp_doc[] = "() - returns the interpolation between two quaternions"; +static char M_Mathutils_DifferenceQuats_doc[] = "() - return the angular displacment difference between two quats"; +static char M_Mathutils_Intersect_doc[] = "(v1, v2, v3, ray, orig, clip=1) - returns the intersection between a ray and a triangle, if possible, returns None otherwise"; +static char M_Mathutils_TriangleArea_doc[] = "(v1, v2, v3) - returns the area size of the 2D or 3D triangle defined"; +static char M_Mathutils_TriangleNormal_doc[] = "(v1, v2, v3) - returns the normal of the 3D triangle defined"; +static char M_Mathutils_QuadNormal_doc[] = "(v1, v2, v3, v4) - returns the normal of the 3D quad defined"; +static char M_Mathutils_LineIntersect_doc[] = "(v1, v2, v3, v4) - returns a tuple with the points on each line respectively closest to the other"; +//-----------------------METHOD DEFINITIONS ---------------------- + +static PyObject *M_Mathutils_Rand(PyObject * self, PyObject * args); +static PyObject *M_Mathutils_AngleBetweenVecs(PyObject * self, PyObject * args); +static PyObject *M_Mathutils_MidpointVecs(PyObject * self, PyObject * args); +static PyObject *M_Mathutils_ProjectVecs(PyObject * self, PyObject * args); +static PyObject *M_Mathutils_RotationMatrix(PyObject * self, PyObject * args); +static PyObject *M_Mathutils_TranslationMatrix(PyObject * self, VectorObject * value); +static PyObject *M_Mathutils_ScaleMatrix(PyObject * self, PyObject * args); +static PyObject *M_Mathutils_OrthoProjectionMatrix(PyObject * self, PyObject * args); +static PyObject *M_Mathutils_ShearMatrix(PyObject * self, PyObject * args); +static PyObject *M_Mathutils_DifferenceQuats(PyObject * self, PyObject * args); +static PyObject *M_Mathutils_Slerp(PyObject * self, PyObject * args); +static PyObject *M_Mathutils_Intersect( PyObject * self, PyObject * args ); +static PyObject *M_Mathutils_TriangleArea( PyObject * self, PyObject * args ); +static PyObject *M_Mathutils_TriangleNormal( PyObject * self, PyObject * args ); +static PyObject *M_Mathutils_QuadNormal( PyObject * self, PyObject * args ); +static PyObject *M_Mathutils_LineIntersect( PyObject * self, PyObject * args ); + +struct PyMethodDef M_Mathutils_methods[] = { + {"Rand", (PyCFunction) M_Mathutils_Rand, METH_VARARGS, M_Mathutils_Rand_doc}, + {"AngleBetweenVecs", (PyCFunction) M_Mathutils_AngleBetweenVecs, METH_VARARGS, M_Mathutils_AngleBetweenVecs_doc}, + {"MidpointVecs", (PyCFunction) M_Mathutils_MidpointVecs, METH_VARARGS, M_Mathutils_MidpointVecs_doc}, + {"ProjectVecs", (PyCFunction) M_Mathutils_ProjectVecs, METH_VARARGS, M_Mathutils_ProjectVecs_doc}, + {"RotationMatrix", (PyCFunction) M_Mathutils_RotationMatrix, METH_VARARGS, M_Mathutils_RotationMatrix_doc}, + {"ScaleMatrix", (PyCFunction) M_Mathutils_ScaleMatrix, METH_VARARGS, M_Mathutils_ScaleMatrix_doc}, + {"ShearMatrix", (PyCFunction) M_Mathutils_ShearMatrix, METH_VARARGS, M_Mathutils_ShearMatrix_doc}, + {"TranslationMatrix", (PyCFunction) M_Mathutils_TranslationMatrix, METH_O, M_Mathutils_TranslationMatrix_doc}, + {"OrthoProjectionMatrix", (PyCFunction) M_Mathutils_OrthoProjectionMatrix, METH_VARARGS, M_Mathutils_OrthoProjectionMatrix_doc}, + {"DifferenceQuats", (PyCFunction) M_Mathutils_DifferenceQuats, METH_VARARGS,M_Mathutils_DifferenceQuats_doc}, + {"Slerp", (PyCFunction) M_Mathutils_Slerp, METH_VARARGS, M_Mathutils_Slerp_doc}, + {"Intersect", ( PyCFunction ) M_Mathutils_Intersect, METH_VARARGS, M_Mathutils_Intersect_doc}, + {"TriangleArea", ( PyCFunction ) M_Mathutils_TriangleArea, METH_VARARGS, M_Mathutils_TriangleArea_doc}, + {"TriangleNormal", ( PyCFunction ) M_Mathutils_TriangleNormal, METH_VARARGS, M_Mathutils_TriangleNormal_doc}, + {"QuadNormal", ( PyCFunction ) M_Mathutils_QuadNormal, METH_VARARGS, M_Mathutils_QuadNormal_doc}, + {"LineIntersect", ( PyCFunction ) M_Mathutils_LineIntersect, METH_VARARGS, M_Mathutils_LineIntersect_doc}, + {NULL, NULL, 0, NULL} +}; + +/*----------------------------MODULE INIT-------------------------*/ +/* from can be Blender.Mathutils or GameLogic.Mathutils for the BGE */ + +#if (PY_VERSION_HEX >= 0x03000000) +static struct PyModuleDef M_Mathutils_module_def = { + {}, /* m_base */ + "Mathutils", /* m_name */ + M_Mathutils_doc, /* m_doc */ + 0, /* m_size */ + M_Mathutils_methods, /* m_methods */ + 0, /* m_reload */ + 0, /* m_traverse */ + 0, /* m_clear */ + 0, /* m_free */ +}; +#endif + +PyObject *Mathutils_Init(const char *from) +{ + PyObject *submodule; + + //seed the generator for the rand function + BLI_srand((unsigned int) (PIL_check_seconds_timer() * 0x7FFFFFFF)); + + if( PyType_Ready( &vector_Type ) < 0 ) + return NULL; + if( PyType_Ready( &matrix_Type ) < 0 ) + return NULL; + if( PyType_Ready( &euler_Type ) < 0 ) + return NULL; + if( PyType_Ready( &quaternion_Type ) < 0 ) + return NULL; + +#if (PY_VERSION_HEX >= 0x03000000) + submodule = PyModule_Create(&M_Mathutils_module_def); + PyDict_SetItemString(PySys_GetObject("modules"), M_Mathutils_module_def.m_name, submodule); +#else + submodule = Py_InitModule3(from, M_Mathutils_methods, M_Mathutils_doc); +#endif + + /* each type has its own new() function */ + PyModule_AddObject( submodule, "Vector", (PyObject *)&vector_Type ); + PyModule_AddObject( submodule, "Matrix", (PyObject *)&matrix_Type ); + PyModule_AddObject( submodule, "Euler", (PyObject *)&euler_Type ); + PyModule_AddObject( submodule, "Quaternion", (PyObject *)&quaternion_Type ); + + return (submodule); +} + +//-----------------------------METHODS---------------------------- +//----------------column_vector_multiplication (internal)--------- +//COLUMN VECTOR Multiplication (Matrix X Vector) +// [1][2][3] [a] +// [4][5][6] * [b] +// [7][8][9] [c] +//vector/matrix multiplication IS NOT COMMUTATIVE!!!! +PyObject *column_vector_multiplication(MatrixObject * mat, VectorObject* vec) +{ + float vecNew[4], vecCopy[4]; + double dot = 0.0f; + int x, y, z = 0; + + if(mat->rowSize != vec->size){ + if(mat->rowSize == 4 && vec->size != 3){ + PyErr_SetString(PyExc_AttributeError, "matrix * vector: matrix row size and vector size must be the same"); + return NULL; + }else{ + vecCopy[3] = 1.0f; + } + } + + for(x = 0; x < vec->size; x++){ + vecCopy[x] = vec->vec[x]; + } + + for(x = 0; x < mat->rowSize; x++) { + for(y = 0; y < mat->colSize; y++) { + dot += mat->matrix[x][y] * vecCopy[y]; + } + vecNew[z++] = (float)dot; + dot = 0.0f; + } + return newVectorObject(vecNew, vec->size, Py_NEW); +} + +//-----------------row_vector_multiplication (internal)----------- +//ROW VECTOR Multiplication - Vector X Matrix +//[x][y][z] * [1][2][3] +// [4][5][6] +// [7][8][9] +//vector/matrix multiplication IS NOT COMMUTATIVE!!!! +PyObject *row_vector_multiplication(VectorObject* vec, MatrixObject * mat) +{ + float vecNew[4], vecCopy[4]; + double dot = 0.0f; + int x, y, z = 0, vec_size = vec->size; + + if(mat->colSize != vec_size){ + if(mat->rowSize == 4 && vec_size != 3){ + PyErr_SetString(PyExc_AttributeError, "vector * matrix: matrix column size and the vector size must be the same"); + return NULL; + }else{ + vecCopy[3] = 1.0f; + } + } + + for(x = 0; x < vec_size; x++){ + vecCopy[x] = vec->vec[x]; + } + + //muliplication + for(x = 0; x < mat->colSize; x++) { + for(y = 0; y < mat->rowSize; y++) { + dot += mat->matrix[y][x] * vecCopy[y]; + } + vecNew[z++] = (float)dot; + dot = 0.0f; + } + return newVectorObject(vecNew, vec_size, Py_NEW); +} + +//-----------------quat_rotation (internal)----------- +//This function multiplies a vector/point * quat or vice versa +//to rotate the point/vector by the quaternion +//arguments should all be 3D +PyObject *quat_rotation(PyObject *arg1, PyObject *arg2) +{ + float rot[3]; + QuaternionObject *quat = NULL; + VectorObject *vec = NULL; + + if(QuaternionObject_Check(arg1)){ + quat = (QuaternionObject*)arg1; + if(VectorObject_Check(arg2)){ + vec = (VectorObject*)arg2; + rot[0] = quat->quat[0]*quat->quat[0]*vec->vec[0] + 2*quat->quat[2]*quat->quat[0]*vec->vec[2] - + 2*quat->quat[3]*quat->quat[0]*vec->vec[1] + quat->quat[1]*quat->quat[1]*vec->vec[0] + + 2*quat->quat[2]*quat->quat[1]*vec->vec[1] + 2*quat->quat[3]*quat->quat[1]*vec->vec[2] - + quat->quat[3]*quat->quat[3]*vec->vec[0] - quat->quat[2]*quat->quat[2]*vec->vec[0]; + rot[1] = 2*quat->quat[1]*quat->quat[2]*vec->vec[0] + quat->quat[2]*quat->quat[2]*vec->vec[1] + + 2*quat->quat[3]*quat->quat[2]*vec->vec[2] + 2*quat->quat[0]*quat->quat[3]*vec->vec[0] - + quat->quat[3]*quat->quat[3]*vec->vec[1] + quat->quat[0]*quat->quat[0]*vec->vec[1] - + 2*quat->quat[1]*quat->quat[0]*vec->vec[2] - quat->quat[1]*quat->quat[1]*vec->vec[1]; + rot[2] = 2*quat->quat[1]*quat->quat[3]*vec->vec[0] + 2*quat->quat[2]*quat->quat[3]*vec->vec[1] + + quat->quat[3]*quat->quat[3]*vec->vec[2] - 2*quat->quat[0]*quat->quat[2]*vec->vec[0] - + quat->quat[2]*quat->quat[2]*vec->vec[2] + 2*quat->quat[0]*quat->quat[1]*vec->vec[1] - + quat->quat[1]*quat->quat[1]*vec->vec[2] + quat->quat[0]*quat->quat[0]*vec->vec[2]; + return newVectorObject(rot, 3, Py_NEW); + } + }else if(VectorObject_Check(arg1)){ + vec = (VectorObject*)arg1; + if(QuaternionObject_Check(arg2)){ + quat = (QuaternionObject*)arg2; + rot[0] = quat->quat[0]*quat->quat[0]*vec->vec[0] + 2*quat->quat[2]*quat->quat[0]*vec->vec[2] - + 2*quat->quat[3]*quat->quat[0]*vec->vec[1] + quat->quat[1]*quat->quat[1]*vec->vec[0] + + 2*quat->quat[2]*quat->quat[1]*vec->vec[1] + 2*quat->quat[3]*quat->quat[1]*vec->vec[2] - + quat->quat[3]*quat->quat[3]*vec->vec[0] - quat->quat[2]*quat->quat[2]*vec->vec[0]; + rot[1] = 2*quat->quat[1]*quat->quat[2]*vec->vec[0] + quat->quat[2]*quat->quat[2]*vec->vec[1] + + 2*quat->quat[3]*quat->quat[2]*vec->vec[2] + 2*quat->quat[0]*quat->quat[3]*vec->vec[0] - + quat->quat[3]*quat->quat[3]*vec->vec[1] + quat->quat[0]*quat->quat[0]*vec->vec[1] - + 2*quat->quat[1]*quat->quat[0]*vec->vec[2] - quat->quat[1]*quat->quat[1]*vec->vec[1]; + rot[2] = 2*quat->quat[1]*quat->quat[3]*vec->vec[0] + 2*quat->quat[2]*quat->quat[3]*vec->vec[1] + + quat->quat[3]*quat->quat[3]*vec->vec[2] - 2*quat->quat[0]*quat->quat[2]*vec->vec[0] - + quat->quat[2]*quat->quat[2]*vec->vec[2] + 2*quat->quat[0]*quat->quat[1]*vec->vec[1] - + quat->quat[1]*quat->quat[1]*vec->vec[2] + quat->quat[0]*quat->quat[0]*vec->vec[2]; + return newVectorObject(rot, 3, Py_NEW); + } + } + + PyErr_SetString(PyExc_RuntimeError, "quat_rotation(internal): internal problem rotating vector/point\n"); + return NULL; + +} + +//----------------------------------Mathutils.Rand() -------------------- +//returns a random number between a high and low value +static PyObject *M_Mathutils_Rand(PyObject * self, PyObject * args) +{ + float high, low, range; + double drand; + //initializers + high = 1.0; + low = 0.0; + + if(!PyArg_ParseTuple(args, "|ff", &low, &high)) { + PyErr_SetString(PyExc_TypeError, "Mathutils.Rand(): expected nothing or optional (float, float)\n"); + return NULL; + } + + if((high < low) || (high < 0 && low > 0)) { + PyErr_SetString(PyExc_ValueError, "Mathutils.Rand(): high value should be larger than low value\n"); + return NULL; + } + //get the random number 0 - 1 + drand = BLI_drand(); + + //set it to range + range = high - low; + drand = drand * range; + drand = drand + low; + + return PyFloat_FromDouble(drand); +} +//----------------------------------VECTOR FUNCTIONS--------------------- +//----------------------------------Mathutils.AngleBetweenVecs() --------- +//calculates the angle between 2 vectors +static PyObject *M_Mathutils_AngleBetweenVecs(PyObject * self, PyObject * args) +{ + VectorObject *vec1 = NULL, *vec2 = NULL; + double dot = 0.0f, angleRads, test_v1 = 0.0f, test_v2 = 0.0f; + int x, size; + + if(!PyArg_ParseTuple(args, "O!O!", &vector_Type, &vec1, &vector_Type, &vec2)) + goto AttributeError1; //not vectors + if(vec1->size != vec2->size) + goto AttributeError1; //bad sizes + + //since size is the same.... + size = vec1->size; + + for(x = 0; x < size; x++) { + test_v1 += vec1->vec[x] * vec1->vec[x]; + test_v2 += vec2->vec[x] * vec2->vec[x]; + } + if (!test_v1 || !test_v2){ + goto AttributeError2; //zero-length vector + } + + //dot product + for(x = 0; x < size; x++) { + dot += vec1->vec[x] * vec2->vec[x]; + } + dot /= (sqrt(test_v1) * sqrt(test_v2)); + + angleRads = (double)saacos(dot); + + return PyFloat_FromDouble(angleRads * (180/ Py_PI)); + +AttributeError1: + PyErr_SetString(PyExc_AttributeError, "Mathutils.AngleBetweenVecs(): expects (2) VECTOR objects of the same size\n"); + return NULL; + +AttributeError2: + PyErr_SetString(PyExc_AttributeError, "Mathutils.AngleBetweenVecs(): zero length vectors are not acceptable arguments\n"); + return NULL; +} +//----------------------------------Mathutils.MidpointVecs() ------------- +//calculates the midpoint between 2 vectors +static PyObject *M_Mathutils_MidpointVecs(PyObject * self, PyObject * args) +{ + VectorObject *vec1 = NULL, *vec2 = NULL; + float vec[4]; + int x; + + if(!PyArg_ParseTuple(args, "O!O!", &vector_Type, &vec1, &vector_Type, &vec2)) { + PyErr_SetString(PyExc_TypeError, "Mathutils.MidpointVecs(): expects (2) vector objects of the same size\n"); + return NULL; + } + if(vec1->size != vec2->size) { + PyErr_SetString(PyExc_AttributeError, "Mathutils.MidpointVecs(): expects (2) vector objects of the same size\n"); + return NULL; + } + + for(x = 0; x < vec1->size; x++) { + vec[x] = 0.5f * (vec1->vec[x] + vec2->vec[x]); + } + return newVectorObject(vec, vec1->size, Py_NEW); +} +//----------------------------------Mathutils.ProjectVecs() ------------- +//projects vector 1 onto vector 2 +static PyObject *M_Mathutils_ProjectVecs(PyObject * self, PyObject * args) +{ + VectorObject *vec1 = NULL, *vec2 = NULL; + float vec[4]; + double dot = 0.0f, dot2 = 0.0f; + int x, size; + + if(!PyArg_ParseTuple(args, "O!O!", &vector_Type, &vec1, &vector_Type, &vec2)) { + PyErr_SetString(PyExc_TypeError, "Mathutils.ProjectVecs(): expects (2) vector objects of the same size\n"); + return NULL; + } + if(vec1->size != vec2->size) { + PyErr_SetString(PyExc_AttributeError, "Mathutils.ProjectVecs(): expects (2) vector objects of the same size\n"); + return NULL; + } + + //since they are the same size... + size = vec1->size; + + //get dot products + for(x = 0; x < size; x++) { + dot += vec1->vec[x] * vec2->vec[x]; + dot2 += vec2->vec[x] * vec2->vec[x]; + } + //projection + dot /= dot2; + for(x = 0; x < size; x++) { + vec[x] = (float)(dot * vec2->vec[x]); + } + return newVectorObject(vec, size, Py_NEW); +} +//----------------------------------MATRIX FUNCTIONS-------------------- +//----------------------------------Mathutils.RotationMatrix() ---------- +//mat is a 1D array of floats - row[0][0],row[0][1], row[1][0], etc. +//creates a rotation matrix +static PyObject *M_Mathutils_RotationMatrix(PyObject * self, PyObject * args) +{ + VectorObject *vec = NULL; + char *axis = NULL; + int matSize; + float angle = 0.0f, norm = 0.0f, cosAngle = 0.0f, sinAngle = 0.0f; + float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; + + if(!PyArg_ParseTuple(args, "fi|sO!", &angle, &matSize, &axis, &vector_Type, &vec)) { + PyErr_SetString(PyExc_TypeError, "Mathutils.RotationMatrix(): expected float int and optional string and vector\n"); + return NULL; + } + + /* Clamp to -360:360 */ + while (angle<-360.0f) + angle+=360.0; + while (angle>360.0f) + angle-=360.0; + + if(matSize != 2 && matSize != 3 && matSize != 4) { + PyErr_SetString(PyExc_AttributeError, "Mathutils.RotationMatrix(): can only return a 2x2 3x3 or 4x4 matrix\n"); + return NULL; + } + if(matSize == 2 && (axis != NULL || vec != NULL)) { + PyErr_SetString(PyExc_AttributeError, "Mathutils.RotationMatrix(): cannot create a 2x2 rotation matrix around arbitrary axis\n"); + return NULL; + } + if((matSize == 3 || matSize == 4) && axis == NULL) { + PyErr_SetString(PyExc_AttributeError, "Mathutils.RotationMatrix(): please choose an axis of rotation for 3d and 4d matrices\n"); + return NULL; + } + if(axis) { + if(((strcmp(axis, "r") == 0) || (strcmp(axis, "R") == 0)) && vec == NULL) { + PyErr_SetString(PyExc_AttributeError, "Mathutils.RotationMatrix(): please define the arbitrary axis of rotation\n"); + return NULL; + } + } + if(vec) { + if(vec->size != 3) { + PyErr_SetString(PyExc_AttributeError, "Mathutils.RotationMatrix(): the arbitrary axis must be a 3D vector\n"); + return NULL; + } + } + //convert to radians + angle = angle * (float) (Py_PI / 180); + if(axis == NULL && matSize == 2) { + //2D rotation matrix + mat[0] = (float) cos (angle); + mat[1] = (float) sin (angle); + mat[2] = -((float) sin(angle)); + mat[3] = (float) cos(angle); + } else if((strcmp(axis, "x") == 0) || (strcmp(axis, "X") == 0)) { + //rotation around X + mat[0] = 1.0f; + mat[4] = (float) cos(angle); + mat[5] = (float) sin(angle); + mat[7] = -((float) sin(angle)); + mat[8] = (float) cos(angle); + } else if((strcmp(axis, "y") == 0) || (strcmp(axis, "Y") == 0)) { + //rotation around Y + mat[0] = (float) cos(angle); + mat[2] = -((float) sin(angle)); + mat[4] = 1.0f; + mat[6] = (float) sin(angle); + mat[8] = (float) cos(angle); + } else if((strcmp(axis, "z") == 0) || (strcmp(axis, "Z") == 0)) { + //rotation around Z + mat[0] = (float) cos(angle); + mat[1] = (float) sin(angle); + mat[3] = -((float) sin(angle)); + mat[4] = (float) cos(angle); + mat[8] = 1.0f; + } else if((strcmp(axis, "r") == 0) || (strcmp(axis, "R") == 0)) { + //arbitrary rotation + //normalize arbitrary axis + norm = (float) sqrt(vec->vec[0] * vec->vec[0] + + vec->vec[1] * vec->vec[1] + + vec->vec[2] * vec->vec[2]); + vec->vec[0] /= norm; + vec->vec[1] /= norm; + vec->vec[2] /= norm; + + if (isnan(vec->vec[0]) || isnan(vec->vec[1]) || isnan(vec->vec[2])) { + /* zero length vector, return an identity matrix, could also return an error */ + mat[0]= mat[4] = mat[8] = 1.0f; + } else { + /* create matrix */ + cosAngle = (float) cos(angle); + sinAngle = (float) sin(angle); + mat[0] = ((vec->vec[0] * vec->vec[0]) * (1 - cosAngle)) + + cosAngle; + mat[1] = ((vec->vec[0] * vec->vec[1]) * (1 - cosAngle)) + + (vec->vec[2] * sinAngle); + mat[2] = ((vec->vec[0] * vec->vec[2]) * (1 - cosAngle)) - + (vec->vec[1] * sinAngle); + mat[3] = ((vec->vec[0] * vec->vec[1]) * (1 - cosAngle)) - + (vec->vec[2] * sinAngle); + mat[4] = ((vec->vec[1] * vec->vec[1]) * (1 - cosAngle)) + + cosAngle; + mat[5] = ((vec->vec[1] * vec->vec[2]) * (1 - cosAngle)) + + (vec->vec[0] * sinAngle); + mat[6] = ((vec->vec[0] * vec->vec[2]) * (1 - cosAngle)) + + (vec->vec[1] * sinAngle); + mat[7] = ((vec->vec[1] * vec->vec[2]) * (1 - cosAngle)) - + (vec->vec[0] * sinAngle); + mat[8] = ((vec->vec[2] * vec->vec[2]) * (1 - cosAngle)) + + cosAngle; + } + } else { + PyErr_SetString(PyExc_AttributeError, "Mathutils.RotationMatrix(): unrecognizable axis of rotation type - expected x,y,z or r\n"); + return NULL; + } + if(matSize == 4) { + //resize matrix + mat[10] = mat[8]; + mat[9] = mat[7]; + mat[8] = mat[6]; + mat[7] = 0.0f; + mat[6] = mat[5]; + mat[5] = mat[4]; + mat[4] = mat[3]; + mat[3] = 0.0f; + } + //pass to matrix creation + return newMatrixObject(mat, matSize, matSize, Py_NEW); +} +//----------------------------------Mathutils.TranslationMatrix() ------- +//creates a translation matrix +static PyObject *M_Mathutils_TranslationMatrix(PyObject * self, VectorObject * vec) +{ + float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; + + if(!VectorObject_Check(vec)) { + PyErr_SetString(PyExc_TypeError, "Mathutils.TranslationMatrix(): expected vector\n"); + return NULL; + } + if(vec->size != 3 && vec->size != 4) { + PyErr_SetString(PyExc_TypeError, "Mathutils.TranslationMatrix(): vector must be 3D or 4D\n"); + return NULL; + } + //create a identity matrix and add translation + Mat4One((float(*)[4]) mat); + mat[12] = vec->vec[0]; + mat[13] = vec->vec[1]; + mat[14] = vec->vec[2]; + + return newMatrixObject(mat, 4, 4, Py_NEW); +} +//----------------------------------Mathutils.ScaleMatrix() ------------- +//mat is a 1D array of floats - row[0][0],row[0][1], row[1][0], etc. +//creates a scaling matrix +static PyObject *M_Mathutils_ScaleMatrix(PyObject * self, PyObject * args) +{ + VectorObject *vec = NULL; + float norm = 0.0f, factor; + int matSize, x; + float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; + + if(!PyArg_ParseTuple(args, "fi|O!", &factor, &matSize, &vector_Type, &vec)) { + PyErr_SetString(PyExc_TypeError, "Mathutils.ScaleMatrix(): expected float int and optional vector\n"); + return NULL; + } + if(matSize != 2 && matSize != 3 && matSize != 4) { + PyErr_SetString(PyExc_AttributeError, "Mathutils.ScaleMatrix(): can only return a 2x2 3x3 or 4x4 matrix\n"); + return NULL; + } + if(vec) { + if(vec->size > 2 && matSize == 2) { + PyErr_SetString(PyExc_AttributeError, "Mathutils.ScaleMatrix(): please use 2D vectors when scaling in 2D\n"); + return NULL; + } + } + if(vec == NULL) { //scaling along axis + if(matSize == 2) { + mat[0] = factor; + mat[3] = factor; + } else { + mat[0] = factor; + mat[4] = factor; + mat[8] = factor; + } + } else { //scaling in arbitrary direction + //normalize arbitrary axis + for(x = 0; x < vec->size; x++) { + norm += vec->vec[x] * vec->vec[x]; + } + norm = (float) sqrt(norm); + for(x = 0; x < vec->size; x++) { + vec->vec[x] /= norm; + } + if(matSize == 2) { + mat[0] = 1 +((factor - 1) *(vec->vec[0] * vec->vec[0])); + mat[1] =((factor - 1) *(vec->vec[0] * vec->vec[1])); + mat[2] =((factor - 1) *(vec->vec[0] * vec->vec[1])); + mat[3] = 1 + ((factor - 1) *(vec->vec[1] * vec->vec[1])); + } else { + mat[0] = 1 + ((factor - 1) *(vec->vec[0] * vec->vec[0])); + mat[1] =((factor - 1) *(vec->vec[0] * vec->vec[1])); + mat[2] =((factor - 1) *(vec->vec[0] * vec->vec[2])); + mat[3] =((factor - 1) *(vec->vec[0] * vec->vec[1])); + mat[4] = 1 + ((factor - 1) *(vec->vec[1] * vec->vec[1])); + mat[5] =((factor - 1) *(vec->vec[1] * vec->vec[2])); + mat[6] =((factor - 1) *(vec->vec[0] * vec->vec[2])); + mat[7] =((factor - 1) *(vec->vec[1] * vec->vec[2])); + mat[8] = 1 + ((factor - 1) *(vec->vec[2] * vec->vec[2])); + } + } + if(matSize == 4) { + //resize matrix + mat[10] = mat[8]; + mat[9] = mat[7]; + mat[8] = mat[6]; + mat[7] = 0.0f; + mat[6] = mat[5]; + mat[5] = mat[4]; + mat[4] = mat[3]; + mat[3] = 0.0f; + } + //pass to matrix creation + return newMatrixObject(mat, matSize, matSize, Py_NEW); +} +//----------------------------------Mathutils.OrthoProjectionMatrix() --- +//mat is a 1D array of floats - row[0][0],row[0][1], row[1][0], etc. +//creates an ortho projection matrix +static PyObject *M_Mathutils_OrthoProjectionMatrix(PyObject * self, PyObject * args) +{ + VectorObject *vec = NULL; + char *plane; + int matSize, x; + float norm = 0.0f; + float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; + + if(!PyArg_ParseTuple(args, "si|O!", &plane, &matSize, &vector_Type, &vec)) { + PyErr_SetString(PyExc_TypeError, "Mathutils.OrthoProjectionMatrix(): expected string and int and optional vector\n"); + return NULL; + } + if(matSize != 2 && matSize != 3 && matSize != 4) { + PyErr_SetString(PyExc_AttributeError,"Mathutils.OrthoProjectionMatrix(): can only return a 2x2 3x3 or 4x4 matrix\n"); + return NULL; + } + if(vec) { + if(vec->size > 2 && matSize == 2) { + PyErr_SetString(PyExc_AttributeError, "Mathutils.OrthoProjectionMatrix(): please use 2D vectors when scaling in 2D\n"); + return NULL; + } + } + if(vec == NULL) { //ortho projection onto cardinal plane + if(((strcmp(plane, "x") == 0) + || (strcmp(plane, "X") == 0)) && matSize == 2) { + mat[0] = 1.0f; + } else if(((strcmp(plane, "y") == 0) + || (strcmp(plane, "Y") == 0)) + && matSize == 2) { + mat[3] = 1.0f; + } else if(((strcmp(plane, "xy") == 0) + || (strcmp(plane, "XY") == 0)) + && matSize > 2) { + mat[0] = 1.0f; + mat[4] = 1.0f; + } else if(((strcmp(plane, "xz") == 0) + || (strcmp(plane, "XZ") == 0)) + && matSize > 2) { + mat[0] = 1.0f; + mat[8] = 1.0f; + } else if(((strcmp(plane, "yz") == 0) + || (strcmp(plane, "YZ") == 0)) + && matSize > 2) { + mat[4] = 1.0f; + mat[8] = 1.0f; + } else { + PyErr_SetString(PyExc_AttributeError, "Mathutils.OrthoProjectionMatrix(): unknown plane - expected: x, y, xy, xz, yz\n"); + return NULL; + } + } else { //arbitrary plane + //normalize arbitrary axis + for(x = 0; x < vec->size; x++) { + norm += vec->vec[x] * vec->vec[x]; + } + norm = (float) sqrt(norm); + for(x = 0; x < vec->size; x++) { + vec->vec[x] /= norm; + } + if(((strcmp(plane, "r") == 0) + || (strcmp(plane, "R") == 0)) && matSize == 2) { + mat[0] = 1 - (vec->vec[0] * vec->vec[0]); + mat[1] = -(vec->vec[0] * vec->vec[1]); + mat[2] = -(vec->vec[0] * vec->vec[1]); + mat[3] = 1 - (vec->vec[1] * vec->vec[1]); + } else if(((strcmp(plane, "r") == 0) + || (strcmp(plane, "R") == 0)) + && matSize > 2) { + mat[0] = 1 - (vec->vec[0] * vec->vec[0]); + mat[1] = -(vec->vec[0] * vec->vec[1]); + mat[2] = -(vec->vec[0] * vec->vec[2]); + mat[3] = -(vec->vec[0] * vec->vec[1]); + mat[4] = 1 - (vec->vec[1] * vec->vec[1]); + mat[5] = -(vec->vec[1] * vec->vec[2]); + mat[6] = -(vec->vec[0] * vec->vec[2]); + mat[7] = -(vec->vec[1] * vec->vec[2]); + mat[8] = 1 - (vec->vec[2] * vec->vec[2]); + } else { + PyErr_SetString(PyExc_AttributeError, "Mathutils.OrthoProjectionMatrix(): unknown plane - expected: 'r' expected for axis designation\n"); + return NULL; + } + } + if(matSize == 4) { + //resize matrix + mat[10] = mat[8]; + mat[9] = mat[7]; + mat[8] = mat[6]; + mat[7] = 0.0f; + mat[6] = mat[5]; + mat[5] = mat[4]; + mat[4] = mat[3]; + mat[3] = 0.0f; + } + //pass to matrix creation + return newMatrixObject(mat, matSize, matSize, Py_NEW); +} +//----------------------------------Mathutils.ShearMatrix() ------------- +//creates a shear matrix +static PyObject *M_Mathutils_ShearMatrix(PyObject * self, PyObject * args) +{ + int matSize; + char *plane; + float factor; + float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; + + if(!PyArg_ParseTuple(args, "sfi", &plane, &factor, &matSize)) { + PyErr_SetString(PyExc_TypeError,"Mathutils.ShearMatrix(): expected string float and int\n"); + return NULL; + } + if(matSize != 2 && matSize != 3 && matSize != 4) { + PyErr_SetString(PyExc_AttributeError,"Mathutils.ShearMatrix(): can only return a 2x2 3x3 or 4x4 matrix\n"); + return NULL; + } + + if(((strcmp(plane, "x") == 0) || (strcmp(plane, "X") == 0)) + && matSize == 2) { + mat[0] = 1.0f; + mat[2] = factor; + mat[3] = 1.0f; + } else if(((strcmp(plane, "y") == 0) + || (strcmp(plane, "Y") == 0)) && matSize == 2) { + mat[0] = 1.0f; + mat[1] = factor; + mat[3] = 1.0f; + } else if(((strcmp(plane, "xy") == 0) + || (strcmp(plane, "XY") == 0)) && matSize > 2) { + mat[0] = 1.0f; + mat[4] = 1.0f; + mat[6] = factor; + mat[7] = factor; + } else if(((strcmp(plane, "xz") == 0) + || (strcmp(plane, "XZ") == 0)) && matSize > 2) { + mat[0] = 1.0f; + mat[3] = factor; + mat[4] = 1.0f; + mat[5] = factor; + mat[8] = 1.0f; + } else if(((strcmp(plane, "yz") == 0) + || (strcmp(plane, "YZ") == 0)) && matSize > 2) { + mat[0] = 1.0f; + mat[1] = factor; + mat[2] = factor; + mat[4] = 1.0f; + mat[8] = 1.0f; + } else { + PyErr_SetString(PyExc_AttributeError, "Mathutils.ShearMatrix(): expected: x, y, xy, xz, yz or wrong matrix size for shearing plane\n"); + return NULL; + } + if(matSize == 4) { + //resize matrix + mat[10] = mat[8]; + mat[9] = mat[7]; + mat[8] = mat[6]; + mat[7] = 0.0f; + mat[6] = mat[5]; + mat[5] = mat[4]; + mat[4] = mat[3]; + mat[3] = 0.0f; + } + //pass to matrix creation + return newMatrixObject(mat, matSize, matSize, Py_NEW); +} +//----------------------------------QUATERNION FUNCTIONS----------------- + +//----------------------------------Mathutils.DifferenceQuats() --------- +//returns the difference between 2 quaternions +static PyObject *M_Mathutils_DifferenceQuats(PyObject * self, PyObject * args) +{ + QuaternionObject *quatU = NULL, *quatV = NULL; + float quat[4], tempQuat[4]; + double dot = 0.0f; + int x; + + if(!PyArg_ParseTuple(args, "O!O!", &quaternion_Type, &quatU, &quaternion_Type, &quatV)) { + PyErr_SetString(PyExc_TypeError, "Mathutils.DifferenceQuats(): expected Quaternion types"); + return NULL; + } + tempQuat[0] = quatU->quat[0]; + tempQuat[1] = -quatU->quat[1]; + tempQuat[2] = -quatU->quat[2]; + tempQuat[3] = -quatU->quat[3]; + + dot = sqrt(tempQuat[0] * tempQuat[0] + tempQuat[1] * tempQuat[1] + + tempQuat[2] * tempQuat[2] + tempQuat[3] * tempQuat[3]); + + for(x = 0; x < 4; x++) { + tempQuat[x] /= (float)(dot * dot); + } + QuatMul(quat, tempQuat, quatV->quat); + return newQuaternionObject(quat, Py_NEW); +} +//----------------------------------Mathutils.Slerp() ------------------ +//attemps to interpolate 2 quaternions and return the result +static PyObject *M_Mathutils_Slerp(PyObject * self, PyObject * args) +{ + QuaternionObject *quatU = NULL, *quatV = NULL; + float quat[4], quat_u[4], quat_v[4], param; + double x, y, dot, sinT, angle, IsinT; + int z; + + if(!PyArg_ParseTuple(args, "O!O!f", &quaternion_Type, &quatU, &quaternion_Type, &quatV, ¶m)) { + PyErr_SetString(PyExc_TypeError, "Mathutils.Slerp(): expected Quaternion types and float"); + return NULL; + } + if(param > 1.0f || param < 0.0f) { + PyErr_SetString(PyExc_AttributeError, "Mathutils.Slerp(): interpolation factor must be between 0.0 and 1.0"); + return NULL; + } + + //copy quats + for(z = 0; z < 4; z++){ + quat_u[z] = quatU->quat[z]; + quat_v[z] = quatV->quat[z]; + } + + //dot product + dot = quat_u[0] * quat_v[0] + quat_u[1] * quat_v[1] + + quat_u[2] * quat_v[2] + quat_u[3] * quat_v[3]; + + //if negative negate a quat (shortest arc) + if(dot < 0.0f) { + quat_v[0] = -quat_v[0]; + quat_v[1] = -quat_v[1]; + quat_v[2] = -quat_v[2]; + quat_v[3] = -quat_v[3]; + dot = -dot; + } + if(dot > .99999f) { //very close + x = 1.0f - param; + y = param; + } else { + //calculate sin of angle + sinT = sqrt(1.0f - (dot * dot)); + //calculate angle + angle = atan2(sinT, dot); + //caluculate inverse of sin(theta) + IsinT = 1.0f / sinT; + x = sin((1.0f - param) * angle) * IsinT; + y = sin(param * angle) * IsinT; + } + //interpolate + quat[0] = (float)(quat_u[0] * x + quat_v[0] * y); + quat[1] = (float)(quat_u[1] * x + quat_v[1] * y); + quat[2] = (float)(quat_u[2] * x + quat_v[2] * y); + quat[3] = (float)(quat_u[3] * x + quat_v[3] * y); + + return newQuaternionObject(quat, Py_NEW); +} +//----------------------------------EULER FUNCTIONS---------------------- +//---------------------------------INTERSECTION FUNCTIONS-------------------- +//----------------------------------Mathutils.Intersect() ------------------- +static PyObject *M_Mathutils_Intersect( PyObject * self, PyObject * args ) +{ + VectorObject *ray, *ray_off, *vec1, *vec2, *vec3; + float dir[3], orig[3], v1[3], v2[3], v3[3], e1[3], e2[3], pvec[3], tvec[3], qvec[3]; + float det, inv_det, u, v, t; + int clip = 1; + + if(!PyArg_ParseTuple(args, "O!O!O!O!O!|i", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3, &vector_Type, &ray, &vector_Type, &ray_off , &clip)) { + PyErr_SetString( PyExc_TypeError, "expected 5 vector types\n" ); + return NULL; + } + if(vec1->size != 3 || vec2->size != 3 || vec3->size != 3 || ray->size != 3 || ray_off->size != 3) { + PyErr_SetString( PyExc_TypeError, "only 3D vectors for all parameters\n"); + return NULL; + } + + VECCOPY(v1, vec1->vec); + VECCOPY(v2, vec2->vec); + VECCOPY(v3, vec3->vec); + + VECCOPY(dir, ray->vec); + Normalize(dir); + + VECCOPY(orig, ray_off->vec); + + /* find vectors for two edges sharing v1 */ + VecSubf(e1, v2, v1); + VecSubf(e2, v3, v1); + + /* begin calculating determinant - also used to calculated U parameter */ + Crossf(pvec, dir, e2); + + /* if determinant is near zero, ray lies in plane of triangle */ + det = Inpf(e1, pvec); + + if (det > -0.000001 && det < 0.000001) { + Py_RETURN_NONE; + } + + inv_det = 1.0f / det; + + /* calculate distance from v1 to ray origin */ + VecSubf(tvec, orig, v1); + + /* calculate U parameter and test bounds */ + u = Inpf(tvec, pvec) * inv_det; + if (clip && (u < 0.0f || u > 1.0f)) { + Py_RETURN_NONE; + } + + /* prepare to test the V parameter */ + Crossf(qvec, tvec, e1); + + /* calculate V parameter and test bounds */ + v = Inpf(dir, qvec) * inv_det; + + if (clip && (v < 0.0f || u + v > 1.0f)) { + Py_RETURN_NONE; + } + + /* calculate t, ray intersects triangle */ + t = Inpf(e2, qvec) * inv_det; + + VecMulf(dir, t); + VecAddf(pvec, orig, dir); + + return newVectorObject(pvec, 3, Py_NEW); +} +//----------------------------------Mathutils.LineIntersect() ------------------- +/* Line-Line intersection using algorithm from mathworld.wolfram.com */ +static PyObject *M_Mathutils_LineIntersect( PyObject * self, PyObject * args ) +{ + PyObject * tuple; + VectorObject *vec1, *vec2, *vec3, *vec4; + float v1[3], v2[3], v3[3], v4[3], i1[3], i2[3]; + + if( !PyArg_ParseTuple( args, "O!O!O!O!", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3, &vector_Type, &vec4 ) ) { + PyErr_SetString( PyExc_TypeError, "expected 4 vector types\n" ); + return NULL; + } + if( vec1->size != vec2->size || vec1->size != vec3->size || vec1->size != vec2->size) { + PyErr_SetString( PyExc_TypeError,"vectors must be of the same size\n" ); + return NULL; + } + if( vec1->size == 3 || vec1->size == 2) { + int result; + + if (vec1->size == 3) { + VECCOPY(v1, vec1->vec); + VECCOPY(v2, vec2->vec); + VECCOPY(v3, vec3->vec); + VECCOPY(v4, vec4->vec); + } + else { + v1[0] = vec1->vec[0]; + v1[1] = vec1->vec[1]; + v1[2] = 0.0f; + + v2[0] = vec2->vec[0]; + v2[1] = vec2->vec[1]; + v2[2] = 0.0f; + + v3[0] = vec3->vec[0]; + v3[1] = vec3->vec[1]; + v3[2] = 0.0f; + + v4[0] = vec4->vec[0]; + v4[1] = vec4->vec[1]; + v4[2] = 0.0f; + } + + result = LineIntersectLine(v1, v2, v3, v4, i1, i2); + + if (result == 0) { + /* colinear */ + Py_RETURN_NONE; + } + else { + tuple = PyTuple_New( 2 ); + PyTuple_SetItem( tuple, 0, newVectorObject(i1, vec1->size, Py_NEW) ); + PyTuple_SetItem( tuple, 1, newVectorObject(i2, vec1->size, Py_NEW) ); + return tuple; + } + } + else { + PyErr_SetString( PyExc_TypeError, "2D/3D vectors only\n" ); + return NULL; + } +} + + + +//---------------------------------NORMALS FUNCTIONS-------------------- +//----------------------------------Mathutils.QuadNormal() ------------------- +static PyObject *M_Mathutils_QuadNormal( PyObject * self, PyObject * args ) +{ + VectorObject *vec1; + VectorObject *vec2; + VectorObject *vec3; + VectorObject *vec4; + float v1[3], v2[3], v3[3], v4[3], e1[3], e2[3], n1[3], n2[3]; + + if( !PyArg_ParseTuple( args, "O!O!O!O!", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3, &vector_Type, &vec4 ) ) { + PyErr_SetString( PyExc_TypeError, "expected 4 vector types\n" ); + return NULL; + } + if( vec1->size != vec2->size || vec1->size != vec3->size || vec1->size != vec4->size) { + PyErr_SetString( PyExc_TypeError,"vectors must be of the same size\n" ); + return NULL; + } + if( vec1->size != 3 ) { + PyErr_SetString( PyExc_TypeError, "only 3D vectors\n" ); + return NULL; + } + VECCOPY(v1, vec1->vec); + VECCOPY(v2, vec2->vec); + VECCOPY(v3, vec3->vec); + VECCOPY(v4, vec4->vec); + + /* find vectors for two edges sharing v2 */ + VecSubf(e1, v1, v2); + VecSubf(e2, v3, v2); + + Crossf(n1, e2, e1); + Normalize(n1); + + /* find vectors for two edges sharing v4 */ + VecSubf(e1, v3, v4); + VecSubf(e2, v1, v4); + + Crossf(n2, e2, e1); + Normalize(n2); + + /* adding and averaging the normals of both triangles */ + VecAddf(n1, n2, n1); + Normalize(n1); + + return newVectorObject(n1, 3, Py_NEW); +} + +//----------------------------Mathutils.TriangleNormal() ------------------- +static PyObject *M_Mathutils_TriangleNormal( PyObject * self, PyObject * args ) +{ + VectorObject *vec1, *vec2, *vec3; + float v1[3], v2[3], v3[3], e1[3], e2[3], n[3]; + + if( !PyArg_ParseTuple( args, "O!O!O!", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3 ) ) { + PyErr_SetString( PyExc_TypeError, "expected 3 vector types\n" ); + return NULL; + } + if( vec1->size != vec2->size || vec1->size != vec3->size ) { + PyErr_SetString( PyExc_TypeError, "vectors must be of the same size\n" ); + return NULL; + } + if( vec1->size != 3 ) { + PyErr_SetString( PyExc_TypeError, "only 3D vectors\n" ); + return NULL; + } + + VECCOPY(v1, vec1->vec); + VECCOPY(v2, vec2->vec); + VECCOPY(v3, vec3->vec); + + /* find vectors for two edges sharing v2 */ + VecSubf(e1, v1, v2); + VecSubf(e2, v3, v2); + + Crossf(n, e2, e1); + Normalize(n); + + return newVectorObject(n, 3, Py_NEW); +} + +//--------------------------------- AREA FUNCTIONS-------------------- +//----------------------------------Mathutils.TriangleArea() ------------------- +static PyObject *M_Mathutils_TriangleArea( PyObject * self, PyObject * args ) +{ + VectorObject *vec1, *vec2, *vec3; + float v1[3], v2[3], v3[3]; + + if( !PyArg_ParseTuple + ( args, "O!O!O!", &vector_Type, &vec1, &vector_Type, &vec2 + , &vector_Type, &vec3 ) ) { + PyErr_SetString( PyExc_TypeError, "expected 3 vector types\n"); + return NULL; + } + if( vec1->size != vec2->size || vec1->size != vec3->size ) { + PyErr_SetString( PyExc_TypeError, "vectors must be of the same size\n" ); + return NULL; + } + + if (vec1->size == 3) { + VECCOPY(v1, vec1->vec); + VECCOPY(v2, vec2->vec); + VECCOPY(v3, vec3->vec); + + return PyFloat_FromDouble( AreaT3Dfl(v1, v2, v3) ); + } + else if (vec1->size == 2) { + v1[0] = vec1->vec[0]; + v1[1] = vec1->vec[1]; + + v2[0] = vec2->vec[0]; + v2[1] = vec2->vec[1]; + + v3[0] = vec3->vec[0]; + v3[1] = vec3->vec[1]; + + return PyFloat_FromDouble( AreaF2Dfl(v1, v2, v3) ); + } + else { + PyErr_SetString( PyExc_TypeError, "only 2D,3D vectors are supported\n" ); + return NULL; + } +} + +/* Utility functions */ + +/*---------------------- EXPP_FloatsAreEqual ------------------------- + Floating point comparisons + floatStep = number of representable floats allowable in between + float A and float B to be considered equal. */ +int EXPP_FloatsAreEqual(float A, float B, int floatSteps) +{ + int a, b, delta; + assert(floatSteps > 0 && floatSteps < (4 * 1024 * 1024)); + a = *(int*)&A; + if (a < 0) + a = 0x80000000 - a; + b = *(int*)&B; + if (b < 0) + b = 0x80000000 - b; + delta = abs(a - b); + if (delta <= floatSteps) + return 1; + return 0; +} +/*---------------------- EXPP_VectorsAreEqual ------------------------- + Builds on EXPP_FloatsAreEqual to test vectors */ +int EXPP_VectorsAreEqual(float *vecA, float *vecB, int size, int floatSteps){ + + int x; + for (x=0; x< size; x++){ + if (EXPP_FloatsAreEqual(vecA[x], vecB[x], floatSteps) == 0) + return 0; + } + return 1; +} + + + +//####################################################################### +//#############################DEPRECATED################################ diff --git a/source/blender/python/generic/Mathutils.h b/source/blender/python/generic/Mathutils.h new file mode 100644 index 00000000000..e8882c3dac2 --- /dev/null +++ b/source/blender/python/generic/Mathutils.h @@ -0,0 +1,68 @@ +/* + * $Id: Mathutils.h 20332 2009-05-22 03:22:56Z campbellbarton $ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * This is a new part of Blender. + * + * Contributor(s): Joseph Gilbert + * + * ***** END GPL LICENSE BLOCK ***** +*/ +//Include this file for access to vector, quat, matrix, euler, etc... + +#ifndef EXPP_Mathutils_H +#define EXPP_Mathutils_H + +#include <Python.h> +#include "../intern/bpy_compat.h" +#include "vector.h" +#include "matrix.h" +#include "quat.h" +#include "euler.h" + +PyObject *Mathutils_Init( const char * from ); + +PyObject *row_vector_multiplication(VectorObject* vec, MatrixObject * mat); +PyObject *column_vector_multiplication(MatrixObject * mat, VectorObject* vec); +PyObject *quat_rotation(PyObject *arg1, PyObject *arg2); + +int EXPP_FloatsAreEqual(float A, float B, int floatSteps); +int EXPP_VectorsAreEqual(float *vecA, float *vecB, int size, int floatSteps); + + +#define Py_PI 3.14159265358979323846 +#define Py_WRAP 1024 +#define Py_NEW 2048 + + +/* Mathutils is used by the BGE and Blender so have to define + * some things here for luddite mac users of py2.3 */ +#ifndef Py_RETURN_NONE +#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None +#endif +#ifndef Py_RETURN_FALSE +#define Py_RETURN_FALSE return Py_INCREF(Py_False), Py_False +#endif +#ifndef Py_RETURN_TRUE +#define Py_RETURN_TRUE return Py_INCREF(Py_True), Py_True +#endif + +#endif /* EXPP_Mathutils_H */ diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c new file mode 100644 index 00000000000..6789aea9c10 --- /dev/null +++ b/source/blender/python/generic/bpy_internal_import.c @@ -0,0 +1,341 @@ +/* + * $Id: bpy_internal_import.c 20434 2009-05-26 18:06:09Z campbellbarton $ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * This is a new part of Blender. + * + * Contributor(s): Willian P. Germano + * + * ***** END GPL LICENSE BLOCK ***** +*/ + +#include "bpy_internal_import.h" +#include "DNA_text_types.h" +#include "DNA_ID.h" + +#include "MEM_guardedalloc.h" +#include "BKE_text.h" /* txt_to_buf */ +#include "BKE_main.h" + +static Main *bpy_import_main= NULL; + +static void free_compiled_text(Text *text) +{ + if(text->compiled) { + Py_DECREF(( PyObject * )text->compiled); + } + text->compiled= NULL; +} + +struct Main *bpy_import_main_get(void) +{ + return bpy_import_main; +} + +void bpy_import_main_set(struct Main *maggie) +{ + bpy_import_main= maggie; +} + + +PyObject *bpy_text_import( char *name, int *found ) +{ + Text *text; + char txtname[22]; /* 21+NULL */ + char *buf = NULL; + int namelen = strlen( name ); +//XXX Main *maggie= bpy_import_main ? bpy_import_main:G.main; + Main *maggie= bpy_import_main; + + *found= 0; + + if (namelen>21-3) return NULL; /* we know this cant be importable, the name is too long for blender! */ + + memcpy( txtname, name, namelen ); + memcpy( &txtname[namelen], ".py", 4 ); + + for(text = maggie->text.first; text; text = text->id.next) { + if( !strcmp( txtname, text->id.name+2 ) ) + break; + } + + if( !text ) + return NULL; + else + *found = 1; + + if( !text->compiled ) { + buf = txt_to_buf( text ); + text->compiled = Py_CompileString( buf, text->id.name+2, Py_file_input ); + MEM_freeN( buf ); + + if( PyErr_Occurred( ) ) { + PyErr_Print( ); + PyErr_Clear( ); + PySys_SetObject("last_traceback", NULL); + free_compiled_text( text ); + return NULL; + } + } + + return PyImport_ExecCodeModule( name, text->compiled ); +} + + +/* + * find in-memory module and recompile + */ + +PyObject *bpy_text_reimport( PyObject *module, int *found ) +{ + Text *text; + char *txtname; + char *name; + char *buf = NULL; +//XXX Main *maggie= bpy_import_main ? bpy_import_main:G.main; + Main *maggie= bpy_import_main; + + *found= 0; + + /* get name, filename from the module itself */ + + txtname = PyModule_GetFilename( module ); + name = PyModule_GetName( module ); + if( !txtname || !name) + return NULL; + + /* look up the text object */ + text = ( Text * ) & ( maggie->text.first ); + while( text ) { + if( !strcmp( txtname, text->id.name+2 ) ) + break; + text = text->id.next; + } + + /* uh-oh.... didn't find it */ + if( !text ) + return NULL; + else + *found = 1; + + /* if previously compiled, free the object */ + /* (can't see how could be NULL, but check just in case) */ + if( text->compiled ){ + Py_DECREF( (PyObject *)text->compiled ); + } + + /* compile the buffer */ + buf = txt_to_buf( text ); + text->compiled = Py_CompileString( buf, text->id.name+2, Py_file_input ); + MEM_freeN( buf ); + + /* if compile failed.... return this error */ + if( PyErr_Occurred( ) ) { + PyErr_Print( ); + PyErr_Clear( ); + PySys_SetObject("last_traceback", NULL); + free_compiled_text( text ); + return NULL; + } + + /* make into a module */ + return PyImport_ExecCodeModule( name, text->compiled ); +} + + +static PyObject *blender_import( PyObject * self, PyObject * args, PyObject * kw) +{ + PyObject *exception, *err, *tb; + char *name; + int found= 0; + PyObject *globals = NULL, *locals = NULL, *fromlist = NULL; + PyObject *newmodule; + + //PyObject_Print(args, stderr, 0); +#if (PY_VERSION_HEX >= 0x02060000) + int dummy_val; /* what does this do?*/ + static char *kwlist[] = {"name", "globals", "locals", "fromlist", "level", 0}; + + if( !PyArg_ParseTupleAndKeywords( args, kw, "s|OOOi:bpy_import_meth", kwlist, + &name, &globals, &locals, &fromlist, &dummy_val) ) + return NULL; +#else + static char *kwlist[] = {"name", "globals", "locals", "fromlist", 0}; + + if( !PyArg_ParseTupleAndKeywords( args, kw, "s|OOO:bpy_import_meth", kwlist, + &name, &globals, &locals, &fromlist ) ) + return NULL; +#endif + + /* import existing builtin modules or modules that have been imported alredy */ + newmodule = PyImport_ImportModuleEx( name, globals, locals, fromlist ); + + if(newmodule) + return newmodule; + + PyErr_Fetch( &exception, &err, &tb ); /* get the python error incase we cant import as blender text either */ + + /* importing from existing modules failed, see if we have this module as blender text */ + newmodule = bpy_text_import( name, &found ); + + if( newmodule ) {/* found module as blender text, ignore above exception */ + PyErr_Clear( ); + Py_XDECREF( exception ); + Py_XDECREF( err ); + Py_XDECREF( tb ); + /* printf( "imported from text buffer...\n" ); */ + } + else if (found==1) { /* blender text module failed to execute but was found, use its error message */ + Py_XDECREF( exception ); + Py_XDECREF( err ); + Py_XDECREF( tb ); + return NULL; + } + else { + /* no blender text was found that could import the module + * rause the original error from PyImport_ImportModuleEx */ + PyErr_Restore( exception, err, tb ); + } + return newmodule; +} + + +/* + * our reload() module, to handle reloading in-memory scripts + */ + +static PyObject *blender_reload( PyObject * self, PyObject * args ) +{ + PyObject *exception, *err, *tb; + PyObject *module = NULL; + PyObject *newmodule = NULL; + int found= 0; + + /* check for a module arg */ + if( !PyArg_ParseTuple( args, "O:bpy_reload_meth", &module ) ) + return NULL; + + /* try reimporting from file */ + newmodule = PyImport_ReloadModule( module ); + if( newmodule ) + return newmodule; + + /* no file, try importing from memory */ + PyErr_Fetch( &exception, &err, &tb ); /*restore for probable later use */ + + newmodule = bpy_text_reimport( module, &found ); + if( newmodule ) {/* found module as blender text, ignore above exception */ + PyErr_Clear( ); + Py_XDECREF( exception ); + Py_XDECREF( err ); + Py_XDECREF( tb ); + /* printf( "imported from text buffer...\n" ); */ + } + else if (found==1) { /* blender text module failed to execute but was found, use its error message */ + Py_XDECREF( exception ); + Py_XDECREF( err ); + Py_XDECREF( tb ); + return NULL; + } + else { + /* no blender text was found that could import the module + * rause the original error from PyImport_ImportModuleEx */ + PyErr_Restore( exception, err, tb ); + } + + return newmodule; +} + +PyMethodDef bpy_import_meth[] = { {"bpy_import_meth", blender_import, METH_VARARGS | METH_KEYWORDS, "blenders import"} }; +PyMethodDef bpy_reload_meth[] = { {"bpy_reload_meth", blender_reload, METH_VARARGS, "blenders reload"} }; + + +/* Clear user modules. + * This is to clear any modules that could be defined from running scripts in blender. + * + * Its also needed for the BGE Python api so imported scripts are not used between levels + * + * This clears every modules that has a __file__ attribute (is not a builtin) + * + * Note that clearing external python modules is important for the BGE otherwise + * it wont reload scripts between loading different blend files or while making the game. + * - use 'clear_all' arg in this case. + * + * Since pythons bultins include a full path even for win32. + * even if we remove a python module a reimport will bring it back again. + */ + +#if 0 // not used anymore but may still come in handy later + +#if defined(WIN32) || defined(WIN64) +#define SEPSTR "\\" +#else +#define SEPSTR "/" +#endif + + +void bpy_text_clear_modules(int clear_all) +{ + PyObject *modules= PySys_GetObject("modules"); + + char *fname; + char *file_extension; + + /* looping over the dict */ + PyObject *key, *value; + int pos = 0; + + /* new list */ + PyObject *list; + + if (modules==NULL) + return; /* should never happen but just incase */ + + list= PyList_New(0); + + /* go over sys.modules and remove anything with a + * sys.modukes[x].__file__ thats ends with a .py and has no path + */ + while (PyDict_Next(modules, &pos, &key, &value)) { + fname= PyModule_GetFilename(value); + if(fname) { + if (clear_all || ((strstr(fname, SEPSTR))==0)) { /* no path ? */ + file_extension = strstr(fname, ".py"); + if(file_extension && (*(file_extension + 3) == '\0' || *(file_extension + 4) == '\0')) { /* .py or pyc extension? */ + /* now we can be fairly sure its a python import from the blendfile */ + PyList_Append(list, key); /* free'd with the list */ + } + } + } + else { + PyErr_Clear(); + } + } + + /* remove all our modules */ + for(pos=0; pos < PyList_Size(list); pos++) { + /* PyObject_Print(key, stderr, 0); */ + key= PyList_GET_ITEM(list, pos); + PyDict_DelItem(modules, key); + } + + Py_DECREF(list); /* removes all references from append */ +} +#endif diff --git a/source/blender/python/generic/bpy_internal_import.h b/source/blender/python/generic/bpy_internal_import.h new file mode 100644 index 00000000000..475ec8dd118 --- /dev/null +++ b/source/blender/python/generic/bpy_internal_import.h @@ -0,0 +1,50 @@ +/* + * $Id: bpy_internal_import.h 20434 2009-05-26 18:06:09Z campbellbarton $ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * This is a new part of Blender. + * + * Contributor(s): Willian P. Germano, Campbell Barton + * + * ***** END GPL LICENSE BLOCK ***** +*/ + +/* Note, the BGE needs to use this too, keep it minimal */ + +#ifndef EXPP_bpy_import_h +#define EXPP_bpy_import_h + +#include <Python.h> +#include "../intern/bpy_compat.h" +#include "compile.h" /* for the PyCodeObject */ +#include "eval.h" /* for PyEval_EvalCode */ + +PyObject* bpy_text_import( char *name, int *found ); +PyObject* bpy_text_reimport( PyObject *module, int *found ); +/* void bpy_text_clear_modules( int clear_all );*/ /* Clear user modules */ +extern PyMethodDef bpy_import_meth[]; +extern PyMethodDef bpy_reload_meth[]; + +/* The game engine has its own Main struct, if this is set search this rather then G.main */ +struct Main *bpy_import_main_get(void); +void bpy_import_main_set(struct Main *maggie); + + +#endif /* EXPP_bpy_import_h */ diff --git a/source/blender/python/generic/euler.c b/source/blender/python/generic/euler.c new file mode 100644 index 00000000000..a65feb7e949 --- /dev/null +++ b/source/blender/python/generic/euler.c @@ -0,0 +1,620 @@ +/* + * $Id: euler.c 20248 2009-05-18 04:11:54Z campbellbarton $ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * + * Contributor(s): Joseph Gilbert + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "Mathutils.h" + +#include "BLI_arithb.h" +#include "BKE_utildefines.h" +#include "BLI_blenlib.h" + + +//-------------------------DOC STRINGS --------------------------- +static char Euler_Zero_doc[] = "() - set all values in the euler to 0"; +static char Euler_Unique_doc[] ="() - sets the euler rotation a unique shortest arc rotation - tests for gimbal lock"; +static char Euler_ToMatrix_doc[] = "() - returns a rotation matrix representing the euler rotation"; +static char Euler_ToQuat_doc[] = "() - returns a quaternion representing the euler rotation"; +static char Euler_Rotate_doc[] = "() - rotate a euler by certain amount around an axis of rotation"; +static char Euler_copy_doc[] = "() - returns a copy of the euler."; +static char Euler_MakeCompatible_doc[] = "(euler) - Make this user compatible with another (no axis flipping)."; + +static PyObject *Euler_Zero( EulerObject * self ); +static PyObject *Euler_Unique( EulerObject * self ); +static PyObject *Euler_ToMatrix( EulerObject * self ); +static PyObject *Euler_ToQuat( EulerObject * self ); +static PyObject *Euler_Rotate( EulerObject * self, PyObject *args ); +static PyObject *Euler_MakeCompatible( EulerObject * self, EulerObject *value ); +static PyObject *Euler_copy( EulerObject * self, PyObject *args ); + +//-----------------------METHOD DEFINITIONS ---------------------- +static struct PyMethodDef Euler_methods[] = { + {"zero", (PyCFunction) Euler_Zero, METH_NOARGS, Euler_Zero_doc}, + {"unique", (PyCFunction) Euler_Unique, METH_NOARGS, Euler_Unique_doc}, + {"toMatrix", (PyCFunction) Euler_ToMatrix, METH_NOARGS, Euler_ToMatrix_doc}, + {"toQuat", (PyCFunction) Euler_ToQuat, METH_NOARGS, Euler_ToQuat_doc}, + {"rotate", (PyCFunction) Euler_Rotate, METH_VARARGS, Euler_Rotate_doc}, + {"makeCompatible", (PyCFunction) Euler_MakeCompatible, METH_O, Euler_MakeCompatible_doc}, + {"__copy__", (PyCFunction) Euler_copy, METH_VARARGS, Euler_copy_doc}, + {"copy", (PyCFunction) Euler_copy, METH_VARARGS, Euler_copy_doc}, + {NULL, NULL, 0, NULL} +}; + +//----------------------------------Mathutils.Euler() ------------------- +//makes a new euler for you to play with +static PyObject *Euler_new(PyObject * self, PyObject * args) +{ + + PyObject *listObject = NULL; + int size, i; + float eul[3], scalar; + PyObject *e; + + size = PyTuple_GET_SIZE(args); + if (size == 1) { + listObject = PyTuple_GET_ITEM(args, 0); + if (PySequence_Check(listObject)) { + size = PySequence_Length(listObject); + } else { // Single argument was not a sequence + PyErr_SetString(PyExc_TypeError, "Mathutils.Euler(): 3d numeric sequence expected\n"); + return NULL; + } + } else if (size == 0) { + //returns a new empty 3d euler + return newEulerObject(NULL, Py_NEW); + } else { + listObject = args; + } + + if (size != 3) { // Invalid euler size + PyErr_SetString(PyExc_AttributeError, "Mathutils.Euler(): 3d numeric sequence expected\n"); + return NULL; + } + + for (i=0; i<size; i++) { + e = PySequence_GetItem(listObject, i); + if (e == NULL) { // Failed to read sequence + Py_DECREF(listObject); + PyErr_SetString(PyExc_RuntimeError, "Mathutils.Euler(): 3d numeric sequence expected\n"); + return NULL; + } + + scalar= (float)PyFloat_AsDouble(e); + Py_DECREF(e); + + if(scalar==-1 && PyErr_Occurred()) { // parsed item is not a number + PyErr_SetString(PyExc_TypeError, "Mathutils.Euler(): 3d numeric sequence expected\n"); + return NULL; + } + + eul[i]= scalar; + } + return newEulerObject(eul, Py_NEW); +} + +//-----------------------------METHODS---------------------------- +//----------------------------Euler.toQuat()---------------------- +//return a quaternion representation of the euler +static PyObject *Euler_ToQuat(EulerObject * self) +{ + float eul[3], quat[4]; + int x; + + for(x = 0; x < 3; x++) { + eul[x] = self->eul[x] * ((float)Py_PI / 180); + } + EulToQuat(eul, quat); + return newQuaternionObject(quat, Py_NEW); +} +//----------------------------Euler.toMatrix()--------------------- +//return a matrix representation of the euler +static PyObject *Euler_ToMatrix(EulerObject * self) +{ + float eul[3]; + float mat[9] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}; + int x; + + for(x = 0; x < 3; x++) { + eul[x] = self->eul[x] * ((float)Py_PI / 180); + } + EulToMat3(eul, (float (*)[3]) mat); + return newMatrixObject(mat, 3, 3 , Py_NEW); +} +//----------------------------Euler.unique()----------------------- +//sets the x,y,z values to a unique euler rotation +static PyObject *Euler_Unique(EulerObject * self) +{ + double heading, pitch, bank; + double pi2 = Py_PI * 2.0f; + double piO2 = Py_PI / 2.0f; + double Opi2 = 1.0f / pi2; + + //radians + heading = self->eul[0] * (float)Py_PI / 180; + pitch = self->eul[1] * (float)Py_PI / 180; + bank = self->eul[2] * (float)Py_PI / 180; + + //wrap heading in +180 / -180 + pitch += Py_PI; + pitch -= floor(pitch * Opi2) * pi2; + pitch -= Py_PI; + + + if(pitch < -piO2) { + pitch = -Py_PI - pitch; + heading += Py_PI; + bank += Py_PI; + } else if(pitch > piO2) { + pitch = Py_PI - pitch; + heading += Py_PI; + bank += Py_PI; + } + //gimbal lock test + if(fabs(pitch) > piO2 - 1e-4) { + heading += bank; + bank = 0.0f; + } else { + bank += Py_PI; + bank -= (floor(bank * Opi2)) * pi2; + bank -= Py_PI; + } + + heading += Py_PI; + heading -= (floor(heading * Opi2)) * pi2; + heading -= Py_PI; + + //back to degrees + self->eul[0] = (float)(heading * 180 / (float)Py_PI); + self->eul[1] = (float)(pitch * 180 / (float)Py_PI); + self->eul[2] = (float)(bank * 180 / (float)Py_PI); + + Py_INCREF(self); + return (PyObject *)self; +} +//----------------------------Euler.zero()------------------------- +//sets the euler to 0,0,0 +static PyObject *Euler_Zero(EulerObject * self) +{ + self->eul[0] = 0.0; + self->eul[1] = 0.0; + self->eul[2] = 0.0; + + Py_INCREF(self); + return (PyObject *)self; +} +//----------------------------Euler.rotate()----------------------- +//rotates a euler a certain amount and returns the result +//should return a unique euler rotation (i.e. no 720 degree pitches :) +static PyObject *Euler_Rotate(EulerObject * self, PyObject *args) +{ + float angle = 0.0f; + char *axis; + int x; + + if(!PyArg_ParseTuple(args, "fs", &angle, &axis)){ + PyErr_SetString(PyExc_TypeError, "euler.rotate():expected angle (float) and axis (x,y,z)"); + return NULL; + } + if(!STREQ3(axis,"x","y","z")){ + PyErr_SetString(PyExc_TypeError, "euler.rotate(): expected axis to be 'x', 'y' or 'z'"); + return NULL; + } + + //covert to radians + angle *= ((float)Py_PI / 180); + for(x = 0; x < 3; x++) { + self->eul[x] *= ((float)Py_PI / 180); + } + euler_rot(self->eul, angle, *axis); + //convert back from radians + for(x = 0; x < 3; x++) { + self->eul[x] *= (180 / (float)Py_PI); + } + + Py_INCREF(self); + return (PyObject *)self; +} + +static PyObject *Euler_MakeCompatible(EulerObject * self, EulerObject *value) +{ + float eul_from_rad[3]; + int x; + + if(!EulerObject_Check(value)) { + PyErr_SetString(PyExc_TypeError, "euler.makeCompatible(euler):expected a single euler argument."); + return NULL; + } + + //covert to radians + for(x = 0; x < 3; x++) { + self->eul[x] = self->eul[x] * ((float)Py_PI / 180); + eul_from_rad[x] = value->eul[x] * ((float)Py_PI / 180); + } + compatible_eul(self->eul, eul_from_rad); + //convert back from radians + for(x = 0; x < 3; x++) { + self->eul[x] *= (180 / (float)Py_PI); + } + + Py_INCREF(self); + return (PyObject *)self; +} + +//----------------------------Euler.rotate()----------------------- +// return a copy of the euler +static PyObject *Euler_copy(EulerObject * self, PyObject *args) +{ + return newEulerObject(self->eul, Py_NEW); +} + + +//----------------------------dealloc()(internal) ------------------ +//free the py_object +static void Euler_dealloc(EulerObject * self) +{ + //only free py_data + if(self->data.py_data){ + PyMem_Free(self->data.py_data); + } + PyObject_DEL(self); +} + +//----------------------------print object (internal)-------------- +//print the object to screen +static PyObject *Euler_repr(EulerObject * self) +{ + char str[64]; + sprintf(str, "[%.6f, %.6f, %.6f](euler)", self->eul[0], self->eul[1], self->eul[2]); + return PyUnicode_FromString(str); +} +//------------------------tp_richcmpr +//returns -1 execption, 0 false, 1 true +static PyObject* Euler_richcmpr(PyObject *objectA, PyObject *objectB, int comparison_type) +{ + EulerObject *eulA = NULL, *eulB = NULL; + int result = 0; + + if (!EulerObject_Check(objectA) || !EulerObject_Check(objectB)){ + if (comparison_type == Py_NE){ + Py_RETURN_TRUE; + }else{ + Py_RETURN_FALSE; + } + } + eulA = (EulerObject*)objectA; + eulB = (EulerObject*)objectB; + + switch (comparison_type){ + case Py_EQ: + result = EXPP_VectorsAreEqual(eulA->eul, eulB->eul, 3, 1); + break; + case Py_NE: + result = EXPP_VectorsAreEqual(eulA->eul, eulB->eul, 3, 1); + if (result == 0){ + result = 1; + }else{ + result = 0; + } + break; + default: + printf("The result of the comparison could not be evaluated"); + break; + } + if (result == 1){ + Py_RETURN_TRUE; + }else{ + Py_RETURN_FALSE; + } +} +//------------------------tp_doc +static char EulerObject_doc[] = "This is a wrapper for euler objects."; +//---------------------SEQUENCE PROTOCOLS------------------------ +//----------------------------len(object)------------------------ +//sequence length +static int Euler_len(EulerObject * self) +{ + return 3; +} +//----------------------------object[]--------------------------- +//sequence accessor (get) +static PyObject *Euler_item(EulerObject * self, int i) +{ + if(i<0) + i= 3-i; + + if(i < 0 || i >= 3) { + PyErr_SetString(PyExc_IndexError, "euler[attribute]: array index out of range"); + return NULL; + } + return PyFloat_FromDouble(self->eul[i]); + +} +//----------------------------object[]------------------------- +//sequence accessor (set) +static int Euler_ass_item(EulerObject * self, int i, PyObject * value) +{ + float f = PyFloat_AsDouble(value); + + if(f == -1 && PyErr_Occurred()) { // parsed item not a number + PyErr_SetString(PyExc_TypeError, "euler[attribute] = x: argument not a number"); + return -1; + } + + if(i<0) + i= 3-i; + + if(i < 0 || i >= 3){ + PyErr_SetString(PyExc_IndexError, "euler[attribute] = x: array assignment index out of range\n"); + return -1; + } + + self->eul[i] = f; + return 0; +} +//----------------------------object[z:y]------------------------ +//sequence slice (get) +static PyObject *Euler_slice(EulerObject * self, int begin, int end) +{ + PyObject *list = NULL; + int count; + + CLAMP(begin, 0, 3); + if (end<0) end= 4+end; + CLAMP(end, 0, 3); + begin = MIN2(begin,end); + + list = PyList_New(end - begin); + for(count = begin; count < end; count++) { + PyList_SetItem(list, count - begin, + PyFloat_FromDouble(self->eul[count])); + } + + return list; +} +//----------------------------object[z:y]------------------------ +//sequence slice (set) +static int Euler_ass_slice(EulerObject * self, int begin, int end, + PyObject * seq) +{ + int i, y, size = 0; + float eul[3]; + PyObject *e, *f; + + CLAMP(begin, 0, 3); + if (end<0) end= 4+end; + CLAMP(end, 0, 3); + begin = MIN2(begin,end); + + size = PySequence_Length(seq); + if(size != (end - begin)){ + PyErr_SetString(PyExc_TypeError, "euler[begin:end] = []: size mismatch in slice assignment"); + return -1; + } + + for (i = 0; i < size; i++) { + e = PySequence_GetItem(seq, i); + if (e == NULL) { // Failed to read sequence + PyErr_SetString(PyExc_RuntimeError, "euler[begin:end] = []: unable to read sequence"); + return -1; + } + + f = PyNumber_Float(e); + if(f == NULL) { // parsed item not a number + Py_DECREF(e); + PyErr_SetString(PyExc_TypeError, "euler[begin:end] = []: sequence argument not a number"); + return -1; + } + + eul[i] = (float)PyFloat_AS_DOUBLE(f); + Py_DECREF(f); + Py_DECREF(e); + } + //parsed well - now set in vector + for(y = 0; y < 3; y++){ + self->eul[begin + y] = eul[y]; + } + return 0; +} +//-----------------PROTCOL DECLARATIONS-------------------------- +static PySequenceMethods Euler_SeqMethods = { + (inquiry) Euler_len, /* sq_length */ + (binaryfunc) 0, /* sq_concat */ + (ssizeargfunc) 0, /* sq_repeat */ + (ssizeargfunc) Euler_item, /* sq_item */ + (ssizessizeargfunc) Euler_slice, /* sq_slice */ + (ssizeobjargproc) Euler_ass_item, /* sq_ass_item */ + (ssizessizeobjargproc) Euler_ass_slice, /* sq_ass_slice */ +}; + + + +/* + * vector axis, vector.x/y/z/w + */ + +static PyObject *Euler_getAxis( EulerObject * self, void *type ) +{ + switch( (long)type ) { + case 'X': /* these are backwards, but that how it works */ + return PyFloat_FromDouble(self->eul[0]); + case 'Y': + return PyFloat_FromDouble(self->eul[1]); + case 'Z': + return PyFloat_FromDouble(self->eul[2]); + } + + PyErr_SetString(PyExc_SystemError, "corrupt euler, cannot get axis"); + return NULL; +} + +static int Euler_setAxis( EulerObject * self, PyObject * value, void * type ) +{ + float param= (float)PyFloat_AsDouble( value ); + + if (param==-1 && PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, "expected a number for the vector axis"); + return -1; + } + + switch( (long)type ) { + case 'X': /* these are backwards, but that how it works */ + self->eul[0]= param; + break; + case 'Y': + self->eul[1]= param; + break; + case 'Z': + self->eul[2]= param; + break; + } + + return 0; +} + +static PyObject *Euler_getWrapped( VectorObject * self, void *type ) +{ + if (self->wrapped == Py_WRAP) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; +} + + +/*****************************************************************************/ +/* Python attributes get/set structure: */ +/*****************************************************************************/ +static PyGetSetDef Euler_getseters[] = { + {"x", + (getter)Euler_getAxis, (setter)Euler_setAxis, + "Euler X axis", + (void *)'X'}, + {"y", + (getter)Euler_getAxis, (setter)Euler_setAxis, + "Euler Y axis", + (void *)'Y'}, + {"z", + (getter)Euler_getAxis, (setter)Euler_setAxis, + "Euler Z axis", + (void *)'Z'}, + {"wrapped", + (getter)Euler_getWrapped, (setter)NULL, + "True when this wraps blenders internal data", + NULL}, + {NULL,NULL,NULL,NULL,NULL} /* Sentinel */ +}; + +//------------------PY_OBECT DEFINITION-------------------------- +PyTypeObject euler_Type = { +#if (PY_VERSION_HEX >= 0x02060000) + PyVarObject_HEAD_INIT(NULL, 0) +#else + /* python 2.5 and below */ + PyObject_HEAD_INIT( NULL ) /* required py macro */ + 0, /* ob_size */ +#endif + "euler", //tp_name + sizeof(EulerObject), //tp_basicsize + 0, //tp_itemsize + (destructor)Euler_dealloc, //tp_dealloc + 0, //tp_print + 0, //tp_getattr + 0, //tp_setattr + 0, //tp_compare + (reprfunc) Euler_repr, //tp_repr + 0, //tp_as_number + &Euler_SeqMethods, //tp_as_sequence + 0, //tp_as_mapping + 0, //tp_hash + 0, //tp_call + 0, //tp_str + 0, //tp_getattro + 0, //tp_setattro + 0, //tp_as_buffer + Py_TPFLAGS_DEFAULT, //tp_flags + EulerObject_doc, //tp_doc + 0, //tp_traverse + 0, //tp_clear + (richcmpfunc)Euler_richcmpr, //tp_richcompare + 0, //tp_weaklistoffset + 0, //tp_iter + 0, //tp_iternext + Euler_methods, //tp_methods + 0, //tp_members + Euler_getseters, //tp_getset + 0, //tp_base + 0, //tp_dict + 0, //tp_descr_get + 0, //tp_descr_set + 0, //tp_dictoffset + 0, //tp_init + 0, //tp_alloc + Euler_new, //tp_new + 0, //tp_free + 0, //tp_is_gc + 0, //tp_bases + 0, //tp_mro + 0, //tp_cache + 0, //tp_subclasses + 0, //tp_weaklist + 0 //tp_del +}; +//------------------------newEulerObject (internal)------------- +//creates a new euler object +/*pass Py_WRAP - if vector is a WRAPPER for data allocated by BLENDER + (i.e. it was allocated elsewhere by MEM_mallocN()) + pass Py_NEW - if vector is not a WRAPPER and managed by PYTHON + (i.e. it must be created here with PyMEM_malloc())*/ +PyObject *newEulerObject(float *eul, int type) +{ + EulerObject *self; + int x; + + self = PyObject_NEW(EulerObject, &euler_Type); + self->data.blend_data = NULL; + self->data.py_data = NULL; + + if(type == Py_WRAP){ + self->data.blend_data = eul; + self->eul = self->data.blend_data; + self->wrapped = Py_WRAP; + }else if (type == Py_NEW){ + self->data.py_data = PyMem_Malloc(3 * sizeof(float)); + self->eul = self->data.py_data; + if(!eul) { //new empty + for(x = 0; x < 3; x++) { + self->eul[x] = 0.0f; + } + }else{ + for(x = 0; x < 3; x++){ + self->eul[x] = eul[x]; + } + } + self->wrapped = Py_NEW; + }else{ //bad type + return NULL; + } + return (PyObject *)self; +} diff --git a/source/blender/python/generic/euler.h b/source/blender/python/generic/euler.h new file mode 100644 index 00000000000..3206668ffa0 --- /dev/null +++ b/source/blender/python/generic/euler.h @@ -0,0 +1,59 @@ +/* + * $Id: euler.h 20248 2009-05-18 04:11:54Z campbellbarton $ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Joseph Gilbert + * + * ***** END GPL LICENSE BLOCK ***** + * + */ + +#ifndef EXPP_euler_h +#define EXPP_euler_h + +#include <Python.h> +#include "../intern/bpy_compat.h" + +extern PyTypeObject euler_Type; + +#define EulerObject_Check(v) (Py_TYPE(v) == &euler_Type) + +typedef struct { + PyObject_VAR_HEAD + struct{ + float *py_data; //python managed + float *blend_data; //blender managed + }data; + float *eul; //1D array of data (alias) + int wrapped; //is wrapped data? +} EulerObject; + +/*struct data contains a pointer to the actual data that the +object uses. It can use either PyMem allocated data (which will +be stored in py_data) or be a wrapper for data allocated through +blender (stored in blend_data). This is an either/or struct not both*/ + +//prototypes +PyObject *newEulerObject( float *eul, int type ); + +#endif /* EXPP_euler_h */ diff --git a/source/blender/python/generic/matrix.c b/source/blender/python/generic/matrix.c new file mode 100644 index 00000000000..e2ab1c3c653 --- /dev/null +++ b/source/blender/python/generic/matrix.c @@ -0,0 +1,1058 @@ +/* + * $Id: matrix.c 20249 2009-05-18 04:27:48Z campbellbarton $ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * Contributor(s): Michel Selten & Joseph Gilbert + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "Mathutils.h" + +#include "BKE_utildefines.h" +#include "BLI_arithb.h" +#include "BLI_blenlib.h" + +/*-------------------------DOC STRINGS ---------------------------*/ +static char Matrix_Zero_doc[] = "() - set all values in the matrix to 0"; +static char Matrix_Identity_doc[] = "() - set the square matrix to it's identity matrix"; +static char Matrix_Transpose_doc[] = "() - set the matrix to it's transpose"; +static char Matrix_Determinant_doc[] = "() - return the determinant of the matrix"; +static char Matrix_Invert_doc[] = "() - set the matrix to it's inverse if an inverse is possible"; +static char Matrix_TranslationPart_doc[] = "() - return a vector encompassing the translation of the matrix"; +static char Matrix_RotationPart_doc[] = "() - return a vector encompassing the rotation of the matrix"; +static char Matrix_scalePart_doc[] = "() - convert matrix to a 3D vector"; +static char Matrix_Resize4x4_doc[] = "() - resize the matrix to a 4x4 square matrix"; +static char Matrix_toEuler_doc[] = "(eul_compat) - convert matrix to a euler angle rotation, optional euler argument that the new euler will be made compatible with."; +static char Matrix_toQuat_doc[] = "() - convert matrix to a quaternion rotation"; +static char Matrix_copy_doc[] = "() - return a copy of the matrix"; + +static PyObject *Matrix_Zero( MatrixObject * self ); +static PyObject *Matrix_Identity( MatrixObject * self ); +static PyObject *Matrix_Transpose( MatrixObject * self ); +static PyObject *Matrix_Determinant( MatrixObject * self ); +static PyObject *Matrix_Invert( MatrixObject * self ); +static PyObject *Matrix_TranslationPart( MatrixObject * self ); +static PyObject *Matrix_RotationPart( MatrixObject * self ); +static PyObject *Matrix_scalePart( MatrixObject * self ); +static PyObject *Matrix_Resize4x4( MatrixObject * self ); +static PyObject *Matrix_toEuler( MatrixObject * self, PyObject *args ); +static PyObject *Matrix_toQuat( MatrixObject * self ); +static PyObject *Matrix_copy( MatrixObject * self ); + +/*-----------------------METHOD DEFINITIONS ----------------------*/ +static struct PyMethodDef Matrix_methods[] = { + {"zero", (PyCFunction) Matrix_Zero, METH_NOARGS, Matrix_Zero_doc}, + {"identity", (PyCFunction) Matrix_Identity, METH_NOARGS, Matrix_Identity_doc}, + {"transpose", (PyCFunction) Matrix_Transpose, METH_NOARGS, Matrix_Transpose_doc}, + {"determinant", (PyCFunction) Matrix_Determinant, METH_NOARGS, Matrix_Determinant_doc}, + {"invert", (PyCFunction) Matrix_Invert, METH_NOARGS, Matrix_Invert_doc}, + {"translationPart", (PyCFunction) Matrix_TranslationPart, METH_NOARGS, Matrix_TranslationPart_doc}, + {"rotationPart", (PyCFunction) Matrix_RotationPart, METH_NOARGS, Matrix_RotationPart_doc}, + {"scalePart", (PyCFunction) Matrix_scalePart, METH_NOARGS, Matrix_scalePart_doc}, + {"resize4x4", (PyCFunction) Matrix_Resize4x4, METH_NOARGS, Matrix_Resize4x4_doc}, + {"toEuler", (PyCFunction) Matrix_toEuler, METH_VARARGS, Matrix_toEuler_doc}, + {"toQuat", (PyCFunction) Matrix_toQuat, METH_NOARGS, Matrix_toQuat_doc}, + {"copy", (PyCFunction) Matrix_copy, METH_NOARGS, Matrix_copy_doc}, + {"__copy__", (PyCFunction) Matrix_copy, METH_NOARGS, Matrix_copy_doc}, + {NULL, NULL, 0, NULL} +}; + +//----------------------------------Mathutils.Matrix() ----------------- +//mat is a 1D array of floats - row[0][0],row[0][1], row[1][0], etc. +//create a new matrix type +static PyObject *Matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + PyObject *argObject, *m, *s; + MatrixObject *mat; + int argSize, seqSize = 0, i, j; + float matrix[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; + float scalar; + + argSize = PyTuple_GET_SIZE(args); + if(argSize > 4){ //bad arg nums + PyErr_SetString(PyExc_AttributeError, "Mathutils.Matrix(): expects 0-4 numeric sequences of the same size\n"); + return NULL; + } else if (argSize == 0) { //return empty 4D matrix + return (PyObject *) newMatrixObject(NULL, 4, 4, Py_NEW); + }else if (argSize == 1){ + //copy constructor for matrix objects + argObject = PyTuple_GET_ITEM(args, 0); + if(MatrixObject_Check(argObject)){ + mat = (MatrixObject*)argObject; + + argSize = mat->rowSize; //rows + seqSize = mat->colSize; //col + for(i = 0; i < (seqSize * argSize); i++){ + matrix[i] = mat->contigPtr[i]; + } + } + }else{ //2-4 arguments (all seqs? all same size?) + for(i =0; i < argSize; i++){ + argObject = PyTuple_GET_ITEM(args, i); + if (PySequence_Check(argObject)) { //seq? + if(seqSize){ //0 at first + if(PySequence_Length(argObject) != seqSize){ //seq size not same + PyErr_SetString(PyExc_AttributeError, "Mathutils.Matrix(): expects 0-4 numeric sequences of the same size\n"); + return NULL; + } + } + seqSize = PySequence_Length(argObject); + }else{ //arg not a sequence + PyErr_SetString(PyExc_TypeError, "Mathutils.Matrix(): expects 0-4 numeric sequences of the same size\n"); + return NULL; + } + } + //all is well... let's continue parsing + for (i = 0; i < argSize; i++){ + m = PyTuple_GET_ITEM(args, i); + if (m == NULL) { // Failed to read sequence + PyErr_SetString(PyExc_RuntimeError, "Mathutils.Matrix(): failed to parse arguments...\n"); + return NULL; + } + + for (j = 0; j < seqSize; j++) { + s = PySequence_GetItem(m, j); + if (s == NULL) { // Failed to read sequence + PyErr_SetString(PyExc_RuntimeError, "Mathutils.Matrix(): failed to parse arguments...\n"); + return NULL; + } + + scalar= (float)PyFloat_AsDouble(s); + Py_DECREF(s); + + if(scalar==-1 && PyErr_Occurred()) { // parsed item is not a number + PyErr_SetString(PyExc_AttributeError, "Mathutils.Matrix(): expects 0-4 numeric sequences of the same size\n"); + return NULL; + } + + matrix[(seqSize*i)+j]= scalar; + } + } + } + return newMatrixObject(matrix, argSize, seqSize, Py_NEW); +} + +/*-----------------------------METHODS----------------------------*/ +/*---------------------------Matrix.toQuat() ---------------------*/ +static PyObject *Matrix_toQuat(MatrixObject * self) +{ + float quat[4]; + + /*must be 3-4 cols, 3-4 rows, square matrix*/ + if(self->colSize < 3 || self->rowSize < 3 || (self->colSize != self->rowSize)) { + PyErr_SetString(PyExc_AttributeError, "Matrix.toQuat(): inappropriate matrix size - expects 3x3 or 4x4 matrix"); + return NULL; + } + if(self->colSize == 3){ + Mat3ToQuat((float (*)[3])*self->matrix, quat); + }else{ + Mat4ToQuat((float (*)[4])*self->matrix, quat); + } + + return newQuaternionObject(quat, Py_NEW); +} +/*---------------------------Matrix.toEuler() --------------------*/ +PyObject *Matrix_toEuler(MatrixObject * self, PyObject *args) +{ + float eul[3], eul_compatf[3]; + EulerObject *eul_compat = NULL; + int x; + + if(!PyArg_ParseTuple(args, "|O!:toEuler", &euler_Type, &eul_compat)) + return NULL; + + if(eul_compat) { + for(x = 0; x < 3; x++) { + eul_compatf[x] = eul_compat->eul[x] * ((float)Py_PI / 180); + } + } + + /*must be 3-4 cols, 3-4 rows, square matrix*/ + if(self->colSize ==3 && self->rowSize ==3) { + if(eul_compat) Mat3ToCompatibleEul((float (*)[3])*self->matrix, eul, eul_compatf); + else Mat3ToEul((float (*)[3])*self->matrix, eul); + }else if (self->colSize ==4 && self->rowSize ==4) { + float tempmat3[3][3]; + Mat3CpyMat4(tempmat3, (float (*)[4])*self->matrix); + Mat3ToEul(tempmat3, eul); + if(eul_compat) Mat3ToCompatibleEul(tempmat3, eul, eul_compatf); + else Mat3ToEul(tempmat3, eul); + + }else { + PyErr_SetString(PyExc_AttributeError, "Matrix.toEuler(): inappropriate matrix size - expects 3x3 or 4x4 matrix\n"); + return NULL; + } + /*have to convert to degrees*/ + for(x = 0; x < 3; x++) { + eul[x] *= (float) (180 / Py_PI); + } + return newEulerObject(eul, Py_NEW); +} +/*---------------------------Matrix.resize4x4() ------------------*/ +PyObject *Matrix_Resize4x4(MatrixObject * self) +{ + int x, first_row_elem, curr_pos, new_pos, blank_columns, blank_rows, index; + + if(self->data.blend_data){ + PyErr_SetString(PyExc_TypeError, "cannot resize wrapped data - only python matrices"); + return NULL; + } + + self->data.py_data = PyMem_Realloc(self->data.py_data, (sizeof(float) * 16)); + if(self->data.py_data == NULL) { + PyErr_SetString(PyExc_MemoryError, "matrix.resize4x4(): problem allocating pointer space"); + return NULL; + } + self->contigPtr = self->data.py_data; /*force*/ + self->matrix = PyMem_Realloc(self->matrix, (sizeof(float *) * 4)); + if(self->matrix == NULL) { + PyErr_SetString(PyExc_MemoryError, "matrix.resize4x4(): problem allocating pointer space"); + return NULL; + } + /*set row pointers*/ + for(x = 0; x < 4; x++) { + self->matrix[x] = self->contigPtr + (x * 4); + } + /*move data to new spot in array + clean*/ + for(blank_rows = (4 - self->rowSize); blank_rows > 0; blank_rows--){ + for(x = 0; x < 4; x++){ + index = (4 * (self->rowSize + (blank_rows - 1))) + x; + if (index == 10 || index == 15){ + self->contigPtr[index] = 1.0f; + }else{ + self->contigPtr[index] = 0.0f; + } + } + } + for(x = 1; x <= self->rowSize; x++){ + first_row_elem = (self->colSize * (self->rowSize - x)); + curr_pos = (first_row_elem + (self->colSize -1)); + new_pos = (4 * (self->rowSize - x )) + (curr_pos - first_row_elem); + for(blank_columns = (4 - self->colSize); blank_columns > 0; blank_columns--){ + self->contigPtr[new_pos + blank_columns] = 0.0f; + } + for(curr_pos = curr_pos; curr_pos >= first_row_elem; curr_pos--){ + self->contigPtr[new_pos] = self->contigPtr[curr_pos]; + new_pos--; + } + } + self->rowSize = 4; + self->colSize = 4; + + Py_INCREF(self); + return (PyObject *)self; +} +/*---------------------------Matrix.translationPart() ------------*/ +PyObject *Matrix_TranslationPart(MatrixObject * self) +{ + float vec[4]; + + if(self->colSize < 3 || self->rowSize < 4){ + PyErr_SetString(PyExc_AttributeError, "Matrix.translationPart: inappropriate matrix size"); + return NULL; + } + + vec[0] = self->matrix[3][0]; + vec[1] = self->matrix[3][1]; + vec[2] = self->matrix[3][2]; + + return newVectorObject(vec, 3, Py_NEW); +} +/*---------------------------Matrix.rotationPart() ---------------*/ +PyObject *Matrix_RotationPart(MatrixObject * self) +{ + float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; + + if(self->colSize < 3 || self->rowSize < 3){ + PyErr_SetString(PyExc_AttributeError, "Matrix.rotationPart: inappropriate matrix size\n"); + return NULL; + } + + mat[0] = self->matrix[0][0]; + mat[1] = self->matrix[0][1]; + mat[2] = self->matrix[0][2]; + mat[3] = self->matrix[1][0]; + mat[4] = self->matrix[1][1]; + mat[5] = self->matrix[1][2]; + mat[6] = self->matrix[2][0]; + mat[7] = self->matrix[2][1]; + mat[8] = self->matrix[2][2]; + + return newMatrixObject(mat, 3, 3, Py_NEW); +} +/*---------------------------Matrix.scalePart() --------------------*/ +PyObject *Matrix_scalePart(MatrixObject * self) +{ + float scale[3], rot[3]; + float mat[3][3], imat[3][3], tmat[3][3]; + + /*must be 3-4 cols, 3-4 rows, square matrix*/ + if(self->colSize == 4 && self->rowSize == 4) + Mat3CpyMat4(mat, (float (*)[4])*self->matrix); + else if(self->colSize == 3 && self->rowSize == 3) + Mat3CpyMat3(mat, (float (*)[3])*self->matrix); + else { + PyErr_SetString(PyExc_AttributeError, "Matrix.scalePart(): inappropriate matrix size - expects 3x3 or 4x4 matrix\n"); + return NULL; + } + /* functionality copied from editobject.c apply_obmat */ + Mat3ToEul(mat, rot); + EulToMat3(rot, tmat); + Mat3Inv(imat, tmat); + Mat3MulMat3(tmat, imat, mat); + + scale[0]= tmat[0][0]; + scale[1]= tmat[1][1]; + scale[2]= tmat[2][2]; + return newVectorObject(scale, 3, Py_NEW); +} +/*---------------------------Matrix.invert() ---------------------*/ +PyObject *Matrix_Invert(MatrixObject * self) +{ + + int x, y, z = 0; + float det = 0.0f; + PyObject *f = NULL; + float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; + + if(self->rowSize != self->colSize){ + PyErr_SetString(PyExc_AttributeError, "Matrix.invert(ed): only square matrices are supported"); + return NULL; + } + + /*calculate the determinant*/ + f = Matrix_Determinant(self); + det = (float)PyFloat_AS_DOUBLE(f); /*Increfs, so we need to decref*/ + Py_DECREF(f); + + if(det != 0) { + /*calculate the classical adjoint*/ + if(self->rowSize == 2) { + mat[0] = self->matrix[1][1]; + mat[1] = -self->matrix[0][1]; + mat[2] = -self->matrix[1][0]; + mat[3] = self->matrix[0][0]; + } else if(self->rowSize == 3) { + Mat3Adj((float (*)[3]) mat,(float (*)[3]) *self->matrix); + } else if(self->rowSize == 4) { + Mat4Adj((float (*)[4]) mat, (float (*)[4]) *self->matrix); + } + /*divide by determinate*/ + for(x = 0; x < (self->rowSize * self->colSize); x++) { + mat[x] /= det; + } + /*set values*/ + for(x = 0; x < self->rowSize; x++) { + for(y = 0; y < self->colSize; y++) { + self->matrix[x][y] = mat[z]; + z++; + } + } + /*transpose + Matrix_Transpose(self);*/ + } else { + PyErr_SetString(PyExc_ValueError, "matrix does not have an inverse"); + return NULL; + } + + Py_INCREF(self); + return (PyObject *)self; +} + + +/*---------------------------Matrix.determinant() ----------------*/ +PyObject *Matrix_Determinant(MatrixObject * self) +{ + float det = 0.0f; + + if(self->rowSize != self->colSize){ + PyErr_SetString(PyExc_AttributeError, "Matrix.determinant: only square matrices are supported"); + return NULL; + } + + if(self->rowSize == 2) { + det = Det2x2(self->matrix[0][0], self->matrix[0][1], + self->matrix[1][0], self->matrix[1][1]); + } else if(self->rowSize == 3) { + det = Det3x3(self->matrix[0][0], self->matrix[0][1], + self->matrix[0][2], self->matrix[1][0], + self->matrix[1][1], self->matrix[1][2], + self->matrix[2][0], self->matrix[2][1], + self->matrix[2][2]); + } else { + det = Det4x4((float (*)[4]) *self->matrix); + } + + return PyFloat_FromDouble( (double) det ); +} +/*---------------------------Matrix.transpose() ------------------*/ +PyObject *Matrix_Transpose(MatrixObject * self) +{ + float t = 0.0f; + + if(self->rowSize != self->colSize){ + PyErr_SetString(PyExc_AttributeError, "Matrix.transpose(d): only square matrices are supported"); + return NULL; + } + + if(self->rowSize == 2) { + t = self->matrix[1][0]; + self->matrix[1][0] = self->matrix[0][1]; + self->matrix[0][1] = t; + } else if(self->rowSize == 3) { + Mat3Transp((float (*)[3])*self->matrix); + } else { + Mat4Transp((float (*)[4])*self->matrix); + } + + Py_INCREF(self); + return (PyObject *)self; +} + + +/*---------------------------Matrix.zero() -----------------------*/ +PyObject *Matrix_Zero(MatrixObject * self) +{ + int row, col; + + for(row = 0; row < self->rowSize; row++) { + for(col = 0; col < self->colSize; col++) { + self->matrix[row][col] = 0.0f; + } + } + Py_INCREF(self); + return (PyObject *)self; +} +/*---------------------------Matrix.identity(() ------------------*/ +PyObject *Matrix_Identity(MatrixObject * self) +{ + if(self->rowSize != self->colSize){ + PyErr_SetString(PyExc_AttributeError, "Matrix.identity: only square matrices are supported\n"); + return NULL; + } + + if(self->rowSize == 2) { + self->matrix[0][0] = 1.0f; + self->matrix[0][1] = 0.0f; + self->matrix[1][0] = 0.0f; + self->matrix[1][1] = 1.0f; + } else if(self->rowSize == 3) { + Mat3One((float (*)[3]) *self->matrix); + } else { + Mat4One((float (*)[4]) *self->matrix); + } + + Py_INCREF(self); + return (PyObject *)self; +} + +/*---------------------------Matrix.inverted() ------------------*/ +PyObject *Matrix_copy(MatrixObject * self) +{ + return (PyObject*)(MatrixObject*)newMatrixObject((float (*))*self->matrix, self->rowSize, self->colSize, Py_NEW); +} + +/*----------------------------dealloc()(internal) ----------------*/ +/*free the py_object*/ +static void Matrix_dealloc(MatrixObject * self) +{ + PyMem_Free(self->matrix); + /*only free py_data*/ + if(self->data.py_data){ + PyMem_Free(self->data.py_data); + } + PyObject_DEL(self); +} + +/*----------------------------print object (internal)-------------*/ +/*print the object to screen*/ +static PyObject *Matrix_repr(MatrixObject * self) +{ + int x, y; + char buffer[48], str[1024]; + + BLI_strncpy(str,"",1024); + for(x = 0; x < self->rowSize; x++){ + sprintf(buffer, "["); + strcat(str,buffer); + for(y = 0; y < (self->colSize - 1); y++) { + sprintf(buffer, "%.6f, ", self->matrix[x][y]); + strcat(str,buffer); + } + if(x < (self->rowSize-1)){ + sprintf(buffer, "%.6f](matrix [row %d])\n", self->matrix[x][y], x); + strcat(str,buffer); + }else{ + sprintf(buffer, "%.6f](matrix [row %d])", self->matrix[x][y], x); + strcat(str,buffer); + } + } + + return PyUnicode_FromString(str); +} +/*------------------------tp_richcmpr*/ +/*returns -1 execption, 0 false, 1 true*/ +static PyObject* Matrix_richcmpr(PyObject *objectA, PyObject *objectB, int comparison_type) +{ + MatrixObject *matA = NULL, *matB = NULL; + int result = 0; + + if (!MatrixObject_Check(objectA) || !MatrixObject_Check(objectB)){ + if (comparison_type == Py_NE){ + Py_RETURN_TRUE; + }else{ + Py_RETURN_FALSE; + } + } + matA = (MatrixObject*)objectA; + matB = (MatrixObject*)objectB; + + if (matA->colSize != matB->colSize || matA->rowSize != matB->rowSize){ + if (comparison_type == Py_NE){ + Py_RETURN_TRUE; + }else{ + Py_RETURN_FALSE; + } + } + + switch (comparison_type){ + case Py_EQ: + /*contigPtr is basically a really long vector*/ + result = EXPP_VectorsAreEqual(matA->contigPtr, matB->contigPtr, + (matA->rowSize * matA->colSize), 1); + break; + case Py_NE: + result = EXPP_VectorsAreEqual(matA->contigPtr, matB->contigPtr, + (matA->rowSize * matA->colSize), 1); + if (result == 0){ + result = 1; + }else{ + result = 0; + } + break; + default: + printf("The result of the comparison could not be evaluated"); + break; + } + if (result == 1){ + Py_RETURN_TRUE; + }else{ + Py_RETURN_FALSE; + } +} +/*------------------------tp_doc*/ +static char MatrixObject_doc[] = "This is a wrapper for matrix objects."; +/*---------------------SEQUENCE PROTOCOLS------------------------ + ----------------------------len(object)------------------------ + sequence length*/ +static int Matrix_len(MatrixObject * self) +{ + return (self->rowSize); +} +/*----------------------------object[]--------------------------- + sequence accessor (get) + the wrapped vector gives direct access to the matrix data*/ +static PyObject *Matrix_item(MatrixObject * self, int i) +{ + if(i < 0 || i >= self->rowSize) { + PyErr_SetString(PyExc_IndexError, "matrix[attribute]: array index out of range"); + return NULL; + } + return newVectorObject(self->matrix[i], self->colSize, Py_WRAP); +} +/*----------------------------object[]------------------------- + sequence accessor (set)*/ +static int Matrix_ass_item(MatrixObject * self, int i, PyObject * ob) +{ + int y, x, size = 0; + float vec[4]; + PyObject *m, *f; + + if(i >= self->rowSize || i < 0){ + PyErr_SetString(PyExc_TypeError, "matrix[attribute] = x: bad row\n"); + return -1; + } + + if(PySequence_Check(ob)){ + size = PySequence_Length(ob); + if(size != self->colSize){ + PyErr_SetString(PyExc_TypeError, "matrix[attribute] = x: bad sequence size\n"); + return -1; + } + for (x = 0; x < size; x++) { + m = PySequence_GetItem(ob, x); + if (m == NULL) { /*Failed to read sequence*/ + PyErr_SetString(PyExc_RuntimeError, "matrix[attribute] = x: unable to read sequence\n"); + return -1; + } + + f = PyNumber_Float(m); + if(f == NULL) { /*parsed item not a number*/ + Py_DECREF(m); + PyErr_SetString(PyExc_TypeError, "matrix[attribute] = x: sequence argument not a number\n"); + return -1; + } + + vec[x] = (float)PyFloat_AS_DOUBLE(f); + Py_DECREF(m); + Py_DECREF(f); + } + /*parsed well - now set in matrix*/ + for(y = 0; y < size; y++){ + self->matrix[i][y] = vec[y]; + } + return 0; + }else{ + PyErr_SetString(PyExc_TypeError, "matrix[attribute] = x: expects a sequence of column size\n"); + return -1; + } +} +/*----------------------------object[z:y]------------------------ + sequence slice (get)*/ +static PyObject *Matrix_slice(MatrixObject * self, int begin, int end) +{ + + PyObject *list = NULL; + int count; + + CLAMP(begin, 0, self->rowSize); + CLAMP(end, 0, self->rowSize); + begin = MIN2(begin,end); + + list = PyList_New(end - begin); + for(count = begin; count < end; count++) { + PyList_SetItem(list, count - begin, + newVectorObject(self->matrix[count], self->colSize, Py_WRAP)); + } + + return list; +} +/*----------------------------object[z:y]------------------------ + sequence slice (set)*/ +static int Matrix_ass_slice(MatrixObject * self, int begin, int end, + PyObject * seq) +{ + int i, x, y, size, sub_size = 0; + float mat[16], f; + PyObject *subseq; + PyObject *m; + + CLAMP(begin, 0, self->rowSize); + CLAMP(end, 0, self->rowSize); + begin = MIN2(begin,end); + + if(PySequence_Check(seq)){ + size = PySequence_Length(seq); + if(size != (end - begin)){ + PyErr_SetString(PyExc_TypeError, "matrix[begin:end] = []: size mismatch in slice assignment\n"); + return -1; + } + /*parse sub items*/ + for (i = 0; i < size; i++) { + /*parse each sub sequence*/ + subseq = PySequence_GetItem(seq, i); + if (subseq == NULL) { /*Failed to read sequence*/ + PyErr_SetString(PyExc_RuntimeError, "matrix[begin:end] = []: unable to read sequence"); + return -1; + } + + if(PySequence_Check(subseq)){ + /*subsequence is also a sequence*/ + sub_size = PySequence_Length(subseq); + if(sub_size != self->colSize){ + Py_DECREF(subseq); + PyErr_SetString(PyExc_TypeError, "matrix[begin:end] = []: size mismatch in slice assignment\n"); + return -1; + } + for (y = 0; y < sub_size; y++) { + m = PySequence_GetItem(subseq, y); + if (m == NULL) { /*Failed to read sequence*/ + Py_DECREF(subseq); + PyErr_SetString(PyExc_RuntimeError, "matrix[begin:end] = []: unable to read sequence\n"); + return -1; + } + + f = PyFloat_AsDouble(m); /* faster to assume a float and raise an error after */ + if(f == -1 && PyErr_Occurred()) { /*parsed item not a number*/ + Py_DECREF(m); + Py_DECREF(subseq); + PyErr_SetString(PyExc_TypeError, "matrix[begin:end] = []: sequence argument not a number\n"); + return -1; + } + + mat[(i * self->colSize) + y] = f; + Py_DECREF(m); + } + }else{ + Py_DECREF(subseq); + PyErr_SetString(PyExc_TypeError, "matrix[begin:end] = []: illegal argument type for built-in operation\n"); + return -1; + } + Py_DECREF(subseq); + } + /*parsed well - now set in matrix*/ + for(x = 0; x < (size * sub_size); x++){ + self->matrix[begin + (int)floor(x / self->colSize)][x % self->colSize] = mat[x]; + } + return 0; + }else{ + PyErr_SetString(PyExc_TypeError, "matrix[begin:end] = []: illegal argument type for built-in operation\n"); + return -1; + } +} +/*------------------------NUMERIC PROTOCOLS---------------------- + ------------------------obj + obj------------------------------*/ +static PyObject *Matrix_add(PyObject * m1, PyObject * m2) +{ + int x, y; + float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; + MatrixObject *mat1 = NULL, *mat2 = NULL; + + mat1 = (MatrixObject*)m1; + mat2 = (MatrixObject*)m2; + + if(!MatrixObject_Check(m1) || !MatrixObject_Check(m2)) { + PyErr_SetString(PyExc_AttributeError, "Matrix addition: arguments not valid for this operation...."); + return NULL; + } + if(mat1->rowSize != mat2->rowSize || mat1->colSize != mat2->colSize){ + PyErr_SetString(PyExc_AttributeError, "Matrix addition: matrices must have the same dimensions for this operation"); + return NULL; + } + + for(x = 0; x < mat1->rowSize; x++) { + for(y = 0; y < mat1->colSize; y++) { + mat[((x * mat1->colSize) + y)] = mat1->matrix[x][y] + mat2->matrix[x][y]; + } + } + + return newMatrixObject(mat, mat1->rowSize, mat1->colSize, Py_NEW); +} +/*------------------------obj - obj------------------------------ + subtraction*/ +static PyObject *Matrix_sub(PyObject * m1, PyObject * m2) +{ + int x, y; + float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; + MatrixObject *mat1 = NULL, *mat2 = NULL; + + mat1 = (MatrixObject*)m1; + mat2 = (MatrixObject*)m2; + + if(!MatrixObject_Check(m1) || !MatrixObject_Check(m2)) { + PyErr_SetString(PyExc_AttributeError, "Matrix addition: arguments not valid for this operation...."); + return NULL; + } + if(mat1->rowSize != mat2->rowSize || mat1->colSize != mat2->colSize){ + PyErr_SetString(PyExc_AttributeError, "Matrix addition: matrices must have the same dimensions for this operation"); + return NULL; + } + + for(x = 0; x < mat1->rowSize; x++) { + for(y = 0; y < mat1->colSize; y++) { + mat[((x * mat1->colSize) + y)] = mat1->matrix[x][y] - mat2->matrix[x][y]; + } + } + + return newMatrixObject(mat, mat1->rowSize, mat1->colSize, Py_NEW); +} +/*------------------------obj * obj------------------------------ + mulplication*/ +static PyObject *Matrix_mul(PyObject * m1, PyObject * m2) +{ + int x, y, z; + float scalar; + float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; + double dot = 0.0f; + MatrixObject *mat1 = NULL, *mat2 = NULL; + + if(MatrixObject_Check(m1)) mat1 = (MatrixObject*)m1; + if(MatrixObject_Check(m2)) mat2 = (MatrixObject*)m2; + + if(mat1 && mat2) { /*MATRIX * MATRIX*/ + if(mat1->colSize != mat2->rowSize){ + PyErr_SetString(PyExc_AttributeError,"Matrix multiplication: matrix A rowsize must equal matrix B colsize"); + return NULL; + } + for(x = 0; x < mat1->rowSize; x++) { + for(y = 0; y < mat2->colSize; y++) { + for(z = 0; z < mat1->colSize; z++) { + dot += (mat1->matrix[x][z] * mat2->matrix[z][y]); + } + mat[((x * mat1->rowSize) + y)] = (float)dot; + dot = 0.0f; + } + } + + return newMatrixObject(mat, mat1->rowSize, mat2->colSize, Py_NEW); + } + + if(mat1==NULL){ + scalar=PyFloat_AsDouble(m1); // may not be a float... + if ((scalar == -1.0 && PyErr_Occurred())==0) { /*FLOAT/INT * MATRIX, this line annoys theeth, lets see if he finds it */ + for(x = 0; x < mat2->rowSize; x++) { + for(y = 0; y < mat2->colSize; y++) { + mat[((x * mat2->colSize) + y)] = scalar * mat2->matrix[x][y]; + } + } + return newMatrixObject(mat, mat2->rowSize, mat2->colSize, Py_NEW); + } + + PyErr_SetString(PyExc_TypeError, "Matrix multiplication: arguments not acceptable for this operation"); + return NULL; + } + else /* if(mat1) { */ { + + if(VectorObject_Check(m2)) { /* MATRIX*VECTOR */ + return column_vector_multiplication(mat1, (VectorObject *)m2); + } + else { + scalar= PyFloat_AsDouble(m2); + if ((scalar == -1.0 && PyErr_Occurred())==0) { /* MATRIX*FLOAT/INT */ + for(x = 0; x < mat1->rowSize; x++) { + for(y = 0; y < mat1->colSize; y++) { + mat[((x * mat1->colSize) + y)] = scalar * mat1->matrix[x][y]; + } + } + return newMatrixObject(mat, mat1->rowSize, mat1->colSize, Py_NEW); + } + } + PyErr_SetString(PyExc_TypeError, "Matrix multiplication: arguments not acceptable for this operation"); + return NULL; + } + + PyErr_SetString(PyExc_TypeError, "Matrix multiplication: arguments not acceptable for this operation\n"); + return NULL; +} +static PyObject* Matrix_inv(MatrixObject *self) +{ + return Matrix_Invert(self); +} + +/*-----------------PROTOCOL DECLARATIONS--------------------------*/ +static PySequenceMethods Matrix_SeqMethods = { + (inquiry) Matrix_len, /* sq_length */ + (binaryfunc) 0, /* sq_concat */ + (ssizeargfunc) 0, /* sq_repeat */ + (ssizeargfunc) Matrix_item, /* sq_item */ + (ssizessizeargfunc) Matrix_slice, /* sq_slice */ + (ssizeobjargproc) Matrix_ass_item, /* sq_ass_item */ + (ssizessizeobjargproc) Matrix_ass_slice, /* sq_ass_slice */ +}; +static PyNumberMethods Matrix_NumMethods = { + (binaryfunc) Matrix_add, /* __add__ */ + (binaryfunc) Matrix_sub, /* __sub__ */ + (binaryfunc) Matrix_mul, /* __mul__ */ + (binaryfunc) 0, /* __div__ */ + (binaryfunc) 0, /* __mod__ */ + (binaryfunc) 0, /* __divmod__ */ + (ternaryfunc) 0, /* __pow__ */ + (unaryfunc) 0, /* __neg__ */ + (unaryfunc) 0, /* __pos__ */ + (unaryfunc) 0, /* __abs__ */ + (inquiry) 0, /* __nonzero__ */ + (unaryfunc) Matrix_inv, /* __invert__ */ + (binaryfunc) 0, /* __lshift__ */ + (binaryfunc) 0, /* __rshift__ */ + (binaryfunc) 0, /* __and__ */ + (binaryfunc) 0, /* __xor__ */ + (binaryfunc) 0, /* __or__ */ + /*(coercion)*/ 0, /* __coerce__ */ + (unaryfunc) 0, /* __int__ */ + (unaryfunc) 0, /* __long__ */ + (unaryfunc) 0, /* __float__ */ + (unaryfunc) 0, /* __oct__ */ + (unaryfunc) 0, /* __hex__ */ +}; + +static PyObject *Matrix_getRowSize( MatrixObject * self, void *type ) +{ + return PyLong_FromLong((long) self->rowSize); +} + +static PyObject *Matrix_getColSize( MatrixObject * self, void *type ) +{ + return PyLong_FromLong((long) self->colSize); +} + +static PyObject *Matrix_getWrapped( MatrixObject * self, void *type ) +{ + if (self->wrapped == Py_WRAP) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; +} + +/*****************************************************************************/ +/* Python attributes get/set structure: */ +/*****************************************************************************/ +static PyGetSetDef Matrix_getseters[] = { + {"rowSize", (getter)Matrix_getRowSize, (setter)NULL, "", NULL}, + {"colSize", (getter)Matrix_getColSize, (setter)NULL, "", NULL}, + {"wrapped", (getter)Matrix_getWrapped, (setter)NULL, "", NULL}, + {NULL,NULL,NULL,NULL,NULL} /* Sentinel */ +}; + +/*------------------PY_OBECT DEFINITION--------------------------*/ +PyTypeObject matrix_Type = { +#if (PY_VERSION_HEX >= 0x02060000) + PyVarObject_HEAD_INIT(NULL, 0) +#else + /* python 2.5 and below */ + PyObject_HEAD_INIT( NULL ) /* required py macro */ + 0, /* ob_size */ +#endif + "matrix", /*tp_name*/ + sizeof(MatrixObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + (destructor)Matrix_dealloc, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + (reprfunc) Matrix_repr, /*tp_repr*/ + &Matrix_NumMethods, /*tp_as_number*/ + &Matrix_SeqMethods, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + MatrixObject_doc, /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + (richcmpfunc)Matrix_richcmpr, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + Matrix_methods, /*tp_methods*/ + 0, /*tp_members*/ + Matrix_getseters, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + Matrix_new, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0 /*tp_del*/ +}; + +/*------------------------newMatrixObject (internal)------------- +creates a new matrix object +self->matrix self->contiguous_ptr (reference to data.xxx) + [0]------------->[0] + [1] + [2] + [1]------------->[3] + [4] + [5] + .... +self->matrix[1][1] = self->contiguous_ptr[4] = self->data.xxx_data[4]*/ + +/*pass Py_WRAP - if vector is a WRAPPER for data allocated by BLENDER + (i.e. it was allocated elsewhere by MEM_mallocN()) + pass Py_NEW - if vector is not a WRAPPER and managed by PYTHON + (i.e. it must be created here with PyMEM_malloc())*/ +PyObject *newMatrixObject(float *mat, int rowSize, int colSize, int type) +{ + MatrixObject *self; + int x, row, col; + + /*matrix objects can be any 2-4row x 2-4col matrix*/ + if(rowSize < 2 || rowSize > 4 || colSize < 2 || colSize > 4){ + PyErr_SetString(PyExc_RuntimeError, "matrix(): row and column sizes must be between 2 and 4"); + return NULL; + } + + self = PyObject_NEW(MatrixObject, &matrix_Type); + self->data.blend_data = NULL; + self->data.py_data = NULL; + self->rowSize = rowSize; + self->colSize = colSize; + + if(type == Py_WRAP){ + self->data.blend_data = mat; + self->contigPtr = self->data.blend_data; + /*create pointer array*/ + self->matrix = PyMem_Malloc(rowSize * sizeof(float *)); + if(self->matrix == NULL) { /*allocation failure*/ + PyErr_SetString( PyExc_MemoryError, "matrix(): problem allocating pointer space"); + return NULL; + } + /*pointer array points to contigous memory*/ + for(x = 0; x < rowSize; x++) { + self->matrix[x] = self->contigPtr + (x * colSize); + } + self->wrapped = Py_WRAP; + }else if (type == Py_NEW){ + self->data.py_data = PyMem_Malloc(rowSize * colSize * sizeof(float)); + if(self->data.py_data == NULL) { /*allocation failure*/ + PyErr_SetString( PyExc_MemoryError, "matrix(): problem allocating pointer space\n"); + return NULL; + } + self->contigPtr = self->data.py_data; + /*create pointer array*/ + self->matrix = PyMem_Malloc(rowSize * sizeof(float *)); + if(self->matrix == NULL) { /*allocation failure*/ + PyMem_Free(self->data.py_data); + PyErr_SetString( PyExc_MemoryError, "matrix(): problem allocating pointer space"); + return NULL; + } + /*pointer array points to contigous memory*/ + for(x = 0; x < rowSize; x++) { + self->matrix[x] = self->contigPtr + (x * colSize); + } + /*parse*/ + if(mat) { /*if a float array passed*/ + for(row = 0; row < rowSize; row++) { + for(col = 0; col < colSize; col++) { + self->matrix[row][col] = mat[(row * colSize) + col]; + } + } + } else if (rowSize == colSize ) { /*or if no arguments are passed return identity matrix for square matrices */ + Matrix_Identity(self); + Py_DECREF(self); + } + self->wrapped = Py_NEW; + }else{ /*bad type*/ + return NULL; + } + return (PyObject *) self; +} diff --git a/source/blender/python/generic/matrix.h b/source/blender/python/generic/matrix.h new file mode 100644 index 00000000000..ef82263fe00 --- /dev/null +++ b/source/blender/python/generic/matrix.h @@ -0,0 +1,61 @@ +/* + * $Id: matrix.h 20248 2009-05-18 04:11:54Z campbellbarton $ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Joseph Gilbert + * + * ***** END GPL LICENSE BLOCK ***** + * + */ + +#ifndef EXPP_matrix_h +#define EXPP_matrix_h + +#include <Python.h> + +extern PyTypeObject matrix_Type; + +#define MatrixObject_Check(v) ((v)->ob_type == &matrix_Type) + +typedef float **ptRow; +typedef struct _Matrix { + PyObject_VAR_HEAD + struct{ + float *py_data; /*python managed*/ + float *blend_data; /*blender managed*/ + }data; + ptRow matrix; /*ptr to the contigPtr (accessor)*/ + float *contigPtr; /*1D array of data (alias)*/ + int rowSize; + int colSize; + int wrapped; /*is wrapped data?*/ +} MatrixObject; + +/*struct data contains a pointer to the actual data that the +object uses. It can use either PyMem allocated data (which will +be stored in py_data) or be a wrapper for data allocated through +blender (stored in blend_data). This is an either/or struct not both*/ + +/*prototypes*/ +PyObject *newMatrixObject(float *mat, int rowSize, int colSize, int type); + +#endif /* EXPP_matrix_H */ diff --git a/source/blender/python/generic/quat.c b/source/blender/python/generic/quat.c new file mode 100644 index 00000000000..4ad5d07b3b8 --- /dev/null +++ b/source/blender/python/generic/quat.c @@ -0,0 +1,847 @@ +/* + * $Id: quat.c 20332 2009-05-22 03:22:56Z campbellbarton $ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * + * Contributor(s): Joseph Gilbert + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "Mathutils.h" + +#include "BLI_arithb.h" +#include "BKE_utildefines.h" +#include "BLI_blenlib.h" + + +//-------------------------DOC STRINGS --------------------------- +static char Quaternion_Identity_doc[] = "() - set the quaternion to it's identity (1, vector)"; +static char Quaternion_Negate_doc[] = "() - set all values in the quaternion to their negative"; +static char Quaternion_Conjugate_doc[] = "() - set the quaternion to it's conjugate"; +static char Quaternion_Inverse_doc[] = "() - set the quaternion to it's inverse"; +static char Quaternion_Normalize_doc[] = "() - normalize the vector portion of the quaternion"; +static char Quaternion_ToEuler_doc[] = "(eul_compat) - return a euler rotation representing the quaternion, optional euler argument that the new euler will be made compatible with."; +static char Quaternion_ToMatrix_doc[] = "() - return a rotation matrix representing the quaternion"; +static char Quaternion_Cross_doc[] = "(other) - return the cross product between this quaternion and another"; +static char Quaternion_Dot_doc[] = "(other) - return the dot product between this quaternion and another"; +static char Quaternion_copy_doc[] = "() - return a copy of the quat"; + +static PyObject *Quaternion_Identity( QuaternionObject * self ); +static PyObject *Quaternion_Negate( QuaternionObject * self ); +static PyObject *Quaternion_Conjugate( QuaternionObject * self ); +static PyObject *Quaternion_Inverse( QuaternionObject * self ); +static PyObject *Quaternion_Normalize( QuaternionObject * self ); +static PyObject *Quaternion_ToEuler( QuaternionObject * self, PyObject *args ); +static PyObject *Quaternion_ToMatrix( QuaternionObject * self ); +static PyObject *Quaternion_Cross( QuaternionObject * self, QuaternionObject * value ); +static PyObject *Quaternion_Dot( QuaternionObject * self, QuaternionObject * value ); +static PyObject *Quaternion_copy( QuaternionObject * self ); + +//-----------------------METHOD DEFINITIONS ---------------------- +static struct PyMethodDef Quaternion_methods[] = { + {"identity", (PyCFunction) Quaternion_Identity, METH_NOARGS, Quaternion_Identity_doc}, + {"negate", (PyCFunction) Quaternion_Negate, METH_NOARGS, Quaternion_Negate_doc}, + {"conjugate", (PyCFunction) Quaternion_Conjugate, METH_NOARGS, Quaternion_Conjugate_doc}, + {"inverse", (PyCFunction) Quaternion_Inverse, METH_NOARGS, Quaternion_Inverse_doc}, + {"normalize", (PyCFunction) Quaternion_Normalize, METH_NOARGS, Quaternion_Normalize_doc}, + {"toEuler", (PyCFunction) Quaternion_ToEuler, METH_VARARGS, Quaternion_ToEuler_doc}, + {"toMatrix", (PyCFunction) Quaternion_ToMatrix, METH_NOARGS, Quaternion_ToMatrix_doc}, + {"cross", (PyCFunction) Quaternion_Cross, METH_O, Quaternion_Cross_doc}, + {"dot", (PyCFunction) Quaternion_Dot, METH_O, Quaternion_Dot_doc}, + {"__copy__", (PyCFunction) Quaternion_copy, METH_NOARGS, Quaternion_copy_doc}, + {"copy", (PyCFunction) Quaternion_copy, METH_NOARGS, Quaternion_copy_doc}, + {NULL, NULL, 0, NULL} +}; + +//----------------------------------Mathutils.Quaternion() -------------- +static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + PyObject *listObject = NULL, *n, *q, *f; + int size, i; + float quat[4], scalar; + double norm = 0.0f, angle = 0.0f; + + size = PyTuple_GET_SIZE(args); + if (size == 1 || size == 2) { //seq? + listObject = PyTuple_GET_ITEM(args, 0); + if (PySequence_Check(listObject)) { + size = PySequence_Length(listObject); + if ((size == 4 && PySequence_Length(args) !=1) || + (size == 3 && PySequence_Length(args) !=2) || (size >4 || size < 3)) { + // invalid args/size + PyErr_SetString(PyExc_AttributeError, "Mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n"); + return NULL; + } + if(size == 3){ //get angle in axis/angle + n = PySequence_GetItem(args, 1); + if(n == NULL) { // parsed item not a number or getItem fail + PyErr_SetString(PyExc_TypeError, "Mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n"); + return NULL; + } + + angle = PyFloat_AsDouble(n); + Py_DECREF(n); + + if (angle==-1 && PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, "Mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n"); + return NULL; + } + } + }else{ + listObject = PyTuple_GET_ITEM(args, 1); + if (size>1 && PySequence_Check(listObject)) { + size = PySequence_Length(listObject); + if (size != 3) { + // invalid args/size + PyErr_SetString(PyExc_AttributeError, "Mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n"); + return NULL; + } + angle = PyFloat_AsDouble(PyTuple_GET_ITEM(args, 0)); + + if (angle==-1 && PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, "Mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n"); + return NULL; + } + } else { // argument was not a sequence + PyErr_SetString(PyExc_TypeError, "Mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n"); + return NULL; + } + } + } else if (size == 0) { //returns a new empty quat + return newQuaternionObject(NULL, Py_NEW); + } else { + listObject = args; + } + + if (size == 3) { // invalid quat size + if(PySequence_Length(args) != 2){ + PyErr_SetString(PyExc_AttributeError, "Mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n"); + return NULL; + } + }else{ + if(size != 4){ + PyErr_SetString(PyExc_AttributeError, "Mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n"); + return NULL; + } + } + + for (i=0; i<size; i++) { //parse + q = PySequence_GetItem(listObject, i); + if (q == NULL) { // Failed to read sequence + PyErr_SetString(PyExc_RuntimeError, "Mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n"); + return NULL; + } + + scalar = PyFloat_AsDouble(q); + if (scalar==-1 && PyErr_Occurred()) { + Py_DECREF(q); + PyErr_SetString(PyExc_TypeError, "Mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n"); + return NULL; + } + + quat[i] = scalar; + Py_DECREF(f); + Py_DECREF(q); + } + if(size == 3){ //calculate the quat based on axis/angle + norm = sqrt(quat[0] * quat[0] + quat[1] * quat[1] + quat[2] * quat[2]); + quat[0] /= (float)norm; + quat[1] /= (float)norm; + quat[2] /= (float)norm; + + angle = angle * (Py_PI / 180); + quat[3] =(float) (sin(angle/ 2.0f)) * quat[2]; + quat[2] =(float) (sin(angle/ 2.0f)) * quat[1]; + quat[1] =(float) (sin(angle/ 2.0f)) * quat[0]; + quat[0] =(float) (cos(angle/ 2.0f)); + } + + return newQuaternionObject(quat, Py_NEW); +} + +//-----------------------------METHODS------------------------------ +//----------------------------Quaternion.toEuler()------------------ +//return the quat as a euler +static PyObject *Quaternion_ToEuler(QuaternionObject * self, PyObject *args) +{ + float eul[3]; + EulerObject *eul_compat = NULL; + int x; + + if(!PyArg_ParseTuple(args, "|O!:toEuler", &euler_Type, &eul_compat)) + return NULL; + + if(eul_compat) { + float mat[3][3], eul_compatf[3]; + + for(x = 0; x < 3; x++) { + eul_compatf[x] = eul_compat->eul[x] * ((float)Py_PI / 180); + } + + QuatToMat3(self->quat, mat); + Mat3ToCompatibleEul(mat, eul, eul_compatf); + } + else { + QuatToEul(self->quat, eul); + } + + + for(x = 0; x < 3; x++) { + eul[x] *= (180 / (float)Py_PI); + } + return newEulerObject(eul, Py_NEW); +} +//----------------------------Quaternion.toMatrix()------------------ +//return the quat as a matrix +static PyObject *Quaternion_ToMatrix(QuaternionObject * self) +{ + float mat[9] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}; + QuatToMat3(self->quat, (float (*)[3]) mat); + + return newMatrixObject(mat, 3, 3, Py_NEW); +} + +//----------------------------Quaternion.cross(other)------------------ +//return the cross quat +static PyObject *Quaternion_Cross(QuaternionObject * self, QuaternionObject * value) +{ + float quat[4]; + + if (!QuaternionObject_Check(value)) { + PyErr_SetString( PyExc_TypeError, "quat.cross(value): expected a quaternion argument" ); + return NULL; + } + + QuatMul(quat, self->quat, value->quat); + return newQuaternionObject(quat, Py_NEW); +} + +//----------------------------Quaternion.dot(other)------------------ +//return the dot quat +static PyObject *Quaternion_Dot(QuaternionObject * self, QuaternionObject * value) +{ + int x; + double dot = 0.0; + + if (!QuaternionObject_Check(value)) { + PyErr_SetString( PyExc_TypeError, "quat.dot(value): expected a quaternion argument" ); + return NULL; + } + + for(x = 0; x < 4; x++) { + dot += self->quat[x] * value->quat[x]; + } + return PyFloat_FromDouble(dot); +} + +//----------------------------Quaternion.normalize()---------------- +//normalize the axis of rotation of [theta,vector] +static PyObject *Quaternion_Normalize(QuaternionObject * self) +{ + NormalQuat(self->quat); + Py_INCREF(self); + return (PyObject*)self; +} +//----------------------------Quaternion.inverse()------------------ +//invert the quat +static PyObject *Quaternion_Inverse(QuaternionObject * self) +{ + double mag = 0.0f; + int x; + + for(x = 1; x < 4; x++) { + self->quat[x] = -self->quat[x]; + } + for(x = 0; x < 4; x++) { + mag += (self->quat[x] * self->quat[x]); + } + mag = sqrt(mag); + for(x = 0; x < 4; x++) { + self->quat[x] /= (float)(mag * mag); + } + + Py_INCREF(self); + return (PyObject*)self; +} +//----------------------------Quaternion.identity()----------------- +//generate the identity quaternion +static PyObject *Quaternion_Identity(QuaternionObject * self) +{ + self->quat[0] = 1.0; + self->quat[1] = 0.0; + self->quat[2] = 0.0; + self->quat[3] = 0.0; + + Py_INCREF(self); + return (PyObject*)self; +} +//----------------------------Quaternion.negate()------------------- +//negate the quat +static PyObject *Quaternion_Negate(QuaternionObject * self) +{ + int x; + for(x = 0; x < 4; x++) { + self->quat[x] = -self->quat[x]; + } + Py_INCREF(self); + return (PyObject*)self; +} +//----------------------------Quaternion.conjugate()---------------- +//negate the vector part +static PyObject *Quaternion_Conjugate(QuaternionObject * self) +{ + int x; + for(x = 1; x < 4; x++) { + self->quat[x] = -self->quat[x]; + } + Py_INCREF(self); + return (PyObject*)self; +} +//----------------------------Quaternion.copy()---------------- +//return a copy of the quat +static PyObject *Quaternion_copy(QuaternionObject * self) +{ + return newQuaternionObject(self->quat, Py_NEW); +} + +//----------------------------dealloc()(internal) ------------------ +//free the py_object +static void Quaternion_dealloc(QuaternionObject * self) +{ + //only free py_data + if(self->data.py_data){ + PyMem_Free(self->data.py_data); + } + PyObject_DEL(self); +} + +//----------------------------print object (internal)-------------- +//print the object to screen +static PyObject *Quaternion_repr(QuaternionObject * self) +{ + char str[64]; + sprintf(str, "[%.6f, %.6f, %.6f, %.6f](quaternion)", self->quat[0], self->quat[1], self->quat[2], self->quat[3]); + return PyUnicode_FromString(str); +} +//------------------------tp_richcmpr +//returns -1 execption, 0 false, 1 true +static PyObject* Quaternion_richcmpr(PyObject *objectA, PyObject *objectB, int comparison_type) +{ + QuaternionObject *quatA = NULL, *quatB = NULL; + int result = 0; + + if (!QuaternionObject_Check(objectA) || !QuaternionObject_Check(objectB)){ + if (comparison_type == Py_NE){ + Py_RETURN_TRUE; + }else{ + Py_RETURN_FALSE; + } + } + quatA = (QuaternionObject*)objectA; + quatB = (QuaternionObject*)objectB; + + switch (comparison_type){ + case Py_EQ: + result = EXPP_VectorsAreEqual(quatA->quat, quatB->quat, 4, 1); + break; + case Py_NE: + result = EXPP_VectorsAreEqual(quatA->quat, quatB->quat, 4, 1); + if (result == 0){ + result = 1; + }else{ + result = 0; + } + break; + default: + printf("The result of the comparison could not be evaluated"); + break; + } + if (result == 1){ + Py_RETURN_TRUE; + }else{ + Py_RETURN_FALSE; + } +} +//------------------------tp_doc +static char QuaternionObject_doc[] = "This is a wrapper for quaternion objects."; +//---------------------SEQUENCE PROTOCOLS------------------------ +//----------------------------len(object)------------------------ +//sequence length +static int Quaternion_len(QuaternionObject * self) +{ + return 4; +} +//----------------------------object[]--------------------------- +//sequence accessor (get) +static PyObject *Quaternion_item(QuaternionObject * self, int i) +{ + if(i < 0 || i >= 4) { + PyErr_SetString(PyExc_IndexError, "quaternion[attribute]: array index out of range\n"); + return NULL; + } + return PyFloat_FromDouble(self->quat[i]); + +} +//----------------------------object[]------------------------- +//sequence accessor (set) +static int Quaternion_ass_item(QuaternionObject * self, int i, PyObject * ob) +{ + PyObject *f = NULL; + + f = PyNumber_Float(ob); + if(f == NULL) { // parsed item not a number + PyErr_SetString(PyExc_TypeError, "quaternion[attribute] = x: argument not a number\n"); + return -1; + } + + if(i < 0 || i >= 4){ + Py_DECREF(f); + PyErr_SetString(PyExc_IndexError, "quaternion[attribute] = x: array assignment index out of range\n"); + return -1; + } + self->quat[i] = (float)PyFloat_AS_DOUBLE(f); + Py_DECREF(f); + return 0; +} +//----------------------------object[z:y]------------------------ +//sequence slice (get) +static PyObject *Quaternion_slice(QuaternionObject * self, int begin, int end) +{ + PyObject *list = NULL; + int count; + + CLAMP(begin, 0, 4); + if (end<0) end= 5+end; + CLAMP(end, 0, 4); + begin = MIN2(begin,end); + + list = PyList_New(end - begin); + for(count = begin; count < end; count++) { + PyList_SetItem(list, count - begin, + PyFloat_FromDouble(self->quat[count])); + } + + return list; +} +//----------------------------object[z:y]------------------------ +//sequence slice (set) +static int Quaternion_ass_slice(QuaternionObject * self, int begin, int end, + PyObject * seq) +{ + int i, y, size = 0; + float quat[4]; + PyObject *q, *f; + + CLAMP(begin, 0, 4); + if (end<0) end= 5+end; + CLAMP(end, 0, 4); + begin = MIN2(begin,end); + + size = PySequence_Length(seq); + if(size != (end - begin)){ + PyErr_SetString(PyExc_TypeError, "quaternion[begin:end] = []: size mismatch in slice assignment\n"); + return -1; + } + + for (i = 0; i < size; i++) { + q = PySequence_GetItem(seq, i); + if (q == NULL) { // Failed to read sequence + PyErr_SetString(PyExc_RuntimeError, "quaternion[begin:end] = []: unable to read sequence\n"); + return -1; + } + + f = PyNumber_Float(q); + if(f == NULL) { // parsed item not a number + Py_DECREF(q); + PyErr_SetString(PyExc_TypeError, "quaternion[begin:end] = []: sequence argument not a number\n"); + return -1; + } + + quat[i] = (float)PyFloat_AS_DOUBLE(f); + Py_DECREF(f); + Py_DECREF(q); + } + //parsed well - now set in vector + for(y = 0; y < size; y++){ + self->quat[begin + y] = quat[y]; + } + return 0; +} +//------------------------NUMERIC PROTOCOLS---------------------- +//------------------------obj + obj------------------------------ +//addition +static PyObject *Quaternion_add(PyObject * q1, PyObject * q2) +{ + int x; + float quat[4]; + QuaternionObject *quat1 = NULL, *quat2 = NULL; + + if(!QuaternionObject_Check(q1) || !QuaternionObject_Check(q2)) { + PyErr_SetString(PyExc_AttributeError, "Quaternion addition: arguments not valid for this operation....\n"); + return NULL; + } + + quat1 = (QuaternionObject*)q1; + quat2 = (QuaternionObject*)q2; + + for(x = 0; x < 4; x++) { + quat[x] = quat1->quat[x] + quat2->quat[x]; + } + + return newQuaternionObject(quat, Py_NEW); +} +//------------------------obj - obj------------------------------ +//subtraction +static PyObject *Quaternion_sub(PyObject * q1, PyObject * q2) +{ + int x; + float quat[4]; + QuaternionObject *quat1 = NULL, *quat2 = NULL; + + if(!QuaternionObject_Check(q1) || !QuaternionObject_Check(q2)) { + PyErr_SetString(PyExc_AttributeError, "Quaternion addition: arguments not valid for this operation....\n"); + return NULL; + } + + quat1 = (QuaternionObject*)q1; + quat2 = (QuaternionObject*)q2; + + for(x = 0; x < 4; x++) { + quat[x] = quat1->quat[x] - quat2->quat[x]; + } + + return newQuaternionObject(quat, Py_NEW); +} +//------------------------obj * obj------------------------------ +//mulplication +static PyObject *Quaternion_mul(PyObject * q1, PyObject * q2) +{ + int x; + float quat[4], scalar; + double dot = 0.0f; + QuaternionObject *quat1 = NULL, *quat2 = NULL; + VectorObject *vec = NULL; + + quat1 = (QuaternionObject*)q1; + quat2 = (QuaternionObject*)q2; + + if(QuaternionObject_Check(q1) && QuaternionObject_Check(q2)) { /* QUAT*QUAT (dot product) */ + for(x = 0; x < 4; x++) { + dot += quat1->quat[x] * quat1->quat[x]; + } + return PyFloat_FromDouble(dot); + } + + /* the only case this can happen (for a supported type is "FLOAT*QUAT" ) */ + if(!QuaternionObject_Check(q1)) { + scalar= PyFloat_AsDouble(q1); + if ((scalar == -1.0 && PyErr_Occurred())==0) { /* FLOAT*QUAT */ + for(x = 0; x < 4; x++) { + quat[x] = quat2->quat[x] * scalar; + } + return newQuaternionObject(quat, Py_NEW); + } + PyErr_SetString(PyExc_TypeError, "Quaternion multiplication: val * quat, val is not an acceptable type"); + return NULL; + } + else { /* QUAT*SOMETHING */ + if(VectorObject_Check(q2)){ /* QUAT*VEC */ + vec = (VectorObject*)q2; + if(vec->size != 3){ + PyErr_SetString(PyExc_TypeError, "Quaternion multiplication: only 3D vector rotations currently supported\n"); + return NULL; + } + return quat_rotation((PyObject*)quat1, (PyObject*)vec); + } + + scalar= PyFloat_AsDouble(q2); + if ((scalar == -1.0 && PyErr_Occurred())==0) { /* QUAT*FLOAT */ + for(x = 0; x < 4; x++) { + quat[x] = quat1->quat[x] * scalar; + } + return newQuaternionObject(quat, Py_NEW); + } + } + + PyErr_SetString(PyExc_TypeError, "Quaternion multiplication: arguments not acceptable for this operation\n"); + return NULL; +} + +//-----------------PROTOCOL DECLARATIONS-------------------------- +static PySequenceMethods Quaternion_SeqMethods = { + (inquiry) Quaternion_len, /* sq_length */ + (binaryfunc) 0, /* sq_concat */ + (ssizeargfunc) 0, /* sq_repeat */ + (ssizeargfunc) Quaternion_item, /* sq_item */ + (ssizessizeargfunc) Quaternion_slice, /* sq_slice */ + (ssizeobjargproc) Quaternion_ass_item, /* sq_ass_item */ + (ssizessizeobjargproc) Quaternion_ass_slice, /* sq_ass_slice */ +}; +static PyNumberMethods Quaternion_NumMethods = { + (binaryfunc) Quaternion_add, /* __add__ */ + (binaryfunc) Quaternion_sub, /* __sub__ */ + (binaryfunc) Quaternion_mul, /* __mul__ */ + (binaryfunc) 0, /* __div__ */ + (binaryfunc) 0, /* __mod__ */ + (binaryfunc) 0, /* __divmod__ */ + (ternaryfunc) 0, /* __pow__ */ + (unaryfunc) 0, /* __neg__ */ + (unaryfunc) 0, /* __pos__ */ + (unaryfunc) 0, /* __abs__ */ + (inquiry) 0, /* __nonzero__ */ + (unaryfunc) 0, /* __invert__ */ + (binaryfunc) 0, /* __lshift__ */ + (binaryfunc) 0, /* __rshift__ */ + (binaryfunc) 0, /* __and__ */ + (binaryfunc) 0, /* __xor__ */ + (binaryfunc) 0, /* __or__ */ + /*(coercion)*/ 0, /* __coerce__ */ + (unaryfunc) 0, /* __int__ */ + (unaryfunc) 0, /* __long__ */ + (unaryfunc) 0, /* __float__ */ + (unaryfunc) 0, /* __oct__ */ + (unaryfunc) 0, /* __hex__ */ + +}; + + +static PyObject *Quaternion_getAxis( QuaternionObject * self, void *type ) +{ + switch( (long)type ) { + case 'W': + return PyFloat_FromDouble(self->quat[0]); + case 'X': + return PyFloat_FromDouble(self->quat[1]); + case 'Y': + return PyFloat_FromDouble(self->quat[2]); + case 'Z': + return PyFloat_FromDouble(self->quat[3]); + } + + PyErr_SetString(PyExc_SystemError, "corrupt quaternion, cannot get axis"); + return NULL; +} + +static int Quaternion_setAxis( QuaternionObject * self, PyObject * value, void * type ) +{ + float param= (float)PyFloat_AsDouble( value ); + + if (param==-1 && PyErr_Occurred()) { + PyErr_SetString( PyExc_TypeError, "expected a number for the vector axis" ); + return -1; + } + switch( (long)type ) { + case 'W': + self->quat[0]= param; + break; + case 'X': + self->quat[1]= param; + break; + case 'Y': + self->quat[2]= param; + break; + case 'Z': + self->quat[3]= param; + break; + } + + return 0; +} + +static PyObject *Quaternion_getWrapped( QuaternionObject * self, void *type ) +{ + if (self->wrapped == Py_WRAP) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; +} + +static PyObject *Quaternion_getMagnitude( QuaternionObject * self, void *type ) +{ + double mag = 0.0; + int i; + for(i = 0; i < 4; i++) { + mag += self->quat[i] * self->quat[i]; + } + return PyFloat_FromDouble(sqrt(mag)); +} + +static PyObject *Quaternion_getAngle( QuaternionObject * self, void *type ) +{ + double ang = self->quat[0]; + ang = 2 * (saacos(ang)); + ang *= (180 / Py_PI); + return PyFloat_FromDouble(ang); +} + +static PyObject *Quaternion_getAxisVec( QuaternionObject * self, void *type ) +{ + int i; + float vec[3]; + double mag = self->quat[0] * (Py_PI / 180); + mag = 2 * (saacos(mag)); + mag = sin(mag / 2); + for(i = 0; i < 3; i++) + vec[i] = (float)(self->quat[i + 1] / mag); + + Normalize(vec); + //If the axis of rotation is 0,0,0 set it to 1,0,0 - for zero-degree rotations + if( EXPP_FloatsAreEqual(vec[0], 0.0f, 10) && + EXPP_FloatsAreEqual(vec[1], 0.0f, 10) && + EXPP_FloatsAreEqual(vec[2], 0.0f, 10) ){ + vec[0] = 1.0f; + } + return (PyObject *) newVectorObject(vec, 3, Py_NEW); +} + + +/*****************************************************************************/ +/* Python attributes get/set structure: */ +/*****************************************************************************/ +static PyGetSetDef Quaternion_getseters[] = { + {"w", + (getter)Quaternion_getAxis, (setter)Quaternion_setAxis, + "Quaternion W value", + (void *)'W'}, + {"x", + (getter)Quaternion_getAxis, (setter)Quaternion_setAxis, + "Quaternion X axis", + (void *)'X'}, + {"y", + (getter)Quaternion_getAxis, (setter)Quaternion_setAxis, + "Quaternion Y axis", + (void *)'Y'}, + {"z", + (getter)Quaternion_getAxis, (setter)Quaternion_setAxis, + "Quaternion Z axis", + (void *)'Z'}, + {"magnitude", + (getter)Quaternion_getMagnitude, (setter)NULL, + "Size of the quaternion", + NULL}, + {"angle", + (getter)Quaternion_getAngle, (setter)NULL, + "angle of the quaternion", + NULL}, + {"axis", + (getter)Quaternion_getAxisVec, (setter)NULL, + "quaternion axis as a vector", + NULL}, + {"wrapped", + (getter)Quaternion_getWrapped, (setter)NULL, + "True when this wraps blenders internal data", + NULL}, + {NULL,NULL,NULL,NULL,NULL} /* Sentinel */ +}; + + +//------------------PY_OBECT DEFINITION-------------------------- +PyTypeObject quaternion_Type = { +#if (PY_VERSION_HEX >= 0x02060000) + PyVarObject_HEAD_INIT(NULL, 0) +#else + /* python 2.5 and below */ + PyObject_HEAD_INIT( NULL ) /* required py macro */ + 0, /* ob_size */ +#endif + "quaternion", //tp_name + sizeof(QuaternionObject), //tp_basicsize + 0, //tp_itemsize + (destructor)Quaternion_dealloc, //tp_dealloc + 0, //tp_print + 0, //tp_getattr + 0, //tp_setattr + 0, //tp_compare + (reprfunc) Quaternion_repr, //tp_repr + &Quaternion_NumMethods, //tp_as_number + &Quaternion_SeqMethods, //tp_as_sequence + 0, //tp_as_mapping + 0, //tp_hash + 0, //tp_call + 0, //tp_str + 0, //tp_getattro + 0, //tp_setattro + 0, //tp_as_buffer + Py_TPFLAGS_DEFAULT, //tp_flags + QuaternionObject_doc, //tp_doc + 0, //tp_traverse + 0, //tp_clear + (richcmpfunc)Quaternion_richcmpr, //tp_richcompare + 0, //tp_weaklistoffset + 0, //tp_iter + 0, //tp_iternext + Quaternion_methods, //tp_methods + 0, //tp_members + Quaternion_getseters, //tp_getset + 0, //tp_base + 0, //tp_dict + 0, //tp_descr_get + 0, //tp_descr_set + 0, //tp_dictoffset + 0, //tp_init + 0, //tp_alloc + Quaternion_new, //tp_new + 0, //tp_free + 0, //tp_is_gc + 0, //tp_bases + 0, //tp_mro + 0, //tp_cache + 0, //tp_subclasses + 0, //tp_weaklist + 0 //tp_del +}; +//------------------------newQuaternionObject (internal)------------- +//creates a new quaternion object +/*pass Py_WRAP - if vector is a WRAPPER for data allocated by BLENDER + (i.e. it was allocated elsewhere by MEM_mallocN()) + pass Py_NEW - if vector is not a WRAPPER and managed by PYTHON + (i.e. it must be created here with PyMEM_malloc())*/ +PyObject *newQuaternionObject(float *quat, int type) +{ + QuaternionObject *self; + int x; + + self = PyObject_NEW(QuaternionObject, &quaternion_Type); + self->data.blend_data = NULL; + self->data.py_data = NULL; + + if(type == Py_WRAP){ + self->data.blend_data = quat; + self->quat = self->data.blend_data; + self->wrapped = Py_WRAP; + }else if (type == Py_NEW){ + self->data.py_data = PyMem_Malloc(4 * sizeof(float)); + self->quat = self->data.py_data; + if(!quat) { //new empty + Quaternion_Identity(self); + Py_DECREF(self); + }else{ + for(x = 0; x < 4; x++){ + self->quat[x] = quat[x]; + } + } + self->wrapped = Py_NEW; + }else{ //bad type + return NULL; + } + return (PyObject *) self; +} diff --git a/source/blender/python/generic/quat.h b/source/blender/python/generic/quat.h new file mode 100644 index 00000000000..cfb50e4dbe1 --- /dev/null +++ b/source/blender/python/generic/quat.h @@ -0,0 +1,59 @@ +/* + * $Id: quat.h 20332 2009-05-22 03:22:56Z campbellbarton $ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Joseph Gilbert + * + * ***** END GPL LICENSE BLOCK ***** + * + */ + +#ifndef EXPP_quat_h +#define EXPP_quat_h + +#include <Python.h> +#include "../intern/bpy_compat.h" + +extern PyTypeObject quaternion_Type; + +#define QuaternionObject_Check(v) (Py_TYPE(v) == &quaternion_Type) + +typedef struct { + PyObject_VAR_HEAD + struct{ + float *py_data; //python managed + float *blend_data; //blender managed + }data; + float *quat; //1D array of data (alias) + int wrapped; //is wrapped data? +} QuaternionObject; + +/*struct data contains a pointer to the actual data that the +object uses. It can use either PyMem allocated data (which will +be stored in py_data) or be a wrapper for data allocated through +blender (stored in blend_data). This is an either/or struct not both*/ + +//prototypes +PyObject *newQuaternionObject( float *quat, int type ); + +#endif /* EXPP_quat_h */ diff --git a/source/blender/python/generic/vector.c b/source/blender/python/generic/vector.c new file mode 100644 index 00000000000..562413c6967 --- /dev/null +++ b/source/blender/python/generic/vector.c @@ -0,0 +1,1862 @@ +/* + * $Id: vector.c 20332 2009-05-22 03:22:56Z campbellbarton $ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * + * Contributor(s): Willian P. Germano, Joseph Gilbert, Ken Hughes, Alex Fraser, Campbell Barton + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "Mathutils.h" + +#include "BLI_blenlib.h" +#include "BKE_utildefines.h" +#include "BLI_arithb.h" + +#define MAX_DIMENSIONS 4 +/* Swizzle axes get packed into a single value that is used as a closure. Each + axis uses SWIZZLE_BITS_PER_AXIS bits. The first bit (SWIZZLE_VALID_AXIS) is + used as a sentinel: if it is unset, the axis is not valid. */ +#define SWIZZLE_BITS_PER_AXIS 3 +#define SWIZZLE_VALID_AXIS 0x4 +#define SWIZZLE_AXIS 0x3 + +/*-------------------------DOC STRINGS ---------------------------*/ +static char Vector_Zero_doc[] = "() - set all values in the vector to 0"; +static char Vector_Normalize_doc[] = "() - normalize the vector"; +static char Vector_Negate_doc[] = "() - changes vector to it's additive inverse"; +static char Vector_Resize2D_doc[] = "() - resize a vector to [x,y]"; +static char Vector_Resize3D_doc[] = "() - resize a vector to [x,y,z]"; +static char Vector_Resize4D_doc[] = "() - resize a vector to [x,y,z,w]"; +static char Vector_ToTrackQuat_doc[] = "(track, up) - extract a quaternion from the vector and the track and up axis"; +static char Vector_Reflect_doc[] = "(mirror) - return a vector reflected on the mirror normal"; +static char Vector_Cross_doc[] = "(other) - return the cross product between this vector and another"; +static char Vector_Dot_doc[] = "(other) - return the dot product between this vector and another"; +static char Vector_copy_doc[] = "() - return a copy of the vector"; +static char Vector_swizzle_doc[] = "Swizzle: Get or set axes in specified order"; +/*-----------------------METHOD DEFINITIONS ----------------------*/ +static PyObject *Vector_Zero( VectorObject * self ); +static PyObject *Vector_Normalize( VectorObject * self ); +static PyObject *Vector_Negate( VectorObject * self ); +static PyObject *Vector_Resize2D( VectorObject * self ); +static PyObject *Vector_Resize3D( VectorObject * self ); +static PyObject *Vector_Resize4D( VectorObject * self ); +static PyObject *Vector_ToTrackQuat( VectorObject * self, PyObject * args ); +static PyObject *Vector_Reflect( VectorObject * self, PyObject * value ); +static PyObject *Vector_Cross( VectorObject * self, VectorObject * value ); +static PyObject *Vector_Dot( VectorObject * self, VectorObject * value ); +static PyObject *Vector_copy( VectorObject * self ); + +static struct PyMethodDef Vector_methods[] = { + {"zero", (PyCFunction) Vector_Zero, METH_NOARGS, Vector_Zero_doc}, + {"normalize", (PyCFunction) Vector_Normalize, METH_NOARGS, Vector_Normalize_doc}, + {"negate", (PyCFunction) Vector_Negate, METH_NOARGS, Vector_Negate_doc}, + {"resize2D", (PyCFunction) Vector_Resize2D, METH_NOARGS, Vector_Resize2D_doc}, + {"resize3D", (PyCFunction) Vector_Resize3D, METH_NOARGS, Vector_Resize2D_doc}, + {"resize4D", (PyCFunction) Vector_Resize4D, METH_NOARGS, Vector_Resize2D_doc}, + {"toTrackQuat", ( PyCFunction ) Vector_ToTrackQuat, METH_VARARGS, Vector_ToTrackQuat_doc}, + {"reflect", ( PyCFunction ) Vector_Reflect, METH_O, Vector_Reflect_doc}, + {"cross", ( PyCFunction ) Vector_Cross, METH_O, Vector_Dot_doc}, + {"dot", ( PyCFunction ) Vector_Dot, METH_O, Vector_Cross_doc}, + {"copy", (PyCFunction) Vector_copy, METH_NOARGS, Vector_copy_doc}, + {"__copy__", (PyCFunction) Vector_copy, METH_NOARGS, Vector_copy_doc}, + {NULL, NULL, 0, NULL} +}; + +//----------------------------------Mathutils.Vector() ------------------ +// Supports 2D, 3D, and 4D vector objects both int and float values +// accepted. Mixed float and int values accepted. Ints are parsed to float +static PyObject *Vector_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + PyObject *listObject = NULL; + int size, i; + float vec[4], f; + PyObject *v; + + size = PyTuple_GET_SIZE(args); /* we know its a tuple because its an arg */ + if (size == 1) { + listObject = PyTuple_GET_ITEM(args, 0); + if (PySequence_Check(listObject)) { + size = PySequence_Length(listObject); + } else { // Single argument was not a sequence + PyErr_SetString(PyExc_TypeError, "Mathutils.Vector(): 2-4 floats or ints expected (optionally in a sequence)\n"); + return NULL; + } + } else if (size == 0) { + //returns a new empty 3d vector + return newVectorObject(NULL, 3, Py_NEW); + } else { + listObject = args; + } + + if (size<2 || size>4) { // Invalid vector size + PyErr_SetString(PyExc_AttributeError, "Mathutils.Vector(): 2-4 floats or ints expected (optionally in a sequence)\n"); + return NULL; + } + + for (i=0; i<size; i++) { + v=PySequence_GetItem(listObject, i); + if (v==NULL) { // Failed to read sequence + PyErr_SetString(PyExc_RuntimeError, "Mathutils.Vector(): 2-4 floats or ints expected (optionally in a sequence)\n"); + return NULL; + } + + f= PyFloat_AsDouble(v); + if(f==-1 && PyErr_Occurred()) { // parsed item not a number + Py_DECREF(v); + PyErr_SetString(PyExc_TypeError, "Mathutils.Vector(): 2-4 floats or ints expected (optionally in a sequence)\n"); + return NULL; + } + + vec[i]= f; + Py_DECREF(v); + } + return newVectorObject(vec, size, Py_NEW); +} + +/*-----------------------------METHODS---------------------------- */ +/*----------------------------Vector.zero() ---------------------- + set the vector data to 0,0,0 */ +static PyObject *Vector_Zero(VectorObject * self) +{ + int i; + for(i = 0; i < self->size; i++) { + self->vec[i] = 0.0f; + } + Py_INCREF(self); + return (PyObject*)self; +} +/*----------------------------Vector.normalize() ----------------- + normalize the vector data to a unit vector */ +static PyObject *Vector_Normalize(VectorObject * self) +{ + int i; + float norm = 0.0f; + + for(i = 0; i < self->size; i++) { + norm += self->vec[i] * self->vec[i]; + } + norm = (float) sqrt(norm); + for(i = 0; i < self->size; i++) { + self->vec[i] /= norm; + } + Py_INCREF(self); + return (PyObject*)self; +} + + +/*----------------------------Vector.resize2D() ------------------ + resize the vector to x,y */ +static PyObject *Vector_Resize2D(VectorObject * self) +{ + if(self->wrapped==Py_WRAP) { + PyErr_SetString(PyExc_TypeError, "vector.resize2d(): cannot resize wrapped data - only python vectors\n"); + return NULL; + } + self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 2)); + if(self->vec == NULL) { + PyErr_SetString(PyExc_MemoryError, "vector.resize2d(): problem allocating pointer space\n\n"); + return NULL; + } + + self->size = 2; + Py_INCREF(self); + return (PyObject*)self; +} +/*----------------------------Vector.resize3D() ------------------ + resize the vector to x,y,z */ +static PyObject *Vector_Resize3D(VectorObject * self) +{ + if (self->wrapped==Py_WRAP) { + PyErr_SetString(PyExc_TypeError, "vector.resize3d(): cannot resize wrapped data - only python vectors\n"); + return NULL; + } + self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 3)); + if(self->vec == NULL) { + PyErr_SetString(PyExc_MemoryError, "vector.resize3d(): problem allocating pointer space\n\n"); + return NULL; + } + + if(self->size == 2) + self->vec[2] = 0.0f; + + self->size = 3; + Py_INCREF(self); + return (PyObject*)self; +} +/*----------------------------Vector.resize4D() ------------------ + resize the vector to x,y,z,w */ +static PyObject *Vector_Resize4D(VectorObject * self) +{ + if(self->wrapped==Py_WRAP) { + PyErr_SetString(PyExc_TypeError, "vector.resize4d(): cannot resize wrapped data - only python vectors"); + return NULL; + } + self->vec = PyMem_Realloc(self->vec, (sizeof(float) * 4)); + if(self->vec == NULL) { + PyErr_SetString(PyExc_MemoryError, "vector.resize4d(): problem allocating pointer space\n\n"); + return NULL; + } + if(self->size == 2){ + self->vec[2] = 0.0f; + self->vec[3] = 1.0f; + }else if(self->size == 3){ + self->vec[3] = 1.0f; + } + self->size = 4; + Py_INCREF(self); + return (PyObject*)self; +} +/*----------------------------Vector.toTrackQuat(track, up) ---------------------- + extract a quaternion from the vector and the track and up axis */ +static PyObject *Vector_ToTrackQuat( VectorObject * self, PyObject * args ) +{ + float vec[3], quat[4]; + char *strack, *sup; + short track = 2, up = 1; + + if( !PyArg_ParseTuple ( args, "|ss", &strack, &sup ) ) { + PyErr_SetString( PyExc_TypeError, "expected optional two strings\n" ); + return NULL; + } + if (self->size != 3) { + PyErr_SetString( PyExc_TypeError, "only for 3D vectors\n" ); + return NULL; + } + + if (strack) { + if (strlen(strack) == 2) { + if (strack[0] == '-') { + switch(strack[1]) { + case 'X': + case 'x': + track = 3; + break; + case 'Y': + case 'y': + track = 4; + break; + case 'z': + case 'Z': + track = 5; + break; + default: + PyErr_SetString( PyExc_ValueError, "only X, -X, Y, -Y, Z or -Z for track axis\n" ); + return NULL; + } + } + else { + PyErr_SetString( PyExc_ValueError, "only X, -X, Y, -Y, Z or -Z for track axis\n" ); + return NULL; + } + } + else if (strlen(strack) == 1) { + switch(strack[0]) { + case '-': + case 'X': + case 'x': + track = 0; + break; + case 'Y': + case 'y': + track = 1; + break; + case 'z': + case 'Z': + track = 2; + break; + default: + PyErr_SetString( PyExc_ValueError, "only X, -X, Y, -Y, Z or -Z for track axis\n" ); + return NULL; + } + } + else { + PyErr_SetString( PyExc_ValueError, "only X, -X, Y, -Y, Z or -Z for track axis\n" ); + return NULL; + } + } + + if (sup) { + if (strlen(sup) == 1) { + switch(*sup) { + case 'X': + case 'x': + up = 0; + break; + case 'Y': + case 'y': + up = 1; + break; + case 'z': + case 'Z': + up = 2; + break; + default: + PyErr_SetString( PyExc_ValueError, "only X, Y or Z for up axis\n" ); + return NULL; + } + } + else { + PyErr_SetString( PyExc_ValueError, "only X, Y or Z for up axis\n" ); + return NULL; + } + } + + if (track == up) { + PyErr_SetString( PyExc_ValueError, "Can't have the same axis for track and up\n" ); + return NULL; + } + + /* + flip vector around, since vectoquat expect a vector from target to tracking object + and the python function expects the inverse (a vector to the target). + */ + vec[0] = -self->vec[0]; + vec[1] = -self->vec[1]; + vec[2] = -self->vec[2]; + + vectoquat(vec, track, up, quat); + + return newQuaternionObject(quat, Py_NEW); +} + +/*----------------------------Vector.reflect(mirror) ---------------------- + return a reflected vector on the mirror normal + ((2 * DotVecs(vec, mirror)) * mirror) - vec + using arithb.c would be nice here */ +static PyObject *Vector_Reflect( VectorObject * self, PyObject * value ) +{ + VectorObject *mirrvec; + float mirror[3]; + float vec[3]; + float reflect[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + float dot2; + + /* for normalizing */ + int i; + float norm = 0.0f; + + if (!VectorObject_Check(value)) { + PyErr_SetString( PyExc_TypeError, "vec.reflect(value): expected a vector argument" ); + return NULL; + } + mirrvec = (VectorObject *)value; + + mirror[0] = mirrvec->vec[0]; + mirror[1] = mirrvec->vec[1]; + if (mirrvec->size > 2) mirror[2] = mirrvec->vec[2]; + else mirror[2] = 0.0; + + /* normalize, whos idea was it not to use arithb.c? :-/ */ + for(i = 0; i < 3; i++) { + norm += mirror[i] * mirror[i]; + } + norm = (float) sqrt(norm); + for(i = 0; i < 3; i++) { + mirror[i] /= norm; + } + /* done */ + + vec[0] = self->vec[0]; + vec[1] = self->vec[1]; + if (self->size > 2) vec[2] = self->vec[2]; + else vec[2] = 0.0; + + dot2 = 2 * vec[0]*mirror[0]+vec[1]*mirror[1]+vec[2]*mirror[2]; + + reflect[0] = (dot2 * mirror[0]) - vec[0]; + reflect[1] = (dot2 * mirror[1]) - vec[1]; + reflect[2] = (dot2 * mirror[2]) - vec[2]; + + return newVectorObject(reflect, self->size, Py_NEW); +} + +static PyObject *Vector_Cross( VectorObject * self, VectorObject * value ) +{ + VectorObject *vecCross = NULL; + + if (!VectorObject_Check(value)) { + PyErr_SetString( PyExc_TypeError, "vec.cross(value): expected a vector argument" ); + return NULL; + } + + if(self->size != 3 || value->size != 3) { + PyErr_SetString(PyExc_AttributeError, "vec.cross(value): expects both vectors to be 3D\n"); + return NULL; + } + + vecCross = (VectorObject *)newVectorObject(NULL, 3, Py_NEW); + Crossf(vecCross->vec, self->vec, value->vec); + return (PyObject *)vecCross; +} + +static PyObject *Vector_Dot( VectorObject * self, VectorObject * value ) +{ + double dot = 0.0; + int x; + + if (!VectorObject_Check(value)) { + PyErr_SetString( PyExc_TypeError, "vec.cross(value): expected a vector argument" ); + return NULL; + } + + if(self->size != value->size) { + PyErr_SetString(PyExc_AttributeError, "vec.dot(value): expects both vectors to have the same size\n"); + return NULL; + } + + for(x = 0; x < self->size; x++) { + dot += self->vec[x] * value->vec[x]; + } + return PyFloat_FromDouble(dot); +} + +/*----------------------------Vector.copy() -------------------------------------- + return a copy of the vector */ +static PyObject *Vector_copy(VectorObject * self) +{ + return newVectorObject(self->vec, self->size, Py_NEW); +} + +/*----------------------------dealloc()(internal) ---------------- + free the py_object */ +static void Vector_dealloc(VectorObject * self) +{ + /* only free non wrapped */ + if(self->wrapped != Py_WRAP){ + PyMem_Free(self->vec); + } + PyObject_DEL(self); +} + +/*----------------------------print object (internal)------------- + print the object to screen */ +static PyObject *Vector_repr(VectorObject * self) +{ + int i; + char buffer[48], str[1024]; + + BLI_strncpy(str,"[",1024); + for(i = 0; i < self->size; i++){ + if(i < (self->size - 1)){ + sprintf(buffer, "%.6f, ", self->vec[i]); + strcat(str,buffer); + }else{ + sprintf(buffer, "%.6f", self->vec[i]); + strcat(str,buffer); + } + } + strcat(str, "](vector)"); + + return PyUnicode_FromString(str); +} +/*---------------------SEQUENCE PROTOCOLS------------------------ + ----------------------------len(object)------------------------ + sequence length*/ +static int Vector_len(VectorObject * self) +{ + return self->size; +} +/*----------------------------object[]--------------------------- + sequence accessor (get)*/ +static PyObject *Vector_item(VectorObject * self, int i) +{ + if(i < 0 || i >= self->size) { + PyErr_SetString(PyExc_IndexError,"vector[index]: out of range\n"); + return NULL; + } + + return PyFloat_FromDouble(self->vec[i]); + +} +/*----------------------------object[]------------------------- + sequence accessor (set)*/ +static int Vector_ass_item(VectorObject * self, int i, PyObject * ob) +{ + float scalar= (float)PyFloat_AsDouble(ob); + if(scalar==-1.0f && PyErr_Occurred()) { /* parsed item not a number */ + PyErr_SetString(PyExc_TypeError, "vector[index] = x: index argument not a number\n"); + return -1; + } + + if(i < 0 || i >= self->size){ + PyErr_SetString(PyExc_IndexError, "vector[index] = x: assignment index out of range\n"); + return -1; + } + self->vec[i] = scalar; + return 0; +} + +/*----------------------------object[z:y]------------------------ + sequence slice (get) */ +static PyObject *Vector_slice(VectorObject * self, int begin, int end) +{ + PyObject *list = NULL; + int count; + + CLAMP(begin, 0, self->size); + if (end<0) end= self->size+end+1; + CLAMP(end, 0, self->size); + begin = MIN2(begin,end); + + list = PyList_New(end - begin); + for(count = begin; count < end; count++) { + PyList_SetItem(list, count - begin, + PyFloat_FromDouble(self->vec[count])); + } + + return list; +} +/*----------------------------object[z:y]------------------------ + sequence slice (set) */ +static int Vector_ass_slice(VectorObject * self, int begin, int end, + PyObject * seq) +{ + int i, y, size = 0; + float vec[4], scalar; + PyObject *v; + + CLAMP(begin, 0, self->size); + if (end<0) end= self->size+end+1; + CLAMP(end, 0, self->size); + begin = MIN2(begin,end); + + size = PySequence_Length(seq); + if(size != (end - begin)){ + PyErr_SetString(PyExc_TypeError, "vector[begin:end] = []: size mismatch in slice assignment\n"); + return -1; + } + + for (i = 0; i < size; i++) { + v = PySequence_GetItem(seq, i); + if (v == NULL) { /* Failed to read sequence */ + PyErr_SetString(PyExc_RuntimeError, "vector[begin:end] = []: unable to read sequence\n"); + return -1; + } + + scalar= (float)PyFloat_AsDouble(v); + if(scalar==-1.0f && PyErr_Occurred()) { /* parsed item not a number */ + Py_DECREF(v); + PyErr_SetString(PyExc_TypeError, "vector[begin:end] = []: sequence argument not a number\n"); + return -1; + } + + vec[i] = scalar; + Py_DECREF(v); + } + /*parsed well - now set in vector*/ + for(y = 0; y < size; y++){ + self->vec[begin + y] = vec[y]; + } + return 0; +} +/*------------------------NUMERIC PROTOCOLS---------------------- + ------------------------obj + obj------------------------------ + addition*/ +static PyObject *Vector_add(PyObject * v1, PyObject * v2) +{ + int i; + float vec[4]; + + VectorObject *vec1 = NULL, *vec2 = NULL; + + if VectorObject_Check(v1) + vec1= (VectorObject *)v1; + + if VectorObject_Check(v2) + vec2= (VectorObject *)v2; + + /* make sure v1 is always the vector */ + if (vec1 && vec2 ) { + /*VECTOR + VECTOR*/ + if(vec1->size != vec2->size) { + PyErr_SetString(PyExc_AttributeError, "Vector addition: vectors must have the same dimensions for this operation\n"); + return NULL; + } + for(i = 0; i < vec1->size; i++) { + vec[i] = vec1->vec[i] + vec2->vec[i]; + } + return newVectorObject(vec, vec1->size, Py_NEW); + } + + PyErr_SetString(PyExc_AttributeError, "Vector addition: arguments not valid for this operation....\n"); + return NULL; +} + +/* ------------------------obj += obj------------------------------ + addition in place */ +static PyObject *Vector_iadd(PyObject * v1, PyObject * v2) +{ + int i; + + VectorObject *vec1 = NULL, *vec2 = NULL; + + if VectorObject_Check(v1) + vec1= (VectorObject *)v1; + + if VectorObject_Check(v2) + vec2= (VectorObject *)v2; + + /* make sure v1 is always the vector */ + if (vec1 && vec2 ) { + /*VECTOR + VECTOR*/ + if(vec1->size != vec2->size) { + PyErr_SetString(PyExc_AttributeError, "Vector addition: vectors must have the same dimensions for this operation\n"); + return NULL; + } + for(i = 0; i < vec1->size; i++) { + vec1->vec[i] += vec2->vec[i]; + } + Py_INCREF( v1 ); + return v1; + } + + PyErr_SetString(PyExc_AttributeError, "Vector addition: arguments not valid for this operation....\n"); + return NULL; +} + +/*------------------------obj - obj------------------------------ + subtraction*/ +static PyObject *Vector_sub(PyObject * v1, PyObject * v2) +{ + int i; + float vec[4]; + VectorObject *vec1 = NULL, *vec2 = NULL; + + if (!VectorObject_Check(v1) || !VectorObject_Check(v2)) { + PyErr_SetString(PyExc_AttributeError, "Vector subtraction: arguments not valid for this operation....\n"); + return NULL; + } + vec1 = (VectorObject*)v1; + vec2 = (VectorObject*)v2; + + if(vec1->size != vec2->size) { + PyErr_SetString(PyExc_AttributeError, "Vector subtraction: vectors must have the same dimensions for this operation\n"); + return NULL; + } + for(i = 0; i < vec1->size; i++) { + vec[i] = vec1->vec[i] - vec2->vec[i]; + } + + return newVectorObject(vec, vec1->size, Py_NEW); +} + +/*------------------------obj -= obj------------------------------ + subtraction*/ +static PyObject *Vector_isub(PyObject * v1, PyObject * v2) +{ + int i, size; + VectorObject *vec1 = NULL, *vec2 = NULL; + + if (!VectorObject_Check(v1) || !VectorObject_Check(v2)) { + PyErr_SetString(PyExc_AttributeError, "Vector subtraction: arguments not valid for this operation....\n"); + return NULL; + } + vec1 = (VectorObject*)v1; + vec2 = (VectorObject*)v2; + + if(vec1->size != vec2->size) { + PyErr_SetString(PyExc_AttributeError, "Vector subtraction: vectors must have the same dimensions for this operation\n"); + return NULL; + } + + size = vec1->size; + for(i = 0; i < vec1->size; i++) { + vec1->vec[i] = vec1->vec[i] - vec2->vec[i]; + } + + Py_INCREF( v1 ); + return v1; +} + +/*------------------------obj * obj------------------------------ + mulplication*/ +static PyObject *Vector_mul(PyObject * v1, PyObject * v2) +{ + VectorObject *vec1 = NULL, *vec2 = NULL; + float scalar; + + if VectorObject_Check(v1) + vec1= (VectorObject *)v1; + + if VectorObject_Check(v2) + vec2= (VectorObject *)v2; + + /* make sure v1 is always the vector */ + if (vec1 && vec2 ) { + int i; + double dot = 0.0f; + + if(vec1->size != vec2->size) { + PyErr_SetString(PyExc_AttributeError, "Vector multiplication: vectors must have the same dimensions for this operation\n"); + return NULL; + } + + /*dot product*/ + for(i = 0; i < vec1->size; i++) { + dot += vec1->vec[i] * vec2->vec[i]; + } + return PyFloat_FromDouble(dot); + } + + /*swap so vec1 is always the vector */ + if (vec2) { + vec1= vec2; + v2= v1; + } + + if (MatrixObject_Check(v2)) { + /* VEC * MATRIX */ + return row_vector_multiplication(vec1, (MatrixObject*)v2); + } else if (QuaternionObject_Check(v2)) { + QuaternionObject *quat = (QuaternionObject*)v2; + if(vec1->size != 3) { + PyErr_SetString(PyExc_TypeError, "Vector multiplication: only 3D vector rotations (with quats) currently supported\n"); + return NULL; + } + return quat_rotation((PyObject*)vec1, (PyObject*)quat); + } + else if (((scalar= PyFloat_AsDouble(v2)) == -1.0 && PyErr_Occurred())==0) { /* VEC*FLOAT */ + int i; + float vec[4]; + + for(i = 0; i < vec1->size; i++) { + vec[i] = vec1->vec[i] * scalar; + } + return newVectorObject(vec, vec1->size, Py_NEW); + + } + + PyErr_SetString(PyExc_TypeError, "Vector multiplication: arguments not acceptable for this operation\n"); + return NULL; +} + +/*------------------------obj *= obj------------------------------ + in place mulplication */ +static PyObject *Vector_imul(PyObject * v1, PyObject * v2) +{ + VectorObject *vec = (VectorObject *)v1; + int i; + float scalar; + + /* only support vec*=float and vec*=mat + vec*=vec result is a float so that wont work */ + if (MatrixObject_Check(v2)) { + float vecCopy[4]; + int x,y, size = vec->size; + MatrixObject *mat= (MatrixObject*)v2; + + if(mat->colSize != size){ + if(mat->rowSize == 4 && vec->size != 3){ + PyErr_SetString(PyExc_AttributeError, "vector * matrix: matrix column size and the vector size must be the same"); + return NULL; + } else { + vecCopy[3] = 1.0f; + } + } + + for(i = 0; i < size; i++){ + vecCopy[i] = vec->vec[i]; + } + + size = MIN2(size, mat->colSize); + + /*muliplication*/ + for(x = 0, i = 0; x < size; x++, i++) { + double dot = 0.0f; + for(y = 0; y < mat->rowSize; y++) { + dot += mat->matrix[y][x] * vecCopy[y]; + } + vec->vec[i] = (float)dot; + } + Py_INCREF( v1 ); + return v1; + } + else if (((scalar= PyFloat_AsDouble(v2)) == -1.0 && PyErr_Occurred())==0) { /* VEC*=FLOAT */ + + for(i = 0; i < vec->size; i++) { + vec->vec[i] *= scalar; + } + + Py_INCREF( v1 ); + return v1; + + } + + PyErr_SetString(PyExc_TypeError, "Vector multiplication: arguments not acceptable for this operation\n"); + return NULL; +} + +/*------------------------obj / obj------------------------------ + divide*/ +static PyObject *Vector_div(PyObject * v1, PyObject * v2) +{ + int i; + float vec[4], scalar; + VectorObject *vec1 = NULL; + + if(!VectorObject_Check(v1)) { /* not a vector */ + PyErr_SetString(PyExc_TypeError, "Vector division: Vector must be divided by a float\n"); + return NULL; + } + vec1 = (VectorObject*)v1; /* vector */ + + scalar = (float)PyFloat_AsDouble(v2); + if(scalar== -1.0f && PyErr_Occurred()) { /* parsed item not a number */ + PyErr_SetString(PyExc_TypeError, "Vector division: Vector must be divided by a float\n"); + return NULL; + } + + if(scalar==0.0) { /* not a vector */ + PyErr_SetString(PyExc_ZeroDivisionError, "Vector division: divide by zero error.\n"); + return NULL; + } + + for(i = 0; i < vec1->size; i++) { + vec[i] = vec1->vec[i] / scalar; + } + return newVectorObject(vec, vec1->size, Py_NEW); +} + +/*------------------------obj /= obj------------------------------ + divide*/ +static PyObject *Vector_idiv(PyObject * v1, PyObject * v2) +{ + int i; + float scalar; + VectorObject *vec1 = NULL; + + /*if(!VectorObject_Check(v1)) { + PyErr_SetString(PyExc_TypeError, "Vector division: Vector must be divided by a float\n"); + return -1; + }*/ + + vec1 = (VectorObject*)v1; /* vector */ + + scalar = (float)PyFloat_AsDouble(v2); + if(scalar==-1.0f && PyErr_Occurred()) { /* parsed item not a number */ + PyErr_SetString(PyExc_TypeError, "Vector division: Vector must be divided by a float\n"); + return NULL; + } + + if(scalar==0.0) { /* not a vector */ + PyErr_SetString(PyExc_ZeroDivisionError, "Vector division: divide by zero error.\n"); + return NULL; + } + for(i = 0; i < vec1->size; i++) { + vec1->vec[i] /= scalar; + } + Py_INCREF( v1 ); + return v1; +} + +/*-------------------------- -obj ------------------------------- + returns the negative of this object*/ +static PyObject *Vector_neg(VectorObject *self) +{ + int i; + float vec[4]; + for(i = 0; i < self->size; i++){ + vec[i] = -self->vec[i]; + } + + return newVectorObject(vec, self->size, Py_NEW); +} + +/*------------------------tp_doc*/ +static char VectorObject_doc[] = "This is a wrapper for vector objects."; +/*------------------------vec_magnitude_nosqrt (internal) - for comparing only */ +static double vec_magnitude_nosqrt(float *data, int size) +{ + double dot = 0.0f; + int i; + + for(i=0; i<size; i++){ + dot += data[i]; + } + /*return (double)sqrt(dot);*/ + /* warning, line above removed because we are not using the length, + rather the comparing the sizes and for this we do not need the sqrt + for the actual length, the dot must be sqrt'd */ + return (double)dot; +} + + +/*------------------------tp_richcmpr + returns -1 execption, 0 false, 1 true */ +static PyObject* Vector_richcmpr(PyObject *objectA, PyObject *objectB, int comparison_type) +{ + VectorObject *vecA = NULL, *vecB = NULL; + int result = 0; + float epsilon = .000001f; + double lenA,lenB; + + if (!VectorObject_Check(objectA) || !VectorObject_Check(objectB)){ + if (comparison_type == Py_NE){ + Py_RETURN_TRUE; + }else{ + Py_RETURN_FALSE; + } + } + vecA = (VectorObject*)objectA; + vecB = (VectorObject*)objectB; + + if (vecA->size != vecB->size){ + if (comparison_type == Py_NE){ + Py_RETURN_TRUE; + }else{ + Py_RETURN_FALSE; + } + } + + switch (comparison_type){ + case Py_LT: + lenA = vec_magnitude_nosqrt(vecA->vec, vecA->size); + lenB = vec_magnitude_nosqrt(vecB->vec, vecB->size); + if( lenA < lenB ){ + result = 1; + } + break; + case Py_LE: + lenA = vec_magnitude_nosqrt(vecA->vec, vecA->size); + lenB = vec_magnitude_nosqrt(vecB->vec, vecB->size); + if( lenA < lenB ){ + result = 1; + }else{ + result = (((lenA + epsilon) > lenB) && ((lenA - epsilon) < lenB)); + } + break; + case Py_EQ: + result = EXPP_VectorsAreEqual(vecA->vec, vecB->vec, vecA->size, 1); + break; + case Py_NE: + result = EXPP_VectorsAreEqual(vecA->vec, vecB->vec, vecA->size, 1); + if (result == 0){ + result = 1; + }else{ + result = 0; + } + break; + case Py_GT: + lenA = vec_magnitude_nosqrt(vecA->vec, vecA->size); + lenB = vec_magnitude_nosqrt(vecB->vec, vecB->size); + if( lenA > lenB ){ + result = 1; + } + break; + case Py_GE: + lenA = vec_magnitude_nosqrt(vecA->vec, vecA->size); + lenB = vec_magnitude_nosqrt(vecB->vec, vecB->size); + if( lenA > lenB ){ + result = 1; + }else{ + result = (((lenA + epsilon) > lenB) && ((lenA - epsilon) < lenB)); + } + break; + default: + printf("The result of the comparison could not be evaluated"); + break; + } + if (result == 1){ + Py_RETURN_TRUE; + }else{ + Py_RETURN_FALSE; + } +} +/*-----------------PROTCOL DECLARATIONS--------------------------*/ +static PySequenceMethods Vector_SeqMethods = { + (inquiry) Vector_len, /* sq_length */ + (binaryfunc) 0, /* sq_concat */ + (ssizeargfunc) 0, /* sq_repeat */ + (ssizeargfunc) Vector_item, /* sq_item */ + (ssizessizeargfunc) Vector_slice, /* sq_slice */ + (ssizeobjargproc) Vector_ass_item, /* sq_ass_item */ + (ssizessizeobjargproc) Vector_ass_slice, /* sq_ass_slice */ +}; + +static PyNumberMethods Vector_NumMethods = { + (binaryfunc) Vector_add, /* __add__ */ + (binaryfunc) Vector_sub, /* __sub__ */ + (binaryfunc) Vector_mul, /* __mul__ */ + (binaryfunc) Vector_div, /* __div__ */ + (binaryfunc) NULL, /* __mod__ */ + (binaryfunc) NULL, /* __divmod__ */ + (ternaryfunc) NULL, /* __pow__ */ + (unaryfunc) Vector_neg, /* __neg__ */ + (unaryfunc) NULL, /* __pos__ */ + (unaryfunc) NULL, /* __abs__ */ + (inquiry) NULL, /* __nonzero__ */ + (unaryfunc) NULL, /* __invert__ */ + (binaryfunc) NULL, /* __lshift__ */ + (binaryfunc) NULL, /* __rshift__ */ + (binaryfunc) NULL, /* __and__ */ + (binaryfunc) NULL, /* __xor__ */ + (binaryfunc) NULL, /* __or__ */ + /*(coercion)*/ NULL, /* __coerce__ */ + (unaryfunc) NULL, /* __int__ */ + (unaryfunc) NULL, /* __long__ */ + (unaryfunc) NULL, /* __float__ */ + (unaryfunc) NULL, /* __oct__ */ + (unaryfunc) NULL, /* __hex__ */ + + /* Added in release 2.0 */ + (binaryfunc) Vector_iadd, /*__iadd__*/ + (binaryfunc) Vector_isub, /*__isub__*/ + (binaryfunc) Vector_imul, /*__imul__*/ + (binaryfunc) Vector_idiv, /*__idiv__*/ + (binaryfunc) NULL, /*__imod__*/ + (ternaryfunc) NULL, /*__ipow__*/ + (binaryfunc) NULL, /*__ilshift__*/ + (binaryfunc) NULL, /*__irshift__*/ + (binaryfunc) NULL, /*__iand__*/ + (binaryfunc) NULL, /*__ixor__*/ + (binaryfunc) NULL, /*__ior__*/ + + /* Added in release 2.2 */ + /* The following require the Py_TPFLAGS_HAVE_CLASS flag */ + (binaryfunc) NULL, /*__floordiv__ __rfloordiv__*/ + (binaryfunc) NULL, /*__truediv__ __rfloordiv__*/ + (binaryfunc) NULL, /*__ifloordiv__*/ + (binaryfunc) NULL, /*__itruediv__*/ +}; +/*------------------PY_OBECT DEFINITION--------------------------*/ + +/* + * vector axis, vector.x/y/z/w + */ + +static PyObject *Vector_getAxis( VectorObject * self, void *type ) +{ + switch( (long)type ) { + case 'X': /* these are backwards, but that how it works */ + return PyFloat_FromDouble(self->vec[0]); + case 'Y': + return PyFloat_FromDouble(self->vec[1]); + case 'Z': /* these are backwards, but that how it works */ + if(self->size < 3) { + PyErr_SetString(PyExc_AttributeError, "vector.z: error, cannot get this axis for a 2D vector\n"); + return NULL; + } + else { + return PyFloat_FromDouble(self->vec[2]); + } + case 'W': + if(self->size < 4) { + PyErr_SetString(PyExc_AttributeError, "vector.w: error, cannot get this axis for a 3D vector\n"); + return NULL; + } + + return PyFloat_FromDouble(self->vec[3]); + default: + { + PyErr_SetString( PyExc_RuntimeError, "undefined type in Vector_getAxis" ); + return NULL; + } + } +} + +static int Vector_setAxis( VectorObject * self, PyObject * value, void * type ) +{ + float param= (float)PyFloat_AsDouble( value ); + + if (param==-1 && PyErr_Occurred()) { + PyErr_SetString( PyExc_TypeError, "expected a number for the vector axis" ); + return -1; + } + switch( (long)type ) { + case 'X': /* these are backwards, but that how it works */ + self->vec[0]= param; + break; + case 'Y': + self->vec[1]= param; + break; + case 'Z': /* these are backwards, but that how it works */ + if(self->size < 3) { + PyErr_SetString(PyExc_AttributeError, "vector.z: error, cannot get this axis for a 2D vector\n"); + return -1; + } + self->vec[2]= param; + break; + case 'W': + if(self->size < 4) { + PyErr_SetString(PyExc_AttributeError, "vector.w: error, cannot get this axis for a 3D vector\n"); + return -1; + } + self->vec[3]= param; + break; + } + + return 0; +} + +/* vector.length */ +static PyObject *Vector_getLength( VectorObject * self, void *type ) +{ + double dot = 0.0f; + int i; + + for(i = 0; i < self->size; i++){ + dot += (self->vec[i] * self->vec[i]); + } + return PyFloat_FromDouble(sqrt(dot)); +} + +static int Vector_setLength( VectorObject * self, PyObject * value ) +{ + double dot = 0.0f, param; + int i; + + param= PyFloat_AsDouble( value ); + if(param==-1.0 && PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, "length must be set to a number"); + return -1; + } + + if (param < 0) { + PyErr_SetString( PyExc_TypeError, "cannot set a vectors length to a negative value" ); + return -1; + } + if (param==0) { + for(i = 0; i < self->size; i++){ + self->vec[i]= 0; + } + return 0; + } + + for(i = 0; i < self->size; i++){ + dot += (self->vec[i] * self->vec[i]); + } + + if (!dot) /* cant sqrt zero */ + return 0; + + dot = sqrt(dot); + + if (dot==param) + return 0; + + dot= dot/param; + + for(i = 0; i < self->size; i++){ + self->vec[i]= self->vec[i] / (float)dot; + } + + return 0; +} + +static PyObject *Vector_getWrapped( VectorObject * self, void *type ) +{ + if (self->wrapped == Py_WRAP) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; +} + + +/* Get a new Vector according to the provided swizzle. This function has little + error checking, as we are in control of the inputs: the closure is set by us + in Vector_createSwizzleGetSeter. */ +static PyObject *Vector_getSwizzle(VectorObject * self, void *closure) +{ + size_t axisA; + size_t axisB; + float vec[MAX_DIMENSIONS]; + unsigned int swizzleClosure; + + /* Unpack the axes from the closure into an array. */ + axisA = 0; + swizzleClosure = (unsigned int) closure; + while (swizzleClosure & SWIZZLE_VALID_AXIS) + { + axisB = swizzleClosure & SWIZZLE_AXIS; + vec[axisA] = self->vec[axisB]; + swizzleClosure = swizzleClosure >> SWIZZLE_BITS_PER_AXIS; + axisA++; + } + + return newVectorObject(vec, axisA, Py_NEW); +} + +/* Set the items of this vector using a swizzle. + - If value is a vector or list this operates like an array copy, except that + the destination is effectively re-ordered as defined by the swizzle. At + most min(len(source), len(dest)) values will be copied. + - If the value is scalar, it is copied to all axes listed in the swizzle. + - If an axis appears more than once in the swizzle, the final occurrance is + the one that determines its value. + + Returns 0 on success and -1 on failure. On failure, the vector will be + unchanged. */ +static int Vector_setSwizzle(VectorObject * self, PyObject * value, void *closure) +{ + VectorObject *vecVal; + PyObject *item; + size_t listLen; + float scalarVal; + + size_t axisB; + size_t axisA; + unsigned int swizzleClosure; + + float vecTemp[MAX_DIMENSIONS]; + + /* Check that the closure can be used with this vector: even 2D vectors have + swizzles defined for axes z and w, but they would be invalid. */ + swizzleClosure = (unsigned int) closure; + while (swizzleClosure & SWIZZLE_VALID_AXIS) + { + axisA = swizzleClosure & SWIZZLE_AXIS; + if (axisA >= self->size) + { + PyErr_SetString(PyExc_AttributeError, "Error: vector does not have specified axis.\n"); + return -1; + } + swizzleClosure = swizzleClosure >> SWIZZLE_BITS_PER_AXIS; + } + + if (VectorObject_Check(value)) + { + /* Copy vector contents onto swizzled axes. */ + vecVal = (VectorObject*) value; + axisB = 0; + swizzleClosure = (unsigned int) closure; + while (swizzleClosure & SWIZZLE_VALID_AXIS && axisB < vecVal->size) + { + axisA = swizzleClosure & SWIZZLE_AXIS; + vecTemp[axisA] = vecVal->vec[axisB]; + + swizzleClosure = swizzleClosure >> SWIZZLE_BITS_PER_AXIS; + axisB++; + } + memcpy(self->vec, vecTemp, axisB * sizeof(float)); + return 0; + } + else if (PyList_Check(value)) + { + /* Copy list contents onto swizzled axes. */ + listLen = PyList_Size(value); + swizzleClosure = (unsigned int) closure; + axisB = 0; + while (swizzleClosure & SWIZZLE_VALID_AXIS && axisB < listLen) + { + item = PyList_GetItem(value, axisB); + scalarVal = (float)PyFloat_AsDouble(item); + + if (scalarVal==-1.0 && PyErr_Occurred()) { + PyErr_SetString(PyExc_AttributeError, "Error: vector does not have specified axis.\n"); + return -1; + } + + + axisA = swizzleClosure & SWIZZLE_AXIS; + vecTemp[axisA] = scalarVal; + + swizzleClosure = swizzleClosure >> SWIZZLE_BITS_PER_AXIS; + axisB++; + } + memcpy(self->vec, vecTemp, axisB * sizeof(float)); + return 0; + } + else if (((scalarVal = (float)PyFloat_AsDouble(value)) == -1.0 && PyErr_Occurred())==0) + { + /* Assign the same value to each axis. */ + swizzleClosure = (unsigned int) closure; + while (swizzleClosure & SWIZZLE_VALID_AXIS) + { + axisA = swizzleClosure & SWIZZLE_AXIS; + self->vec[axisA] = scalarVal; + + swizzleClosure = swizzleClosure >> SWIZZLE_BITS_PER_AXIS; + } + return 0; + } + else + { + PyErr_SetString( PyExc_TypeError, "Expected a Vector, list or scalar value." ); + return -1; + } +} + +/*****************************************************************************/ +/* Python attributes get/set structure: */ +/*****************************************************************************/ +static PyGetSetDef Vector_getseters[] = { + {"x", + (getter)Vector_getAxis, (setter)Vector_setAxis, + "Vector X axis", + (void *)'X'}, + {"y", + (getter)Vector_getAxis, (setter)Vector_setAxis, + "Vector Y axis", + (void *)'Y'}, + {"z", + (getter)Vector_getAxis, (setter)Vector_setAxis, + "Vector Z axis", + (void *)'Z'}, + {"w", + (getter)Vector_getAxis, (setter)Vector_setAxis, + "Vector Z axis", + (void *)'W'}, + {"length", + (getter)Vector_getLength, (setter)Vector_setLength, + "Vector Length", + NULL}, + {"magnitude", + (getter)Vector_getLength, (setter)Vector_setLength, + "Vector Length", + NULL}, + {"wrapped", + (getter)Vector_getWrapped, (setter)NULL, + "True when this wraps blenders internal data", + NULL}, + + /* autogenerated swizzle attrs, see python script below */ + {"xx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 36 */ + {"xxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 292 */ + {"xxxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2340 */ + {"xxxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2852 */ + {"xxxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3364 */ + {"xxxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3876 */ + {"xxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 356 */ + {"xxyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2404 */ + {"xxyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2916 */ + {"xxyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3428 */ + {"xxyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3940 */ + {"xxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 420 */ + {"xxzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2468 */ + {"xxzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2980 */ + {"xxzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3492 */ + {"xxzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4004 */ + {"xxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 484 */ + {"xxwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2532 */ + {"xxwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3044 */ + {"xxwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3556 */ + {"xxww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4068 */ + {"xy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 44 */ + {"xyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 300 */ + {"xyxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2348 */ + {"xyxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2860 */ + {"xyxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3372 */ + {"xyxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3884 */ + {"xyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 364 */ + {"xyyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2412 */ + {"xyyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2924 */ + {"xyyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3436 */ + {"xyyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3948 */ + {"xyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 428 */ + {"xyzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2476 */ + {"xyzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2988 */ + {"xyzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3500 */ + {"xyzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4012 */ + {"xyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 492 */ + {"xywx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2540 */ + {"xywy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3052 */ + {"xywz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3564 */ + {"xyww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4076 */ + {"xz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 52 */ + {"xzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 308 */ + {"xzxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2356 */ + {"xzxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2868 */ + {"xzxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3380 */ + {"xzxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3892 */ + {"xzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 372 */ + {"xzyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2420 */ + {"xzyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2932 */ + {"xzyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3444 */ + {"xzyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3956 */ + {"xzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 436 */ + {"xzzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2484 */ + {"xzzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2996 */ + {"xzzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3508 */ + {"xzzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4020 */ + {"xzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 500 */ + {"xzwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2548 */ + {"xzwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3060 */ + {"xzwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3572 */ + {"xzww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4084 */ + {"xw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 60 */ + {"xwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 316 */ + {"xwxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2364 */ + {"xwxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2876 */ + {"xwxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3388 */ + {"xwxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3900 */ + {"xwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 380 */ + {"xwyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2428 */ + {"xwyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2940 */ + {"xwyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3452 */ + {"xwyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3964 */ + {"xwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 444 */ + {"xwzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2492 */ + {"xwzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3004 */ + {"xwzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3516 */ + {"xwzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4028 */ + {"xww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 508 */ + {"xwwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2556 */ + {"xwwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3068 */ + {"xwwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3580 */ + {"xwww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((0|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4092 */ + {"yx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 37 */ + {"yxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 293 */ + {"yxxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2341 */ + {"yxxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2853 */ + {"yxxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3365 */ + {"yxxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3877 */ + {"yxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 357 */ + {"yxyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2405 */ + {"yxyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2917 */ + {"yxyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3429 */ + {"yxyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3941 */ + {"yxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 421 */ + {"yxzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2469 */ + {"yxzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2981 */ + {"yxzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3493 */ + {"yxzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4005 */ + {"yxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 485 */ + {"yxwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2533 */ + {"yxwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3045 */ + {"yxwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3557 */ + {"yxww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4069 */ + {"yy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 45 */ + {"yyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 301 */ + {"yyxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2349 */ + {"yyxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2861 */ + {"yyxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3373 */ + {"yyxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3885 */ + {"yyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 365 */ + {"yyyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2413 */ + {"yyyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2925 */ + {"yyyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3437 */ + {"yyyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3949 */ + {"yyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 429 */ + {"yyzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2477 */ + {"yyzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2989 */ + {"yyzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3501 */ + {"yyzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4013 */ + {"yyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 493 */ + {"yywx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2541 */ + {"yywy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3053 */ + {"yywz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3565 */ + {"yyww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4077 */ + {"yz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 53 */ + {"yzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 309 */ + {"yzxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2357 */ + {"yzxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2869 */ + {"yzxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3381 */ + {"yzxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3893 */ + {"yzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 373 */ + {"yzyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2421 */ + {"yzyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2933 */ + {"yzyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3445 */ + {"yzyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3957 */ + {"yzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 437 */ + {"yzzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2485 */ + {"yzzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2997 */ + {"yzzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3509 */ + {"yzzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4021 */ + {"yzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 501 */ + {"yzwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2549 */ + {"yzwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3061 */ + {"yzwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3573 */ + {"yzww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4085 */ + {"yw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 61 */ + {"ywx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 317 */ + {"ywxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2365 */ + {"ywxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2877 */ + {"ywxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3389 */ + {"ywxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3901 */ + {"ywy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 381 */ + {"ywyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2429 */ + {"ywyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2941 */ + {"ywyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3453 */ + {"ywyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3965 */ + {"ywz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 445 */ + {"ywzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2493 */ + {"ywzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3005 */ + {"ywzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3517 */ + {"ywzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4029 */ + {"yww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 509 */ + {"ywwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2557 */ + {"ywwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3069 */ + {"ywwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3581 */ + {"ywww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((1|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4093 */ + {"zx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 38 */ + {"zxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 294 */ + {"zxxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2342 */ + {"zxxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2854 */ + {"zxxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3366 */ + {"zxxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3878 */ + {"zxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 358 */ + {"zxyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2406 */ + {"zxyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2918 */ + {"zxyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3430 */ + {"zxyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3942 */ + {"zxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 422 */ + {"zxzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2470 */ + {"zxzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2982 */ + {"zxzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3494 */ + {"zxzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4006 */ + {"zxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 486 */ + {"zxwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2534 */ + {"zxwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3046 */ + {"zxwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3558 */ + {"zxww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4070 */ + {"zy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 46 */ + {"zyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 302 */ + {"zyxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2350 */ + {"zyxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2862 */ + {"zyxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3374 */ + {"zyxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3886 */ + {"zyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 366 */ + {"zyyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2414 */ + {"zyyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2926 */ + {"zyyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3438 */ + {"zyyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3950 */ + {"zyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 430 */ + {"zyzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2478 */ + {"zyzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2990 */ + {"zyzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3502 */ + {"zyzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4014 */ + {"zyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 494 */ + {"zywx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2542 */ + {"zywy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3054 */ + {"zywz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3566 */ + {"zyww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4078 */ + {"zz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 54 */ + {"zzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 310 */ + {"zzxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2358 */ + {"zzxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2870 */ + {"zzxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3382 */ + {"zzxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3894 */ + {"zzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 374 */ + {"zzyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2422 */ + {"zzyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2934 */ + {"zzyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3446 */ + {"zzyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3958 */ + {"zzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 438 */ + {"zzzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2486 */ + {"zzzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2998 */ + {"zzzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3510 */ + {"zzzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4022 */ + {"zzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 502 */ + {"zzwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2550 */ + {"zzwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3062 */ + {"zzwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3574 */ + {"zzww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4086 */ + {"zw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 62 */ + {"zwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 318 */ + {"zwxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2366 */ + {"zwxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2878 */ + {"zwxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3390 */ + {"zwxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3902 */ + {"zwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 382 */ + {"zwyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2430 */ + {"zwyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2942 */ + {"zwyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3454 */ + {"zwyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3966 */ + {"zwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 446 */ + {"zwzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2494 */ + {"zwzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3006 */ + {"zwzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3518 */ + {"zwzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4030 */ + {"zww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 510 */ + {"zwwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2558 */ + {"zwwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3070 */ + {"zwwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3582 */ + {"zwww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((2|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4094 */ + {"wx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 39 */ + {"wxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 295 */ + {"wxxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2343 */ + {"wxxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2855 */ + {"wxxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3367 */ + {"wxxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3879 */ + {"wxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 359 */ + {"wxyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2407 */ + {"wxyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2919 */ + {"wxyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3431 */ + {"wxyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3943 */ + {"wxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 423 */ + {"wxzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2471 */ + {"wxzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2983 */ + {"wxzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3495 */ + {"wxzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4007 */ + {"wxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 487 */ + {"wxwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2535 */ + {"wxwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3047 */ + {"wxwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3559 */ + {"wxww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4071 */ + {"wy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 47 */ + {"wyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 303 */ + {"wyxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2351 */ + {"wyxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2863 */ + {"wyxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3375 */ + {"wyxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3887 */ + {"wyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 367 */ + {"wyyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2415 */ + {"wyyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2927 */ + {"wyyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3439 */ + {"wyyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3951 */ + {"wyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 431 */ + {"wyzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2479 */ + {"wyzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2991 */ + {"wyzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3503 */ + {"wyzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4015 */ + {"wyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 495 */ + {"wywx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2543 */ + {"wywy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3055 */ + {"wywz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3567 */ + {"wyww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4079 */ + {"wz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 55 */ + {"wzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 311 */ + {"wzxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2359 */ + {"wzxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2871 */ + {"wzxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3383 */ + {"wzxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3895 */ + {"wzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 375 */ + {"wzyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2423 */ + {"wzyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2935 */ + {"wzyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3447 */ + {"wzyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3959 */ + {"wzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 439 */ + {"wzzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2487 */ + {"wzzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2999 */ + {"wzzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3511 */ + {"wzzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4023 */ + {"wzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 503 */ + {"wzwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2551 */ + {"wzwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3063 */ + {"wzwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3575 */ + {"wzww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4087 */ + {"ww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, /* 63 */ + {"wwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 319 */ + {"wwxx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2367 */ + {"wwxy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2879 */ + {"wwxz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3391 */ + {"wwxw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3903 */ + {"wwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 383 */ + {"wwyx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2431 */ + {"wwyy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2943 */ + {"wwyz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3455 */ + {"wwyw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3967 */ + {"wwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 447 */ + {"wwzx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2495 */ + {"wwzy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3007 */ + {"wwzz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3519 */ + {"wwzw", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4031 */ + {"www", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2))))}, /* 511 */ + {"wwwx", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((0|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 2559 */ + {"wwwy", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((1|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3071 */ + {"wwwz", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((2|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 3583 */ + {"wwww", (getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)((3|SWIZZLE_VALID_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((3|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) )}, /* 4095 */ + {NULL,NULL,NULL,NULL,NULL} /* Sentinel */ +}; + +/* Python script used to make swizzle array */ +/* +SWIZZLE_BITS_PER_AXIS = 3 +SWIZZLE_VALID_AXIS = 0x4 + +axis_dict = {} +axis_pos = {'x':0, 'y':1, 'z':2, 'w':3} +axises = 'xyzw' +while len(axises) >= 2: + + for axis_0 in axises: + axis_0_pos = axis_pos[axis_0] + for axis_1 in axises: + axis_1_pos = axis_pos[axis_1] + axis_dict[axis_0+axis_1] = '((%s|SWIZZLE_VALID_AXIS) | ((%s|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS))' % (axis_0_pos, axis_1_pos) + if len(axises)>2: + for axis_2 in axises: + axis_2_pos = axis_pos[axis_2] + axis_dict[axis_0+axis_1+axis_2] = '((%s|SWIZZLE_VALID_AXIS) | ((%s|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((%s|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)))' % (axis_0_pos, axis_1_pos, axis_2_pos) + if len(axises)>3: + for axis_3 in axises: + axis_3_pos = axis_pos[axis_3] + axis_dict[axis_0+axis_1+axis_2+axis_3] = '((%s|SWIZZLE_VALID_AXIS) | ((%s|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS) | ((%s|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*2)) | ((%s|SWIZZLE_VALID_AXIS)<<(SWIZZLE_BITS_PER_AXIS*3))) ' % (axis_0_pos, axis_1_pos, axis_2_pos, axis_3_pos) + + axises = axises[:-1] + + +items = axis_dict.items() +items.sort(key = lambda a: a[0].replace('x', '0').replace('y', '1').replace('z', '2').replace('w', '3')) + +unique = set() +for key, val in items: + num = eval(val) + print '\t{"%s", %s(getter)Vector_getSwizzle, (setter)Vector_setSwizzle, Vector_swizzle_doc, (void *)((unsigned int)%s)}, // %s' % (key, (' '*(4-len(key))), axis_dict[key], num) + unique.add(num) + +if len(unique) != len(items): + print "ERROR" + +*/ + + + + +/* Note + Py_TPFLAGS_CHECKTYPES allows us to avoid casting all types to Vector when coercing + but this means for eg that + vec*mat and mat*vec both get sent to Vector_mul and it neesd to sort out the order +*/ + +PyTypeObject vector_Type = { +#if (PY_VERSION_HEX >= 0x02060000) + PyVarObject_HEAD_INIT(NULL, 0) +#else + /* python 2.5 and below */ + PyObject_HEAD_INIT( NULL ) /* required py macro */ + 0, /* ob_size */ +#endif + /* For printing, in format "<module>.<name>" */ + "Blender Vector", /* char *tp_name; */ + sizeof( VectorObject ), /* int tp_basicsize; */ + 0, /* tp_itemsize; For allocation */ + + /* Methods to implement standard operations */ + + ( destructor ) Vector_dealloc,/* destructor tp_dealloc; */ + NULL, /* printfunc tp_print; */ + NULL, /* getattrfunc tp_getattr; */ + NULL, /* setattrfunc tp_setattr; */ + NULL, /* cmpfunc tp_compare; */ + ( reprfunc ) Vector_repr, /* reprfunc tp_repr; */ + + /* Method suites for standard classes */ + + &Vector_NumMethods, /* PyNumberMethods *tp_as_number; */ + &Vector_SeqMethods, /* PySequenceMethods *tp_as_sequence; */ + NULL, /* PyMappingMethods *tp_as_mapping; */ + + /* More standard operations (here for binary compatibility) */ + + NULL, /* hashfunc tp_hash; */ + NULL, /* ternaryfunc tp_call; */ + NULL, /* reprfunc tp_str; */ + NULL, /* getattrofunc tp_getattro; */ + NULL, /* setattrofunc tp_setattro; */ + + /* Functions to access object as input/output buffer */ + NULL, /* PyBufferProcs *tp_as_buffer; */ + + /*** Flags to define presence of optional/expanded features ***/ + Py_TPFLAGS_DEFAULT, + VectorObject_doc, /* char *tp_doc; Documentation string */ + /*** Assigned meaning in release 2.0 ***/ + /* call function for all accessible objects */ + NULL, /* traverseproc tp_traverse; */ + + /* delete references to contained objects */ + NULL, /* inquiry tp_clear; */ + + /*** Assigned meaning in release 2.1 ***/ + /*** rich comparisons ***/ + (richcmpfunc)Vector_richcmpr, /* richcmpfunc tp_richcompare; */ + + /*** weak reference enabler ***/ + 0, /* long tp_weaklistoffset; */ + + /*** Added in release 2.2 ***/ + /* Iterators */ + NULL, /* getiterfunc tp_iter; */ + NULL, /* iternextfunc tp_iternext; */ + + /*** Attribute descriptor and subclassing stuff ***/ + Vector_methods, /* struct PyMethodDef *tp_methods; */ + NULL, /* struct PyMemberDef *tp_members; */ + Vector_getseters, /* struct PyGetSetDef *tp_getset; */ + NULL, /* struct _typeobject *tp_base; */ + NULL, /* PyObject *tp_dict; */ + NULL, /* descrgetfunc tp_descr_get; */ + NULL, /* descrsetfunc tp_descr_set; */ + 0, /* long tp_dictoffset; */ + NULL, /* initproc tp_init; */ + NULL, /* allocfunc tp_alloc; */ + Vector_new, /* newfunc tp_new; */ + /* Low-level free-memory routine */ + NULL, /* freefunc tp_free; */ + /* For PyObject_IS_GC */ + NULL, /* inquiry tp_is_gc; */ + NULL, /* PyObject *tp_bases; */ + /* method resolution order */ + NULL, /* PyObject *tp_mro; */ + NULL, /* PyObject *tp_cache; */ + NULL, /* PyObject *tp_subclasses; */ + NULL, /* PyObject *tp_weaklist; */ + NULL +}; + + +/*------------------------newVectorObject (internal)------------- + creates a new vector object + pass Py_WRAP - if vector is a WRAPPER for data allocated by BLENDER + (i.e. it was allocated elsewhere by MEM_mallocN()) + pass Py_NEW - if vector is not a WRAPPER and managed by PYTHON + (i.e. it must be created here with PyMEM_malloc())*/ +PyObject *newVectorObject(float *vec, int size, int type) +{ + int i; + VectorObject *self = PyObject_NEW(VectorObject, &vector_Type); + + if(size > 4 || size < 2) + return NULL; + self->size = size; + + if(type == Py_WRAP) { + self->vec = vec; + self->wrapped = Py_WRAP; + } else if (type == Py_NEW) { + self->vec = PyMem_Malloc(size * sizeof(float)); + if(!vec) { /*new empty*/ + for(i = 0; i < size; i++){ + self->vec[i] = 0.0f; + } + if(size == 4) /* do the homogenous thing */ + self->vec[3] = 1.0f; + }else{ + for(i = 0; i < size; i++){ + self->vec[i] = vec[i]; + } + } + self->wrapped = Py_NEW; + }else{ /*bad type*/ + return NULL; + } + return (PyObject *) self; +} + +/* + #############################DEPRECATED################################ + ####################################################################### + ----------------------------Vector.negate() -------------------- + set the vector to it's negative -x, -y, -z */ +static PyObject *Vector_Negate(VectorObject * self) +{ + int i; + for(i = 0; i < self->size; i++) { + self->vec[i] = -(self->vec[i]); + } + /*printf("Vector.negate(): Deprecated: use -vector instead\n");*/ + Py_INCREF(self); + return (PyObject*)self; +} +/*################################################################### + ###########################DEPRECATED##############################*/ diff --git a/source/blender/python/generic/vector.h b/source/blender/python/generic/vector.h new file mode 100644 index 00000000000..d2eb826ef10 --- /dev/null +++ b/source/blender/python/generic/vector.h @@ -0,0 +1,50 @@ +/* $Id: vector.h 20332 2009-05-22 03:22:56Z campbellbarton $ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Willian P. Germano & Joseph Gilbert + * + * ***** END GPL LICENSE BLOCK ***** + * + */ + +#ifndef EXPP_vector_h +#define EXPP_vector_h + +#include <Python.h> +#include "../intern/bpy_compat.h" + +extern PyTypeObject vector_Type; + +#define VectorObject_Check(v) (((PyObject *)v)->ob_type == &vector_Type) + +typedef struct { + PyObject_VAR_HEAD + float *vec; /*1D array of data (alias), wrapped status depends on wrapped status */ + short size; /* vec size 2,3 or 4 */ + short wrapped; /* is wrapped data? */ +} VectorObject; + +/*prototypes*/ +PyObject *newVectorObject(float *vec, int size, int type); + +#endif /* EXPP_vector_h */ diff --git a/source/blender/python/intern/Makefile b/source/blender/python/intern/Makefile index 3e28f5aac31..0c4a540a4bd 100644 --- a/source/blender/python/intern/Makefile +++ b/source/blender/python/intern/Makefile @@ -37,6 +37,7 @@ CFLAGS += $(LEVEL_1_C_WARNINGS) # OpenGL and Python CPPFLAGS += $(OGL_CPPFLAGS) +CPPFLAGS += -I$(NAN_GLEW)/include CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) # PreProcessor stuff diff --git a/source/blender/python/intern/bpy_compat.h b/source/blender/python/intern/bpy_compat.h index ad6b7a5e85c..1ad9376c13b 100644 --- a/source/blender/python/intern/bpy_compat.h +++ b/source/blender/python/intern/bpy_compat.h @@ -88,6 +88,26 @@ typedef Py_ssize_t (*lenfunc)(PyObject *); #endif +#if PY_VERSION_HEX < 0x03000000 +#ifndef ssizeargfunc +#define ssizeargfunc intargfunc +#endif + +#ifndef ssizessizeargfunc +#define ssizessizeargfunc intintargfunc +#endif + +#ifndef ssizeobjargproc +#define ssizeobjargproc intobjargproc +#endif + +#ifndef ssizessizeobjargproc +#define ssizessizeobjargproc intintobjargproc +#endif +#endif + + + /* defined in bpy_util.c */ #if PY_VERSION_HEX < 0x03000000 PyObject *Py_CmpToRich(int op, int cmp); diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 7b3a67ebff5..559ed537757 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -36,6 +36,9 @@ #include "BPY_extern.h" +#include "../generic/bpy_internal_import.h" // our own imports + + void BPY_free_compiled_text( struct Text *text ) { if( text->compiled ) { @@ -56,6 +59,7 @@ static void bpy_init_modules( void ) PyModule_AddObject( mod, "data", BPY_rna_module() ); /* PyModule_AddObject( mod, "doc", BPY_rna_doc() ); */ PyModule_AddObject( mod, "types", BPY_rna_types() ); + PyModule_AddObject( mod, "props", BPY_rna_props() ); PyModule_AddObject( mod, "ops", BPY_operator_module() ); PyModule_AddObject( mod, "ui", BPY_ui_module() ); // XXX very experemental, consider this a test, especially PyCObject is not meant to be perminant @@ -100,6 +104,7 @@ static PyObject *CreateGlobalDictionary( bContext *C ) {"FloatProperty", (PyCFunction)BPy_FloatProperty, METH_VARARGS|METH_KEYWORDS, ""}, {"IntProperty", (PyCFunction)BPy_IntProperty, METH_VARARGS|METH_KEYWORDS, ""}, {"BoolProperty", (PyCFunction)BPy_BoolProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {"StringProperty", (PyCFunction)BPy_StringProperty, METH_VARARGS|METH_KEYWORDS, ""}, {NULL, NULL, 0, NULL} }; @@ -131,10 +136,17 @@ void BPY_start_python( int argc, char **argv ) /* bpy.* and lets us import it */ bpy_init_modules(); + { /* our own import and reload functions */ + PyObject *item; + //PyObject *m = PyImport_AddModule("__builtin__"); + //PyObject *d = PyModule_GetDict(m); + PyObject *d = PyEval_GetBuiltins( ); + PyDict_SetItemString(d, "reload", item=PyCFunction_New(bpy_reload_meth, NULL)); Py_DECREF(item); + PyDict_SetItemString(d, "__import__", item=PyCFunction_New(bpy_import_meth, NULL)); Py_DECREF(item); + } py_tstate = PyGILState_GetThisThreadState(); PyEval_ReleaseThread(py_tstate); - } void BPY_end_python( void ) @@ -150,7 +162,7 @@ void BPY_end_python( void ) } /* Can run a file or text block */ -int BPY_run_python_script( bContext *C, const char *fn, struct Text *text ) +int BPY_run_python_script( bContext *C, const char *fn, struct Text *text, struct ReportList *reports) { PyObject *py_dict, *py_result; PyGILState_STATE gilstate; @@ -164,6 +176,7 @@ int BPY_run_python_script( bContext *C, const char *fn, struct Text *text ) gilstate = PyGILState_Ensure(); BPY_update_modules(); /* can give really bad results if this isnt here */ + bpy_import_main_set(CTX_data_main(C)); py_dict = CreateGlobalDictionary(C); @@ -178,7 +191,7 @@ int BPY_run_python_script( bContext *C, const char *fn, struct Text *text ) MEM_freeN( buf ); if( PyErr_Occurred( ) ) { - PyErr_Print(); PyErr_Clear(); + BPy_errors_to_report(reports); BPY_free_compiled_text( text ); PyGILState_Release(gilstate); return 0; @@ -194,13 +207,14 @@ int BPY_run_python_script( bContext *C, const char *fn, struct Text *text ) } if (!py_result) { - PyErr_Print(); PyErr_Clear(); + BPy_errors_to_report(reports); } else { Py_DECREF( py_result ); } Py_DECREF(py_dict); PyGILState_Release(gilstate); + bpy_import_main_set(NULL); //BPY_end_python(); return py_result ? 1:0; @@ -221,7 +235,7 @@ static void exit_pydraw( SpaceScript * sc, short err ) script = sc->script; if( err ) { - PyErr_Print(); PyErr_Clear(); + BPy_errors_to_report(NULL); // TODO, reports script->flags = 0; /* mark script struct for deletion */ SCRIPT_SET_NULL(script); script->scriptname[0] = '\0'; @@ -250,7 +264,7 @@ static int bpy_run_script_init(bContext *C, SpaceScript * sc) return 0; if (sc->script->py_draw==NULL && sc->script->scriptname[0] != '\0') - BPY_run_python_script(C, sc->script->scriptname, NULL); + BPY_run_python_script(C, sc->script->scriptname, NULL, NULL); if (sc->script->py_draw==NULL) return 0; @@ -329,7 +343,7 @@ int BPY_run_python_script_space(const char *modulename, const char *func) } if (!py_result) { - PyErr_Print(); PyErr_Clear(); + BPy_errors_to_report(NULL); // TODO - reports } else Py_DECREF( py_result ); @@ -357,69 +371,78 @@ void BPY_run_ui_scripts(bContext *C, int reload) DIR *dir; struct dirent *de; char *file_extension; + char *dirname; char path[FILE_MAX]; - char *dirname= BLI_gethome_folder("ui"); - int filelen; /* filename length */ + char *dirs[] = {"io", "ui", NULL}; + int a, filelen; /* filename length */ PyGILState_STATE gilstate; PyObject *mod; PyObject *sys_path_orig; PyObject *sys_path_new; - - if(!dirname) - return; - - dir = opendir(dirname); - if(!dir) - return; - gilstate = PyGILState_Ensure(); - /* backup sys.path */ - sys_path_orig= PySys_GetObject("path"); - Py_INCREF(sys_path_orig); /* dont free it */ - - sys_path_new= PyList_New(1); - PyList_SET_ITEM(sys_path_new, 0, PyUnicode_FromString(dirname)); - PySys_SetObject("path", sys_path_new); - Py_DECREF(sys_path_new); - // XXX - evil, need to access context BPy_SetContext(C); - - while((de = readdir(dir)) != NULL) { - /* We could stat the file but easier just to let python - * import it and complain if theres a problem */ - - file_extension = strstr(de->d_name, ".py"); + bpy_import_main_set(CTX_data_main(C)); + + for(a=0; dirs[a]; a++) { + dirname= BLI_gethome_folder(dirs[a]); + + if(!dirname) + continue; + + dir = opendir(dirname); + + if(!dir) + continue; + + /* backup sys.path */ + sys_path_orig= PySys_GetObject("path"); + Py_INCREF(sys_path_orig); /* dont free it */ - if(file_extension && *(file_extension + 3) == '\0') { - filelen = strlen(de->d_name); - BLI_strncpy(path, de->d_name, filelen-2); /* cut off the .py on copy */ + sys_path_new= PyList_New(1); + PyList_SET_ITEM(sys_path_new, 0, PyUnicode_FromString(dirname)); + PySys_SetObject("path", sys_path_new); + Py_DECREF(sys_path_new); - mod= PyImport_ImportModuleLevel(path, NULL, NULL, NULL, 0); - if (mod) { - if (reload) { - PyObject *mod_orig= mod; - mod= PyImport_ReloadModule(mod); - Py_DECREF(mod_orig); - } - } + while((de = readdir(dir)) != NULL) { + /* We could stat the file but easier just to let python + * import it and complain if theres a problem */ + + file_extension = strstr(de->d_name, ".py"); - if(mod) { - Py_DECREF(mod); /* could be NULL from reloading */ - } else { - PyErr_Print(); PyErr_Clear(); - fprintf(stderr, "unable to import \"%s\" %s/%s\n", path, dirname, de->d_name); + if(file_extension && *(file_extension + 3) == '\0') { + filelen = strlen(de->d_name); + BLI_strncpy(path, de->d_name, filelen-2); /* cut off the .py on copy */ + + mod= PyImport_ImportModuleLevel(path, NULL, NULL, NULL, 0); + if (mod) { + if (reload) { + PyObject *mod_orig= mod; + mod= PyImport_ReloadModule(mod); + Py_DECREF(mod_orig); + } + } + + if(mod) { + Py_DECREF(mod); /* could be NULL from reloading */ + } else { + BPy_errors_to_report(NULL); // TODO - reports + fprintf(stderr, "unable to import \"%s\" %s/%s\n", path, dirname, de->d_name); + } + } } - } - closedir(dir); + closedir(dir); + + PySys_SetObject("path", sys_path_orig); + Py_DECREF(sys_path_orig); + } - PySys_SetObject("path", sys_path_orig); - Py_DECREF(sys_path_orig); + bpy_import_main_set(NULL); PyGILState_Release(gilstate); #ifdef TIME_REGISTRATION @@ -530,7 +553,7 @@ static float pydriver_error(ChannelDriver *driver) driver->flag |= DRIVER_FLAG_INVALID; /* py expression failed */ fprintf(stderr, "\nError in Driver: The following Python expression failed:\n\t'%s'\n\n", driver->expression); - PyErr_Print(); PyErr_Clear(); + BPy_errors_to_report(NULL); // TODO - reports return 0.0f; } @@ -589,7 +612,7 @@ float BPY_pydriver_eval (ChannelDriver *driver) } fprintf(stderr, "\tBPY_pydriver_eval() - couldn't add variable '%s' to namespace \n", dtar->name); - PyErr_Print(); PyErr_Clear(); + BPy_errors_to_report(NULL); // TODO - reports } } diff --git a/source/blender/python/intern/bpy_operator_wrap.c b/source/blender/python/intern/bpy_operator_wrap.c index 6ab990acdf5..f4fdd0c6194 100644 --- a/source/blender/python/intern/bpy_operator_wrap.c +++ b/source/blender/python/intern/bpy_operator_wrap.c @@ -40,6 +40,8 @@ #include "bpy_compat.h" #include "bpy_util.h" +#include "../generic/bpy_internal_import.h" // our own imports + #define PYOP_ATTR_PROP "__props__" #define PYOP_ATTR_UINAME "__label__" #define PYOP_ATTR_IDNAME "__name__" /* use pythons class name */ @@ -137,19 +139,6 @@ static PyObject *pyop_dict_from_event(wmEvent *event) return dict; } -/* TODO - a whole traceback would be ideal */ -static void pyop_error_report(ReportList *reports) -{ - PyObject *exception, *v, *tb; - PyErr_Fetch(&exception, &v, &tb); - if (exception == NULL) - return; - /* Now we know v != NULL too */ - BKE_report(reports, RPT_ERROR, _PyUnicode_AsString(v)); - - PyErr_Print(); -} - static struct BPY_flag_def pyop_ret_flags[] = { {"RUNNING_MODAL", OPERATOR_RUNNING_MODAL}, {"CANCELLED", OPERATOR_CANCELLED}, @@ -190,9 +179,12 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperator *op, wmEvent *eve PyObject *ret= NULL, *py_class_instance, *item= NULL; int ret_flag= (mode==PYOP_POLL ? 0:OPERATOR_CANCELLED); PointerRNA ptr_context; - PyObject *py_context; + PointerRNA ptr_operator; + PyObject *py_operator; PyGILState_STATE gilstate = PyGILState_Ensure(); + + bpy_import_main_set(CTX_data_main(C)); BPY_update_modules(); // XXX - the RNA pointers can change so update before running, would like a nicer solutuon for this. @@ -226,20 +218,29 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperator *op, wmEvent *eve RNA_property_collection_end(&iter); } - + + /* set operator pointer RNA as instance "__operator__" attribute */ + RNA_pointer_create(NULL, &RNA_Operator, op, &ptr_operator); + py_operator= pyrna_struct_CreatePyObject(&ptr_operator); + PyObject_SetAttrString(py_class_instance, "__operator__", py_operator); + Py_DECREF(py_operator); + + RNA_pointer_create(NULL, &RNA_Context, C, &ptr_context); if (mode==PYOP_INVOKE) { item= PyObject_GetAttrString(py_class, "invoke"); - args = PyTuple_New(2); - PyTuple_SET_ITEM(args, 1, pyop_dict_from_event(event)); + args = PyTuple_New(3); + + // PyTuple_SET_ITEM "steals" object reference, it is + // an object passed shouldn't be DECREF'ed + PyTuple_SET_ITEM(args, 1, pyrna_struct_CreatePyObject(&ptr_context)); + PyTuple_SET_ITEM(args, 2, pyop_dict_from_event(event)); } else if (mode==PYOP_EXEC) { - item= PyObject_GetAttrString(py_class, "exec"); + item= PyObject_GetAttrString(py_class, "execute"); args = PyTuple_New(2); - RNA_pointer_create(NULL, &RNA_Context, C, &ptr_context); - py_context = pyrna_struct_CreatePyObject(&ptr_context); - PyTuple_SET_ITEM(args, 1, py_context); + PyTuple_SET_ITEM(args, 1, pyrna_struct_CreatePyObject(&ptr_context)); } else if (mode==PYOP_POLL) { item= PyObject_GetAttrString(py_class, "poll"); @@ -256,13 +257,13 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperator *op, wmEvent *eve } if (ret == NULL) { /* covers py_class_instance failing too */ - pyop_error_report(op->reports); + BPy_errors_to_report(op->reports); } else { if (mode==PYOP_POLL) { if (PyBool_Check(ret) == 0) { PyErr_SetString(PyExc_ValueError, "Python poll function return value "); - pyop_error_report(op->reports); + BPy_errors_to_report(op->reports); } else { ret_flag= ret==Py_True ? 1:0; @@ -270,8 +271,9 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperator *op, wmEvent *eve } else if (BPY_flag_from_seq(pyop_ret_flags, ret, &ret_flag) == -1) { /* the returned value could not be converted into a flag */ - pyop_error_report(op->reports); - + BPy_errors_to_report(op->reports); + + ret_flag = OPERATOR_CANCELLED; } /* there is no need to copy the py keyword dict modified by * pyot->py_invoke(), back to the operator props since they are just @@ -284,7 +286,34 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperator *op, wmEvent *eve Py_DECREF(ret); } + /* print operator return value */ + if (mode != PYOP_POLL) { + char flag_str[100]; + char class_name[100]; + BPY_flag_def *flag_def = pyop_ret_flags; + + strcpy(flag_str, ""); + + while(flag_def->name) { + if (ret_flag & flag_def->flag) { + if(flag_str[1]) + sprintf(flag_str, "%s | %s", flag_str, flag_def->name); + else + strcpy(flag_str, flag_def->name); + } + flag_def++; + } + + /* get class name */ + item= PyObject_GetAttrString(py_class, PYOP_ATTR_IDNAME); + Py_DECREF(item); + strcpy(class_name, _PyUnicode_AsString(item)); + + fprintf(stderr, "%s's %s returned %s\n", class_name, mode == PYOP_EXEC ? "execute" : "invoke", flag_str); + } + PyGILState_Release(gilstate); + bpy_import_main_set(NULL); return ret_flag; } @@ -334,7 +363,7 @@ void PYTHON_OT_wrapper(wmOperatorType *ot, void *userdata) /* api callbacks, detailed checks dont on adding */ if (PyObject_HasAttrString(py_class, "invoke")) ot->invoke= PYTHON_OT_invoke; - if (PyObject_HasAttrString(py_class, "exec")) + if (PyObject_HasAttrString(py_class, "execute")) ot->exec= PYTHON_OT_exec; if (PyObject_HasAttrString(py_class, "poll")) ot->poll= PYTHON_OT_poll; @@ -387,6 +416,7 @@ void PYTHON_OT_wrapper(wmOperatorType *ot, void *userdata) PyObject *PYOP_wrap_add(PyObject *self, PyObject *py_class) { PyObject *base_class, *item; + wmOperatorType *ot; char *idname= NULL; @@ -397,8 +427,8 @@ PyObject *PYOP_wrap_add(PyObject *self, PyObject *py_class) {PYOP_ATTR_UINAME, 's', 0, BPY_CLASS_ATTR_OPTIONAL}, {PYOP_ATTR_PROP, 'l', 0, BPY_CLASS_ATTR_OPTIONAL}, {PYOP_ATTR_DESCRIPTION, 's', 0, BPY_CLASS_ATTR_NONE_OK}, - {"exec", 'f', 2, BPY_CLASS_ATTR_OPTIONAL}, - {"invoke", 'f', 2, BPY_CLASS_ATTR_OPTIONAL}, + {"execute", 'f', 2, BPY_CLASS_ATTR_OPTIONAL}, + {"invoke", 'f', 3, BPY_CLASS_ATTR_OPTIONAL}, {"poll", 'f', 2, BPY_CLASS_ATTR_OPTIONAL}, {NULL, 0, 0, 0} }; @@ -417,9 +447,10 @@ PyObject *PYOP_wrap_add(PyObject *self, PyObject *py_class) Py_DECREF(item); idname = _PyUnicode_AsString(item); - if (WM_operatortype_find(idname)) { - PyErr_Format( PyExc_AttributeError, "Operator alredy exists with this name \"%s\"", idname); - return NULL; + /* remove if it already exists */ + if ((ot=WM_operatortype_find(idname))) { + Py_XDECREF((PyObject*)ot->pyop_data); + WM_operatortype_remove(idname); } /* If we have properties set, check its a list of dicts */ diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 12c19bd3471..5727bb97483 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -481,7 +481,9 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyObject *v BPy_StructRNA *param= (BPy_StructRNA*)value; int raise_error= 0; if(data) { - if(ptype == &RNA_AnyType) { + int flag = RNA_property_flag(prop); + + if(flag & PROP_RNAPTR) { if(value == Py_None) memset(data, 0, sizeof(PointerRNA)); else @@ -763,6 +765,39 @@ static PyMappingMethods pyrna_prop_as_mapping = { ( objobjargproc ) pyrna_prop_assign_subscript, /* mp_ass_subscript */ }; +static int pyrna_prop_contains(BPy_PropertyRNA * self, PyObject *value) +{ + PointerRNA newptr; /* not used, just so RNA_property_collection_lookup_string runs */ + char *keyname = _PyUnicode_AsString(value); + + if(keyname==NULL) { + PyErr_SetString(PyExc_TypeError, "PropertyRNA - key in prop, key must be a string type"); + return -1; + } + + if (RNA_property_type(self->prop) != PROP_COLLECTION) { + PyErr_SetString(PyExc_TypeError, "PropertyRNA - key in prop, is only valid for collection types"); + return -1; + } + + + if (RNA_property_collection_lookup_string(&self->ptr, self->prop, keyname, &newptr)) + return 1; + + return 0; +} + +static PySequenceMethods pyrna_prop_as_sequence = { + NULL, /* Cant set the len otherwise it can evaluate as false */ + NULL, /* sq_concat */ + NULL, /* sq_repeat */ + NULL, /* sq_item */ + NULL, /* sq_slice */ + NULL, /* sq_ass_item */ + NULL, /* sq_ass_slice */ + (objobjproc)pyrna_prop_contains, /* sq_contains */ +}; + static PyObject *pyrna_struct_dir(BPy_StructRNA * self) { PyObject *ret, *dict; @@ -1176,8 +1211,9 @@ PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *data) { PointerRNA newptr; StructRNA *type= RNA_property_pointer_type(ptr, prop); + int flag = RNA_property_flag(prop); - if(type == &RNA_AnyType) { + if(flag & PROP_RNAPTR) { /* in this case we get the full ptr */ newptr= *(PointerRNA*)data; } @@ -1274,11 +1310,19 @@ static PyObject * pyrna_func_call(PyObject * self, PyObject *args, PyObject *kw) ret= NULL; if (err==0) { /* call function */ - RNA_function_call(self_ptr, self_func, parms); + ReportList reports; + bContext *C= BPy_GetContext(); + + BKE_reports_init(&reports, RPT_STORE); + RNA_function_call(C, &reports, self_ptr, self_func, parms); + + err= (BPy_reports_to_error(&reports))? -1: 0; + BKE_reports_clear(&reports); /* return value */ - if(pret) - ret= pyrna_param_to_py(&funcptr, pret, retdata); + if(err==0) + if(pret) + ret= pyrna_param_to_py(&funcptr, pret, retdata); } /* cleanup */ @@ -1403,7 +1447,7 @@ PyTypeObject pyrna_prop_Type = { /* Method suites for standard classes */ NULL, /* PyNumberMethods *tp_as_number; */ - NULL, /* PySequenceMethods *tp_as_sequence; */ + &pyrna_prop_as_sequence, /* PySequenceMethods *tp_as_sequence; */ &pyrna_prop_as_mapping, /* PyMappingMethods *tp_as_mapping; */ /* More standard operations (here for binary compatibility) */ @@ -1716,7 +1760,44 @@ PyObject *BPY_rna_types(void) return (PyObject *)self; } +static struct PyMethodDef props_methods[] = { + {"FloatProperty", (PyCFunction)BPy_FloatProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {"IntProperty", (PyCFunction)BPy_IntProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {"BoolProperty", (PyCFunction)BPy_BoolProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {"StringProperty", (PyCFunction)BPy_StringProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {NULL, NULL, 0, NULL} +}; +#if PY_VERSION_HEX >= 0x03000000 +static struct PyModuleDef props_module = { + PyModuleDef_HEAD_INIT, + "bpyprops", + "", + -1,/* multiple "initialization" just copies the module dict. */ + props_methods, + NULL, NULL, NULL, NULL +}; +#endif + +PyObject *BPY_rna_props( void ) +{ + PyObject *submodule, *mod; +#if PY_VERSION_HEX >= 0x03000000 + submodule= PyModule_Create(&props_module); +#else /* Py2.x */ + submodule= Py_InitModule3( "bpy.props", props_methods, "" ); +#endif + + mod = PyModule_New("props"); + PyModule_AddObject( submodule, "props", mod ); + + /* INCREF since its its assumed that all these functions return the + * module with a new ref like PyDict_New, since they are passed to + * PyModule_AddObject which steals a ref */ + Py_INCREF(submodule); + + return submodule; +} /* Orphan functions, not sure where they should go */ @@ -1736,7 +1817,7 @@ PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw) return NULL; } - if (self) { + if (self && PyCObject_Check(self)) { StructRNA *srna = PyCObject_AsVoidPtr(self); RNA_def_float(srna, id, def, min, max, name, description, soft_min, soft_max); Py_RETURN_NONE; @@ -1763,7 +1844,7 @@ PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw) return NULL; } - if (self) { + if (self && PyCObject_Check(self)) { StructRNA *srna = PyCObject_AsVoidPtr(self); RNA_def_int(srna, id, def, min, max, name, description, soft_min, soft_max); Py_RETURN_NONE; @@ -1790,7 +1871,7 @@ PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw) return NULL; } - if (self) { + if (self && PyCObject_Check(self)) { StructRNA *srna = PyCObject_AsVoidPtr(self); RNA_def_boolean(srna, id, def, name, description); Py_RETURN_NONE; @@ -1803,6 +1884,33 @@ PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw) } } +PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw) +{ + static char *kwlist[] = {"attr", "name", "description", "maxlen", "default", NULL}; + char *id, *name="", *description="", *def=""; + int maxlen=0; + + if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssis:StringProperty", kwlist, &id, &name, &description, &maxlen, &def)) + return NULL; + + if (PyTuple_Size(args) > 0) { + PyErr_SetString(PyExc_ValueError, "all args must be keywors"); // TODO - py3 can enforce this. + return NULL; + } + + if (self && PyCObject_Check(self)) { + StructRNA *srna = PyCObject_AsVoidPtr(self); + RNA_def_string(srna, id, def, maxlen, name, description); + Py_RETURN_NONE; + } else { + PyObject *ret = PyTuple_New(2); + PyTuple_SET_ITEM(ret, 0, PyCObject_FromVoidPtr((void *)BPy_StringProperty, NULL)); + PyTuple_SET_ITEM(ret, 1, kw); + Py_INCREF(kw); + return ret; + } +} + /*-------------------- Type Registration ------------------------*/ static int rna_function_arg_count(FunctionRNA *func) @@ -2085,7 +2193,7 @@ PyObject *pyrna_basetype_register(PyObject *self, PyObject *args) C= BPy_GetContext(); /* call the register callback */ - BKE_reports_init(&reports, RPT_PRINT); + BKE_reports_init(&reports, RPT_STORE); srna= reg(C, &reports, py_class, bpy_class_validate, bpy_class_call, bpy_class_free); if(!srna) { diff --git a/source/blender/python/intern/bpy_rna.h b/source/blender/python/intern/bpy_rna.h index a2a3015912b..d2f01b06336 100644 --- a/source/blender/python/intern/bpy_rna.h +++ b/source/blender/python/intern/bpy_rna.h @@ -63,6 +63,7 @@ typedef struct { PyObject *BPY_rna_module( void ); /*PyObject *BPY_rna_doc( void );*/ PyObject *BPY_rna_types( void ); +PyObject *BPY_rna_props( void ); PyObject *pyrna_struct_CreatePyObject( PointerRNA *ptr ); PyObject *pyrna_prop_CreatePyObject( PointerRNA *ptr, PropertyRNA *prop ); @@ -76,6 +77,7 @@ PyObject * pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop); PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw); PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw); PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw); +PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw); /* function for registering types */ PyObject *pyrna_basetype_register(PyObject *self, PyObject *args); diff --git a/source/blender/python/intern/bpy_util.c b/source/blender/python/intern/bpy_util.c index c447e7de982..d837892fb4d 100644 --- a/source/blender/python/intern/bpy_util.c +++ b/source/blender/python/intern/bpy_util.c @@ -81,6 +81,7 @@ int BPY_flag_from_seq(BPY_flag_def *flagdef, PyObject *seq, int *flag) char *cstring; PyObject *item; BPY_flag_def *fd; + *flag = 0; if (PySequence_Check(seq)) { i= PySequence_Length(seq); @@ -108,6 +109,9 @@ int BPY_flag_from_seq(BPY_flag_def *flagdef, PyObject *seq, int *flag) error_val= 1; } + if (*flag == 0) + error_val = 1; + if (error_val) { char *buf = bpy_flag_error_str(flagdef); PyErr_SetString(PyExc_AttributeError, buf); @@ -168,6 +172,12 @@ void PyObSpit(char *name, PyObject *var) { PyObject_Print(var, stderr, 0); fprintf(stderr, " ref:%d ", var->ob_refcnt); fprintf(stderr, " ptr:%ld", (long)var); + + fprintf(stderr, " type:"); + if(Py_TYPE(var)) + fprintf(stderr, "%s", Py_TYPE(var)->tp_name); + else + fprintf(stderr, "<NIL>"); } fprintf(stderr, "\n"); } @@ -329,6 +339,72 @@ int BPY_class_validate(const char *class_type, PyObject *class, PyObject *base_c return 0; } + + +/* returns the exception string as a new PyUnicode object, depends on external StringIO module */ +PyObject *BPY_exception_buffer(void) +{ + PyObject *stdout_backup = PySys_GetObject("stdout"); /* borrowed */ + PyObject *stderr_backup = PySys_GetObject("stderr"); /* borrowed */ + PyObject *string_io = NULL; + PyObject *string_io_buf = NULL; + PyObject *string_io_mod; + PyObject *string_io_getvalue; + + PyObject *error_type, *error_value, *error_traceback; + + if (!PyErr_Occurred()) + return NULL; + + PyErr_Fetch(&error_type, &error_value, &error_traceback); + + PyErr_Clear(); + + /* import StringIO / io + * string_io = StringIO.StringIO() + */ + +#if PY_VERSION_HEX < 0x03000000 + if(! (string_io_mod= PyImport_ImportModule("StringIO")) ) { +#else + if(! (string_io_mod= PyImport_ImportModule("io")) ) { +#endif + return NULL; + } else if (! (string_io = PyObject_CallMethod(string_io_mod, "StringIO", NULL))) { + Py_DECREF(string_io_mod); + return NULL; + } else if (! (string_io_getvalue= PyObject_GetAttrString(string_io, "getvalue"))) { + Py_DECREF(string_io_mod); + Py_DECREF(string_io); + return NULL; + } + + Py_INCREF(stdout_backup); // since these were borrowed we dont want them freed when replaced. + Py_INCREF(stderr_backup); + + PySys_SetObject("stdout", string_io); // both of these are free'd when restoring + PySys_SetObject("stderr", string_io); + + PyErr_Restore(error_type, error_value, error_traceback); + PyErr_Print(); /* print the error */ + PyErr_Clear(); + + string_io_buf = PyObject_CallObject(string_io_getvalue, NULL); + + PySys_SetObject("stdout", stdout_backup); + PySys_SetObject("stderr", stderr_backup); + + Py_DECREF(stdout_backup); /* now sys owns the ref again */ + Py_DECREF(stderr_backup); + + Py_DECREF(string_io_mod); + Py_DECREF(string_io_getvalue); + Py_DECREF(string_io); /* free the original reference */ + + PyErr_Clear(); + return string_io_buf; +} + char *BPy_enum_as_string(EnumPropertyItem *item) { DynStr *dynstr= BLI_dynstr_new(); @@ -358,3 +434,33 @@ int BPy_reports_to_error(ReportList *reports) return (report_str != NULL); } + +int BPy_errors_to_report(ReportList *reports) +{ + PyObject *pystring; + char *cstring; + + if (!PyErr_Occurred()) + return 1; + + /* less hassle if we allow NULL */ + if(reports==NULL) { + PyErr_Print(); + PyErr_Clear(); + return 1; + } + + pystring= BPY_exception_buffer(); + + if(pystring==NULL) { + BKE_report(reports, RPT_ERROR, "unknown py-exception, could not convert"); + return 0; + } + + cstring= _PyUnicode_AsString(pystring); + + BKE_report(reports, RPT_ERROR, cstring); + fprintf(stderr, "%s\n", cstring); // not exactly needed. just for testing + Py_DECREF(pystring); + return 1; +} diff --git a/source/blender/python/intern/bpy_util.h b/source/blender/python/intern/bpy_util.h index 49f48802249..6429af67eb0 100644 --- a/source/blender/python/intern/bpy_util.h +++ b/source/blender/python/intern/bpy_util.h @@ -47,6 +47,8 @@ void PyObSpit(char *name, PyObject *var); void PyLineSpit(void); void BPY_getFileAndNum(char **filename, int *lineno); +PyObject *BPY_exception_buffer(void); + /* own python like utility function */ PyObject *PyObject_GetAttrStringArgs(PyObject *o, Py_ssize_t n, ...); @@ -73,6 +75,7 @@ char *BPy_enum_as_string(struct EnumPropertyItem *item); /* error reporting */ int BPy_reports_to_error(struct ReportList *reports); +int BPy_errors_to_report(struct ReportList *reports); /* TODO - find a better solution! */ struct bContext *BPy_GetContext(void); diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 199ff5dbb43..98e5819c0d3 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -1857,8 +1857,6 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem strand->totvert++; } else{ - sd.first = 0; - sd.time = time; sd.size = hasize; if(k==1){ @@ -1866,8 +1864,13 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem sd.time = 0.0f; VECSUB(loc0,loc1,loc); VECADD(loc0,loc1,loc0); + + render_new_particle(re, obr, psmd->dm, ma, &sd, loc1, loc0, seed); } + sd.first = 0; + sd.time = time; + if(k) render_new_particle(re, obr, psmd->dm, ma, &sd, loc, loc1, seed); @@ -2558,7 +2561,7 @@ static void init_render_surf(Render *re, ObjectRen *obr) if(need_orco) orcobase= orco= get_object_orco(re, ob); displist.first= displist.last= 0; - makeDispListSurf(re->scene, ob, &displist, 1); + makeDispListSurf(re->scene, ob, &displist, 1, 0); dl= displist.first; /* walk along displaylist and create rendervertices/-faces */ diff --git a/source/blender/render/intern/source/texture.c b/source/blender/render/intern/source/texture.c index 16f876fdd38..d9fc075c1c4 100644 --- a/source/blender/render/intern/source/texture.c +++ b/source/blender/render/intern/source/texture.c @@ -2418,13 +2418,13 @@ void do_lamp_tex(LampRen *la, float *lavec, ShadeInput *shi, float *colf, int ef /* placement */ - if(mtex->projx) texvec[0]= mtex->size[0]*(co[mtex->projx-1]+mtex->ofs[0]); + if(mtex->projx && co) texvec[0]= mtex->size[0]*(co[mtex->projx-1]+mtex->ofs[0]); else texvec[0]= mtex->size[0]*(mtex->ofs[0]); - if(mtex->projy) texvec[1]= mtex->size[1]*(co[mtex->projy-1]+mtex->ofs[1]); + if(mtex->projy && co) texvec[1]= mtex->size[1]*(co[mtex->projy-1]+mtex->ofs[1]); else texvec[1]= mtex->size[1]*(mtex->ofs[1]); - if(mtex->projz) texvec[2]= mtex->size[2]*(co[mtex->projz-1]+mtex->ofs[2]); + if(mtex->projz && co) texvec[2]= mtex->size[2]*(co[mtex->projz-1]+mtex->ofs[2]); else texvec[2]= mtex->size[2]*(mtex->ofs[2]); if(shi->osatex) { diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c index 627aebbe875..9b64ad6d38c 100644 --- a/source/blender/windowmanager/intern/wm_cursors.c +++ b/source/blender/windowmanager/intern/wm_cursors.c @@ -316,7 +316,7 @@ BEGIN_CURSOR_BLOCK static char ew_smsk[]={ 0x00, 0x00, 0x00, 0x00, 0x10, 0x08, 0x38, 0x1c, - 0x3c, 0x3c, 0xfe, 0x7f, 0xff, 0xff, 0x3f, 0xfc, + 0x3c, 0x3c, 0xfe, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0x3c, 0x3c, 0x38, 0x1c, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; @@ -943,17 +943,17 @@ END_CURSOR_BLOCK /********************** Swap Area Cursor ***********************/ BEGIN_CURSOR_BLOCK static char swap_sbm[]={ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xff, 0x07, 0xff, 0x07, - 0xff, 0x07, 0xff, 0x07, 0xff, 0x07, 0xff, 0x07, - 0xff, 0x07, 0xff, 0x07, 0xff, 0x07, 0xff, 0x07, + 0xc0, 0xff, 0x40, 0x80, 0x40, 0x80, 0x40, 0x9c, + 0x40, 0x98, 0x40, 0x94, 0x00, 0x82, 0xfe, 0x80, + 0x7e, 0xfd, 0xbe, 0x01, 0xda, 0x01, 0xe2, 0x01, + 0xe2, 0x01, 0xc2, 0x01, 0xfe, 0x01, 0x00, 0x00, }; static char swap_smsk[]={ - 0xc0, 0xff, 0xc0, 0xff, 0xc0, 0xff, 0xc0, 0xff, - 0xc0, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xff, 0x07, - 0xff, 0x07, 0xff, 0x07, 0xff, 0x07, 0xff, 0x07, + 0xc0, 0xff, 0xc0, 0xff, 0xc0, 0xff, 0xc0, 0xff, + 0xc0, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0x03, 0xff, 0x03, 0xff, 0x03, + 0xff, 0x03, 0xff, 0x03, 0xff, 0x03, 0xff, 0x03, }; static BCursor SwapCursor = { diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index f5c8e535002..ea6a65859e5 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -76,7 +76,7 @@ void wm_event_add(wmWindow *win, wmEvent *event_to_add) BLI_addtail(&win->queue, event); } -static void wm_event_free(wmEvent *event) +void wm_event_free(wmEvent *event) { if(event->customdata && event->customdatafree) MEM_freeN(event->customdata); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 3b6d605df61..46e9df10adc 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1399,10 +1399,10 @@ void WM_radial_control_string(wmOperator *op, char str[], int maxlen) void WM_OT_radial_control_partial(wmOperatorType *ot) { static EnumPropertyItem prop_mode_items[] = { - {WM_RADIALCONTROL_SIZE, "SIZE", "Size", ""}, - {WM_RADIALCONTROL_STRENGTH, "STRENGTH", "Strength", ""}, - {WM_RADIALCONTROL_ANGLE, "ANGLE", "Angle", ""}, - {0, NULL, NULL, NULL}}; + {WM_RADIALCONTROL_SIZE, "SIZE", 0, "Size", ""}, + {WM_RADIALCONTROL_STRENGTH, "STRENGTH", 0, "Strength", ""}, + {WM_RADIALCONTROL_ANGLE, "ANGLE", 0, "Angle", ""}, + {0, NULL, 0, NULL, NULL}}; /* Should be set in custom invoke() */ RNA_def_float(ot->srna, "initial_value", 0, 0, FLT_MAX, "Initial Value", "", 0, FLT_MAX); @@ -1484,12 +1484,12 @@ static int ten_timer_exec(bContext *C, wmOperator *op) static void WM_OT_ten_timer(wmOperatorType *ot) { static EnumPropertyItem prop_type_items[] = { - {0, "DRAW", "Draw Region", ""}, - {1, "DRAWSWAP", "Draw Region + Swap", ""}, - {2, "DRAWWINSWAP", "Draw Window + Swap", ""}, - {3, "ANIMSTEP", "Anim Step", ""}, - {4, "UNDO", "Undo/Redo", ""}, - {0, NULL, NULL, NULL}}; + {0, "DRAW", 0, "Draw Region", ""}, + {1, "DRAWSWAP", 0, "Draw Region + Swap", ""}, + {2, "DRAWWINSWAP", 0, "Draw Window + Swap", ""}, + {3, "ANIMSTEP", 0, "Anim Step", ""}, + {4, "UNDO", 0, "Undo/Redo", ""}, + {0, NULL, 0, NULL, NULL}}; ot->name= "Ten Timer"; ot->idname= "WM_OT_ten_timer"; diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index cb6bcb41366..2d320458543 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -595,6 +595,12 @@ void wm_window_process_events(const bContext *C) PIL_sleep_ms(5); } +void wm_window_process_events_nosleep(const bContext *C) +{ + if(GHOST_ProcessEvents(g_system, 0)) + GHOST_DispatchEvents(g_system); +} + /* exported as handle callback to bke blender.c */ void wm_window_testbreak(void) { diff --git a/source/blender/windowmanager/wm_event_system.h b/source/blender/windowmanager/wm_event_system.h index 99853c77a55..9a3bba9af1d 100644 --- a/source/blender/windowmanager/wm_event_system.h +++ b/source/blender/windowmanager/wm_event_system.h @@ -82,6 +82,8 @@ enum { /* wm_event_system.c */ void wm_event_add (wmWindow *win, wmEvent *event_to_add); void wm_event_free_all (wmWindow *win); +void wm_event_free (wmEvent *event); + /* goes over entire hierarchy: events -> window -> screen -> area -> region */ void wm_event_do_handlers (bContext *C); diff --git a/source/blender/windowmanager/wm_window.h b/source/blender/windowmanager/wm_window.h index 7bf08617fb6..45fa9bf6cf7 100644 --- a/source/blender/windowmanager/wm_window.h +++ b/source/blender/windowmanager/wm_window.h @@ -40,6 +40,7 @@ void wm_window_free (bContext *C, wmWindow *win); void wm_window_title (wmWindowManager *wm, wmWindow *win); void wm_window_add_ghostwindows (wmWindowManager *wm); void wm_window_process_events (const bContext *C); +void wm_window_process_events_nosleep(const bContext *C); void wm_window_make_drawable(bContext *C, wmWindow *win); diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 221c0a92e09..4701eba810f 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -221,6 +221,7 @@ IF(UNIX) blender_radiosity blender_ONL bf_python + bf_gen_python bf_blenkernel bf_nodes bf_gpu @@ -269,6 +270,7 @@ IF(UNIX) extern_qhull bf_moto bf_python + bf_gen_python bf_quicktime extern_binreloc extern_glew diff --git a/source/creator/creator.c b/source/creator/creator.c index 5ffce91ec2d..9bf09a46461 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -77,6 +77,8 @@ #include "WM_api.h" +#include "RNA_define.h" + #include "GPU_draw.h" #include "GPU_extensions.h" @@ -310,11 +312,13 @@ int main(int argc, char **argv) BLI_where_am_i(bprogname, argv[0]); + RNA_init(); + /* Hack - force inclusion of the plugin api functions, * see blenpluginapi:pluginapi.c */ pluginapi_force_ref(); - + init_nodesystem(); initglobals(); /* blender.c */ @@ -710,7 +714,7 @@ int main(int argc, char **argv) //XXX // FOR TESTING ONLY a++; - BPY_run_python_script(C, argv[a], NULL); + BPY_run_python_script(C, argv[a], NULL, NULL); // use reports? #if 0 a++; if (a < argc) { @@ -719,7 +723,7 @@ int main(int argc, char **argv) main_init_screen(); scr_init = 1; } - BPY_run_python_script(C, argv[a], NULL); + BPY_run_python_script(C, argv[a], NULL, NULL); // use reports? } else printf("\nError: you must specify a Python script after '-P '.\n"); #endif @@ -868,7 +872,7 @@ static void error_cb(char *err) static void mem_error_cb(char *errorStr) { - fprintf(stderr, "%s", errorStr); + fputs(errorStr, stderr); fflush(stderr); } diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 4ac28e36c48..44678cb73eb 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -66,16 +66,18 @@ #include "SYS_System.h" /***/ - #include "DNA_view3d_types.h" #include "DNA_screen_types.h" +#include "DNA_windowmanager_types.h" #include "BKE_global.h" #include "BKE_report.h" + #include "BKE_utildefines.h" //XXX #include "BIF_screen.h" //XXX #include "BIF_scrarea.h" -#include "BKE_main.h" +#include "BKE_main.h" +//#include "BKE_context.h" #include "BLI_blenlib.h" #include "BLO_readfile.h" #include "DNA_scene_types.h" @@ -84,15 +86,20 @@ #include "GPU_extensions.h" #include "Value.h" + + #ifdef __cplusplus extern "C" { #endif //XXX #include "BSE_headerbuttons.h" -void update_for_newframe(); +#include "../../blender/windowmanager/WM_types.h" +#include "../../blender/windowmanager/wm_window.h" +#include "../../blender/windowmanager/wm_event_system.h" #ifdef __cplusplus } #endif + static BlendFileData *load_game_data(char *filename) { ReportList reports; @@ -111,18 +118,28 @@ static BlendFileData *load_game_data(char *filename) return bfd; } -extern "C" void StartKetsjiShell(struct ScrArea *area, - struct ARegion *ar, - char* scenename, - struct Main* maggie1, - struct SpaceIpo *sipo, - int always_use_expand_framing) + +/* screw it, BKE_context.h is complaining! */ +extern "C" struct wmWindow *CTX_wm_window(const bContext *C); +extern "C" struct ScrArea *CTX_wm_area(const bContext *C); +extern "C" struct ARegion *CTX_wm_region(const bContext *C); +extern "C" struct Scene *CTX_data_scene(const bContext *C); +extern "C" struct Main *CTX_data_main(const bContext *C); + +extern "C" void StartKetsjiShell(struct bContext *C, int always_use_expand_framing) { + /* context values */ + struct wmWindow *win= CTX_wm_window(C); + struct ScrArea *area= CTX_wm_area(C); // curarea + struct ARegion *ar= CTX_wm_region(C); + struct Scene *scene= CTX_data_scene(C); + struct Main* maggie1= CTX_data_main(C); + + int exitrequested = KX_EXIT_REQUEST_NO_REQUEST; - Scene *scene= NULL; // XXX give as arg Main* blenderdata = maggie1; - char* startscenename = scenename; + char* startscenename = scene->id.name+2; char pathname[FILE_MAXDIR+FILE_MAXFILE], oldsce[FILE_MAXDIR+FILE_MAXFILE]; STR_String exitstring = ""; BlendFileData *bfd= NULL; @@ -156,7 +173,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, bool nodepwarnings = (SYS_GetCommandLineInt(syshandle, "ignore_deprecation_warnings", 0) != 0); bool novertexarrays = (SYS_GetCommandLineInt(syshandle, "novertexarrays", 0) != 0); // create the canvas, rasterizer and rendertools - RAS_ICanvas* canvas = new KX_BlenderCanvas(area); + RAS_ICanvas* canvas = new KX_BlenderCanvas(win, ar); canvas->SetMouseState(RAS_ICanvas::MOUSE_INVISIBLE); RAS_IRenderTools* rendertools = new KX_BlenderRenderTools(); RAS_IRasterizer* rasterizer = NULL; @@ -236,7 +253,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, } for (i = 0; i < 16; i++) { - float *projmat_linear; //XXX = (float*) area->winmat; + float *projmat_linear= (float*) rv3d->winmat; projmat.setElem(i, projmat_linear[i]); } @@ -338,10 +355,11 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, ketsjiengine->SetCameraOverrideProjectionMatrix(projmat); ketsjiengine->SetCameraOverrideViewMatrix(viewmat); ketsjiengine->SetCameraOverrideClipping(v3d->near, v3d->far); + ketsjiengine->SetCameraOverrideLens(v3d->lens); } // create a scene converter, create and convert the startingscene - KX_ISceneConverter* sceneconverter = new KX_BlenderSceneConverter(blenderdata,sipo, ketsjiengine); + KX_ISceneConverter* sceneconverter = new KX_BlenderSceneConverter(blenderdata, ketsjiengine); ketsjiengine->SetSceneConverter(sceneconverter); sceneconverter->addInitFromFrame=false; if (always_use_expand_framing) @@ -423,7 +441,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, exitrequested = ketsjiengine->GetExitCode(); // kick the engine - bool render = ketsjiengine->NextFrame(); + bool render = ketsjiengine->NextFrame(); // XXX 2.5 Bug, This is never true! FIXME- Campbell if (render) { @@ -431,26 +449,37 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, ketsjiengine->Render(); } + wm_window_process_events_nosleep(C); + // test for the ESC key - while (0) //XXX while (qtest()) + //XXX while (qtest()) + while(wmEvent *event= (wmEvent *)win->queue.first) { - short val; - unsigned short event = 0; //XXX extern_qread(&val); + short val = 0; + //unsigned short event = 0; //XXX extern_qread(&val); - if (keyboarddevice->ConvertBlenderEvent(event,val)) + if (keyboarddevice->ConvertBlenderEvent(event->type,event->val)) exitrequested = KX_EXIT_REQUEST_BLENDER_ESC; /* Coordinate conversion... where * should this really be? */ - if (event==MOUSEX) { - val = 0;//XXX val - scrarea_get_win_x(area); - } else if (event==MOUSEY) { - val = 0;//XXX scrarea_get_win_height(area) - (val - scrarea_get_win_y(area)) - 1; + if (event->type==MOUSEMOVE) { + /* Note nice! XXX 2.5 event hack */ + val = event->x - ar->winrct.xmin; + mousedevice->ConvertBlenderEvent(MOUSEX, val); + + val = ar->winy - (event->y - ar->winrct.ymin) - 1; + mousedevice->ConvertBlenderEvent(MOUSEY, val); + } + else { + mousedevice->ConvertBlenderEvent(event->type,event->val); } - mousedevice->ConvertBlenderEvent(event,val); + BLI_remlink(&win->queue, event); + wm_event_free(event); } + } printf("\nBlender Game Engine Finished\n\n"); exitstring = ketsjiengine->GetExitString(); @@ -557,11 +586,11 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, PyGILState_Release(gilstate); } -extern "C" void StartKetsjiShellSimulation(struct ScrArea *area, +extern "C" void StartKetsjiShellSimulation(struct wmWindow *win, + struct ScrArea *area, struct ARegion *ar, char* scenename, struct Main* maggie, - struct SpaceIpo *sipo, int always_use_expand_framing) { int exitrequested = KX_EXIT_REQUEST_NO_REQUEST; @@ -596,7 +625,7 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area, bool usemat = false; // create the canvas, rasterizer and rendertools - RAS_ICanvas* canvas = new KX_BlenderCanvas(area); + RAS_ICanvas* canvas = new KX_BlenderCanvas(win, ar); //canvas->SetMouseState(RAS_ICanvas::MOUSE_INVISIBLE); RAS_IRenderTools* rendertools = new KX_BlenderRenderTools(); RAS_IRasterizer* rasterizer = NULL; @@ -649,7 +678,7 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area, cframe=blscene->r.cfra; startFrame = blscene->r.sfra; blscene->r.cfra=startFrame; - update_for_newframe(); + // update_for_newframe(); // XXX scene_update_for_newframe wont cut it! ketsjiengine->SetGame2IpoMode(game2ipo,startFrame); } @@ -660,7 +689,7 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area, if (exitrequested != KX_EXIT_REQUEST_QUIT_GAME) { // create a scene converter, create and convert the startingscene - KX_ISceneConverter* sceneconverter = new KX_BlenderSceneConverter(maggie,sipo, ketsjiengine); + KX_ISceneConverter* sceneconverter = new KX_BlenderSceneConverter(maggie, ketsjiengine); ketsjiengine->SetSceneConverter(sceneconverter); sceneconverter->addInitFromFrame=true; @@ -723,7 +752,7 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area, // kick the engine ketsjiengine->NextFrame(); blscene->r.cfra=blscene->r.cfra+1; - update_for_newframe(); + // update_for_newframe(); // XXX scene_update_for_newframe wont cut it } exitstring = ketsjiengine->GetExitString(); diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp index 750a1ef3f93..aa83d17a03a 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp @@ -26,15 +26,16 @@ * ***** END GPL LICENSE BLOCK ***** */ -//XXX #include "BIF_scrarea.h" #include "KX_BlenderCanvas.h" +#include "DNA_screen_types.h" #ifdef HAVE_CONFIG_H #include <config.h> #endif -KX_BlenderCanvas::KX_BlenderCanvas(struct ScrArea *area) : -m_area(area) +KX_BlenderCanvas::KX_BlenderCanvas(struct wmWindow *win, ARegion *ar) : +m_win(win), +m_ar(ar) { } @@ -50,7 +51,7 @@ void KX_BlenderCanvas::Init() void KX_BlenderCanvas::SwapBuffers() { - BL_SwapBuffers(); + BL_SwapBuffers(m_win); } void KX_BlenderCanvas::BeginFrame() @@ -93,12 +94,12 @@ void KX_BlenderCanvas::ClearBuffer(int type) int KX_BlenderCanvas::GetWidth( ) const { - return 0; //XXX scrarea_get_win_width(m_area); + return m_ar->winx; } int KX_BlenderCanvas::GetHeight( ) const { - return 0; //XXX scrarea_get_win_height(m_area); + return m_ar->winy; } RAS_Rect & @@ -116,8 +117,8 @@ SetViewPort( ){ int vp_width = (x2 - x1) + 1; int vp_height = (y2 - y1) + 1; - int minx = 0;//XXX scrarea_get_win_x(m_area); - int miny = 0;//XXX scrarea_get_win_y(m_area); + int minx = m_ar->winrct.xmin; + int miny = m_ar->winrct.ymin; m_area_rect.SetLeft(minx + x1); m_area_rect.SetBottom(miny + y1); @@ -159,9 +160,9 @@ void KX_BlenderCanvas::SetMouseState(RAS_MouseState mousestate) // (0,0) is top left, (width,height) is bottom right void KX_BlenderCanvas::SetMousePosition(int x,int y) { - int winX = 0;//XXX scrarea_get_win_x(m_area); - int winY = 0;//XXX scrarea_get_win_y(m_area); - int winH = 0;//XXX scrarea_get_win_height(m_area); + int winX = m_ar->winrct.xmin; + int winY = m_ar->winrct.ymin; + int winH = m_ar->winy; BL_warp_pointer(winX + x, winY + (winH-y-1)); } @@ -170,5 +171,5 @@ void KX_BlenderCanvas::SetMousePosition(int x,int y) void KX_BlenderCanvas::MakeScreenShot(const char* filename) { - BL_MakeScreenShot(m_area, filename); + BL_MakeScreenShot(m_ar, filename); } diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h index bc202a8558c..fd41fb90f2f 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h @@ -40,7 +40,8 @@ #include "KX_BlenderGL.h" -struct ScrArea; +struct ARegion; +struct wmWindow; /** * 2D Blender device context abstraction. @@ -57,9 +58,9 @@ private: public: /* Construct a new canvas. * - * @param area The Blender ScrArea to run the game within. + * @param area The Blender ARegion to run the game within. */ - KX_BlenderCanvas(struct ScrArea* area); + KX_BlenderCanvas(struct wmWindow* win, struct ARegion* ar); ~KX_BlenderCanvas(); void @@ -162,7 +163,8 @@ public: private: /** Blender area the game engine is running within */ - struct ScrArea* m_area; + struct ARegion* m_ar; + struct wmWindow* m_win; RAS_Rect m_area_rect; }; diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp index de7a7f54fde..5cf696fe146 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp @@ -27,7 +27,14 @@ */ #include "KX_BlenderGL.h" + +#ifdef __cplusplus +extern "C" { +#endif #include "BLF_api.h" +#ifdef __cplusplus +} +#endif #ifdef HAVE_CONFIG_H #include <config.h> @@ -58,6 +65,7 @@ #include "DNA_image_types.h" #include "DNA_view3d_types.h" #include "DNA_material_types.h" +#include "DNA_windowmanager_types.h" #include "BKE_global.h" #include "BKE_bmfont.h" @@ -68,7 +76,7 @@ extern "C" { //XXX #include "BIF_mywindow.h" //XXX #include "BIF_toolbox.h" //XXX #include "BIF_graphics.h" /* For CURSOR_NONE CURSOR_WAIT CURSOR_STD */ - +void wm_window_swap_buffers(wmWindow *win); // wm_window.h } /* end of blender block */ @@ -86,8 +94,10 @@ void BL_warp_pointer(int x,int y) //XXX warp_pointer(x,y); } -void BL_SwapBuffers() +void BL_SwapBuffers(wmWindow *win) { + //wmWindow *window= CTX_wm_window(C); + wm_window_swap_buffers(win); //XXX myswapbuffers(); } @@ -214,7 +224,7 @@ void BL_NormalMouse() #define MAX_FILE_LENGTH 512 -void BL_MakeScreenShot(struct ScrArea *area, const char* filename) +void BL_MakeScreenShot(struct ARegion *ar, const char* filename) { char copyfilename[MAX_FILE_LENGTH]; strcpy(copyfilename,filename); diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.h b/source/gameengine/BlenderRoutines/KX_BlenderGL.h index b891a7343c2..1e65f29d87c 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderGL.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderGL.h @@ -33,14 +33,15 @@ extern "C" { #endif //__cplusplus -struct ScrArea; +struct wmWindow; +struct ARegion; // special swapbuffers, that takes care of which area (viewport) needs to be swapped -void BL_SwapBuffers(); +void BL_SwapBuffers(struct wmWindow *win); void BL_warp_pointer(int x,int y); -void BL_MakeScreenShot(struct ScrArea *area, const char* filename); +void BL_MakeScreenShot(struct ARegion *ar, const char* filename); void BL_HideMouse(); void BL_NormalMouse(); diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp index 17d1bf65ca4..ffff7185fe4 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp @@ -28,8 +28,6 @@ #include "GL/glew.h" -#include "DNA_scene_types.h" - #include "RAS_IRenderTools.h" #include "RAS_IRasterizer.h" #include "RAS_LightObject.h" @@ -41,6 +39,7 @@ #include "KX_BlenderMaterial.h" #include "KX_RayCast.h" #include "KX_IPhysicsController.h" +#include "KX_Light.h" #include "PHY_IPhysicsEnvironment.h" @@ -330,21 +329,12 @@ int KX_BlenderRenderTools::applyLights(int objectlayer, const MT_Transform& view { // taken from blender source, incompatibility between Blender Object / GameObject KX_Scene* kxscene = (KX_Scene*)m_auxilaryClientInfo; - int scenelayer = ~0; float glviewmat[16]; unsigned int count; - float vec[4]; - - vec[3]= 1.0; + std::vector<struct RAS_LightObject*>::iterator lit = m_lights.begin(); - if(kxscene && kxscene->GetBlenderScene()) - scenelayer = kxscene->GetBlenderScene()->lay; - for(count=0; count<m_numgllights; count++) glDisable((GLenum)(GL_LIGHT0+count)); - - //std::vector<struct RAS_LightObject*> m_lights; - std::vector<struct RAS_LightObject*>::iterator lit = m_lights.begin(); viewmat.getValue(glviewmat); @@ -353,82 +343,14 @@ int KX_BlenderRenderTools::applyLights(int objectlayer, const MT_Transform& view for (lit = m_lights.begin(), count = 0; !(lit==m_lights.end()) && count < m_numgllights; ++lit) { RAS_LightObject* lightdata = (*lit); - KX_Scene* lightscene = (KX_Scene*)lightdata->m_scene; - - /* only use lights in the same layer as the object */ - if(!(lightdata->m_layer & objectlayer)) - continue; - /* only use lights in the same scene, and in a visible layer */ - if(kxscene != lightscene || !(lightdata->m_layer & scenelayer)) - continue; - - vec[0] = (*(lightdata->m_worldmatrix))(0,3); - vec[1] = (*(lightdata->m_worldmatrix))(1,3); - vec[2] = (*(lightdata->m_worldmatrix))(2,3); - vec[3] = 1; - - if(lightdata->m_type==RAS_LightObject::LIGHT_SUN) { - - vec[0] = (*(lightdata->m_worldmatrix))(0,2); - vec[1] = (*(lightdata->m_worldmatrix))(1,2); - vec[2] = (*(lightdata->m_worldmatrix))(2,2); - //vec[0]= base->object->obmat[2][0]; - //vec[1]= base->object->obmat[2][1]; - //vec[2]= base->object->obmat[2][2]; - vec[3]= 0.0; - glLightfv((GLenum)(GL_LIGHT0+count), GL_POSITION, vec); - } - else { - //vec[3]= 1.0; - glLightfv((GLenum)(GL_LIGHT0+count), GL_POSITION, vec); - glLightf((GLenum)(GL_LIGHT0+count), GL_CONSTANT_ATTENUATION, 1.0); - glLightf((GLenum)(GL_LIGHT0+count), GL_LINEAR_ATTENUATION, lightdata->m_att1/lightdata->m_distance); - // without this next line it looks backward compatible. - //attennuation still is acceptable - glLightf((GLenum)(GL_LIGHT0+count), GL_QUADRATIC_ATTENUATION, lightdata->m_att2/(lightdata->m_distance*lightdata->m_distance)); - - if(lightdata->m_type==RAS_LightObject::LIGHT_SPOT) { - vec[0] = -(*(lightdata->m_worldmatrix))(0,2); - vec[1] = -(*(lightdata->m_worldmatrix))(1,2); - vec[2] = -(*(lightdata->m_worldmatrix))(2,2); - //vec[0]= -base->object->obmat[2][0]; - //vec[1]= -base->object->obmat[2][1]; - //vec[2]= -base->object->obmat[2][2]; - glLightfv((GLenum)(GL_LIGHT0+count), GL_SPOT_DIRECTION, vec); - glLightf((GLenum)(GL_LIGHT0+count), GL_SPOT_CUTOFF, lightdata->m_spotsize/2.0); - glLightf((GLenum)(GL_LIGHT0+count), GL_SPOT_EXPONENT, 128.0*lightdata->m_spotblend); - } - else glLightf((GLenum)(GL_LIGHT0+count), GL_SPOT_CUTOFF, 180.0); - } - - if (lightdata->m_nodiffuse) - { - vec[0] = vec[1] = vec[2] = vec[3] = 0.0; - } else { - vec[0]= lightdata->m_energy*lightdata->m_red; - vec[1]= lightdata->m_energy*lightdata->m_green; - vec[2]= lightdata->m_energy*lightdata->m_blue; - vec[3]= 1.0; - } - glLightfv((GLenum)(GL_LIGHT0+count), GL_DIFFUSE, vec); - if (lightdata->m_nospecular) - { - vec[0] = vec[1] = vec[2] = vec[3] = 0.0; - } else if (lightdata->m_nodiffuse) { - vec[0]= lightdata->m_energy*lightdata->m_red; - vec[1]= lightdata->m_energy*lightdata->m_green; - vec[2]= lightdata->m_energy*lightdata->m_blue; - vec[3]= 1.0; - } - glLightfv((GLenum)(GL_LIGHT0+count), GL_SPECULAR, vec); - glEnable((GLenum)(GL_LIGHT0+count)); + KX_LightObject *kxlight = (KX_LightObject*)lightdata->m_light; - count++; + if(kxlight->ApplyLight(kxscene, objectlayer, count)) + count++; } glPopMatrix(); return count; - } void KX_BlenderRenderTools::MotionBlur(RAS_IRasterizer* rasterizer) diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index e4dd588f06a..c0d28d28bda 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -51,11 +51,19 @@ #include "BKE_utildefines.h" #include "FloatValue.h" #include "PyObjectPlus.h" +#include "KX_PyMath.h" #ifdef HAVE_CONFIG_H #include <config.h> #endif +extern "C" { +#include "BKE_animsys.h" +#include "BKE_action.h" +#include "RNA_access.h" +#include "RNA_define.h" +} + BL_ActionActuator::~BL_ActionActuator() { if (m_pose) @@ -359,15 +367,35 @@ bool BL_ActionActuator::Update(double curtime, bool frame) /* Get the underlying pose from the armature */ obj->GetPose(&m_pose); - + +// 2.4x function, /* Override the necessary channels with ones from the action */ // XXX extract_pose_from_action(m_pose, m_action, m_localtime); + + +// 2.5x - replacement for extract_pose_from_action(...) above. + { + struct PointerRNA id_ptr; + Object *arm= obj->GetArmatureObject(); + bPose *pose_back= arm->pose; + + arm->pose= m_pose; + RNA_id_pointer_create((ID *)arm, &id_ptr); + animsys_evaluate_action(&id_ptr, m_action, NULL, m_localtime); + + arm->pose= pose_back; + +// 2.5x - could also do this but looks too high level, constraints use this, it works ok. +// Object workob; /* evaluate using workob */ +// what_does_obaction((Scene *)obj->GetScene(), obj->GetArmatureObject(), &workob, m_pose, m_action, NULL, m_localtime); + } + // done getting the pose from the action + /* Perform the user override (if any) */ if (m_userpose){ extract_pose_from_pose(m_pose, m_userpose); -// clear_pose(m_userpose); - MEM_freeN(m_userpose); + game_free_pose(m_userpose); //cant use MEM_freeN(m_userpose) because the channels need freeing too. m_userpose = NULL; } #if 1 @@ -381,7 +409,7 @@ bool BL_ActionActuator::Update(double curtime, bool frame) /* Find percentages */ newweight = (m_blendframe/(float)m_blendin); - // XXX blend_poses(m_pose, m_blendpose, 1.0 - newweight, ACTSTRIPMODE_BLEND); + game_blend_poses(m_pose, m_blendpose, 1.0 - newweight); /* Increment current blending percentage */ m_blendframe = (curtime - m_blendstart)*KX_KetsjiEngine::GetAnimFrameRate(); @@ -767,22 +795,55 @@ PyObject* BL_ActionActuator::PySetFrameProperty(PyObject* args, Py_RETURN_NONE; } -/* -PyObject* BL_ActionActuator::PyGetChannel(PyObject* args, - PyObject* kwds) { - char *string; +PyObject* BL_ActionActuator::PyGetChannel(PyObject* value) { + char *string= PyString_AsString(value); - if (PyArg_ParseTuple(args,"s:getChannel",&string)) - { - m_propname = string; + if (!string) { + PyErr_SetString(PyExc_TypeError, "expected a single string"); + return NULL; } - else { + + bPoseChannel *pchan; + + + // get_pose_channel accounts for NULL pose, run on both incase one exists but + // the channel doesnt + if( !(pchan=get_pose_channel(m_userpose, string)) && + !(pchan=get_pose_channel(m_pose, string)) ) + { + PyErr_SetString(PyExc_ValueError, "channel doesnt exist"); return NULL; } + + PyObject *ret = PyTuple_New(3); - Py_RETURN_NONE; -} + PyObject *list = PyList_New(3); + PyList_SET_ITEM(list, 0, PyFloat_FromDouble(pchan->loc[0])); + PyList_SET_ITEM(list, 1, PyFloat_FromDouble(pchan->loc[1])); + PyList_SET_ITEM(list, 2, PyFloat_FromDouble(pchan->loc[2])); + PyTuple_SET_ITEM(ret, 0, list); + + list = PyList_New(3); + PyList_SET_ITEM(list, 0, PyFloat_FromDouble(pchan->size[0])); + PyList_SET_ITEM(list, 1, PyFloat_FromDouble(pchan->size[1])); + PyList_SET_ITEM(list, 2, PyFloat_FromDouble(pchan->size[2])); + PyTuple_SET_ITEM(ret, 1, list); + + list = PyList_New(4); + PyList_SET_ITEM(list, 0, PyFloat_FromDouble(pchan->quat[0])); + PyList_SET_ITEM(list, 1, PyFloat_FromDouble(pchan->quat[1])); + PyList_SET_ITEM(list, 2, PyFloat_FromDouble(pchan->quat[2])); + PyList_SET_ITEM(list, 3, PyFloat_FromDouble(pchan->quat[3])); + PyTuple_SET_ITEM(ret, 2, list); + + return ret; +/* + return Py_BuildValue("([fff][fff][ffff])", + pchan->loc[0], pchan->loc[1], pchan->loc[2], + pchan->size[0], pchan->size[1], pchan->size[2], + pchan->quat[0], pchan->quat[1], pchan->quat[2], pchan->quat[3] ); */ +} /* getType */ const char BL_ActionActuator::GetType_doc[] = @@ -857,76 +918,69 @@ KX_PYMETHODDEF_DOC(BL_ActionActuator, setChannel, "\t - matrix : A 4x4 matrix specifying the overriding transformation\n" "\t as an offset from the bone's rest position.\n") { - float matrix[4][4]; + BL_ArmatureObject *obj = (BL_ArmatureObject*)GetParent(); char *string; - PyObject* pylist; - bool error = false; - int row,col; - int mode = 0; /* 0 for bone space, 1 for armature/world space */ + PyObject *pymat= NULL; + PyObject *pyloc= NULL, *pysize= NULL, *pyquat= NULL; + bPoseChannel *pchan; - if (!PyArg_ParseTuple(args,"sO|i:setChannel", &string, &pylist, &mode)) - return NULL; - - if (pylist->ob_type == &CListValue::Type) - { - CListValue* listval = (CListValue*) pylist; - if (listval->GetCount() == 4) - { - for (row=0;row<4;row++) // each row has a 4-vector [x,y,z, w] - { - CListValue* vecval = (CListValue*)listval->GetValue(row); - for (col=0;col<4;col++) - { - matrix[row][col] = vecval->GetValue(col)->GetNumber(); - - } - } - } - else - { - error = true; - } + if(PyTuple_Size(args)==2) { + if (!PyArg_ParseTuple(args,"sO:setChannel", &string, &pymat)) // matrix + return NULL; } - else - { - // assert the list is long enough... - int numitems = PyList_Size(pylist); - if (numitems == 4) - { - for (row=0;row<4;row++) // each row has a 4-vector [x,y,z, w] - { - - PyObject* veclist = PyList_GetItem(pylist,row); // here we have a vector4 list - for (col=0;col<4;col++) - { - matrix[row][col] = PyFloat_AsDouble(PyList_GetItem(veclist,col)); - - } - } - } - else - { - error = true; - } + else if(PyTuple_Size(args)==4) { + if (!PyArg_ParseTuple(args,"sOOO:setChannel", &string, &pyloc, &pysize, &pyquat)) // loc/size/quat + return NULL; + } + else { + PyErr_SetString(PyExc_ValueError, "Expected a string and a 4x4 matrix (2 args) or a string and loc/size/quat sequences (4 args)"); + return NULL; } - if (!error) - { - -/* DO IT HERE */ - bPoseChannel *pchan= verify_pose_channel(m_userpose, string); - - Mat4ToQuat(matrix, pchan->quat); - Mat4ToSize(matrix, pchan->size); + if(pymat) { + float matrix[4][4]; + MT_Matrix4x4 mat; + + if(!PyMatTo(pymat, mat)) + return NULL; + + mat.setValue((const float *)matrix); + + BL_ArmatureObject *obj = (BL_ArmatureObject*)GetParent(); + obj->GetPose(&m_pose); /* Get the underlying pose from the armature */ + + if (!m_userpose) { + obj->GetPose(&m_pose); /* Get the underlying pose from the armature */ + game_copy_pose(&m_userpose, m_pose); + } + pchan= verify_pose_channel(m_userpose, string); // adds the channel if its not there. + VECCOPY (pchan->loc, matrix[3]); + Mat4ToSize(matrix, pchan->size); + Mat4ToQuat(matrix, pchan->quat); + } + else { + MT_Vector3 loc; + MT_Vector3 size; + MT_Vector4 quat; - pchan->flag |= POSE_ROT|POSE_LOC|POSE_SIZE; - - if (!m_userpose){ - m_userpose = (bPose*)MEM_callocN(sizeof(bPose), "userPose"); + if (!PyVecTo(pyloc, loc) || !PyVecTo(pysize, size) || !PyVecTo(pyquat, quat)) + return NULL; + + // same as above + if (!m_userpose) { + obj->GetPose(&m_pose); /* Get the underlying pose from the armature */ + game_copy_pose(&m_userpose, m_pose); } + pchan= verify_pose_channel(m_userpose, string); + + // for some reason loc.setValue(pchan->loc) fails + pchan->loc[0]= loc[0]; pchan->loc[1]= loc[1]; pchan->loc[2]= loc[2]; + pchan->size[0]= size[0]; pchan->size[1]= size[1]; pchan->size[2]= size[2]; + pchan->quat[0]= quat[0]; pchan->quat[1]= quat[1]; pchan->quat[2]= quat[2]; pchan->quat[3]= quat[3]; } + pchan->flag |= POSE_ROT|POSE_LOC|POSE_SIZE; Py_RETURN_NONE; } @@ -986,7 +1040,7 @@ PyMethodDef BL_ActionActuator::Methods[] = { {"getFrame", (PyCFunction) BL_ActionActuator::sPyGetFrame, METH_VARARGS, (PY_METHODCHAR)GetFrame_doc}, {"getProperty", (PyCFunction) BL_ActionActuator::sPyGetProperty, METH_VARARGS, (PY_METHODCHAR)GetProperty_doc}, {"getFrameProperty", (PyCFunction) BL_ActionActuator::sPyGetFrameProperty, METH_VARARGS, (PY_METHODCHAR)GetFrameProperty_doc}, -// {"getChannel", (PyCFunction) BL_ActionActuator::sPyGetChannel, METH_VARARGS}, + {"getChannel", (PyCFunction) BL_ActionActuator::sPyGetChannel, METH_O}, {"getType", (PyCFunction) BL_ActionActuator::sPyGetType, METH_VARARGS, (PY_METHODCHAR)GetType_doc}, {"setType", (PyCFunction) BL_ActionActuator::sPySetType, METH_VARARGS, (PY_METHODCHAR)SetType_doc}, {"getContinue", (PyCFunction) BL_ActionActuator::sPyGetContinue, METH_NOARGS, 0}, diff --git a/source/gameengine/Converter/BL_ActionActuator.h b/source/gameengine/Converter/BL_ActionActuator.h index b3c15c08f50..422b16bb3ec 100644 --- a/source/gameengine/Converter/BL_ActionActuator.h +++ b/source/gameengine/Converter/BL_ActionActuator.h @@ -104,7 +104,7 @@ public: KX_PYMETHOD_DOC(BL_ActionActuator,GetFrame); KX_PYMETHOD_DOC(BL_ActionActuator,GetProperty); KX_PYMETHOD_DOC(BL_ActionActuator,GetFrameProperty); -// KX_PYMETHOD(BL_ActionActuator,GetChannel); + KX_PYMETHOD_O(BL_ActionActuator,GetChannel); KX_PYMETHOD_DOC(BL_ActionActuator,GetType); KX_PYMETHOD_DOC(BL_ActionActuator,SetType); KX_PYMETHOD_NOARGS(BL_ActionActuator,GetContinue); diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp index 6fc5c40d570..f8a9b1b637f 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.cpp +++ b/source/gameengine/Converter/BL_ArmatureObject.cpp @@ -38,6 +38,7 @@ #include "DNA_action_types.h" #include "DNA_armature_types.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "MT_Matrix4x4.h" @@ -48,10 +49,12 @@ BL_ArmatureObject::BL_ArmatureObject( void* sgReplicationInfo, SG_Callbacks callbacks, - Object *armature ) + Object *armature, + Scene *scene) : KX_GameObject(sgReplicationInfo,callbacks), m_objArma(armature), + m_scene(scene), // maybe remove later. needed for where_is_pose m_framePose(NULL), m_lastframe(0.0), m_activeAct(NULL), @@ -93,9 +96,9 @@ void BL_ArmatureObject::ApplyPose() { m_armpose = m_objArma->pose; m_objArma->pose = m_pose; - + //m_scene->r.cfra++; if(m_lastapplyframe != m_lastframe) { - where_is_pose(NULL, m_objArma); // XXX + where_is_pose(m_scene, m_objArma); // XXX m_lastapplyframe = m_lastframe; } } diff --git a/source/gameengine/Converter/BL_ArmatureObject.h b/source/gameengine/Converter/BL_ArmatureObject.h index d5402cfd126..e1e176840a6 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.h +++ b/source/gameengine/Converter/BL_ArmatureObject.h @@ -51,7 +51,8 @@ public: BL_ArmatureObject( void* sgReplicationInfo, SG_Callbacks callbacks, - Object *armature + Object *armature, + Scene *scene ); virtual ~BL_ArmatureObject(); @@ -67,6 +68,7 @@ public: struct bArmature * GetArmature() { return m_armature; } const struct bArmature * GetArmature() const { return m_armature; } + const struct Scene * GetScene() const { return m_scene; } Object* GetArmatureObject() {return m_objArma;} @@ -84,6 +86,7 @@ protected: struct bPose *m_pose; struct bPose *m_armpose; struct bPose *m_framePose; + struct Scene *m_scene; // need for where_is_pose double m_lastframe; class BL_ActionActuator *m_activeAct; short m_activePriority; diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index c25bdbe71f7..b907e300879 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1795,7 +1795,8 @@ static KX_GameObject *gameobject_from_blenderobject( gameobj = new BL_ArmatureObject( kxscene, KX_Scene::m_callbacks, - ob // handle + ob, + blenderscene // handle ); /* Get the current pose from the armature object and apply it as the rest pose */ break; diff --git a/source/gameengine/Converter/CMakeLists.txt b/source/gameengine/Converter/CMakeLists.txt index 44692241e6f..031c2234ea8 100644 --- a/source/gameengine/Converter/CMakeLists.txt +++ b/source/gameengine/Converter/CMakeLists.txt @@ -49,6 +49,7 @@ SET(INC ../../../source/blender ../../../source/blender/include ../../../source/blender/makesdna + ../../../source/blender/makesrna ../../../source/gameengine/Rasterizer ../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer ../../../source/gameengine/GameLogic diff --git a/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp b/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp index 17bb3dedd36..c3264a2bc37 100644 --- a/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp +++ b/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp @@ -28,32 +28,30 @@ #include "KX_BlenderScalarInterpolator.h" +#include <cstring> + extern "C" { #include "DNA_ipo_types.h" -#include "BKE_ipo.h" +#include "DNA_action_types.h" +#include "DNA_anim_types.h" +#include "BKE_fcurve.h" } -static const int BL_MAX_CHANNELS = 32; - float BL_ScalarInterpolator::GetValue(float currentTime) const { - return 0; // XXX IPO_GetFloatValue(m_blender_ipo, m_channel, currentTime); + // XXX 2.4x IPO_GetFloatValue(m_blender_adt, m_channel, currentTime); + return evaluate_fcurve(m_fcu, currentTime); } - - -BL_InterpolatorList::BL_InterpolatorList(struct Ipo *ipo) { - IPO_Channel channels[BL_MAX_CHANNELS]; - - int num_channels = 0; // XXX IPO_GetChannels(ipo, channels); - - int i; - - for (i = 0; i != num_channels; ++i) { - BL_ScalarInterpolator *new_ipo = - new BL_ScalarInterpolator(ipo, channels[i]); - - //assert(new_ipo); - push_back(new_ipo); +BL_InterpolatorList::BL_InterpolatorList(struct AnimData *adt) { + if(adt->action==NULL) + return; + + for(FCurve *fcu= (FCurve *)adt->action->curves.first; fcu; fcu= (FCurve *)fcu->next) { + if(fcu->rna_path) { + BL_ScalarInterpolator *new_ipo = new BL_ScalarInterpolator(fcu); + //assert(new_ipo); + push_back(new_ipo); + } } } @@ -64,15 +62,13 @@ BL_InterpolatorList::~BL_InterpolatorList() { } } - -KX_IScalarInterpolator *BL_InterpolatorList::GetScalarInterpolator(BL_IpoChannel channel) { - BL_InterpolatorList::iterator i = begin(); - while (!(i == end()) && - (static_cast<BL_ScalarInterpolator *>(*i))->GetChannel() != - channel) { - ++i; +KX_IScalarInterpolator *BL_InterpolatorList::GetScalarInterpolator(char *rna_path, int array_index) { + for(BL_InterpolatorList::iterator i = begin(); (i != end()) ; i++ ) + { + FCurve *fcu= (static_cast<BL_ScalarInterpolator *>(*i))->GetFCurve(); + if(array_index==fcu->array_index && strcmp(rna_path, fcu->rna_path)==0) + return *i; } - - return (i == end()) ? 0 : *i; + return NULL; } diff --git a/source/gameengine/Converter/KX_BlenderScalarInterpolator.h b/source/gameengine/Converter/KX_BlenderScalarInterpolator.h index 94d15aff6be..396a7d197df 100644 --- a/source/gameengine/Converter/KX_BlenderScalarInterpolator.h +++ b/source/gameengine/Converter/KX_BlenderScalarInterpolator.h @@ -38,29 +38,26 @@ typedef unsigned short BL_IpoChannel; class BL_ScalarInterpolator : public KX_IScalarInterpolator { public: BL_ScalarInterpolator() {} // required for use in STL list - BL_ScalarInterpolator(struct Ipo *ipo, BL_IpoChannel channel) : - m_blender_ipo(ipo), - m_channel(channel) + BL_ScalarInterpolator(struct FCurve* fcu) : + m_fcu(fcu) {} virtual ~BL_ScalarInterpolator() {} virtual float GetValue(float currentTime) const; - - BL_IpoChannel GetChannel() const { return m_channel; } + struct FCurve *GetFCurve() { return m_fcu;}; private: - struct Ipo *m_blender_ipo; - BL_IpoChannel m_channel; + struct FCurve *m_fcu; }; class BL_InterpolatorList : public std::vector<KX_IScalarInterpolator *> { public: - BL_InterpolatorList(struct Ipo *ipo); + BL_InterpolatorList(struct AnimData *adt); ~BL_InterpolatorList(); - KX_IScalarInterpolator *GetScalarInterpolator(BL_IpoChannel channel); + KX_IScalarInterpolator *GetScalarInterpolator(char *rna_path, int array_index); }; #endif //__KX_SCALARINTERPOLATOR_H diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index b13e3f7cadb..86e20b88580 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -94,11 +94,9 @@ extern "C" KX_BlenderSceneConverter::KX_BlenderSceneConverter( struct Main* maggie, - struct SpaceIpo* sipo, class KX_KetsjiEngine* engine ) : m_maggie(maggie), - m_sipo(sipo), m_ketsjiEngine(engine), m_alwaysUseExpandFraming(false), m_usemat(false), @@ -115,11 +113,11 @@ KX_BlenderSceneConverter::~KX_BlenderSceneConverter() // delete sumoshapes - int numipolists = m_map_blender_to_gameipolist.size(); - for (i=0; i<numipolists; i++) { - BL_InterpolatorList *ipoList= *m_map_blender_to_gameipolist.at(i); + int numAdtLists = m_map_blender_to_gameAdtList.size(); + for (i=0; i<numAdtLists; i++) { + BL_InterpolatorList *adtList= *m_map_blender_to_gameAdtList.at(i); - delete (ipoList); + delete (adtList); } vector<pair<KX_Scene*,KX_WorldInfo*> >::iterator itw = m_worldinfos.begin(); @@ -575,18 +573,18 @@ void KX_BlenderSceneConverter::RegisterPolyMaterial(RAS_IPolyMaterial *polymat) void KX_BlenderSceneConverter::RegisterInterpolatorList( - BL_InterpolatorList *ipoList, - struct Ipo *for_ipo) + BL_InterpolatorList *adtList, + struct AnimData *for_adt) { - m_map_blender_to_gameipolist.insert(CHashedPtr(for_ipo), ipoList); + m_map_blender_to_gameAdtList.insert(CHashedPtr(for_adt), adtList); } BL_InterpolatorList *KX_BlenderSceneConverter::FindInterpolatorList( - struct Ipo *for_ipo) + struct AnimData *for_adt) { - BL_InterpolatorList **listp = m_map_blender_to_gameipolist[CHashedPtr(for_ipo)]; + BL_InterpolatorList **listp = m_map_blender_to_gameAdtList[CHashedPtr(for_adt)]; return listp?*listp:NULL; } @@ -641,14 +639,14 @@ void KX_BlenderSceneConverter::RegisterWorldInfo( * When deleting an IPO curve from Python, check if the IPO is being * edited and if so clear the pointer to the old curve. */ -void KX_BlenderSceneConverter::localDel_ipoCurve ( IpoCurve * icu ,struct SpaceIpo* sipo) +void KX_BlenderSceneConverter::localDel_ipoCurve ( IpoCurve * icu ) { - if (!sipo) +#if 0 //XXX + if (!G.sipo) return; int i; -#if 0 //XXX - EditIpo *ei= (EditIpo *)sipo->editipo; + EditIpo *ei= (EditIpo *)G.sipo->editipo; if (!ei) return; for(i=0; i<G.sipo->totipo; i++, ei++) { @@ -753,7 +751,7 @@ void KX_BlenderSceneConverter::ResetPhysicsObjectsAnimationIpo(bool clearIpo) if( tmpicu->bezt ) MEM_freeN( tmpicu->bezt ); MEM_freeN( tmpicu ); - localDel_ipoCurve( tmpicu ,m_sipo); + localDel_ipoCurve( tmpicu ); } } } else diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.h b/source/gameengine/Converter/KX_BlenderSceneConverter.h index f7c1a506457..b65f49c2b59 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.h +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.h @@ -44,7 +44,6 @@ class BL_InterpolatorList; class BL_Material; struct IpoCurve; struct Main; -struct SpaceIpo; struct Scene; class KX_BlenderSceneConverter : public KX_ISceneConverter @@ -66,10 +65,9 @@ class KX_BlenderSceneConverter : public KX_ISceneConverter GEN_Map<CHashedPtr,SCA_IActuator*> m_map_blender_to_gameactuator; GEN_Map<CHashedPtr,SCA_IController*> m_map_blender_to_gamecontroller; - GEN_Map<CHashedPtr,BL_InterpolatorList*> m_map_blender_to_gameipolist; + GEN_Map<CHashedPtr,BL_InterpolatorList*> m_map_blender_to_gameAdtList; Main* m_maggie; - SpaceIpo* m_sipo; STR_String m_newfilename; class KX_KetsjiEngine* m_ketsjiEngine; @@ -78,13 +76,12 @@ class KX_BlenderSceneConverter : public KX_ISceneConverter bool m_usemat; bool m_useglslmat; - void localDel_ipoCurve ( IpoCurve * icu ,struct SpaceIpo* sipo); + void localDel_ipoCurve ( IpoCurve * icu ); // struct Ipo* findIpoForName(char* objName); public: KX_BlenderSceneConverter( Main* maggie, - SpaceIpo *sipo, class KX_KetsjiEngine* engine ); @@ -124,8 +121,8 @@ public: void RegisterBlenderMaterial(BL_Material *mat); - void RegisterInterpolatorList(BL_InterpolatorList *ipoList, struct Ipo *for_ipo); - BL_InterpolatorList *FindInterpolatorList(struct Ipo *for_ipo); + void RegisterInterpolatorList(BL_InterpolatorList *adtList, struct AnimData *for_adt); + BL_InterpolatorList *FindInterpolatorList(struct AnimData *for_adt); void RegisterGameActuator(SCA_IActuator *act, struct bActuator *for_actuator); SCA_IActuator *FindGameActuator(struct bActuator *for_actuator); diff --git a/source/gameengine/Converter/KX_IpoConvert.cpp b/source/gameengine/Converter/KX_IpoConvert.cpp index f19390db8a9..d3a2e1a9ba4 100644 --- a/source/gameengine/Converter/KX_IpoConvert.cpp +++ b/source/gameengine/Converter/KX_IpoConvert.cpp @@ -71,20 +71,20 @@ #include "STR_HashedString.h" -static BL_InterpolatorList *GetIpoList(struct Ipo *for_ipo, KX_BlenderSceneConverter *converter) { - BL_InterpolatorList *ipoList= converter->FindInterpolatorList(for_ipo); +static BL_InterpolatorList *GetAdtList(struct AnimData *for_adt, KX_BlenderSceneConverter *converter) { + BL_InterpolatorList *adtList= converter->FindInterpolatorList(for_adt); - if (!ipoList) { - ipoList = new BL_InterpolatorList(for_ipo); - converter->RegisterInterpolatorList(ipoList, for_ipo); + if (!adtList) { + adtList = new BL_InterpolatorList(for_adt); + converter->RegisterInterpolatorList(adtList, for_adt); } - return ipoList; + return adtList; } void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_BlenderSceneConverter *converter) { - if (blenderobject->ipo) { + if (blenderobject->adt) { KX_IpoSGController* ipocontr = new KX_IpoSGController(); gameobj->GetSGNode()->AddSGController(ipocontr); @@ -120,271 +120,79 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend ) ); - BL_InterpolatorList *ipoList= GetIpoList(blenderobject->ipo, converter); + BL_InterpolatorList *adtList= GetAdtList(blenderobject->adt, converter); - // For each active channel in the ipoList add an + // For each active channel in the adtList add an // interpolator to the game object. - KX_IScalarInterpolator *ipo; + KX_IInterpolator *interpolator; + KX_IScalarInterpolator *interp; - ipo = ipoList->GetScalarInterpolator(OB_LOC_X); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetPosition()[0]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_LOC_X, true); - - } - - ipo = ipoList->GetScalarInterpolator(OB_LOC_Y); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetPosition()[1]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_LOC_Y, true); - } - - ipo = ipoList->GetScalarInterpolator(OB_LOC_Z); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetPosition()[2]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_LOC_Z, true); - } - - // Master the art of cut & paste programming... - - ipo = ipoList->GetScalarInterpolator(OB_DLOC_X); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetDeltaPosition()[0]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_DLOC_X, true); - } - - ipo = ipoList->GetScalarInterpolator(OB_DLOC_Y); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetDeltaPosition()[1]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_DLOC_Y, true); - } - - ipo = ipoList->GetScalarInterpolator(OB_DLOC_Z); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetDeltaPosition()[2]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_DLOC_Z, true); - } - - // Explore the finesse of reuse and slight modification - - ipo = ipoList->GetScalarInterpolator(OB_ROT_X); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetEulerAngles()[0]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_ROT_X, true); - } - ipo = ipoList->GetScalarInterpolator(OB_ROT_Y); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetEulerAngles()[1]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_ROT_Y, true); - } - ipo = ipoList->GetScalarInterpolator(OB_ROT_Z); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetEulerAngles()[2]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_ROT_Z, true); - } - - // Hmmm, the need for a macro comes to mind... - - ipo = ipoList->GetScalarInterpolator(OB_DROT_X); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetDeltaEulerAngles()[0]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_DROT_X, true); - } - ipo = ipoList->GetScalarInterpolator(OB_DROT_Y); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetDeltaEulerAngles()[1]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_DROT_Y, true); - } - ipo = ipoList->GetScalarInterpolator(OB_DROT_Z); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetDeltaEulerAngles()[2]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_DROT_Z, true); - } - - // Hang on, almost there... - - ipo = ipoList->GetScalarInterpolator(OB_SIZE_X); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetScaling()[0]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_SIZE_X, true); + for(int i=0; i<3; i++) { + if ((interp = adtList->GetScalarInterpolator("location", i))) { + interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetPosition()[i]), interp); + ipocontr->AddInterpolator(interpolator); + ipocontr->SetIPOChannelActive(OB_LOC_X+i, true); + } } - ipo = ipoList->GetScalarInterpolator(OB_SIZE_Y); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetScaling()[1]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_SIZE_Y, true); + for(int i=0; i<3; i++) { + if ((interp = adtList->GetScalarInterpolator("delta_location", i))) { + interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetDeltaPosition()[i]), interp); + ipocontr->AddInterpolator(interpolator); + ipocontr->SetIPOChannelActive(OB_DLOC_X+i, true); + } } - ipo = ipoList->GetScalarInterpolator(OB_SIZE_Z); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetScaling()[2]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_SIZE_Z, true); + for(int i=0; i<3; i++) { + if ((interp = adtList->GetScalarInterpolator("rotation", i))) { + interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetEulerAngles()[i]), interp); + ipocontr->AddInterpolator(interpolator); + ipocontr->SetIPOChannelActive(OB_ROT_X+i, true); + } } - - // The last few... - - ipo = ipoList->GetScalarInterpolator(OB_DSIZE_X); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetDeltaScaling()[0]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_DSIZE_X, true); + for(int i=0; i<3; i++) { + if ((interp = adtList->GetScalarInterpolator("delta_rotation", i))) { + interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetDeltaEulerAngles()[i]), interp); + ipocontr->AddInterpolator(interpolator); + ipocontr->SetIPOChannelActive(OB_DROT_X+i, true); + } } - ipo = ipoList->GetScalarInterpolator(OB_DSIZE_Y); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetDeltaScaling()[1]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_DSIZE_Y, true); + for(int i=0; i<3; i++) { + if ((interp = adtList->GetScalarInterpolator("scale", i))) { + interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetScaling()[i]), interp); + ipocontr->AddInterpolator(interpolator); + ipocontr->SetIPOChannelActive(OB_SIZE_X+i, true); + } } - ipo = ipoList->GetScalarInterpolator(OB_DSIZE_Z); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetDeltaScaling()[2]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_DSIZE_Z, true); + for(int i=0; i<3; i++) { + if ((interp = adtList->GetScalarInterpolator("delta_scale", i))) { + interpolator= new KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetDeltaScaling()[i]), interp); + ipocontr->AddInterpolator(interpolator); + ipocontr->SetIPOChannelActive(OB_DSIZE_X+i, true); + } } { KX_ObColorIpoSGController* ipocontr_obcol=NULL; - - ipo = ipoList->GetScalarInterpolator(OB_COL_R); - if (ipo) - { - if (!ipocontr_obcol) - { - ipocontr_obcol = new KX_ObColorIpoSGController(); - gameobj->GetSGNode()->AddSGController(ipocontr_obcol); - ipocontr_obcol->SetObject(gameobj->GetSGNode()); - } - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &ipocontr_obcol->m_rgba[0], - ipo); - ipocontr_obcol->AddInterpolator(interpolator); - } - ipo = ipoList->GetScalarInterpolator(OB_COL_G); - if (ipo) - { - if (!ipocontr_obcol) - { - ipocontr_obcol = new KX_ObColorIpoSGController(); - gameobj->GetSGNode()->AddSGController(ipocontr_obcol); - ipocontr_obcol->SetObject(gameobj->GetSGNode()); - } - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &ipocontr_obcol->m_rgba[1], - ipo); - ipocontr_obcol->AddInterpolator(interpolator); - } - ipo = ipoList->GetScalarInterpolator(OB_COL_B); - if (ipo) - { - if (!ipocontr_obcol) - { - ipocontr_obcol = new KX_ObColorIpoSGController(); - gameobj->GetSGNode()->AddSGController(ipocontr_obcol); - ipocontr_obcol->SetObject(gameobj->GetSGNode()); - } - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &ipocontr_obcol->m_rgba[2], - ipo); - ipocontr_obcol->AddInterpolator(interpolator); - } - ipo = ipoList->GetScalarInterpolator(OB_COL_A); - if (ipo) - { - if (!ipocontr_obcol) - { - ipocontr_obcol = new KX_ObColorIpoSGController(); - gameobj->GetSGNode()->AddSGController(ipocontr_obcol); - ipocontr_obcol->SetObject(gameobj->GetSGNode()); + + for(int i=0; i<4; i++) { + if (interp = adtList->GetScalarInterpolator("color", i)) { + if (!ipocontr_obcol) { + ipocontr_obcol = new KX_ObColorIpoSGController(); + gameobj->GetSGNode()->AddSGController(ipocontr_obcol); + ipocontr_obcol->SetObject(gameobj->GetSGNode()); + } + interpolator= new KX_ScalarInterpolator(&ipocontr_obcol->m_rgba[i], interp); + ipocontr_obcol->AddInterpolator(interpolator); } - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &ipocontr_obcol->m_rgba[3], - ipo); - ipocontr_obcol->AddInterpolator(interpolator); } } - - } - - } void BL_ConvertLampIpos(struct Lamp* blenderlamp, KX_GameObject *lightobj,KX_BlenderSceneConverter *converter) { - if (blenderlamp->ipo) { + if (blenderlamp->adt) { KX_LightIpoSGController* ipocontr = new KX_LightIpoSGController(); lightobj->GetSGNode()->AddSGController(ipocontr); @@ -396,51 +204,32 @@ void BL_ConvertLampIpos(struct Lamp* blenderlamp, KX_GameObject *lightobj,KX_Ble ipocontr->m_col_rgb[2] = blenderlamp->b; ipocontr->m_dist = blenderlamp->dist; - BL_InterpolatorList *ipoList= GetIpoList(blenderlamp->ipo, converter); + BL_InterpolatorList *adtList= GetAdtList(blenderlamp->adt, converter); - // For each active channel in the ipoList add an + // For each active channel in the adtList add an // interpolator to the game object. - KX_IScalarInterpolator *ipo; + KX_IInterpolator *interpolator; + KX_IScalarInterpolator *interp; - ipo = ipoList->GetScalarInterpolator(LA_ENERGY); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator(&ipocontr->m_energy, ipo); + if ((interp= adtList->GetScalarInterpolator("energy", 0))) { + interpolator= new KX_ScalarInterpolator(&ipocontr->m_energy, interp); ipocontr->AddInterpolator(interpolator); ipocontr->SetModifyEnergy(true); } - ipo = ipoList->GetScalarInterpolator(LA_DIST); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator(&ipocontr->m_dist, ipo); + if ((interp = adtList->GetScalarInterpolator("distance", 0))) { + interpolator= new KX_ScalarInterpolator(&ipocontr->m_dist, interp); ipocontr->AddInterpolator(interpolator); ipocontr->SetModifyDist(true); } - - ipo = ipoList->GetScalarInterpolator(LA_COL_R); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator(&ipocontr->m_col_rgb[0], ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyColor(true); - } - - ipo = ipoList->GetScalarInterpolator(LA_COL_G); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator(&ipocontr->m_col_rgb[1], ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyColor(true); - } - - ipo = ipoList->GetScalarInterpolator(LA_COL_B); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator(&ipocontr->m_col_rgb[2], ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyColor(true); + + for(int i=0; i<3; i++) { + if ((interp = adtList->GetScalarInterpolator("color", i))) { + interpolator= new KX_ScalarInterpolator(&ipocontr->m_col_rgb[i], interp); + ipocontr->AddInterpolator(interpolator); + ipocontr->SetModifyColor(true); + } } } } @@ -451,7 +240,7 @@ void BL_ConvertLampIpos(struct Lamp* blenderlamp, KX_GameObject *lightobj,KX_Ble void BL_ConvertCameraIpos(struct Camera* blendercamera, KX_GameObject *cameraobj,KX_BlenderSceneConverter *converter) { - if (blendercamera->ipo) { + if (blendercamera->adt) { KX_CameraIpoSGController* ipocontr = new KX_CameraIpoSGController(); cameraobj->GetSGNode()->AddSGController(ipocontr); @@ -461,33 +250,28 @@ void BL_ConvertCameraIpos(struct Camera* blendercamera, KX_GameObject *cameraobj ipocontr->m_clipstart = blendercamera->clipsta; ipocontr->m_clipend = blendercamera->clipend; - BL_InterpolatorList *ipoList= GetIpoList(blendercamera->ipo, converter); + BL_InterpolatorList *adtList= GetAdtList(blendercamera->adt, converter); - // For each active channel in the ipoList add an + // For each active channel in the adtList add an // interpolator to the game object. - KX_IScalarInterpolator *ipo; + KX_IInterpolator *interpolator; + KX_IScalarInterpolator *interp; - ipo = ipoList->GetScalarInterpolator(CAM_LENS); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator(&ipocontr->m_lens, ipo); + if ((interp = adtList->GetScalarInterpolator("lens", 0))) { + interpolator= new KX_ScalarInterpolator(&ipocontr->m_lens, interp); ipocontr->AddInterpolator(interpolator); ipocontr->SetModifyLens(true); } - ipo = ipoList->GetScalarInterpolator(CAM_STA); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator(&ipocontr->m_clipstart, ipo); + if ((interp = adtList->GetScalarInterpolator("clip_start", 0))) { + interpolator= new KX_ScalarInterpolator(&ipocontr->m_clipstart, interp); ipocontr->AddInterpolator(interpolator); ipocontr->SetModifyClipStart(true); } - ipo = ipoList->GetScalarInterpolator(CAM_END); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator(&ipocontr->m_clipend, ipo); + if ((interp = adtList->GetScalarInterpolator("clip_end", 0))) { + interpolator= new KX_ScalarInterpolator(&ipocontr->m_clipend, interp); ipocontr->AddInterpolator(interpolator); ipocontr->SetModifyClipEnd(true); } @@ -499,7 +283,7 @@ void BL_ConvertCameraIpos(struct Camera* blendercamera, KX_GameObject *cameraobj void BL_ConvertWorldIpos(struct World* blenderworld,KX_BlenderSceneConverter *converter) { - if (blenderworld->ipo) { + if (blenderworld->adt) { KX_WorldIpoController* ipocontr = new KX_WorldIpoController(); @@ -514,49 +298,30 @@ void BL_ConvertWorldIpos(struct World* blenderworld,KX_BlenderSceneConverter *co ipocontr->m_mist_rgb[1] = blenderworld->horg; ipocontr->m_mist_rgb[2] = blenderworld->horb; - BL_InterpolatorList *ipoList= GetIpoList(blenderworld->ipo, converter); + BL_InterpolatorList *adtList= GetAdtList(blenderworld->adt, converter); - // For each active channel in the ipoList add an + // For each active channel in the adtList add an // interpolator to the game object. - KX_IScalarInterpolator *ipo; + KX_IInterpolator *interpolator; + KX_IScalarInterpolator *interp; - ipo = ipoList->GetScalarInterpolator(WO_HOR_R); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator(&ipocontr->m_mist_rgb[0], ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyMistColor(true); - } - - ipo = ipoList->GetScalarInterpolator(WO_HOR_G); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator(&ipocontr->m_mist_rgb[1], ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyMistColor(true); - } - - ipo = ipoList->GetScalarInterpolator(WO_HOR_B); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator(&ipocontr->m_mist_rgb[2], ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyMistColor(true); + for(int i=0; i<3; i++) { + if ((interp = adtList->GetScalarInterpolator("horizon_color", i))) { + interpolator= new KX_ScalarInterpolator(&ipocontr->m_mist_rgb[i], interp); + ipocontr->AddInterpolator(interpolator); + ipocontr->SetModifyMistColor(true); + } } - ipo = ipoList->GetScalarInterpolator(WO_MISTDI); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator(&ipocontr->m_mist_dist, ipo); + if ((interp = adtList->GetScalarInterpolator("mist.depth", 0))) { + interpolator= new KX_ScalarInterpolator(&ipocontr->m_mist_dist, interp); ipocontr->AddInterpolator(interpolator); ipocontr->SetModifyMistDist(true); } - ipo = ipoList->GetScalarInterpolator(WO_MISTSTA); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator(&ipocontr->m_mist_start, ipo); + if ((interp = adtList->GetScalarInterpolator("mist.start", 0))) { + interpolator= new KX_ScalarInterpolator(&ipocontr->m_mist_start, interp); ipocontr->AddInterpolator(interpolator); ipocontr->SetModifyMistStart(true); } @@ -570,12 +335,12 @@ static void ConvertMaterialIpos( KX_BlenderSceneConverter *converter ) { - if (blendermaterial->ipo) { + if (blendermaterial->adt) { KX_MaterialIpoController* ipocontr = new KX_MaterialIpoController(matname_hash); gameobj->GetSGNode()->AddSGController(ipocontr); ipocontr->SetObject(gameobj->GetSGNode()); - BL_InterpolatorList *ipoList= GetIpoList(blendermaterial->ipo, converter); + BL_InterpolatorList *adtList= GetAdtList(blendermaterial->adt, converter); ipocontr->m_rgba[0] = blendermaterial->r; @@ -592,163 +357,82 @@ static void ConvertMaterialIpos( ipocontr->m_ref = blendermaterial->ref; ipocontr->m_emit = blendermaterial->emit; ipocontr->m_alpha = blendermaterial->alpha; - KX_IScalarInterpolator *ipo; - // -- - ipo = ipoList->GetScalarInterpolator(MA_COL_R); - if (ipo) { - if (!ipocontr) { - ipocontr = new KX_MaterialIpoController(matname_hash); - gameobj->GetSGNode()->AddSGController(ipocontr); - ipocontr->SetObject(gameobj->GetSGNode()); - } - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &ipocontr->m_rgba[0], - ipo); - ipocontr->AddInterpolator(interpolator); - } - - ipo = ipoList->GetScalarInterpolator(MA_COL_G); - if (ipo) { - if (!ipocontr) { - ipocontr = new KX_MaterialIpoController(matname_hash); - gameobj->GetSGNode()->AddSGController(ipocontr); - ipocontr->SetObject(gameobj->GetSGNode()); - } - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &ipocontr->m_rgba[1], - ipo); - ipocontr->AddInterpolator(interpolator); - } + KX_IInterpolator *interpolator; + KX_IScalarInterpolator *sinterp; - ipo = ipoList->GetScalarInterpolator(MA_COL_B); - if (ipo) { - if (!ipocontr) { - ipocontr = new KX_MaterialIpoController(matname_hash); - gameobj->GetSGNode()->AddSGController(ipocontr); - ipocontr->SetObject(gameobj->GetSGNode()); + // -- + for(int i=0; i<3; i++) { + if ((sinterp = adtList->GetScalarInterpolator("diffuse_color", i))) { + if (!ipocontr) { + ipocontr = new KX_MaterialIpoController(matname_hash); + gameobj->GetSGNode()->AddSGController(ipocontr); + ipocontr->SetObject(gameobj->GetSGNode()); + } + interpolator= new KX_ScalarInterpolator(&ipocontr->m_rgba[i], sinterp); + ipocontr->AddInterpolator(interpolator); } - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &ipocontr->m_rgba[2], - ipo); - ipocontr->AddInterpolator(interpolator); } - ipo = ipoList->GetScalarInterpolator(MA_ALPHA); - if (ipo) { + if ((sinterp = adtList->GetScalarInterpolator("alpha", 0))) { if (!ipocontr) { ipocontr = new KX_MaterialIpoController(matname_hash); gameobj->GetSGNode()->AddSGController(ipocontr); ipocontr->SetObject(gameobj->GetSGNode()); } - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &ipocontr->m_rgba[3], - ipo); + interpolator= new KX_ScalarInterpolator(&ipocontr->m_rgba[3], sinterp); ipocontr->AddInterpolator(interpolator); } - // -- - ipo = ipoList->GetScalarInterpolator(MA_SPEC_R ); - if (ipo) { - if (!ipocontr) { - ipocontr = new KX_MaterialIpoController(matname_hash); - gameobj->GetSGNode()->AddSGController(ipocontr); - ipocontr->SetObject(gameobj->GetSGNode()); - } - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &ipocontr->m_specrgb[0], - ipo); - ipocontr->AddInterpolator(interpolator); - } - - ipo = ipoList->GetScalarInterpolator(MA_SPEC_G); - if (ipo) { - if (!ipocontr) { - ipocontr = new KX_MaterialIpoController(matname_hash); - gameobj->GetSGNode()->AddSGController(ipocontr); - ipocontr->SetObject(gameobj->GetSGNode()); + for(int i=0; i<3; i++) { + if ((sinterp = adtList->GetScalarInterpolator("specular_color", i))) { + if (!ipocontr) { + ipocontr = new KX_MaterialIpoController(matname_hash); + gameobj->GetSGNode()->AddSGController(ipocontr); + ipocontr->SetObject(gameobj->GetSGNode()); + } + interpolator= new KX_ScalarInterpolator(&ipocontr->m_specrgb[i], sinterp); + ipocontr->AddInterpolator(interpolator); } - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &ipocontr->m_specrgb[1], - ipo); - ipocontr->AddInterpolator(interpolator); } - ipo = ipoList->GetScalarInterpolator(MA_SPEC_B); - if (ipo) { - if (!ipocontr) { - ipocontr = new KX_MaterialIpoController(matname_hash); - gameobj->GetSGNode()->AddSGController(ipocontr); - ipocontr->SetObject(gameobj->GetSGNode()); - } - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &ipocontr->m_specrgb[2], - ipo); - ipocontr->AddInterpolator(interpolator); - } - - // -- - ipo = ipoList->GetScalarInterpolator(MA_HARD); - if (ipo) { + if ((sinterp = adtList->GetScalarInterpolator("specular_hardness", 0))) { if (!ipocontr) { ipocontr = new KX_MaterialIpoController(matname_hash); gameobj->GetSGNode()->AddSGController(ipocontr); ipocontr->SetObject(gameobj->GetSGNode()); } - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &ipocontr->m_hard, - ipo); + interpolator= new KX_ScalarInterpolator(&ipocontr->m_hard, sinterp); ipocontr->AddInterpolator(interpolator); } - ipo = ipoList->GetScalarInterpolator(MA_SPEC); - if (ipo) { + if ((sinterp = adtList->GetScalarInterpolator("specularity", 0))) { if (!ipocontr) { ipocontr = new KX_MaterialIpoController(matname_hash); gameobj->GetSGNode()->AddSGController(ipocontr); ipocontr->SetObject(gameobj->GetSGNode()); } - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &ipocontr->m_spec, - ipo); + interpolator= new KX_ScalarInterpolator(&ipocontr->m_spec, sinterp); ipocontr->AddInterpolator(interpolator); } - - ipo = ipoList->GetScalarInterpolator(MA_REF); - if (ipo) { + if ((sinterp = adtList->GetScalarInterpolator("diffuse_reflection", 0))) { if (!ipocontr) { ipocontr = new KX_MaterialIpoController(matname_hash); gameobj->GetSGNode()->AddSGController(ipocontr); ipocontr->SetObject(gameobj->GetSGNode()); } - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &ipocontr->m_ref, - ipo); + interpolator= new KX_ScalarInterpolator(&ipocontr->m_ref, sinterp); ipocontr->AddInterpolator(interpolator); } - ipo = ipoList->GetScalarInterpolator(MA_EMIT); - if (ipo) { + if ((sinterp = adtList->GetScalarInterpolator("emit", 0))) { if (!ipocontr) { ipocontr = new KX_MaterialIpoController(matname_hash); gameobj->GetSGNode()->AddSGController(ipocontr); ipocontr->SetObject(gameobj->GetSGNode()); } - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &ipocontr->m_emit, - ipo); + interpolator= new KX_ScalarInterpolator(&ipocontr->m_emit, sinterp); ipocontr->AddInterpolator(interpolator); } } diff --git a/source/gameengine/Converter/Makefile b/source/gameengine/Converter/Makefile index 938994e8b62..abded70f289 100644 --- a/source/gameengine/Converter/Makefile +++ b/source/gameengine/Converter/Makefile @@ -48,6 +48,7 @@ CPPFLAGS += -I../../blender CPPFLAGS += -I../../blender/windowmanager CPPFLAGS += -I../../blender/imbuf CPPFLAGS += -I../../blender/makesdna +CPPFLAGS += -I../../blender/makesrna CPPFLAGS += -I../../blender/editors/include CPPFLAGS += -I../../blender/blenlib CPPFLAGS += -I../../blender/blenkernel diff --git a/source/gameengine/Converter/SConscript b/source/gameengine/Converter/SConscript index af0d39771de..3e0929e605a 100644 --- a/source/gameengine/Converter/SConscript +++ b/source/gameengine/Converter/SConscript @@ -19,6 +19,7 @@ incs += ' #source/gameengine/Physics/Dummy' incs += ' #source/gameengine/Network/LoopBackNetwork' incs += ' #source/blender/misc #source/blender/blenloader #source/blender/gpu' incs += ' #source/blender/windowmanager' +incs += ' #source/blender/makesrna' if env['WITH_BF_SOLID']: incs += ' #source/gameengine/Physics/Sumo #source/gameengine/Physics/Sumo/Fuzzics/include' diff --git a/source/gameengine/Expressions/InputParser.cpp b/source/gameengine/Expressions/InputParser.cpp index b15b206a38a..96a52aec028 100644 --- a/source/gameengine/Expressions/InputParser.cpp +++ b/source/gameengine/Expressions/InputParser.cpp @@ -636,63 +636,3 @@ void CParser::SetContext(CValue* context) } m_identifierContext = context; } - - - - -PyObject* CParserPyMake(PyObject* ignored,PyObject* args) -{ - char* txt; - if (!PyArg_ParseTuple(args,"s",&txt)) - return NULL; - CParser parser; - CExpression* expr = parser.ProcessText(txt); - CValue* val = expr->Calculate(); - expr->Release(); - return val->GetProxy(); -} - -static PyMethodDef CParserMethods[] = -{ - { "calc", CParserPyMake , METH_VARARGS}, - { NULL,NULL} // Sentinel -}; - - -#if (PY_VERSION_HEX >= 0x03000000) -static struct PyModuleDef Expression_module_def = { - {}, /* m_base */ - "Expression", /* m_name */ - 0, /* m_doc */ - 0, /* m_size */ - CParserMethods, /* m_methods */ - 0, /* m_reload */ - 0, /* m_traverse */ - 0, /* m_clear */ - 0, /* m_free */ -}; -#endif - -extern "C" { - void initExpressionModule(void) - { - PyObject *m; - /* Use existing module where possible - * be careful not to init any runtime vars after this */ - m = PyImport_ImportModule( "Expression" ); - if(m) { - Py_DECREF(m); - //return m; - } - else { - PyErr_Clear(); - -#if (PY_VERSION_HEX >= 0x03000000) - PyModule_Create(&Expression_module_def); -#else - Py_InitModule("Expression",CParserMethods); -#endif - } - } -} - diff --git a/source/gameengine/Expressions/ListValue.cpp b/source/gameengine/Expressions/ListValue.cpp index a0d73c75d60..59344ddb7b7 100644 --- a/source/gameengine/Expressions/ListValue.cpp +++ b/source/gameengine/Expressions/ListValue.cpp @@ -20,6 +20,8 @@ #include <algorithm> #include "BoolValue.h" +#include "BLO_sys_types.h" /* for intptr_t support */ + #ifdef HAVE_CONFIG_H #include <config.h> #endif @@ -209,6 +211,30 @@ static PyObject *listvalue_buffer_concat(PyObject * self, PyObject * other) return listval_new->NewProxy(true); /* python owns this list */ } +static int listvalue_buffer_contains(PyObject *self_v, PyObject *value) +{ + CListValue *self= static_cast<CListValue *>(BGE_PROXY_REF(self_v)); + + if (self==NULL) { + PyErr_SetString(PyExc_SystemError, "val in CList, "BGE_PROXY_ERROR_MSG); + return -1; + } + + if (PyString_Check(value)) { + if (self->FindValue((const char *)PyString_AsString(value))) { + return 1; + } + } + else if (BGE_PROXY_CHECK_TYPE(value)) { /* not dict like at all but this worked before __contains__ was used */ + CValue *item= static_cast<CValue *>(BGE_PROXY_REF(value)); + for (int i=0; i < self->GetCount(); i++) + if (self->GetValue(i) == item) // Com + return 1; + + } // not using CheckEqual + + return 0; +} static PySequenceMethods listvalue_as_sequence = { @@ -225,6 +251,7 @@ static PySequenceMethods listvalue_as_sequence = { NULL, /*sq_ass_item*/ NULL, /*sq_ass_slice*/ #endif + (objobjproc)listvalue_buffer_contains, /* sq_contains */ }; @@ -264,7 +291,9 @@ PyTypeObject CListValue::Type = { 0, py_base_getattro, py_base_setattro, - 0,0,0,0,0,0,0,0,0, + 0, + Py_TPFLAGS_DEFAULT, + 0,0,0,0,0,0,0, Methods }; @@ -499,7 +528,7 @@ PyObject* CListValue::Pyreverse() bool CListValue::CheckEqual(CValue* first,CValue* second) { bool result = false; - + CValue* eqval = ((CValue*)first)->Calc(VALUE_EQL_OPERATOR,(CValue*)second); if (eqval==NULL) @@ -528,7 +557,7 @@ PyObject* CListValue::Pyindex(PyObject *value) for (int i=0;i<numelem;i++) { CValue* elem = GetValue(i); - if (CheckEqual(checkobj,elem)) + if (checkobj==elem || CheckEqual(checkobj,elem)) { result = PyInt_FromLong(i); break; @@ -560,7 +589,7 @@ PyObject* CListValue::Pycount(PyObject* value) for (int i=0;i<numelem;i++) { CValue* elem = GetValue(i); - if (CheckEqual(checkobj,elem)) + if (checkobj==elem || CheckEqual(checkobj,elem)) { numfound ++; } diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h index 369c00782cc..c002dccefe4 100644 --- a/source/gameengine/Expressions/PyObjectPlus.h +++ b/source/gameengine/Expressions/PyObjectPlus.h @@ -113,8 +113,8 @@ typedef struct { if ((m_ignore_deprecation_warnings || wlink.warn_done)==0) \ { \ ShowDeprecationWarning_func(old_way, new_way); \ + \ WarnLink *wlink_last= GetDeprecationWarningLinkLast(); \ - ShowDeprecationWarning_func(old_way, new_way); \ wlink.warn_done = true; \ wlink.link = NULL; \ \ diff --git a/source/gameengine/Expressions/SConscript b/source/gameengine/Expressions/SConscript index b5c69eafe6b..07cab62c020 100644 --- a/source/gameengine/Expressions/SConscript +++ b/source/gameengine/Expressions/SConscript @@ -3,7 +3,7 @@ Import ('env') sources = env.Glob('*.cpp') -incs ='. #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/SceneGraph' +incs ='. #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/SceneGraph #source/blender/blenloader' incs += ' ' + env['BF_PYTHON_INC'] cxxflags = [] diff --git a/source/gameengine/Expressions/Value.cpp b/source/gameengine/Expressions/Value.cpp index e6ef9733da8..61dabff510b 100644 --- a/source/gameengine/Expressions/Value.cpp +++ b/source/gameengine/Expressions/Value.cpp @@ -725,54 +725,6 @@ PyObject* CValue::ConvertKeysToPython( void ) return pylist; } -/* -PyObject* CValue::PyMake(PyObject* ignored,PyObject* args) -{ - - //if (!PyArg_ParseTuple(args,"s:make",&name)) return NULL; - Py_RETURN_NONE;//new CValue(); -} -*/ - -#if (PY_VERSION_HEX >= 0x03000000) -static struct PyModuleDef CValue_module_def = { - {}, /* m_base */ - "CValue", /* m_name */ - 0, /* m_doc */ - 0, /* m_size */ - CValueMethods, /* m_methods */ - 0, /* m_reload */ - 0, /* m_traverse */ - 0, /* m_clear */ - 0, /* m_free */ -}; -#endif - -extern "C" { - void initCValue(void) - { - PyObject *m; - /* Use existing module where possible - * be careful not to init any runtime vars after this */ - m = PyImport_ImportModule( "CValue" ); - if(m) { - Py_DECREF(m); - //return m; - } - else { - PyErr_Clear(); - -#if (PY_VERSION_HEX >= 0x03000000) - PyModule_Create(&CValue_module_def); -#else - Py_InitModule("CValue",CValueMethods); -#endif - } - } -} - - - #endif //NO_EXP_PYTHON_EMBEDDING /////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp index d83179d4f80..6140702534c 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp +++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp @@ -158,12 +158,13 @@ bool SCA_Joystick::aAxisIsPositive(int axis_single) bool SCA_Joystick::aAnyButtonPressIsPositive(void) { +#ifndef DISABLE_SDL /* this is needed for the "all events" option * so we know if there are no buttons pressed */ for (int i=0; i<m_buttonmax; i++) if (SDL_JoystickGetButton(m_private->m_joystick, i)) return true; - +#endif return false; } diff --git a/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp b/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp deleted file mode 100644 index b1e2b5af0e6..00000000000 --- a/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp +++ /dev/null @@ -1,412 +0,0 @@ -/** - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "GL/glew.h" - -#include "GPC_PolygonMaterial.h" -#include "MT_Vector3.h" -#include "RAS_IRasterizer.h" -#include "RAS_GLExtensionManager.h" - -/* This list includes only data type definitions */ -#include "DNA_object_types.h" -#include "DNA_material_types.h" -#include "DNA_image_types.h" -#include "DNA_lamp_types.h" -#include "DNA_group_types.h" -#include "DNA_scene_types.h" -#include "DNA_camera_types.h" -#include "DNA_property_types.h" -#include "DNA_text_types.h" -#include "DNA_sensor_types.h" -#include "DNA_controller_types.h" -#include "DNA_actuator_types.h" -#include "DNA_mesh_types.h" -#include "DNA_meshdata_types.h" -#include "DNA_view3d_types.h" -#include "DNA_world_types.h" - -#include "BKE_global.h" -#include "BKE_image.h" -#include "BKE_mesh.h" - -#include "MEM_guardedalloc.h" - -#include "IMB_imbuf_types.h" -/* end of blender include block */ - -static Image *fCurpage=0; -static int fCurtile=0, fCurmode=0, fCurTileXRep=0, fCurTileYRep=0; -static short fTexWindx, fTexWindy, fTexWinsx, fTexWinsy; -static int fDoMipMap = 1; -static int fLinearMipMap=1; -static int fAlphamode= -1; - - /* (n&(n-1)) zeros the least significant bit of n */ -static int is_pow2(int num) { - return ((num)&(num-1))==0; -} -static int smaller_pow2(int num) { - while (!is_pow2(num)) - num= num&(num-1); - return num; -} - -static void my_make_repbind(Image *ima) -{ - if(ima==0 || ima->ibufs.first==0) return; - - if(ima->repbind) { - glDeleteTextures(ima->totbind, (GLuint*)ima->repbind); - delete (ima->repbind); - ima->repbind= 0; - } - ima->totbind= ima->xrep*ima->yrep; - if(ima->totbind>1) { - ima->repbind= (unsigned int *) malloc(sizeof(int)*ima->totbind); - for (int i=0;i<ima->totbind;i++) - ((int*)ima->repbind)[i] = 0; - } -} - -extern "C" int set_tpage(MTFace *tface); - -int set_tpage(MTFace *tface) -{ - static MTFace *lasttface= 0; - Image *ima; - unsigned int *rect, *bind; - int tpx, tpy, tilemode, tileXRep,tileYRep; - - /* disable */ - if(tface==0) { - if(lasttface==0) return 0; - - lasttface= 0; - fCurtile= 0; - fCurpage= 0; - if(fCurmode!=0) { - glMatrixMode(GL_TEXTURE); - glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); - } - fCurmode= 0; - fCurTileXRep=0; - fCurTileYRep=0; - fAlphamode= -1; - - glDisable(GL_BLEND); - glDisable(GL_TEXTURE_2D); - glDisable(GL_TEXTURE_GEN_S); - glDisable(GL_TEXTURE_GEN_T); - return 0; - } - lasttface= tface; - - if( fAlphamode != tface->transp) { - fAlphamode= tface->transp; - - if(fAlphamode) { - if(fAlphamode==TF_ADD) { - glEnable(GL_BLEND); - glBlendFunc(GL_ONE, GL_ONE); - glDisable ( GL_ALPHA_TEST ); - /* glBlendEquationEXT(GL_FUNC_ADD_EXT); */ - } - else if(fAlphamode==TF_ALPHA) { - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glDisable ( GL_ALPHA_TEST ); - /* glBlendEquationEXT(GL_FUNC_ADD_EXT); */ - } - else if (fAlphamode==TF_CLIP){ - glDisable(GL_BLEND); - glEnable ( GL_ALPHA_TEST ); - glAlphaFunc(GL_GREATER, 0.5f); - } - /* else { */ - /* glBlendFunc(GL_ONE, GL_ONE); */ - /* glBlendEquationEXT(GL_FUNC_REVERSE_SUBTRACT_EXT); */ - /* } */ - } - else glDisable(GL_BLEND); - } - - ima= (struct Image *) tface->tpage; - - /* Enable or disable environment mapping */ - if (ima && (ima->flag & IMA_REFLECT)){ - - glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); - glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); - - glEnable(GL_TEXTURE_GEN_S); - glEnable(GL_TEXTURE_GEN_T); - } - else{ - glDisable(GL_TEXTURE_GEN_S); - glDisable(GL_TEXTURE_GEN_T); - } - - tilemode= tface->mode & TF_TILES; - tileXRep = 0; - tileYRep = 0; - if (ima) - { - tileXRep = ima->xrep; - tileYRep = ima->yrep; - } - - - if(ima==fCurpage && fCurtile==tface->tile && tilemode==fCurmode && fCurTileXRep==tileXRep && fCurTileYRep == tileYRep) return ima!=0; - - if(tilemode!=fCurmode || fCurTileXRep!=tileXRep || fCurTileYRep != tileYRep) - { - glMatrixMode(GL_TEXTURE); - glLoadIdentity(); - - if(tilemode && ima!=0) - glScalef(ima->xrep, ima->yrep, 1.0); - - glMatrixMode(GL_MODELVIEW); - } - - if(ima==0 || ima->ok==0) { - glDisable(GL_TEXTURE_2D); - - fCurtile= tface->tile; - fCurpage= 0; - fCurmode= tilemode; - fCurTileXRep = tileXRep; - fCurTileYRep = tileYRep; - - return 0; - } - - ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); - - if(ibuf==0) { - ima->ok= 0; - - fCurtile= tface->tile; - fCurpage= 0; - fCurmode= tilemode; - fCurTileXRep = tileXRep; - fCurTileYRep = tileYRep; - - glDisable(GL_TEXTURE_2D); - return 0; - } - - if(ima->tpageflag & IMA_TWINANIM) fCurtile= ima->lastframe; - else fCurtile= tface->tile; - - if(tilemode) { - - if(ima->repbind==0) my_make_repbind(ima); - - if(fCurtile>=ima->totbind) fCurtile= 0; - - /* this happens when you change repeat buttons */ - if(ima->repbind) bind= ima->repbind+fCurtile; - else bind= &ima->bindcode; - - if(*bind==0) { - - fTexWindx= ibuf->x/ima->xrep; - fTexWindy= ibuf->y/ima->yrep; - - if(fCurtile>=ima->xrep*ima->yrep) fCurtile= ima->xrep*ima->yrep-1; - - fTexWinsy= fCurtile / ima->xrep; - fTexWinsx= fCurtile - fTexWinsy*ima->xrep; - - fTexWinsx*= fTexWindx; - fTexWinsy*= fTexWindy; - - tpx= fTexWindx; - tpy= fTexWindy; - - rect= ibuf->rect + fTexWinsy*ibuf->x + fTexWinsx; - } - } - else { - bind= &ima->bindcode; - - if(*bind==0) { - tpx= ibuf->x; - tpy= ibuf->y; - rect= ibuf->rect; - } - } - - if(*bind==0) { - int rectw= tpx, recth= tpy; - unsigned int *tilerect= NULL, *scalerect= NULL; - - /* - * Maarten: - * According to Ton this code is not needed anymore. It was used only - * in really old Blenders. - * Reevan: - * Actually it is needed for backwards compatibility. Simpledemo 6 does not display correctly without it. - */ -#if 1 - if (tilemode) { - int y; - - tilerect= (unsigned int*)MEM_mallocN(rectw*recth*sizeof(*tilerect), "tilerect"); - for (y=0; y<recth; y++) { - unsigned int *rectrow= &rect[y*ibuf->x]; - unsigned int *tilerectrow= &tilerect[y*rectw]; - - memcpy(tilerectrow, rectrow, tpx*sizeof(*rectrow)); - } - - rect= tilerect; - } -#endif - if (!is_pow2(rectw) || !is_pow2(recth)) { - rectw= smaller_pow2(rectw); - recth= smaller_pow2(recth); - - scalerect= (unsigned int *)MEM_mallocN(rectw*recth*sizeof(*scalerect), "scalerect"); - gluScaleImage(GL_RGBA, tpx, tpy, GL_UNSIGNED_BYTE, rect, rectw, recth, GL_UNSIGNED_BYTE, scalerect); - rect= scalerect; - } - - glGenTextures(1, (GLuint*)bind); - - /* - if(G.f & G_DEBUG) { - printf("var1: %s\n", ima->id.name+2); - printf("var1: %d, var2: %d\n", *bind, tpx); - printf("var1: %d, var2: %d\n", fCurtile, tilemode); - } - */ - glBindTexture( GL_TEXTURE_2D, *bind); - - if (!fDoMipMap) - { - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, rectw, recth, 0, GL_RGBA, GL_UNSIGNED_BYTE, rect); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - } else - { - int minfilter= fLinearMipMap?GL_LINEAR_MIPMAP_LINEAR:GL_LINEAR_MIPMAP_NEAREST; - - gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, rectw, recth, GL_RGBA, GL_UNSIGNED_BYTE, rect); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minfilter); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - } - - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - - if (tilerect) - MEM_freeN(tilerect); - if (scalerect) - MEM_freeN(scalerect); - } - else glBindTexture( GL_TEXTURE_2D, *bind); - - - - glEnable(GL_TEXTURE_2D); - - fCurpage= ima; - fCurmode= tilemode; - fCurTileXRep = tileXRep; - fCurTileYRep = tileYRep; - - return 1; -} - -#if 0 -GPC_PolygonMaterial::GPC_PolygonMaterial(const STR_String& texname, bool ba, const STR_String& matname, - int tile, int tileXrep, int tileYrep, int mode, bool transparant, bool zsort, - int lightlayer, bool bIsTriangle, void* clientobject, void* tpage) : - RAS_IPolyMaterial(texname, ba, matname, tile, tileXrep, tileYrep, mode, - transparant, zsort, lightlayer, bIsTriangle, clientobject), m_tface((struct MTFace*)tpage) -{ - // clear local caching info - my_set_tpage(0); -} - - -GPC_PolygonMaterial::~GPC_PolygonMaterial(void) -{ -} - - -void GPC_PolygonMaterial::Activate(RAS_IRasterizer* rasty, TCachingInfo& cachingInfo) const -{ - if (GetCachingInfo() != cachingInfo) - { - if (!cachingInfo) - { - my_set_tpage(0); - } - cachingInfo = GetCachingInfo(); - - if ((m_drawingmode & 4)&& (rasty->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED) ) - { - update_realtime_texture((struct MTFace*) m_tface, rasty->GetTime()); - my_set_tpage(m_tface); - rasty->EnableTextures(true); - } else - { - my_set_tpage(0); - rasty->EnableTextures(false); - } - - //TF_TWOSIDE == 512, todo, make this a ketsji enum - if(m_drawingmode & 512) { - rasty->SetCullFace(false); - } - - else - { - rasty->SetCullFace(true);//glEnable(GL_CULL_FACE); - //else glDisable(GL_CULL_FACE); - } - } - rasty->SetSpecularity(m_specular[0],m_specular[1],m_specular[2],m_specularity); - rasty->SetShinyness(m_shininess); - rasty->SetDiffuse(m_diffuse[0], m_diffuse[1],m_diffuse[2], 1.0); -} - -#endif -void GPC_PolygonMaterial::SetMipMappingEnabled(bool enabled) -{ - fDoMipMap = enabled ? 1 : 0; -} diff --git a/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.h b/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.h deleted file mode 100644 index 212decd078c..00000000000 --- a/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.h +++ /dev/null @@ -1,89 +0,0 @@ -/** - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#ifndef __GPC_POLYGONMATERIAL -#define __GPC_POLYGONMATERIAL - -#include "RAS_IPolygonMaterial.h" - -namespace GPC_PolygonMaterial -{ - void SetMipMappingEnabled(bool enabled = false); -}; - -#if 0 -class GPC_PolygonMaterial : public RAS_IPolyMaterial -{ - struct MTFace* m_tface; - -public: - GPC_PolygonMaterial(const STR_String& texname, bool ba, const STR_String& matname, - int tile, int tileXrep, int tileYrep, int mode, bool transparant, bool zsort, - int lightlayer, bool bIsTriangle, void* clientobject, void* tpage); - - virtual ~GPC_PolygonMaterial(void); - - /** - * Returns the caching information for this material, - * This can be used to speed up the rasterizing process. - * @return The caching information. - */ - virtual TCachingInfo GetCachingInfo(void) const; - - /** - * Activates the material in the (OpenGL) rasterizer. - * On entry, the cachingInfo contains info about the last activated material. - * On exit, the cachingInfo should contain updated info about this material. - * @param rasty The rasterizer in which the material should be active. - * @param cachingInfo The information about the material used to speed up rasterizing. - */ - virtual void Activate(RAS_IRasterizer* rasty, TCachingInfo& cachingInfo) const; - - /** - * Returns the Blender texture face structure that is used for this material. - * @return The material's texture face. - */ - MTFace* GetMTFace(void) const; - - static void SetMipMappingEnabled(bool enabled = false); -}; - - -inline MTFace* GPC_PolygonMaterial::GetMTFace(void) const -{ - return m_tface; -} - -inline GPC_PolygonMaterial::TCachingInfo GPC_PolygonMaterial::GetCachingInfo(void) const -{ - return GetMTFace(); -} -#endif -#endif // __GPC_POLYGONMATERIAL_H - diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp index c5c9dcc6c0f..24fca3feb8b 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp @@ -29,8 +29,6 @@ #include "GL/glew.h" -#include "DNA_scene_types.h" - #include "RAS_IRenderTools.h" #include "RAS_IRasterizer.h" #include "RAS_LightObject.h" @@ -42,6 +40,7 @@ #include "KX_BlenderMaterial.h" #include "KX_RayCast.h" #include "KX_IPhysicsController.h" +#include "KX_Light.h" #include "PHY_IPhysicsEnvironment.h" @@ -387,21 +386,12 @@ int GPC_RenderTools::applyLights(int objectlayer, const MT_Transform& viewmat) { // taken from blender source, incompatibility between Blender Object / GameObject KX_Scene* kxscene = (KX_Scene*)m_auxilaryClientInfo; - int scenelayer = ~0; float glviewmat[16]; unsigned int count; - float vec[4]; - - vec[3]= 1.0; + std::vector<struct RAS_LightObject*>::iterator lit = m_lights.begin(); - if(kxscene && kxscene->GetBlenderScene()) - scenelayer = kxscene->GetBlenderScene()->lay; - for(count=0; count<m_numgllights; count++) glDisable((GLenum)(GL_LIGHT0+count)); - - //std::vector<struct RAS_LightObject*> m_lights; - std::vector<struct RAS_LightObject*>::iterator lit = m_lights.begin(); viewmat.getValue(glviewmat); @@ -410,82 +400,14 @@ int GPC_RenderTools::applyLights(int objectlayer, const MT_Transform& viewmat) for (lit = m_lights.begin(), count = 0; !(lit==m_lights.end()) && count < m_numgllights; ++lit) { RAS_LightObject* lightdata = (*lit); - KX_Scene* lightscene = (KX_Scene*)lightdata->m_scene; - - /* only use lights in the same layer as the object */ - if(!(lightdata->m_layer & objectlayer)) - continue; - /* only use lights in the same scene, and in a visible layer */ - if(kxscene != lightscene || !(lightdata->m_layer & scenelayer)) - continue; - - vec[0] = (*(lightdata->m_worldmatrix))(0,3); - vec[1] = (*(lightdata->m_worldmatrix))(1,3); - vec[2] = (*(lightdata->m_worldmatrix))(2,3); - vec[3] = 1; - - if(lightdata->m_type==RAS_LightObject::LIGHT_SUN) { - - vec[0] = (*(lightdata->m_worldmatrix))(0,2); - vec[1] = (*(lightdata->m_worldmatrix))(1,2); - vec[2] = (*(lightdata->m_worldmatrix))(2,2); - //vec[0]= base->object->obmat[2][0]; - //vec[1]= base->object->obmat[2][1]; - //vec[2]= base->object->obmat[2][2]; - vec[3]= 0.0; - glLightfv((GLenum)(GL_LIGHT0+count), GL_POSITION, vec); - } - else { - //vec[3]= 1.0; - glLightfv((GLenum)(GL_LIGHT0+count), GL_POSITION, vec); - glLightf((GLenum)(GL_LIGHT0+count), GL_CONSTANT_ATTENUATION, 1.0); - glLightf((GLenum)(GL_LIGHT0+count), GL_LINEAR_ATTENUATION, lightdata->m_att1/lightdata->m_distance); - // without this next line it looks backward compatible. - //attennuation still is acceptable - glLightf((GLenum)(GL_LIGHT0+count), GL_QUADRATIC_ATTENUATION, lightdata->m_att2/(lightdata->m_distance*lightdata->m_distance)); - - if(lightdata->m_type==RAS_LightObject::LIGHT_SPOT) { - vec[0] = -(*(lightdata->m_worldmatrix))(0,2); - vec[1] = -(*(lightdata->m_worldmatrix))(1,2); - vec[2] = -(*(lightdata->m_worldmatrix))(2,2); - //vec[0]= -base->object->obmat[2][0]; - //vec[1]= -base->object->obmat[2][1]; - //vec[2]= -base->object->obmat[2][2]; - glLightfv((GLenum)(GL_LIGHT0+count), GL_SPOT_DIRECTION, vec); - glLightf((GLenum)(GL_LIGHT0+count), GL_SPOT_CUTOFF, lightdata->m_spotsize/2.0); - glLightf((GLenum)(GL_LIGHT0+count), GL_SPOT_EXPONENT, 128.0*lightdata->m_spotblend); - } - else glLightf((GLenum)(GL_LIGHT0+count), GL_SPOT_CUTOFF, 180.0); - } - - if (lightdata->m_nodiffuse) - { - vec[0] = vec[1] = vec[2] = vec[3] = 0.0; - } else { - vec[0]= lightdata->m_energy*lightdata->m_red; - vec[1]= lightdata->m_energy*lightdata->m_green; - vec[2]= lightdata->m_energy*lightdata->m_blue; - vec[3]= 1.0; - } - glLightfv((GLenum)(GL_LIGHT0+count), GL_DIFFUSE, vec); - if (lightdata->m_nospecular) - { - vec[0] = vec[1] = vec[2] = vec[3] = 0.0; - } else if (lightdata->m_nodiffuse) { - vec[0]= lightdata->m_energy*lightdata->m_red; - vec[1]= lightdata->m_energy*lightdata->m_green; - vec[2]= lightdata->m_energy*lightdata->m_blue; - vec[3]= 1.0; - } - glLightfv((GLenum)(GL_LIGHT0+count), GL_SPECULAR, vec); - glEnable((GLenum)(GL_LIGHT0+count)); + KX_LightObject *kxlight = (KX_LightObject*)lightdata->m_light; - count++; + if(kxlight->ApplyLight(kxscene, objectlayer, count)) + count++; } glPopMatrix(); return count; - } void GPC_RenderTools::MotionBlur(RAS_IRasterizer* rasterizer) diff --git a/source/gameengine/GamePlayer/ghost/CMakeLists.txt b/source/gameengine/GamePlayer/ghost/CMakeLists.txt index 71961f27339..0d4abf1e1fe 100644 --- a/source/gameengine/GamePlayer/ghost/CMakeLists.txt +++ b/source/gameengine/GamePlayer/ghost/CMakeLists.txt @@ -51,6 +51,7 @@ SET(INC ../../../../source/blender ../../../../source/blender/include ../../../../source/blender/makesdna + ../../../../source/blender/makesrna ../../../../source/gameengine/Rasterizer ../../../../source/gameengine/GameLogic ../../../../source/gameengine/Expressions diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index bdee8a78cfe..e5932180fe1 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -663,7 +663,7 @@ bool GPG_Application::startEngine(void) */ // create a scene converter, create and convert the stratingscene - m_sceneconverter = new KX_BlenderSceneConverter(m_maggie,0, m_ketsjiengine); + m_sceneconverter = new KX_BlenderSceneConverter(m_maggie, m_ketsjiengine); if (m_sceneconverter) { STR_String startscenename = m_startSceneName.Ptr(); diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index b69188e5476..2433c587179 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -86,6 +86,8 @@ extern "C" #include "BKE_main.h" #include "BKE_utildefines.h" +#include "RNA_define.h" + #ifdef WIN32 #include <windows.h> #ifdef NDEBUG @@ -344,6 +346,8 @@ int main(int argc, char** argv) */ #endif // __APPLE__ + RNA_init(); + init_nodesystem(); initglobals(); diff --git a/source/gameengine/GamePlayer/ghost/Makefile b/source/gameengine/GamePlayer/ghost/Makefile index c82edca0d45..49ad9457ee3 100644 --- a/source/gameengine/GamePlayer/ghost/Makefile +++ b/source/gameengine/GamePlayer/ghost/Makefile @@ -68,6 +68,7 @@ CPPFLAGS += -I../../../blender/blenlib CPPFLAGS += -I../../../blender/blenloader CPPFLAGS += -I../../../blender/imbuf CPPFLAGS += -I../../../blender/makesdna +CPPFLAGS += -I../../../blender/makesrna CPPFLAGS += -I../../../blender/readblenfile CPPFLAGS += -I../../../blender/gpu diff --git a/source/gameengine/GamePlayer/ghost/SConscript b/source/gameengine/GamePlayer/ghost/SConscript index 1cb7c9f2457..390b6f5e089 100644 --- a/source/gameengine/GamePlayer/ghost/SConscript +++ b/source/gameengine/GamePlayer/ghost/SConscript @@ -26,6 +26,7 @@ incs = ['.', '#source/blender', '#source/blender/include', '#source/blender/makesdna', + '#source/blender/makesrna', '#source/gameengine/BlenderRoutines', '#source/gameengine/Rasterizer', '#source/gameengine/GameLogic', diff --git a/source/gameengine/Ketsji/CMakeLists.txt b/source/gameengine/Ketsji/CMakeLists.txt index 4aaa49a8493..ee1ff2c6502 100644 --- a/source/gameengine/Ketsji/CMakeLists.txt +++ b/source/gameengine/Ketsji/CMakeLists.txt @@ -53,7 +53,8 @@ SET(INC ../../../source/gameengine/Ketsji ../../../source/blender/blenlib ../../../source/blender/blenkernel - ../../../source/blender/python/api2_2x + ../../../source/blender/python + ../../../source/blender/python/generic ../../../source/blender ../../../source/blender/include ../../../source/blender/makesdna diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp index ba4d6e22872..40f6c99c03c 100644 --- a/source/gameengine/Ketsji/KX_Camera.cpp +++ b/source/gameengine/Ketsji/KX_Camera.cpp @@ -547,12 +547,15 @@ PyTypeObject KX_Camera::Type = { 0, 0, py_base_repr, - 0,0, + 0, + &KX_GameObject::Sequence, &KX_GameObject::Mapping, 0,0,0, py_base_getattro, py_base_setattro, - 0,0,0,0,0,0,0,0,0, + 0, + Py_TPFLAGS_DEFAULT, + 0,0,0,0,0,0,0, Methods }; diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 7f417b325c8..b266095c715 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1287,7 +1287,7 @@ PyObject* KX_GameObject::PyGetPosition() return PyObjectFrom(NodeGetWorldPosition()); } -PyObject *KX_GameObject::Map_GetItem(PyObject *self_v, PyObject *item) +static PyObject *Map_GetItem(PyObject *self_v, PyObject *item) { KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(self_v); const char *attr_str= PyString_AsString(item); @@ -1295,7 +1295,7 @@ PyObject *KX_GameObject::Map_GetItem(PyObject *self_v, PyObject *item) PyObject* pyconvert; if (self==NULL) { - PyErr_SetString(PyExc_SystemError, BGE_PROXY_ERROR_MSG); + PyErr_SetString(PyExc_SystemError, "val = gameOb[key]: KX_GameObject, "BGE_PROXY_ERROR_MSG); return NULL; } @@ -1321,7 +1321,7 @@ PyObject *KX_GameObject::Map_GetItem(PyObject *self_v, PyObject *item) } -int KX_GameObject::Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val) +static int Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val) { KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(self_v); const char *attr_str= PyString_AsString(key); @@ -1329,7 +1329,7 @@ int KX_GameObject::Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val) PyErr_Clear(); if (self==NULL) { - PyErr_SetString(PyExc_SystemError, BGE_PROXY_ERROR_MSG); + PyErr_SetString(PyExc_SystemError, "gameOb[key] = value: KX_GameObject, "BGE_PROXY_ERROR_MSG); return -1; } @@ -1409,11 +1409,40 @@ int KX_GameObject::Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val) return 0; /* success */ } -/* Cant set the len otherwise it can evaluate as false */ +static int Seq_Contains(PyObject *self_v, PyObject *value) +{ + KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(self_v); + + if (self==NULL) { + PyErr_SetString(PyExc_SystemError, "val in gameOb: KX_GameObject, "BGE_PROXY_ERROR_MSG); + return -1; + } + + if(PyString_Check(value) && self->GetProperty(PyString_AsString(value))) + return 1; + + if (self->m_attr_dict && PyDict_GetItem(self->m_attr_dict, value)) + return 1; + + return 0; +} + + PyMappingMethods KX_GameObject::Mapping = { (lenfunc)NULL , /*inquiry mp_length */ - (binaryfunc)KX_GameObject::Map_GetItem, /*binaryfunc mp_subscript */ - (objobjargproc)KX_GameObject::Map_SetItem, /*objobjargproc mp_ass_subscript */ + (binaryfunc)Map_GetItem, /*binaryfunc mp_subscript */ + (objobjargproc)Map_SetItem, /*objobjargproc mp_ass_subscript */ +}; + +PySequenceMethods KX_GameObject::Sequence = { + NULL, /* Cant set the len otherwise it can evaluate as false */ + NULL, /* sq_concat */ + NULL, /* sq_repeat */ + NULL, /* sq_item */ + NULL, /* sq_slice */ + NULL, /* sq_ass_item */ + NULL, /* sq_ass_slice */ + (objobjproc)Seq_Contains, /* sq_contains */ }; PyTypeObject KX_GameObject::Type = { @@ -1433,12 +1462,15 @@ PyTypeObject KX_GameObject::Type = { 0, 0, py_base_repr, - 0,0, + 0, + &Sequence, &Mapping, 0,0,0, py_base_getattro, py_base_setattro, - 0,0,0,0,0,0,0,0,0, + 0, + Py_TPFLAGS_DEFAULT, + 0,0,0,0,0,0,0, Methods }; @@ -2207,7 +2239,7 @@ PyObject* KX_GameObject::PyGetChildrenRecursive() PyObject* KX_GameObject::PyGetMesh(PyObject* args) { - ShowDeprecationWarning("getMesh()", "the meshes property"); + ShowDeprecationWarning("getMesh()", "the meshes property (now a list of meshes)"); int mesh = 0; @@ -2779,16 +2811,11 @@ PyObject* KX_GameObject::Pyget(PyObject *args) /* Matches python dict.has_key() */ PyObject* KX_GameObject::Pyhas_key(PyObject* value) { - if(PyString_Check(value) && GetProperty(PyString_AsString(value))) - Py_RETURN_TRUE; - - if (m_attr_dict && PyDict_GetItem(m_attr_dict, value)) - Py_RETURN_TRUE; - - Py_RETURN_FALSE; + // the ONLY error case is invalid data, this is checked by the macro'd static function + // that calls this one. but make sure Seq_Contains doesnt add extra errors later on. + return PyBool_FromLong(Seq_Contains((PyObject *)this, value)); } - /* --------------------------------------------------------------------- * Some stuff taken from the header * --------------------------------------------------------------------- */ diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index dbdea97031d..ff5c8a01e6e 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -917,10 +917,8 @@ public: static PyObject* pyattr_get_actuators(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); /* getitem/setitem */ - static Py_ssize_t Map_Len(PyObject* self); static PyMappingMethods Mapping; - static PyObject* Map_GetItem(PyObject *self_v, PyObject *item); - static int Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val); + static PySequenceMethods Sequence; private : diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index b30b79e7f23..a43ea59220b 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -1078,6 +1078,11 @@ void KX_KetsjiEngine::SetCameraOverrideClipping(float near, float far) m_overrideCamFar = far; } +void KX_KetsjiEngine::SetCameraOverrideLens(float lens) +{ + m_overrideCamLens = lens; +} + void KX_KetsjiEngine::GetSceneViewport(KX_Scene *scene, KX_Camera* cam, RAS_Rect& area, RAS_Rect& viewport) { // In this function we make sure the rasterizer settings are upto @@ -1351,6 +1356,8 @@ void KX_KetsjiEngine::PostProcessScene(KX_Scene* scene) KX_Camera* activecam = NULL; RAS_CameraData camdata = RAS_CameraData(); + if (override_camera) camdata.m_lens = m_overrideCamLens; + activecam = new KX_Camera(scene,KX_Scene::m_callbacks,camdata); activecam->SetName("__default__cam__"); diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h index 6fa379e551a..abba23ca376 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.h +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h @@ -129,6 +129,7 @@ private: MT_CmMatrix4x4 m_overrideCamViewMat; float m_overrideCamNear; float m_overrideCamFar; + float m_overrideCamLens; bool m_stereo; int m_curreye; @@ -253,6 +254,7 @@ public: void SetCameraOverrideProjectionMatrix(const MT_CmMatrix4x4& mat); void SetCameraOverrideViewMatrix(const MT_CmMatrix4x4& mat); void SetCameraOverrideClipping(float near, float far); + void SetCameraOverrideLens(float lens); /** * Sets display of all frames. diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp index fe575384a35..ae9e097a96e 100644 --- a/source/gameengine/Ketsji/KX_Light.cpp +++ b/source/gameengine/Ketsji/KX_Light.cpp @@ -35,6 +35,8 @@ #pragma warning (disable : 4786) #endif +#include "GL/glew.h" + #include "KX_Light.h" #include "KX_Camera.h" #include "RAS_IRasterizer.h" @@ -43,6 +45,7 @@ #include "KX_PyMath.h" #include "DNA_object_types.h" +#include "DNA_scene_types.h" #include "GPU_material.h" KX_LightObject::KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks, @@ -56,8 +59,8 @@ KX_LightObject::KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks, m_rendertools(rendertools) { m_lightobj = lightobj; - m_lightobj.m_worldmatrix = GetOpenGLMatrixPtr(); m_lightobj.m_scene = sgReplicationInfo; + m_lightobj.m_light = this; m_rendertools->AddLight(&m_lightobj); m_glsl = glsl; m_blenderscene = ((KX_Scene*)sgReplicationInfo)->GetBlenderScene(); @@ -84,12 +87,102 @@ CValue* KX_LightObject::GetReplica() replica->ProcessReplica(); - replica->m_lightobj.m_worldmatrix = replica->GetOpenGLMatrixPtr(); + replica->m_lightobj.m_light = replica; m_rendertools->AddLight(&replica->m_lightobj); return replica; } +bool KX_LightObject::ApplyLight(KX_Scene *kxscene, int oblayer, int slot) +{ + KX_Scene* lightscene = (KX_Scene*)m_lightobj.m_scene; + float vec[4]; + int scenelayer = ~0; + + if(kxscene && kxscene->GetBlenderScene()) + scenelayer = kxscene->GetBlenderScene()->lay; + + /* only use lights in the same layer as the object */ + if(!(m_lightobj.m_layer & oblayer)) + return false; + /* only use lights in the same scene, and in a visible layer */ + if(kxscene != lightscene || !(m_lightobj.m_layer & scenelayer)) + return false; + + // lights don't get their openGL matrix updated, do it now + if(GetSGNode()->IsDirty()) + GetOpenGLMatrix(); + + MT_CmMatrix4x4& worldmatrix= *GetOpenGLMatrixPtr(); + + vec[0] = worldmatrix(0,3); + vec[1] = worldmatrix(1,3); + vec[2] = worldmatrix(2,3); + vec[3] = 1.0f; + + if(m_lightobj.m_type==RAS_LightObject::LIGHT_SUN) { + + vec[0] = worldmatrix(0,2); + vec[1] = worldmatrix(1,2); + vec[2] = worldmatrix(2,2); + //vec[0]= base->object->obmat[2][0]; + //vec[1]= base->object->obmat[2][1]; + //vec[2]= base->object->obmat[2][2]; + vec[3]= 0.0; + glLightfv((GLenum)(GL_LIGHT0+slot), GL_POSITION, vec); + } + else { + //vec[3]= 1.0; + glLightfv((GLenum)(GL_LIGHT0+slot), GL_POSITION, vec); + glLightf((GLenum)(GL_LIGHT0+slot), GL_CONSTANT_ATTENUATION, 1.0); + glLightf((GLenum)(GL_LIGHT0+slot), GL_LINEAR_ATTENUATION, m_lightobj.m_att1/m_lightobj.m_distance); + // without this next line it looks backward compatible. + //attennuation still is acceptable + glLightf((GLenum)(GL_LIGHT0+slot), GL_QUADRATIC_ATTENUATION, m_lightobj.m_att2/(m_lightobj.m_distance*m_lightobj.m_distance)); + + if(m_lightobj.m_type==RAS_LightObject::LIGHT_SPOT) { + vec[0] = -worldmatrix(0,2); + vec[1] = -worldmatrix(1,2); + vec[2] = -worldmatrix(2,2); + //vec[0]= -base->object->obmat[2][0]; + //vec[1]= -base->object->obmat[2][1]; + //vec[2]= -base->object->obmat[2][2]; + glLightfv((GLenum)(GL_LIGHT0+slot), GL_SPOT_DIRECTION, vec); + glLightf((GLenum)(GL_LIGHT0+slot), GL_SPOT_CUTOFF, m_lightobj.m_spotsize/2.0); + glLightf((GLenum)(GL_LIGHT0+slot), GL_SPOT_EXPONENT, 128.0*m_lightobj.m_spotblend); + } + else + glLightf((GLenum)(GL_LIGHT0+slot), GL_SPOT_CUTOFF, 180.0); + } + + if (m_lightobj.m_nodiffuse) { + vec[0] = vec[1] = vec[2] = vec[3] = 0.0; + } + else { + vec[0]= m_lightobj.m_energy*m_lightobj.m_red; + vec[1]= m_lightobj.m_energy*m_lightobj.m_green; + vec[2]= m_lightobj.m_energy*m_lightobj.m_blue; + vec[3]= 1.0; + } + + glLightfv((GLenum)(GL_LIGHT0+slot), GL_DIFFUSE, vec); + if(m_lightobj.m_nospecular) + { + vec[0] = vec[1] = vec[2] = vec[3] = 0.0; + } + else if (m_lightobj.m_nodiffuse) { + vec[0]= m_lightobj.m_energy*m_lightobj.m_red; + vec[1]= m_lightobj.m_energy*m_lightobj.m_green; + vec[2]= m_lightobj.m_energy*m_lightobj.m_blue; + vec[3]= 1.0; + } + + glLightfv((GLenum)(GL_LIGHT0+slot), GL_SPECULAR, vec); + glEnable((GLenum)(GL_LIGHT0+slot)); + + return true; +} + GPULamp *KX_LightObject::GetGPULamp() { if(m_glsl) @@ -200,12 +293,15 @@ PyTypeObject KX_LightObject::Type = { 0, 0, py_base_repr, - 0,0, + 0, + &KX_GameObject::Sequence, &KX_GameObject::Mapping, 0,0,0, py_base_getattro, py_base_setattro, - 0,0,0,0,0,0,0,0,0, + 0, + Py_TPFLAGS_DEFAULT, + 0,0,0,0,0,0,0, Methods }; diff --git a/source/gameengine/Ketsji/KX_Light.h b/source/gameengine/Ketsji/KX_Light.h index 35f25515e3b..358c705080a 100644 --- a/source/gameengine/Ketsji/KX_Light.h +++ b/source/gameengine/Ketsji/KX_Light.h @@ -54,7 +54,10 @@ public: virtual CValue* GetReplica(); RAS_LightObject* GetLightData() { return &m_lightobj;} - /* GLSL shadow */ + /* OpenGL Light */ + bool ApplyLight(KX_Scene *kxscene, int oblayer, int slot); + + /* GLSL Light */ struct GPULamp *GetGPULamp(); bool HasShadowBuffer(); int GetShadowLayer(); diff --git a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp index a098d99864f..4ec901a2f5e 100644 --- a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp +++ b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp @@ -630,6 +630,7 @@ PyObject* initPythonConstraintBinding() #if (PY_VERSION_HEX >= 0x03000000) m = PyModule_Create(&PhysicsConstraints_module_def); + PyDict_SetItemString(PySys_GetObject("modules"), PhysicsConstraints_module_def.m_name, m); #else m = Py_InitModule4("PhysicsConstraints", physicsconstraints_methods, PhysicsConstraints_module_documentation, diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index fc3e48f504c..736460d33db 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -42,6 +42,13 @@ #pragma warning (disable : 4786) #endif //WIN32 +extern "C" { + #include "bpy_internal_import.h" /* from the blender python api, but we want to import text too! */ + #include "Mathutils.h" // Blender.Mathutils module copied here so the blenderlayer can use. + #include "Geometry.h" // Blender.Geometry module copied here so the blenderlayer can use. + #include "BGL.h" +} + #include "KX_PythonInit.h" //python physics binding #include "KX_PyConstraintBinding.h" @@ -70,6 +77,7 @@ #include "MT_Vector3.h" #include "MT_Point3.h" #include "ListValue.h" +#include "InputParser.h" #include "KX_Scene.h" #include "SND_DeviceManager.h" @@ -81,23 +89,11 @@ #include "PyObjectPlus.h" -//XXX -#if 0 - #include "KX_PythonInitTypes.h" /* we only need this to get a list of libraries from the main struct */ #include "DNA_ID.h" -extern "C" { - #include "bpy_internal_import.h" /* from the blender python api, but we want to import text too! */ -#if PY_VERSION_HEX < 0x03000000 - #include "Mathutils.h" // Blender.Mathutils module copied here so the blenderlayer can use. - #include "Geometry.h" // Blender.Geometry module copied here so the blenderlayer can use. - #include "BGL.h" -#endif -} -#endif #include "marshal.h" /* python header for loading/saving dicts */ @@ -502,6 +498,32 @@ static PyObject *pyPrintExt(PyObject *,PyObject *,PyObject *) } +static PyObject *gEvalExpression(PyObject*, PyObject* value) +{ + char* txt= PyString_AsString(value); + + if (txt==NULL) { + PyErr_SetString(PyExc_TypeError, "Expression.calc(text): expects a single string argument"); + return NULL; + } + + CParser parser; + CExpression* expr = parser.ProcessText(txt); + CValue* val = expr->Calculate(); + expr->Release(); + + if (val) { + PyObject* pyobj = val->ConvertValueToPython(); + if (pyobj) + return pyobj; + else + return val->GetProxy(); + } + + Py_RETURN_NONE; +} + + static struct PyMethodDef game_methods[] = { {"expandPath", (PyCFunction)gPyExpandPath, METH_VARARGS, (PY_METHODCHAR)gPyExpandPath_doc}, {"sendMessage", (PyCFunction)gPySendMessage, METH_VARARGS, (PY_METHODCHAR)gPySendMessage_doc}, @@ -530,6 +552,7 @@ static struct PyMethodDef game_methods[] = { {"getAverageFrameRate", (PyCFunction) gPyGetAverageFrameRate, METH_NOARGS, (PY_METHODCHAR)"Gets the estimated average frame rate"}, {"getBlendFileList", (PyCFunction)gPyGetBlendFileList, METH_VARARGS, (PY_METHODCHAR)"Gets a list of blend files in the same directory as the current blend file"}, {"PrintGLInfo", (PyCFunction)pyPrintExt, METH_NOARGS, (PY_METHODCHAR)"Prints GL Extension Info"}, + {"EvalExpression", (PyCFunction)gEvalExpression, METH_O, (PY_METHODCHAR)"Evaluate a string as a game logic expression"}, {NULL, (PyCFunction) NULL, 0, NULL } }; @@ -1036,6 +1059,7 @@ PyObject* initGameLogic(KX_KetsjiEngine *engine, KX_Scene* scene) // quick hack // Create the module and add the functions #if (PY_VERSION_HEX >= 0x03000000) m = PyModule_Create(&GameLogic_module_def); + PyDict_SetItemString(PySys_GetObject("modules"), GameLogic_module_def.m_name, m); #else m = Py_InitModule4("GameLogic", game_methods, GameLogic_module_documentation, @@ -1352,10 +1376,9 @@ PyObject *KXpy_import(PyObject *self, PyObject *args) } /* Import blender texts as python modules */ - /* XXX 2.5 - * m= bpy_text_import(name, &found); + m= bpy_text_import(name, &found); if (m) - return m; */ + return m; if(found==0) /* if its found but could not import then it has its own error */ PyErr_Format(PyExc_ImportError, "Import of external Module %.20s not allowed.", name); @@ -1379,9 +1402,9 @@ PyObject *KXpy_reload(PyObject *self, PyObject *args) { if( !PyArg_ParseTuple( args, "O:bpy_reload_meth", &module ) ) return NULL; - /* XXX 2.5 newmodule= bpy_text_reimport( module, &found ); + newmodule= bpy_text_reimport( module, &found ); if (newmodule) - return newmodule; */ + return newmodule; if (found==0) /* if its found but could not import then it has its own error */ PyErr_SetString(PyExc_ImportError, "reload(module): failed to reload from blenders internal text"); @@ -1462,8 +1485,8 @@ void setSandbox(TPythonSecurityLevel level) */ default: /* Allow importing internal text, from bpy_internal_import.py */ - /* XXX 2.5 PyDict_SetItemString(d, "reload", item=PyCFunction_New(bpy_reload_meth, NULL)); Py_DECREF(item); */ - /* XXX 2.5 PyDict_SetItemString(d, "__import__", item=PyCFunction_New(bpy_import_meth, NULL)); Py_DECREF(item); */ + PyDict_SetItemString(d, "reload", item=PyCFunction_New(bpy_reload_meth, NULL)); Py_DECREF(item); + PyDict_SetItemString(d, "__import__", item=PyCFunction_New(bpy_import_meth, NULL)); Py_DECREF(item); break; } } @@ -1606,9 +1629,9 @@ PyObject* initGamePlayerPythonScripting(const STR_String& progname, TPythonSecur //importBlenderModules() setSandbox(level); - /* XXX 2.5 initPyTypes(); */ + initPyTypes(); - /* XXX 2.5 bpy_import_main_set(maggie); */ + bpy_import_main_set(maggie); initPySysObjects(maggie); @@ -1626,7 +1649,7 @@ void exitGamePlayerPythonScripting() restorePySysObjects(); /* get back the original sys.path and clear the backup */ Py_Finalize(); - /* XXX 2.5 bpy_import_main_set(NULL); */ + bpy_import_main_set(NULL); PyObjectPlus::ClearDeprecationWarning(); } @@ -1645,9 +1668,9 @@ PyObject* initGamePythonScripting(const STR_String& progname, TPythonSecurityLev Py_FrozenFlag=1; setSandbox(level); - /* XXX 2.5 initPyTypes(); */ + initPyTypes(); - /* XXX 2.5 bpy_import_main_set(maggie); */ + bpy_import_main_set(maggie); initPySysObjects(maggie); @@ -1660,7 +1683,7 @@ PyObject* initGamePythonScripting(const STR_String& progname, TPythonSecurityLev void exitGamePythonScripting() { restorePySysObjects(); /* get back the original sys.path and clear the backup */ - /* XXX 2.5 bpy_import_main_set(NULL); */ + bpy_import_main_set(NULL); PyObjectPlus::ClearDeprecationWarning(); } @@ -1702,6 +1725,7 @@ PyObject* initRasterizer(RAS_IRasterizer* rasty,RAS_ICanvas* canvas) // Create the module and add the functions #if (PY_VERSION_HEX >= 0x03000000) m = PyModule_Create(&Rasterizer_module_def); + PyDict_SetItemString(PySys_GetObject("modules"), Rasterizer_module_def.m_name, m); #else m = Py_InitModule4("Rasterizer", rasterizer_methods, Rasterizer_module_documentation, @@ -1836,6 +1860,7 @@ PyObject* initGameKeys() // Create the module and add the functions #if (PY_VERSION_HEX >= 0x03000000) m = PyModule_Create(&GameKeys_module_def); + PyDict_SetItemString(PySys_GetObject("modules"), GameKeys_module_def.m_name, m); #else m = Py_InitModule4("GameKeys", gamekeys_methods, GameKeys_module_documentation, @@ -1970,26 +1995,20 @@ PyObject* initGameKeys() return d; } -#if PY_VERSION_HEX < 0x03000000 PyObject* initMathutils() { - return NULL; //XXX Mathutils_Init("Mathutils"); // Use as a top level module in BGE + return Mathutils_Init("Mathutils"); // Use as a top level module in BGE } PyObject* initGeometry() { - return NULL; // XXX Geometry_Init("Geometry"); // Use as a top level module in BGE + return Geometry_Init("Geometry"); // Use as a top level module in BGE } PyObject* initBGL() { - return NULL; // XXX 2.5 BGL_Init("BGL"); // Use as a top level module in BGE + return BGL_Init("BGL"); // Use as a top level module in BGE } -#else // TODO Py3k conversion -PyObject* initMathutils() {Py_INCREF(Py_None);return Py_None;} -PyObject* initGeometry() {Py_INCREF(Py_None);return Py_None;} -PyObject* initBGL() {Py_INCREF(Py_None);return Py_None;} -#endif void KX_SetActiveScene(class KX_Scene* scene) { @@ -2022,11 +2041,17 @@ int saveGamePythonConfig( char **marshal_buffer) if (pyGlobalDictMarshal) { // for testing only // PyObject_Print(pyGlobalDictMarshal, stderr, 0); - + char *marshal_cstring; + +#if PY_VERSION_HEX < 0x03000000 + marshal_cstring = PyString_AsString(pyGlobalDictMarshal); marshal_length= PyString_Size(pyGlobalDictMarshal); +#else // py3 uses byte arrays + marshal_cstring = PyBytes_AsString(pyGlobalDictMarshal); + marshal_length= PyBytes_Size(pyGlobalDictMarshal); +#endif *marshal_buffer = new char[marshal_length + 1]; - memcpy(*marshal_buffer, PyString_AsString(pyGlobalDictMarshal), marshal_length); - + memcpy(*marshal_buffer, marshal_cstring, marshal_length); Py_DECREF(pyGlobalDictMarshal); } else { printf("Error, GameLogic.globalDict could not be marshal'd\n"); @@ -2103,5 +2128,5 @@ void setGamePythonPath(char *path) // engine but loading blend files within the BGE wont overwrite gp_GamePythonPathOrig void resetGamePythonPath() { - gp_GamePythonPathOrig[0] == '\0'; + gp_GamePythonPathOrig[0] = '\0'; } diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp index 5c02a2db646..c13271f66a5 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.cpp +++ b/source/gameengine/Ketsji/KX_SoundActuator.cpp @@ -112,7 +112,7 @@ bool KX_SoundActuator::Update(double curtime, bool frame) return false; // actual audio device playing state - bool isplaying = (m_soundObject->GetPlaystate() != SND_STOPPED) ? true : false; + bool isplaying = (m_soundObject->GetPlaystate() != SND_STOPPED && m_soundObject->GetPlaystate() != SND_INITIAL) ? true : false; if (m_pino) { @@ -194,7 +194,7 @@ bool KX_SoundActuator::Update(double curtime, bool frame) } } // verify that the sound is still playing - isplaying = (m_soundObject->GetPlaystate() != SND_STOPPED) ? true : false; + isplaying = (m_soundObject->GetPlaystate() != SND_STOPPED && m_soundObject->GetPlaystate() != SND_INITIAL) ? true : false; if (isplaying) { diff --git a/source/gameengine/Ketsji/Makefile b/source/gameengine/Ketsji/Makefile index bdc0b335b02..59b3ff178fb 100644 --- a/source/gameengine/Ketsji/Makefile +++ b/source/gameengine/Ketsji/Makefile @@ -41,7 +41,7 @@ CPPFLAGS += -I$(NAN_GLEW)/include CPPFLAGS += -I$(OPENGL_HEADERS) CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) CPPFLAGS += -I../../blender/python -CPPFLAGS += -I../../blender/python/api2_2x +CPPFLAGS += -I../../blender/python/generic CPPFLAGS += -I$(NAN_STRING)/include CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_SUMO) -I$(NAN_MOTO)/include diff --git a/source/gameengine/Ketsji/SConscript b/source/gameengine/Ketsji/SConscript index 5ab15c9eab3..49dbacc8916 100644 --- a/source/gameengine/Ketsji/SConscript +++ b/source/gameengine/Ketsji/SConscript @@ -6,32 +6,7 @@ Import ('env') sources = env.Glob('*.cpp') defs = '' -# XXX 2.5 -# Mathutils C files. -""" -if not env['BF_PYTHON_VERSION'].startswith('3'): - # TODO - py3 support - sources.extend([\ - '#source/blender/python/api2_2x/Mathutils.c',\ - '#source/blender/python/api2_2x/Geometry.c',\ - '#source/blender/python/api2_2x/euler.c',\ - '#source/blender/python/api2_2x/matrix.c',\ - '#source/blender/python/api2_2x/quat.c',\ - '#source/blender/python/api2_2x/vector.c',\ - '#source/blender/python/api2_2x/constant.c',\ - ]) - - sources.extend([\ - '#source/blender/python/api2_2x/BGL.c' - ]) - -sources.extend([\ - '#source/blender/python/api2_2x/bpy_internal_import.c' -]) -""" - - -incs = '. #source/blender/python/api2_2x' # Only for Mathutils! and bpy_internal_import.h, be very careful +incs = '. #source/blender/python/generic' # Only for Mathutils! and bpy_internal_import.h, be very careful incs += ' #source/kernel/gen_system #intern/string #intern/guardedalloc' incs += ' #source/gameengine/Rasterizer/RAS_OpenGLRasterizer' diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index d22c09b4d3e..3c41a856660 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -979,6 +979,7 @@ void CcdPhysicsController::setScaling(float scaleX,float scaleY,float scaleZ) if (m_object && m_object->getCollisionShape()) { + m_object->activate(true); // without this, sleeping objects scale wont be applied in bullet if python changes the scale - Campbell. m_object->getCollisionShape()->setLocalScaling(m_cci.m_scaling); //printf("no inertia recalc for fixed objects with mass=0\n"); @@ -1016,14 +1017,21 @@ void CcdPhysicsController::ApplyTorque(float torqueX,float torqueY,float torque } if (body) { - //workaround for incompatibility between 'DYNAMIC' game object, and angular factor - //a DYNAMIC object has some inconsistency: it has no angular effect due to collisions, but still has torque - const btVector3& angFac = body->getAngularFactor(); - btVector3 tmpFac(0,0,1); - body->setAngularFactor(tmpFac); - body->applyTorque(torque); - body->setAngularFactor(angFac); - } + if (m_cci.m_bRigid) + { + body->applyTorque(torque); + } + else + { + //workaround for incompatibility between 'DYNAMIC' game object, and angular factor + //a DYNAMIC object has some inconsistency: it has no angular effect due to collisions, but still has torque + const btVector3& angFac = body->getAngularFactor(); + btVector3 tmpFac(0,0,1); + body->setAngularFactor(tmpFac); + body->applyTorque(torque); + body->setAngularFactor(angFac); + } + } } } diff --git a/source/gameengine/PyDoc/GameLogic.py b/source/gameengine/PyDoc/GameLogic.py index 3ec30a63c58..46f00fa7ea6 100644 --- a/source/gameengine/PyDoc/GameLogic.py +++ b/source/gameengine/PyDoc/GameLogic.py @@ -271,7 +271,7 @@ Documentation for the GameLogic Module. @var KX_PARENT_REMOVE: @var KX_PARENT_SET: -@group Shader: MODELMATRIX*, MODELVIEWMATRIX*, VIEWMATRIX*, CAM_POS, CONSTANT_TIMER +@group Shader: MODELMATRIX*, MODELVIEWMATRIX*, VIEWMATRIX*, CAM_POS, CONSTANT_TIMER, SHD_TANGENT @var VIEWMATRIX: @var VIEWMATRIX_INVERSE: @var VIEWMATRIX_INVERSETRANSPOSE: @@ -285,8 +285,8 @@ Documentation for the GameLogic Module. @var MODELVIEWMATRIX_INVERSETRANSPOSE: @var MODELVIEWMATRIX_TRANSPOSE: @var CAM_POS: Current camera position -@var CONSTANT_TIMER: Current camera position -@var SHD_TANGENT: Current camera position +@var CONSTANT_TIMER: User a timer for the uniform value. +@var SHD_TANGENT: Not yet documented. @group Blender Material: BL_* @var BL_DST_ALPHA: @@ -302,6 +302,13 @@ Documentation for the GameLogic Module. @var BL_ZERO: @group Deprecated: addActiveActuator + +@var globalDict: A dictionary that is saved between loading blend files so you can use + it to store inventory and other variables you want to store between + scenes and blend files. It can also be written to a file and loaded + later on with the game load/save actuators. + note: only python built in types such as int/string/bool/float/tuples/lists + can be saved, GameObjects, Actuators etc will not work as expectred. """ import GameTypes @@ -441,6 +448,14 @@ def setPhysicsTicRate(ticrate): @type ticrate: float """ +def EvalExpression(text): + """ + Evaluate the string as an expression, similar to the expression controller logic brick. + @param text: The expression to evaluate. + @type text: string + @return: The result of the expression. The type depends on the expression. + """ + #{ Utility functions def getAverageFrameRate(): """ diff --git a/source/gameengine/PyDoc/GameTypes.py b/source/gameengine/PyDoc/GameTypes.py index 4ab175a8f6c..63dd1a7fabf 100644 --- a/source/gameengine/PyDoc/GameTypes.py +++ b/source/gameengine/PyDoc/GameTypes.py @@ -336,15 +336,23 @@ class BL_ActionActuator(SCA_IActuator): @ivar framePropName: The name of the property that is set to the current frame number. @type framePropName: string """ - def setChannel(channel, matrix, mode = False): + def setChannel(channel, matrix): """ - @param channel: A string specifying the name of the bone channel. + Alternative to the 2 arguments, 4 arguments (channel, matrix, loc, size, quat) are also supported. + + @param channel: A string specifying the name of the bone channel, created if missing. @type channel: string @param matrix: A 4x4 matrix specifying the overriding transformation as an offset from the bone's rest position. @type matrix: list [[float]] - @param mode: True for armature/world space, False for bone space - @type mode: boolean + """ + + def getChannel(channel): + """ + @param channel: A string specifying the name of the bone channel. error raised if missing. + @type channel: string + @rtype: tuple + @return: (loc, size, quat) """ #{ Deprecated diff --git a/source/gameengine/Rasterizer/RAS_LightObject.h b/source/gameengine/Rasterizer/RAS_LightObject.h index 6b63a891981..b45a35e4266 100644 --- a/source/gameengine/Rasterizer/RAS_LightObject.h +++ b/source/gameengine/Rasterizer/RAS_LightObject.h @@ -39,8 +39,9 @@ struct RAS_LightObject LIGHT_NORMAL }; bool m_modified; - int m_layer; + int m_layer; void *m_scene; + void *m_light; float m_energy; float m_distance; @@ -55,7 +56,6 @@ struct RAS_LightObject float m_spotblend; LightType m_type; - MT_CmMatrix4x4* m_worldmatrix; bool m_nodiffuse; bool m_nospecular; diff --git a/source/gameengine/VideoTexture/blendVideoTex.cpp b/source/gameengine/VideoTexture/blendVideoTex.cpp index 1dcc72c8f7d..dad52a426b6 100644 --- a/source/gameengine/VideoTexture/blendVideoTex.cpp +++ b/source/gameengine/VideoTexture/blendVideoTex.cpp @@ -204,6 +204,7 @@ PyObject* initVideoTexture(void) #if (PY_VERSION_HEX >= 0x03000000) m = PyModule_Create(&VideoTexture_module_def); + PyDict_SetItemString(PySys_GetObject("modules"), VideoTexture_module_def.m_name, m); #else m = Py_InitModule4("VideoTexture", moduleMethods, "Module that allows to play video files on textures in GameBlender.", diff --git a/tools/Blender.py b/tools/Blender.py index bb82f9caa1d..164a9d097e6 100644 --- a/tools/Blender.py +++ b/tools/Blender.py @@ -51,6 +51,7 @@ blenderdeps = [] # don't manipulate this one outside this module! possible_types = ['core'] # can be set in ie. SConstruct libs = {} +vcp = [] def getresources(): return resources @@ -406,7 +407,8 @@ class BlenderEnvironment(SConsEnvironment): SConsEnvironment.Default(self, res) resources.append(res) - def BlenderLib(self=None, libname=None, sources=None, includes=[], defines=[], libtype='common', priority = 100, compileflags=None, cc_compileflags=None, cxx_compileflags=None): + def BlenderLib(self=None, libname=None, sources=None, includes=[], defines=[], libtype='common', priority = 100, compileflags=None, cc_compileflags=None, cxx_compileflags=None): + global vcp if not self or not libname or not sources: print bc.FAIL+'Cannot continue. Missing argument for BuildBlenderLib '+libname+bc.ENDC self.Exit() @@ -452,12 +454,24 @@ class BlenderEnvironment(SConsEnvironment): targetdir = '#'+targetdir lib = lenv.Library(target= targetdir, source=sources) SConsEnvironment.Default(self, lib) # we add to default target, because this way we get some kind of progress info during build + if self['BF_MSVS'] and self['OURPLATFORM'] in ('win32-vc', 'win64-vc'): + #if targetdir[0] == '#': + # targetdir = targetdir[1:-1] + print "! ",targetdir+ '.vcproj' # + self['MSVSPROJECTSUFFIX'] + vcproject = self.MSVSProject(target = targetdir + '.vcproj', # + self['MSVSPROJECTSUFFIX'], + srcs = sources, + buildtarget = lib, + variant = 'Release', + auto_build_solution=0) + vcp.append(vcproject) + SConsEnvironment.Default(self, vcproject) else: print bc.WARNING+'Not building '+bc.ENDC+bc.OKGREEN+libname+bc.ENDC+' for '+bc.OKBLUE+'BF_QUICK'+bc.ENDC # note: libs is a global add_lib_to_dict(self, libs, libtype, libname, priority) def BlenderProg(self=None, builddir=None, progname=None, sources=None, includes=None, libs=None, libpath=None, binarykind=''): + global vcp print bc.HEADER+'Configuring program '+bc.ENDC+bc.OKGREEN+progname+bc.ENDC lenv = self.Clone() if lenv['OURPLATFORM'] in ('win32-vc', 'cygwin', 'win64-vc'): @@ -495,6 +509,12 @@ class BlenderEnvironment(SConsEnvironment): brs = lenv.Command(f, prog, [bsc]) SConsEnvironment.Default(self, brs) SConsEnvironment.Default(self, prog) + if self['BF_MSVS'] and self['OURPLATFORM'] in ('win32-vc', 'win64-vc') and progname == 'blender': + print "! ",builddir + "/" + progname + '.sln' + sln = self.MSVSProject(target = builddir + "/" + progname + '.sln', + projects= vcp, + variant = 'Release') + SConsEnvironment.Default(self, sln) program_list.append(prog) if lenv['OURPLATFORM']=='darwin': lenv['BINARYKIND'] = binarykind diff --git a/tools/btools.py b/tools/btools.py index bbf8d0a232e..377a389941f 100755 --- a/tools/btools.py +++ b/tools/btools.py @@ -65,6 +65,7 @@ def validate_arguments(args, bc): 'WITH_BF_LCMS', 'BF_LCMS_LIB', 'WITH_BF_DOCS', 'BF_NUMJOBS', + 'BF_MSVS', ] # Have options here that scons expects to be lists @@ -157,7 +158,7 @@ def read_opts(cfg, args): (BoolVariable('WITH_BF_STATICPYTHON', 'Staticly link to python', False)), (BoolVariable('BF_NO_ELBEEM', 'Disable Fluid Sim', False)), - + ('BF_PROFILE_FLAGS', 'Profiling compiler flags', ''), (BoolVariable('WITH_BF_OPENAL', 'Use OpenAL if true', False)), ('BF_OPENAL', 'base path for OpenAL', ''), ('BF_OPENAL_INC', 'include path for python headers', ''), @@ -248,7 +249,7 @@ def read_opts(cfg, args): ('BF_ICONV_LIB', 'iconv library', ''), ('BF_ICONV_LIBPATH', 'iconv library path', ''), - (BoolVariable('WITH_BF_GAMEENGINE', 'Build with gameengine' , True)), + (BoolVariable('WITH_BF_GAMEENGINE', 'Build with gameengine' , False)), (BoolVariable('WITH_BF_ODE', 'Use ODE if true', True)), ('BF_ODE', 'ODE base path', ''), @@ -363,7 +364,8 @@ def read_opts(cfg, args): (BoolVariable('WITH_BF_DOCS', 'Generate API documentation', False)), ('BF_CONFIG', 'SCons python config file used to set default options', 'user_config.py'), - ('BF_NUMJOBS', 'Number of build processes to spawn', '1') + ('BF_NUMJOBS', 'Number of build processes to spawn', '1'), + ('BF_MSVS', 'Generate MSVS project files and solution', False) ) # end of opts.AddOptions() @@ -403,9 +405,13 @@ def NSIS_Installer(target=None, source=None, env=None): ns = open("00.sconsblender.nsi","r") + ns_cnt = str(ns.read()) ns.close() + # set Python version we compile against + ns_cnt = string.replace(ns_cnt, "[PYTHON_VERSION]", env['BF_PYTHON_VERSION']) + # do root rootlist = [] rootdir = os.listdir(inst_dir+"\\") |