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" @@ -309,6 +309,10 @@ RelativePath="..\..\..\source\blender\editors\include\ED_view3d.h" > + + @@ -726,6 +730,10 @@ RelativePath="..\..\..\source\blender\editors\space_buttons\buttons_intern.h" > + + @@ -874,6 +882,10 @@ RelativePath="..\..\..\source\blender\editors\space_sequencer\sequencer_add.c" > + + @@ -882,10 +894,6 @@ RelativePath="..\..\..\source\blender\editors\space_sequencer\sequencer_edit.c" > - - 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 @@ + + 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 @@ - - 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 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): +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.width=width - self.height=height + 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 + ): + self.name=name + self.flag=flag + 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-2.5.py b/release/scripts/export_obj-2.5.py index 2effe7556bc..b206a751dcf 100644 --- a/release/scripts/export_obj-2.5.py +++ b/release/scripts/export_obj-2.5.py @@ -221,20 +221,25 @@ def write(filename, objects, file.write('mtllib %s\n' % ( mtlfilename.split('\\')[-1].split('/')[-1] )) # Get the container mesh. - used for applying modifiers and non mesh objects. - containerMesh = meshName = tempMesh = None - for meshName in Blender.NMesh.GetNames(): - if meshName.startswith(temp_mesh_name): - tempMesh = Mesh.Get(meshName) - if not tempMesh.users: - containerMesh = tempMesh - if not containerMesh: - containerMesh = Mesh.New(temp_mesh_name) + +# containerMesh = meshName = tempMesh = None +# for meshName in Blender.NMesh.GetNames(): +# if meshName.startswith(temp_mesh_name): +# tempMesh = Mesh.Get(meshName) +# if not tempMesh.users: +# containerMesh = tempMesh +# if not containerMesh: +# containerMesh = Mesh.New(temp_mesh_name) + + # XXX this mesh is not removed + # XXX this mesh should not be in database + containerMesh = bpy.data.add_mesh(temp_mesh_name) if EXPORT_ROTX90: mat_xrot90= Blender.Mathutils.RotationMatrix(-90, 4, 'x') - del meshName - del tempMesh +# del meshName +# del tempMesh # Initialize totals, these are updated each object totverts = totuvco = totno = 1 diff --git a/release/ui/buttons_data_armature.py b/release/ui/buttons_data_armature.py index 0b02eee9f7b..1086e77c3f7 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.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) @@ -54,8 +58,8 @@ class DATA_PT_display(DataButtonsPanel): __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() @@ -123,4 +127,4 @@ class DATA_PT_ghost(DataButtonsPanel): bpy.types.register(DATA_PT_skeleton) bpy.types.register(DATA_PT_display) bpy.types.register(DATA_PT_paths) -bpy.types.register(DATA_PT_ghost) +bpy.types.register(DATA_PT_ghost) \ No newline at end of file diff --git a/release/ui/buttons_data_bone.py b/release/ui/buttons_data_bone.py index 3f36a3d4909..2abe76b93c1 100644 --- a/release/ui/buttons_data_bone.py +++ b/release/ui/buttons_data_bone.py @@ -14,8 +14,8 @@ class BONE_PT_bone(BoneButtonsPanel): __label__ = "Bone" def draw(self, context): - bone = context.bone layout = self.layout + bone = context.bone split = layout.split() @@ -50,5 +50,4 @@ class BONE_PT_bone(BoneButtonsPanel): sub.itemR(bone, "cyclic_offset") -bpy.types.register(BONE_PT_bone) - +bpy.types.register(BONE_PT_bone) \ No newline at end of file diff --git a/release/ui/buttons_data_camera.py b/release/ui/buttons_data_camera.py index 362e4f96aa2..57abafb95c8 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.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 @@ -83,4 +87,4 @@ class DATA_PT_camera_display(DataButtonsPanel): col.itemR(cam, "draw_size", text="Size") bpy.types.register(DATA_PT_camera) -bpy.types.register(DATA_PT_camera_display) +bpy.types.register(DATA_PT_camera_display) \ No newline at end of file diff --git a/release/ui/buttons_data_curve.py b/release/ui/buttons_data_curve.py index b8b7d6a324f..f42c991a36f 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.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.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() @@ -141,4 +144,4 @@ class DATA_PT_current_curve(DataButtonsPanel): bpy.types.register(DATA_PT_shape_curve) bpy.types.register(DATA_PT_geometry) bpy.types.register(DATA_PT_pathanim) -bpy.types.register(DATA_PT_current_curve) +bpy.types.register(DATA_PT_current_curve) \ No newline at end of file diff --git a/release/ui/buttons_data_empty.py b/release/ui/buttons_data_empty.py index 7f994c94a07..7eed54d1db6 100644 --- a/release/ui/buttons_data_empty.py +++ b/release/ui/buttons_data_empty.py @@ -7,18 +7,17 @@ class DataButtonsPanel(bpy.types.Panel): __context__ = "data" def poll(self, context): - ob = context.object - return (ob and ob.type == 'EMPTY') + return (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") -bpy.types.register(DATA_PT_empty) +bpy.types.register(DATA_PT_empty) \ No newline at end of file diff --git a/release/ui/buttons_data_lamp.py b/release/ui/buttons_data_lamp.py index f626eb45ed6..7328abc7c35 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.type == '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) diff --git a/release/ui/buttons_data_lattice.py b/release/ui/buttons_data_lattice.py index 8f83cbb45f9..9382ee3525c 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.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) @@ -47,4 +51,4 @@ class DATA_PT_lattice(DataButtonsPanel): row.itemR(lat, "outside") row.itemR(lat, "shape_keys") -bpy.types.register(DATA_PT_lattice) +bpy.types.register(DATA_PT_lattice) \ No newline at end of file diff --git a/release/ui/buttons_data_mesh.py b/release/ui/buttons_data_mesh.py index c3742b38cc1..5e4fb203944 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.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) @@ -44,4 +48,4 @@ class DATA_PT_mesh(DataButtonsPanel): layout.itemR(mesh, "texco_mesh") -bpy.types.register(DATA_PT_mesh) +bpy.types.register(DATA_PT_mesh) \ No newline at end of file diff --git a/release/ui/buttons_data_modifier.py b/release/ui/buttons_data_modifier.py index 0f5d446f889..adc448b20b5 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" @@ -415,4 +411,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..d6f6feaa389 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.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.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..b7703bca94e 100644 --- a/release/ui/buttons_material.py +++ b/release/ui/buttons_material.py @@ -1,4 +1,4 @@ - + import bpy class MaterialButtonsPanel(bpy.types.Panel): @@ -13,13 +13,10 @@ class MATERIAL_PT_preview(MaterialButtonsPanel): __idname__= "MATERIAL_PT_preview" __label__ = "Preview" - def poll(self, context): - return (context.material or context.object) - def draw(self, context): layout = self.layout - mat = context.material + layout.template_preview(mat) class MATERIAL_PT_material(MaterialButtonsPanel): @@ -27,10 +24,11 @@ class MATERIAL_PT_material(MaterialButtonsPanel): __label__ = "Material" def poll(self, context): - return (context.material or context.object) + return (context.object != None) def draw(self, context): layout = self.layout + mat = context.material ob = context.object slot = context.material_slot @@ -49,78 +47,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") + split = layout.split() + split.active = mat.shadeless== False - row = layout.row() - row.column().itemR(sss, "color") - row.column().itemR(sss, "radius") - - 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 +314,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 +343,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 +366,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 +386,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 +412,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) \ No newline at end of file diff --git a/release/ui/buttons_objects.py b/release/ui/buttons_objects.py index 6d75146fe5f..48ab0d2d755 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") @@ -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..09c21b4eb64 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.settings layout.itemR(cloth, "enable_collision", text="") def draw(self, context): layout = self.layout + cloth = context.cloth.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() diff --git a/release/ui/buttons_scene.py b/release/ui/buttons_scene.py index 13b7f6a8dee..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") @@ -133,16 +129,15 @@ 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() @@ -163,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") @@ -204,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() @@ -248,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() @@ -282,4 +274,4 @@ bpy.types.register(RENDER_PT_dimensions) bpy.types.register(RENDER_PT_antialiasing) bpy.types.register(RENDER_PT_shading) bpy.types.register(RENDER_PT_output) -bpy.types.register(RENDER_PT_stamp) +bpy.types.register(RENDER_PT_stamp) \ No newline at end of file diff --git a/release/ui/buttons_texture.py b/release/ui/buttons_texture.py index 9652a5984dc..286c1240d0e 100644 --- a/release/ui/buttons_texture.py +++ b/release/ui/buttons_texture.py @@ -7,19 +7,16 @@ 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) - def draw(self, context): layout = self.layout - tex = context.texture + layout.template_preview(tex) class TEXTURE_PT_texture(TextureButtonsPanel): @@ -27,10 +24,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) def draw(self, context): layout = self.layout + tex = context.texture ma = context.material la = context.lamp @@ -71,7 +69,7 @@ class TEXTURE_PT_mapping(TextureButtonsPanel): __label__ = "Mapping" def poll(self, context): - return (context.texture != None and context.texture.type != 'NONE') + return (context.texture_slot and context.texture and context.texture.type != 'NONE') def draw(self, context): layout = self.layout @@ -118,10 +116,11 @@ class TEXTURE_PT_influence(TextureButtonsPanel): __label__ = "Influence" def poll(self, context): - return (context.texture != None and context.texture.type != 'NONE') + 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 @@ -178,9 +177,7 @@ class TEXTURE_PT_influence(TextureButtonsPanel): class TEXTURE_PT_colors(TextureButtonsPanel): __idname__= "TEXTURE_PT_colors" __label__ = "Colors" - - def poll(self, context): - return (context.texture != None and context.texture.type != 'NONE') + __default_closed__ = True def draw(self, context): layout = self.layout @@ -528,4 +525,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..647ef8aa65e 100644 --- a/release/ui/buttons_world.py +++ b/release/ui/buttons_world.py @@ -12,26 +12,24 @@ class WorldButtonsPanel(bpy.types.Panel): class WORLD_PT_preview(WorldButtonsPanel): __label__ = "Preview" - def poll(self, context): - return (context.scene or context.world) - 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 +59,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 +70,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 +94,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 +115,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 +153,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() @@ -172,4 +176,4 @@ bpy.types.register(WORLD_PT_world) bpy.types.register(WORLD_PT_ambient_occlusion) bpy.types.register(WORLD_PT_mist) bpy.types.register(WORLD_PT_stars) -bpy.types.register(WORLD_PT_color_correction) +bpy.types.register(WORLD_PT_color_correction) \ No newline at end of file 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_sequencer.py b/release/ui/space_sequencer.py index b0caeee3e48..94858db81ad 100644 --- a/release/ui/space_sequencer.py +++ b/release/ui/space_sequencer.py @@ -18,7 +18,7 @@ class SEQUENCER_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, "SEQUENCER_MT_view") row.itemR(st, "display_mode") diff --git a/release/ui/space_text.py b/release/ui/space_text.py index 8daca086111..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,9 @@ 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() @@ -85,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 @@ -140,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..94446f4d1d5 100644 --- a/source/Makefile +++ b/source/Makefile @@ -226,6 +226,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/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 5a3b3207e29..921f5cac67c 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -29,6 +29,7 @@ #include #include #include +#include #include @@ -143,11 +144,12 @@ void blf_font_draw(FontBLF *font, char *str) 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 (pen_x < old_pen_x) + pen_x= old_pen_x; + } } if (font->flags & BLF_USER_KERNING) { @@ -174,7 +176,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, old_pen_x; + float pen_x, pen_y, old_pen_x; int i, has_kerning; if (!font->glyph_cache) @@ -222,11 +224,12 @@ void blf_font_boundbox(FontBLF *font, char *str, rctf *box) 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 (pen_x < old_pen_x) + old_pen_x= pen_x; + } } if (font->flags & BLF_USER_KERNING) { @@ -318,7 +321,7 @@ 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= BLF_USER_KERNING; + font->flags= BLF_USER_KERNING | BLF_FONT_KERNING; font->dpi= 0; font->size= 0; font->kerning= 0.0f; 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/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 d54bc749b71..fb1b2e9cf70 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -800,6 +800,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; @@ -810,7 +811,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); } } 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/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; istrinfo[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..e4c366dd3d7 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -545,7 +545,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"; diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 3ef7b82864c..bf3d27cafbf 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -209,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; @@ -285,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; @@ -668,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); } @@ -3396,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; @@ -3476,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; @@ -3819,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; @@ -4285,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; @@ -4514,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; @@ -5145,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; @@ -5482,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; @@ -5596,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; @@ -5855,7 +5855,7 @@ static void clothModifier_updateDepgraph( } } -CustomDataMask clothModifier_requiredDataMask(ModifierData *md) +CustomDataMask clothModifier_requiredDataMask(Object *ob, ModifierData *md) { CustomDataMask dataMask = 0; @@ -6239,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); @@ -6287,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; imtex[i]; + if(mtex && (ma->septex & (1<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; ipsys->vgroup[i]){ @@ -6637,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; @@ -7551,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; @@ -7815,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 */ @@ -7930,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; @@ -7964,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) @@ -7990,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) { @@ -8049,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; @@ -8078,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) @@ -8105,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) @@ -8717,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; @@ -8727,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; mmtex[m]; - if(mtex && (ma->septex & (1<septex & (1<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; mmtex[m]; - if(mtex && (ma->septex & (1<septex & (1<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 596c27a14f5..52f13eeadb8 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -1761,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/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 6cde040e5fd..1502b475350 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -4733,6 +4733,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) { @@ -9129,6 +9137,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 943e23861ad..f8112406e80 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1884,6 +1884,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 9e0e50a8de5..c52ade1bba8 100644 --- a/source/blender/editors/animation/anim_channels.c +++ b/source/blender/editors/animation/anim_channels.c @@ -721,17 +721,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 c2beb34e7b5..ef682c871bc 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -118,6 +118,7 @@ int ED_operator_node_active(struct bContext *C); 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_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 eb3a037d7b1..62469686e7f 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -491,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 @@ -539,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 * 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 e37f7d2158c..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) @@ -475,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; @@ -733,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; @@ -745,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; } } @@ -759,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) { @@ -839,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 /* ************************************************ */ @@ -1859,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; } @@ -2267,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); @@ -2279,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; iicon= (BIFIconID)icon; + but->flag |= UI_HAS_ICON; + but->flag|= UI_ICON_LEFT; } if (!prop || !RNA_property_editable(&but->rnapoin, prop)) { @@ -2653,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); } @@ -2736,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); } @@ -2779,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; abuttons.first; but; but= but->next) { if(but->flag & UI_BUT_ALIGN) return; diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 0f6dbc430fb..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; @@ -640,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; @@ -1774,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; } @@ -1985,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; } @@ -2027,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; @@ -2806,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; @@ -2951,13 +3128,11 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event) 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; @@ -3421,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 */ diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 83d3ec7fc46..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; @@ -408,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; acurlayout, (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..06582762fdb 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -69,6 +69,7 @@ #define PNL_ACTIVE 2 #define PNL_WAS_ACTIVE 4 #define PNL_ANIM_ALIGN 8 +#define PNL_NEW_ADDED 16 typedef enum uiHandlePanelState { PANEL_STATE_DRAG, @@ -157,18 +158,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 +184,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 +218,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 +248,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 +256,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 diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 7ccb6c5163b..32bcae77e6b 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -1948,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 f1d29ac8688..831a8a5bf6c 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -91,7 +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.5; + style->paneltitle.kerning= 0.0; style->paneltitle.shadow= 5; style->paneltitle.shadx= 2; style->paneltitle.shady= -2; @@ -100,7 +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.5; + style->grouplabel.kerning= 0.0; style->grouplabel.shadow= 3; style->grouplabel.shadx= 1; style->grouplabel.shady= -1; @@ -108,7 +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.5; + style->widgetlabel.kerning= 0.0; style->widgetlabel.shadow= 3; style->widgetlabel.shadx= 1; style->widgetlabel.shady= -1; @@ -117,7 +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.5; + style->widget.kerning= 0.0; style->widget.shadowalpha= 0.25f; style->columnspace= 5; diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 63de328af0f..a0ee264cf01 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1448,10 +1448,8 @@ void uiTemplateCurveMapping(uiLayout *layout, CurveMapping *cumap, int type) void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, char *propname) { - uiBlock *block; uiLayout *uRow, *uSplit, *uCol; PropertyRNA *prop; - StructRNA *type; int groups, cols, layers; int group, col, layer, row; diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 27f42da9fa0..119fd8a3fe5 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; @@ -1118,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 ***************** */ @@ -1552,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; @@ -2079,6 +2148,13 @@ 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); diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 1cb58c986d0..0a65718b708 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); } @@ -608,6 +612,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); + } @@ -1233,6 +1241,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 b6cc57990a3..e88e86ca8db 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/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 3f4d175c94e..2aa6758850e 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -179,6 +179,11 @@ int ED_operator_image_active(bContext *C) return ed_spacetype_test(C, SPACE_IMAGE); } +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); @@ -1192,9 +1197,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..2dba08b4601 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -1245,10 +1245,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 d4782418be7..b82e44f3aa3 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_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 bb923ca6f95..9aaef9fca8a 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 +#include + +#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 +#include + +#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 +#include + +#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; aprop); + 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; aprop.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; nr0) { + /* 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<state_mask = (1<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; atotlinks; 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; atotlinks; 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; atotlinks; 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; atotlinks; 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<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<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; ascaflag |= OB_SHOWSENS; + else if(event==1) ob->scaflag &= ~OB_SHOWSENS; + } + + for(a=0; asensors.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; ascaflag |= OB_SHOWCONT; + else if(event==1) ob->scaflag &= ~OB_SHOWCONT; + } + + for(a=0; acontrollers.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; ascaflag |= OB_SHOWACT; + else if(event==1) ob->scaflag &= ~OB_SHOWACT; + } + + for(a=0; aactuators.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<retval); + but->retval = B_REDR; +} + +static int first_bit(unsigned int mask) +{ + int bit; + + for (bit=0; bit<32; bit++) { + if (mask & (1<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; itotlinks; 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; aactuators.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; ascavisflag & 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; iacttotlinks; 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<controllers.first; + while(cont) { + if (cont->state_mask & (1<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; ascavisflag & 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; ascavisflag & 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 +#include + +#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_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 245076508a0..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; @@ -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 ebb42aa2098..95970798e53 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -521,7 +521,7 @@ 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; /* Dont report error messages while live editing */ @@ -972,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) { @@ -1270,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) { @@ -1613,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) { @@ -2469,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_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 769001b30a8..e697b6dfa7d 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 6fce4fa990d..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 { diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 4c2c2520ee3..416acd7467e 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -361,6 +361,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 */ @@ -753,8 +768,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 87931f8e93d..9d554c88a95 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -244,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]; @@ -378,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 d827d10ec27..f7b069d8227 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -479,6 +479,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); @@ -527,6 +529,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 */ diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h index 553d0ecf028..11f04273842 100644 --- a/source/blender/makesrna/RNA_define.h +++ b/source/blender/makesrna/RNA_define.h @@ -136,6 +136,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); diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index 7e62ea6d823..b527a4f11b3 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; 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..2914e488efa 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -38,7 +38,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..78757c4f4b5 100644 --- a/source/blender/makesrna/intern/Makefile +++ b/source/blender/makesrna/intern/Makefile @@ -47,6 +47,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 diff --git a/source/blender/makesrna/intern/SConscript b/source/blender/makesrna/intern/SConscript index 0ad14553bfb..0f1edbc973c 100644 --- a/source/blender/makesrna/intern/SConscript +++ b/source/blender/makesrna/intern/SConscript @@ -46,11 +46,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 304a008229a..b3fdd8e4457 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); @@ -1146,9 +1146,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)); @@ -1467,6 +1465,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr for(i=0; itotitem; 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 +1564,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)); diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index f114e72e990..d015f400e54 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -53,6 +53,8 @@ void RNA_exit() /* Pointer */ +PointerRNA PointerRNA_NULL = {{0}, 0, 0}; + void RNA_main_pointer_create(struct Main *main, PointerRNA *r_ptr) { r_ptr->id.data= NULL; @@ -677,6 +679,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; @@ -2700,7 +2707,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) { 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 702dc9fa65d..2ed47effec1 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 aa74e7429e2..631550964d6 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -256,16 +256,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."); 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 e64f58e9a9c..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."); diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index ef9bd86c2d9..4b34680c07f 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); 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 6bab4206dc6..de648af14b6 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 6b3c9767e2e..137230b681b 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; diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 6b72646da4a..4b6e595e001 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -976,6 +976,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; @@ -2220,15 +2227,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 ea26118f267..806219ec6bf 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,12 +279,12 @@ 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", ""}, - {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", ""}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "FModifierGenerator_Function", "FModifier"); @@ -336,11 +336,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."); @@ -428,11 +428,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."); @@ -542,10 +542,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"); @@ -575,14 +575,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_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_types.h b/source/blender/makesrna/intern/rna_internal_types.h index 840b5745681..0140f2b091e 100644 --- a/source/blender/makesrna/intern/rna_internal_types.h +++ b/source/blender/makesrna/intern/rna_internal_types.h @@ -129,6 +129,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; diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c index 3070e0a9076..5bff90df962 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."); 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 de547eab617..01999731f74 100644 --- a/source/blender/makesrna/intern/rna_lattice.c +++ b/source/blender/makesrna/intern/rna_lattice.c @@ -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."); diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 1ab70154442..b055b8d2f56 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; amtex[a] == mtex) + return (ma->septex & (1<id.data; + MTex *mtex= (MTex*)ptr->data; + int a; + + for(a=0; amtex[a] == mtex) { + if(value) + ma->septex &= ~(1<septex |= (1<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 4d5cef123dc..9c1764802fa 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"); @@ -590,78 +590,78 @@ static StructRNA *rna_def_object(BlenderRNA *brna) 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.."); 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 e0f670e8ded..0d621ef604a 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -626,26 +626,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."); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 83b6df502a6..27f46fe5fcc 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -41,14 +41,14 @@ /* 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 @@ -172,161 +172,161 @@ 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", "Automatically determine the number of threads, based on CPUs"}, - {R_FIXED_THREADS, "THREADS_FIXED", "Fixed", "Manually determine the number of threads"}, - {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 + {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", "JPEG 2000", ""}, + {R_JP2, "JPEG2000", 0, "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_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", ""}, + {R_MOVIE, "MOVIE", 0, "Movie", ""}, #endif //#ifdef WITH_OPENEXR - {R_OPENEXR, "OPENEXR", "OpenEXR", ""}, - {R_MULTILAYER, "MULTILAYER", "MultiLayer", ""}, + {R_OPENEXR, "OPENEXR", 0, "OpenEXR", ""}, + {R_MULTILAYER, "MULTILAYER", 0, "MultiLayer", ""}, //#endif - {R_TIFF, "TIFF", "TIFF", ""}, // XXX only with G.have_libtiff - {0, NULL, NULL, NULL}}; + {R_TIFF, "TIFF", 0, "TIFF", ""}, // XXX only with G.have_libtiff + {0, NULL, 0, NULL, NULL}}; //#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}}; + {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", "MPEG-1", ""}, - {FFMPEG_MPEG2, "MPEG2", "MPEG-2", ""}, - {FFMPEG_MPEG4, "MPEG4", "MPEG-4", ""}, - {FFMPEG_AVI, "AVI", "Avi", ""}, - {FFMPEG_MOV, "QUICKTIME", "Quicktime", ""}, - {FFMPEG_DV, "DV", "DV", ""}, - {FFMPEG_H264, "H264", "H264", ""}, - {FFMPEG_XVID, "XVID", "XVid", ""}, - {FFMPEG_OGG, "OGG", "OGG", ""}, - {FFMPEG_FLV, "FLASH", "Flash", ""}, - {0, NULL, NULL, NULL}}; + {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", "MPEG-1", ""}, - {CODEC_ID_MPEG2VIDEO, "MPEG2", "MPEG-2", ""}, - {CODEC_ID_MPEG4, "MPEG4", "MPEG-4(divx)", ""}, - {CODEC_ID_HUFFYUV, "HUFFYUV", "HuffYUV", ""}, - {CODEC_ID_DVVIDEO, "DV", "DV", ""}, - {CODEC_ID_H264, "H264", "H264", ""}, - {CODEC_ID_XVID, "XVID", "XVid", ""}, - {CODEC_ID_THEORA, "THEORA", "OGG Theora", ""}, - {CODEC_ID_FLV1, "FLASH", "FlashVideo1", ""}, - {0, NULL, NULL, NULL}}; + {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", "MP2", ""}, - {CODEC_ID_MP3, "MP3", "MP3", ""}, - {CODEC_ID_AC3, "AC3", "AC3", ""}, - {CODEC_ID_AAC, "AAC", "AAC", ""}, - {CODEC_ID_VORBIS, "VORBIS", "Vorbis", ""}, - {CODEC_ID_PCM_S16LE, "PCM", "PCM", ""}, - {0, NULL, NULL, NULL}}; + {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 */ @@ -840,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."); 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 b3975e2469e..f21982cc3cd 100644 --- a/source/blender/makesrna/intern/rna_sequence.c +++ b/source/blender/makesrna/intern/rna_sequence.c @@ -40,6 +40,8 @@ #ifdef RNA_RUNTIME +#include "MEM_guardedalloc.h" + static int rna_SequenceEditor_name_length(PointerRNA *ptr) { return strlen("Sequence Editor"); @@ -356,41 +358,41 @@ static void rna_def_sequence(BlenderRNA *brna) 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."); @@ -785,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"); @@ -870,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 a27c7926428..3b8b88beaff 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,17 +815,20 @@ 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); diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index 86278c53eef..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/Movie", ""}, - {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 +#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/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 082e4896d16..65d83bec552 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -891,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; @@ -1321,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"); @@ -1357,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); } @@ -1396,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); @@ -1476,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); @@ -1627,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"); @@ -1780,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"); @@ -1890,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"); @@ -2075,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); 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_world.c b/source/blender/makesrna/intern/rna_world.c index 697efc88af1..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"); @@ -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"); @@ -165,7 +165,7 @@ static void rna_def_ambient_occlusion(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "aodistfac"); RNA_def_property_ui_text(prop, "Strength", "Distance attenuation factor, the higher, the 'shorter' the shadows."); - prop= RNA_def_property(srna, "energy", PROP_FLOAT, PROP_PERCENTAGE); + 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", "Amount of enerygy generated by ambient occlusion."); @@ -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"); @@ -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."); 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/SConscript b/source/blender/python/SConscript index 9d7fcf6a9cf..c974ebe1092 100644 --- a/source/blender/python/SConscript +++ b/source/blender/python/SConscript @@ -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; iparent= NULL; + buffer->ndimensions= ndimensions; + buffer->dimensions= dimensions; + buffer->type= type; + buffer->buf.asvoid= buf; + + for (i= 0; ibuf.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; idimensions[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; jndimensions; 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= 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; countparent) 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; indimensions); + int i; + + for (i= 0; indimensions; 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..345536d64be --- /dev/null +++ b/source/blender/python/generic/BGL.h @@ -0,0 +1,337 @@ +/* + * $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 +#endif + +#include +#include "BIF_gl.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; indexvec[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 +#include "Mathutils.h" + +PyObject *Geometry_Init( const char *from ); + +#endif /* EXPP_Geometry_H */ diff --git a/source/blender/python/generic/Mathutils.c b/source/blender/python/generic/Mathutils.c new file mode 100644 index 00000000000..1e2e59edbaf --- /dev/null +++ b/source/blender/python/generic/Mathutils.c @@ -0,0 +1,1712 @@ +/* + * $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_Vector_doc[] = "() - create a new vector object from a list of floats"; +static char M_Mathutils_Matrix_doc[] = "() - create a new matrix object from a list of floats"; +static char M_Mathutils_Quaternion_doc[] = "() - create a quaternion from a list or an axis of rotation and an angle"; +static char M_Mathutils_Euler_doc[] = "() - create and return a new euler object"; +static char M_Mathutils_Rand_doc[] = "() - return a random number"; +static char M_Mathutils_CrossVecs_doc[] = "() - returns a vector perpedicular to the 2 vectors crossed"; +static char M_Mathutils_CopyVec_doc[] = "() - create a copy of vector"; +static char M_Mathutils_DotVecs_doc[] = "() - return the dot product of two vectors"; +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_MatMultVec_doc[] = "() - multiplies a matrix by a column vector"; +static char M_Mathutils_VecMultMat_doc[] = "() - multiplies a row vector by a matrix"; +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_CopyMat_doc[] = "() - create a copy of a matrix"; +static char M_Mathutils_TranslationMatrix_doc[] = "(vec) - create a translation matrix from a vector"; +static char M_Mathutils_CopyQuat_doc[] = "() - copy quatB to quatA"; +static char M_Mathutils_CopyEuler_doc[] = "() - copy eulB to eultA"; +static char M_Mathutils_CrossQuats_doc[] = "() - return the mutliplication of two quaternions"; +static char M_Mathutils_DotQuats_doc[] = "() - return the dot product of two quaternions"; +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_RotateEuler_doc[] = "() - rotate euler by an axis and angle"; +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 ---------------------- +struct PyMethodDef M_Mathutils_methods[] = { + {"Rand", (PyCFunction) M_Mathutils_Rand, METH_VARARGS, M_Mathutils_Rand_doc}, + {"Vector", (PyCFunction) M_Mathutils_Vector, METH_VARARGS, M_Mathutils_Vector_doc}, + {"CrossVecs", (PyCFunction) M_Mathutils_CrossVecs, METH_VARARGS, M_Mathutils_CrossVecs_doc}, + {"DotVecs", (PyCFunction) M_Mathutils_DotVecs, METH_VARARGS, M_Mathutils_DotVecs_doc}, + {"AngleBetweenVecs", (PyCFunction) M_Mathutils_AngleBetweenVecs, METH_VARARGS, M_Mathutils_AngleBetweenVecs_doc}, + {"MidpointVecs", (PyCFunction) M_Mathutils_MidpointVecs, METH_VARARGS, M_Mathutils_MidpointVecs_doc}, + {"VecMultMat", (PyCFunction) M_Mathutils_VecMultMat, METH_VARARGS, M_Mathutils_VecMultMat_doc}, + {"ProjectVecs", (PyCFunction) M_Mathutils_ProjectVecs, METH_VARARGS, M_Mathutils_ProjectVecs_doc}, + {"CopyVec", (PyCFunction) M_Mathutils_CopyVec, METH_VARARGS, M_Mathutils_CopyVec_doc}, + {"Matrix", (PyCFunction) M_Mathutils_Matrix, METH_VARARGS, M_Mathutils_Matrix_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}, + {"CopyMat", (PyCFunction) M_Mathutils_CopyMat, METH_VARARGS, M_Mathutils_CopyMat_doc}, + {"OrthoProjectionMatrix", (PyCFunction) M_Mathutils_OrthoProjectionMatrix, METH_VARARGS, M_Mathutils_OrthoProjectionMatrix_doc}, + {"MatMultVec", (PyCFunction) M_Mathutils_MatMultVec, METH_VARARGS, M_Mathutils_MatMultVec_doc}, + {"Quaternion", (PyCFunction) M_Mathutils_Quaternion, METH_VARARGS, M_Mathutils_Quaternion_doc}, + {"CopyQuat", (PyCFunction) M_Mathutils_CopyQuat, METH_VARARGS, M_Mathutils_CopyQuat_doc}, + {"CrossQuats", (PyCFunction) M_Mathutils_CrossQuats, METH_VARARGS, M_Mathutils_CrossQuats_doc}, + {"DotQuats", (PyCFunction) M_Mathutils_DotQuats, METH_VARARGS, M_Mathutils_DotQuats_doc}, + {"DifferenceQuats", (PyCFunction) M_Mathutils_DifferenceQuats, METH_VARARGS,M_Mathutils_DifferenceQuats_doc}, + {"Slerp", (PyCFunction) M_Mathutils_Slerp, METH_VARARGS, M_Mathutils_Slerp_doc}, + {"Euler", (PyCFunction) M_Mathutils_Euler, METH_VARARGS, M_Mathutils_Euler_doc}, + {"CopyEuler", (PyCFunction) M_Mathutils_CopyEuler, METH_VARARGS, M_Mathutils_CopyEuler_doc}, + {"RotateEuler", (PyCFunction) M_Mathutils_RotateEuler, METH_VARARGS, M_Mathutils_RotateEuler_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 + + 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 +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.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 +PyObject *M_Mathutils_Vector(PyObject * self, PyObject * args) +{ + PyObject *listObject = NULL; + int size, i; + float vec[4], f; + PyObject *v; + + size = PySequence_Length(args); + if (size == 1) { + listObject = PySequence_GetItem(args, 0); + if (PySequence_Check(listObject)) { + size = PySequence_Length(listObject); + } else { // Single argument was not a sequence + Py_XDECREF(listObject); + 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 { + Py_INCREF(args); + listObject = args; + } + + if (size<2 || size>4) { // Invalid vector size + Py_XDECREF(listObject); + PyErr_SetString(PyExc_AttributeError, "Mathutils.Vector(): 2-4 floats or ints expected (optionally in a sequence)\n"); + return NULL; + } + + for (i=0; isize != 3 || vec2->size != 3) { + PyErr_SetString(PyExc_AttributeError, "Mathutils.CrossVecs(): expects (2) 3D vector objects\n"); + return NULL; + } + vecCross = newVectorObject(NULL, 3, Py_NEW); + Crossf(((VectorObject*)vecCross)->vec, vec1->vec, vec2->vec); + return vecCross; +} +//----------------------------------Mathutils.DotVec() ------------------- +//calculates the dot product of two vectors +PyObject *M_Mathutils_DotVecs(PyObject * self, PyObject * args) +{ + VectorObject *vec1 = NULL, *vec2 = NULL; + double dot = 0.0f; + int x; + + if(!PyArg_ParseTuple(args, "O!O!", &vector_Type, &vec1, &vector_Type, &vec2)) { + PyErr_SetString(PyExc_TypeError, "Mathutils.DotVecs(): expects (2) vector objects of the same size\n"); + return NULL; + } + + if(vec1->size != vec2->size) { + PyErr_SetString(PyExc_AttributeError, "Mathutils.DotVecs(): expects (2) vector objects of the same size\n"); + return NULL; + } + + for(x = 0; x < vec1->size; x++) { + dot += vec1->vec[x] * vec2->vec[x]; + } + return PyFloat_FromDouble(dot); +} +//----------------------------------Mathutils.AngleBetweenVecs() --------- +//calculates the angle between 2 vectors +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 +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 +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.Matrix() ----------------- +//mat is a 1D array of floats - row[0][0],row[0][1], row[1][0], etc. +//create a new matrix type +PyObject *M_Mathutils_Matrix(PyObject * self, PyObject * args) +{ + PyObject *listObject = NULL; + PyObject *argObject, *m, *s, *f; + 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}; + + argSize = PySequence_Length(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 = PySequence_GetItem(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]; + } + } + Py_DECREF(argObject); + }else{ //2-4 arguments (all seqs? all same size?) + for(i =0; i < argSize; i++){ + argObject = PySequence_GetItem(args, i); + if (PySequence_Check(argObject)) { //seq? + if(seqSize){ //0 at first + if(PySequence_Length(argObject) != seqSize){ //seq size not same + Py_DECREF(argObject); + 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 + Py_XDECREF(argObject); + PyErr_SetString(PyExc_TypeError, "Mathutils.Matrix(): expects 0-4 numeric sequences of the same size\n"); + return NULL; + } + Py_DECREF(argObject); + } + //all is well... let's continue parsing + listObject = args; + for (i = 0; i < argSize; i++){ + m = PySequence_GetItem(listObject, 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 + Py_DECREF(m); + PyErr_SetString(PyExc_RuntimeError, "Mathutils.Matrix(): failed to parse arguments...\n"); + return NULL; + } + + f = PyNumber_Float(s); + if(f == NULL) { // parsed item is not a number + Py_DECREF(m); + Py_DECREF(s); + PyErr_SetString(PyExc_AttributeError, "Mathutils.Matrix(): expects 0-4 numeric sequences of the same size\n"); + return NULL; + } + + matrix[(seqSize*i)+j]=(float)PyFloat_AS_DOUBLE(f); + Py_DECREF(f); + Py_DECREF(s); + } + Py_DECREF(m); + } + } + return newMatrixObject(matrix, argSize, seqSize, Py_NEW); +} +//----------------------------------Mathutils.RotationMatrix() ---------- +//mat is a 1D array of floats - row[0][0],row[0][1], row[1][0], etc. +//creates a rotation matrix +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 +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 +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 +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 +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.Quaternion() -------------- +PyObject *M_Mathutils_Quaternion(PyObject * self, PyObject * args) +{ + PyObject *listObject = NULL, *n, *q, *f; + int size, i; + float quat[4]; + double norm = 0.0f, angle = 0.0f; + + size = PySequence_Length(args); + if (size == 1 || size == 2) { //seq? + listObject = PySequence_GetItem(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 + Py_DECREF(listObject); + 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 + Py_DECREF(listObject); + 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()) { + Py_DECREF(listObject); + PyErr_SetString(PyExc_TypeError, "Mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n"); + return NULL; + } + } + }else{ + Py_DECREF(listObject); /* assume the list is teh second arg */ + listObject = PySequence_GetItem(args, 1); + if (size>1 && PySequence_Check(listObject)) { + size = PySequence_Length(listObject); + if (size != 3) { + // invalid args/size + Py_DECREF(listObject); + PyErr_SetString(PyExc_AttributeError, "Mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n"); + return NULL; + } + n = PySequence_GetItem(args, 0); + if(n == NULL) { // parsed item not a number or getItem fail + Py_DECREF(listObject); + 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()) { + Py_DECREF(listObject); + PyErr_SetString(PyExc_TypeError, "Mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n"); + return NULL; + } + } else { // argument was not a sequence + Py_XDECREF(listObject); + 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 { + Py_INCREF(args); + listObject = args; + } + + if (size == 3) { // invalid quat size + if(PySequence_Length(args) != 2){ + Py_DECREF(listObject); + PyErr_SetString(PyExc_AttributeError, "Mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n"); + return NULL; + } + }else{ + if(size != 4){ + Py_DECREF(listObject); + PyErr_SetString(PyExc_AttributeError, "Mathutils.Quaternion(): 4d numeric sequence expected or 3d vector and number\n"); + return NULL; + } + } + + for (i=0; iquat, quatV->quat); + + return newQuaternionObject(quat, Py_NEW); +} +//----------------------------------Mathutils.DotQuats() ---------------- +//returns the dot product of 2 quaternions +PyObject *M_Mathutils_DotQuats(PyObject * self, PyObject * args) +{ + QuaternionObject *quatU = NULL, *quatV = NULL; + double dot = 0.0f; + int x; + + if(!PyArg_ParseTuple(args, "O!O!", &quaternion_Type, &quatU, &quaternion_Type, &quatV)) { + PyErr_SetString(PyExc_TypeError, "Mathutils.DotQuats(): expected Quaternion types"); + return NULL; + } + + for(x = 0; x < 4; x++) { + dot += quatU->quat[x] * quatV->quat[x]; + } + return PyFloat_FromDouble(dot); +} +//----------------------------------Mathutils.DifferenceQuats() --------- +//returns the difference between 2 quaternions +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 +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---------------------- +//----------------------------------Mathutils.Euler() ------------------- +//makes a new euler for you to play with +PyObject *M_Mathutils_Euler(PyObject * self, PyObject * args) +{ + + PyObject *listObject = NULL; + int size, i; + float eul[3]; + PyObject *e, *f; + + size = PySequence_Length(args); + if (size == 1) { + listObject = PySequence_GetItem(args, 0); + if (PySequence_Check(listObject)) { + size = PySequence_Length(listObject); + } else { // Single argument was not a sequence + Py_DECREF(listObject); + 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 { + Py_INCREF(args); + listObject = args; + } + + if (size != 3) { // Invalid euler size + Py_DECREF(listObject); + PyErr_SetString(PyExc_AttributeError, "Mathutils.Euler(): 3d numeric sequence expected\n"); + return NULL; + } + + for (i=0; isize != 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 */ +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() ------------------- +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() ------------------- +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() ------------------- +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; + } +} +//#############################DEPRECATED################################ +//####################################################################### +//----------------------------------Mathutils.CopyMat() ----------------- +//copies a matrix into a new matrix +PyObject *M_Mathutils_CopyMat(PyObject * self, PyObject * args) +{ + PyObject *matrix = NULL; + static char warning = 1; + + if( warning ) { + printf("Mathutils.CopyMat(): deprecated :use Mathutils.Matrix() to copy matrices\n"); + --warning; + } + + matrix = M_Mathutils_Matrix(self, args); + if(matrix == NULL) + return NULL; //error string already set if we get here + else + return matrix; +} +//----------------------------------Mathutils.CopyVec() ----------------- +//makes a new vector that is a copy of the input +PyObject *M_Mathutils_CopyVec(PyObject * self, PyObject * args) +{ + PyObject *vec = NULL; + static char warning = 1; + + if( warning ) { + printf("Mathutils.CopyVec(): Deprecated: use Mathutils.Vector() to copy vectors\n"); + --warning; + } + + vec = M_Mathutils_Vector(self, args); + if(vec == NULL) + return NULL; //error string already set if we get here + else + return vec; +} +//----------------------------------Mathutils.CopyQuat() -------------- +//Copies a quaternion to a new quat +PyObject *M_Mathutils_CopyQuat(PyObject * self, PyObject * args) +{ + PyObject *quat = NULL; + static char warning = 1; + + if( warning ) { + printf("Mathutils.CopyQuat(): Deprecated: use Mathutils.Quaternion() to copy vectors\n"); + --warning; + } + + quat = M_Mathutils_Quaternion(self, args); + if(quat == NULL) + return NULL; //error string already set if we get here + else + return quat; +} +//----------------------------------Mathutils.CopyEuler() --------------- +//copies a euler to a new euler +PyObject *M_Mathutils_CopyEuler(PyObject * self, PyObject * args) +{ + PyObject *eul = NULL; + static char warning = 1; + + if( warning ) { + printf("Mathutils.CopyEuler(): deprecated:use Mathutils.Euler() to copy vectors\n"); + --warning; + } + + eul = M_Mathutils_Euler(self, args); + if(eul == NULL) + return NULL; //error string already set if we get here + else + return eul; +} +//----------------------------------Mathutils.RotateEuler() ------------ +//rotates a euler a certain amount and returns the result +//should return a unique euler rotation (i.e. no 720 degree pitches :) +PyObject *M_Mathutils_RotateEuler(PyObject * self, PyObject * args) +{ + EulerObject *Eul = NULL; + float angle; + char *axis; + static char warning = 1; + + if( warning ) { + printf("Mathutils.RotateEuler(): Deprecated:use Euler.rotate() to rotate a euler\n"); + --warning; + } + + if(!PyArg_ParseTuple(args, "O!fs", &euler_Type, &Eul, &angle, &axis)) { + PyErr_SetString(PyExc_TypeError, "Mathutils.RotateEuler(): expected euler type & float & string"); + return NULL; + } + + Euler_Rotate(Eul, Py_BuildValue("fs", angle, axis)); + Py_RETURN_NONE; +} +//----------------------------------Mathutils.MatMultVec() -------------- +//COLUMN VECTOR Multiplication (Matrix X Vector) +PyObject *M_Mathutils_MatMultVec(PyObject * self, PyObject * args) +{ + MatrixObject *mat = NULL; + VectorObject *vec = NULL; + static char warning = 1; + + if( warning ) { + printf("Mathutils.MatMultVec(): Deprecated: use matrix * vec to perform column vector multiplication\n"); + --warning; + } + + //get pyObjects + if(!PyArg_ParseTuple(args, "O!O!", &matrix_Type, &mat, &vector_Type, &vec)) { + PyErr_SetString(PyExc_TypeError, "Mathutils.MatMultVec(): MatMultVec() expects a matrix and a vector object - in that order\n"); + return NULL; + } + + return column_vector_multiplication(mat, vec); +} +//----------------------------------Mathutils.VecMultMat() --------------- +//ROW VECTOR Multiplication - Vector X Matrix +PyObject *M_Mathutils_VecMultMat(PyObject * self, PyObject * args) +{ + MatrixObject *mat = NULL; + VectorObject *vec = NULL; + static char warning = 1; + + if( warning ) { + printf("Mathutils.VecMultMat(): Deprecated: use vec * matrix to perform row vector multiplication\n"); + --warning; + } + + //get pyObjects + if(!PyArg_ParseTuple(args, "O!O!", &vector_Type, &vec, &matrix_Type, &mat)) { + PyErr_SetString(PyExc_TypeError, "Mathutils.VecMultMat(): VecMultMat() expects a vector and matrix object - in that order\n"); + return NULL; + } + + return row_vector_multiplication(vec, mat); +} + +/* 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..4c8153e5e54 --- /dev/null +++ b/source/blender/python/generic/Mathutils.h @@ -0,0 +1,100 @@ +/* + * $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 +#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); + +PyObject *M_Mathutils_Rand(PyObject * self, PyObject * args); +PyObject *M_Mathutils_Vector(PyObject * self, PyObject * args); +PyObject *M_Mathutils_AngleBetweenVecs(PyObject * self, PyObject * args); +PyObject *M_Mathutils_MidpointVecs(PyObject * self, PyObject * args); +PyObject *M_Mathutils_ProjectVecs(PyObject * self, PyObject * args); +PyObject *M_Mathutils_Matrix(PyObject * self, PyObject * args); +PyObject *M_Mathutils_RotationMatrix(PyObject * self, PyObject * args); +PyObject *M_Mathutils_TranslationMatrix(PyObject * self, VectorObject * value); +PyObject *M_Mathutils_ScaleMatrix(PyObject * self, PyObject * args); +PyObject *M_Mathutils_OrthoProjectionMatrix(PyObject * self, PyObject * args); +PyObject *M_Mathutils_ShearMatrix(PyObject * self, PyObject * args); +PyObject *M_Mathutils_Quaternion(PyObject * self, PyObject * args); +PyObject *M_Mathutils_DifferenceQuats(PyObject * self, PyObject * args); +PyObject *M_Mathutils_Slerp(PyObject * self, PyObject * args); +PyObject *M_Mathutils_Euler(PyObject * self, PyObject * args); +PyObject *M_Mathutils_Intersect( PyObject * self, PyObject * args ); +PyObject *M_Mathutils_TriangleArea( PyObject * self, PyObject * args ); +PyObject *M_Mathutils_TriangleNormal( PyObject * self, PyObject * args ); +PyObject *M_Mathutils_QuadNormal( PyObject * self, PyObject * args ); +PyObject *M_Mathutils_LineIntersect( PyObject * self, PyObject * args ); +//DEPRECATED +PyObject *M_Mathutils_CopyMat(PyObject * self, PyObject * args); +PyObject *M_Mathutils_CopyVec(PyObject * self, PyObject * args); +PyObject *M_Mathutils_CopyQuat(PyObject * self, PyObject * args); +PyObject *M_Mathutils_CopyEuler(PyObject * self, PyObject * args); +PyObject *M_Mathutils_RotateEuler(PyObject * self, PyObject * args); +PyObject *M_Mathutils_MatMultVec(PyObject * self, PyObject * args); +PyObject *M_Mathutils_VecMultMat(PyObject * self, PyObject * args); +PyObject *M_Mathutils_CrossVecs(PyObject * self, PyObject * args); +PyObject *M_Mathutils_DotVecs(PyObject * self, PyObject * args); +PyObject *M_Mathutils_CrossQuats(PyObject * self, PyObject * args); +PyObject *M_Mathutils_DotQuats(PyObject * self, PyObject * args); + +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..9c3ce572cc4 --- /dev/null +++ b/source/blender/python/generic/bpy_internal_import.h @@ -0,0 +1,49 @@ +/* + * $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 +#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..82131b10710 --- /dev/null +++ b/source/blender/python/generic/euler.c @@ -0,0 +1,558 @@ +/* + * $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 --------------------------- +char Euler_Zero_doc[] = "() - set all values in the euler to 0"; +char Euler_Unique_doc[] ="() - sets the euler rotation a unique shortest arc rotation - tests for gimbal lock"; +char Euler_ToMatrix_doc[] = "() - returns a rotation matrix representing the euler rotation"; +char Euler_ToQuat_doc[] = "() - returns a quaternion representing the euler rotation"; +char Euler_Rotate_doc[] = "() - rotate a euler by certain amount around an axis of rotation"; +char Euler_copy_doc[] = "() - returns a copy of the euler."; +char Euler_MakeCompatible_doc[] = "(euler) - Make this user compatible with another (no axis flipping)."; +//-----------------------METHOD DEFINITIONS ---------------------- +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} +}; +//-----------------------------METHODS---------------------------- +//----------------------------Euler.toQuat()---------------------- +//return a quaternion representation of the euler +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 +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 +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 +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 :) +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; +} + +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 +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 + 0, //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..f94f060a61d --- /dev/null +++ b/source/blender/python/generic/euler.h @@ -0,0 +1,65 @@ +/* + * $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 + +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 *Euler_Zero( EulerObject * self ); +PyObject *Euler_Unique( EulerObject * self ); +PyObject *Euler_ToMatrix( EulerObject * self ); +PyObject *Euler_ToQuat( EulerObject * self ); +PyObject *Euler_Rotate( EulerObject * self, PyObject *args ); +PyObject *Euler_MakeCompatible( EulerObject * self, EulerObject *value ); +PyObject *Euler_copy( EulerObject * self, PyObject *args ); +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..16c72d69dde --- /dev/null +++ b/source/blender/python/generic/matrix.c @@ -0,0 +1,1002 @@ +/* + * $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 ---------------------------*/ +char Matrix_Zero_doc[] = "() - set all values in the matrix to 0"; +char Matrix_Identity_doc[] = "() - set the square matrix to it's identity matrix"; +char Matrix_Transpose_doc[] = "() - set the matrix to it's transpose"; +char Matrix_Determinant_doc[] = "() - return the determinant of the matrix"; +char Matrix_Invert_doc[] = "() - set the matrix to it's inverse if an inverse is possible"; +char Matrix_TranslationPart_doc[] = "() - return a vector encompassing the translation of the matrix"; +char Matrix_RotationPart_doc[] = "() - return a vector encompassing the rotation of the matrix"; +char Matrix_scalePart_doc[] = "() - convert matrix to a 3D vector"; +char Matrix_Resize4x4_doc[] = "() - resize the matrix to a 4x4 square matrix"; +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."; +char Matrix_toQuat_doc[] = "() - convert matrix to a quaternion rotation"; +char Matrix_copy_doc[] = "() - return a copy of the matrix"; +/*-----------------------METHOD DEFINITIONS ----------------------*/ +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} +}; +/*-----------------------------METHODS----------------------------*/ +/*---------------------------Matrix.toQuat() ---------------------*/ +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) +{ + Py_XDECREF(self->coerced_object); + PyMem_Free(self->matrix); + /*only free py_data*/ + if(self->data.py_data){ + PyMem_Free(self->data.py_data); + } + PyObject_DEL(self); +} +/*----------------------------getattr()(internal) ----------------*/ +/*object.attribute access (get)*/ +static PyObject *Matrix_getattr(MatrixObject * self, char *name) +{ + if(STREQ(name, "rowSize")) { + return PyLong_FromLong((long) self->rowSize); + } else if(STREQ(name, "colSize")) { + return PyLong_FromLong((long) self->colSize); + } + if(STREQ(name, "wrapped")){ + if(self->wrapped == Py_WRAP) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; + } +#if 0 //XXX + return Py_FindMethod(Matrix_methods, (PyObject *) self, name); +#else + PyErr_SetString(PyExc_AttributeError, "blender 2.5 is not finished yet"); + return NULL; +#endif +} +/*----------------------------setattr()(internal) ----------------*/ +/*object.attribute access (set)*/ +static int Matrix_setattr(MatrixObject * self, char *name, PyObject * v) +{ + /* This is not supported. */ + return (-1); +} +/*----------------------------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(mat1->coerced_object || mat2->coerced_object){ + 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(mat1->coerced_object || mat2->coerced_object){ + 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; + PyObject *f = NULL; + + mat1 = (MatrixObject*)m1; + mat2 = (MatrixObject*)m2; + + if(mat1->coerced_object){ + if (PyFloat_Check(mat1->coerced_object) || + PyLong_Check(mat1->coerced_object)){ /*FLOAT/INT * MATRIX*/ + f = PyNumber_Float(mat1->coerced_object); + if(f == NULL) { /*parsed item not a number*/ + PyErr_SetString(PyExc_TypeError, "Matrix multiplication: arguments not acceptable for this operation"); + return NULL; + } + + scalar = (float)PyFloat_AS_DOUBLE(f); + Py_DECREF(f); + 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); + } + }else{ + if(mat2->coerced_object){ + /* MATRIX * VECTOR operation is now being done by vector */ + /*if(VectorObject_Check(mat2->coerced_object)){ + vec = (VectorObject*)mat2->coerced_object; + return column_vector_multiplication(mat1, vec); + }else */ + if (PyFloat_Check(mat2->coerced_object) || PyLong_Check(mat2->coerced_object)){ /*MATRIX * FLOAT/INT*/ + f = PyNumber_Float(mat2->coerced_object); + if(f == NULL) { /*parsed item not a number*/ + PyErr_SetString(PyExc_TypeError, "Matrix multiplication: arguments not acceptable for this operation\n"); + return NULL; + } + + scalar = (float)PyFloat_AS_DOUBLE(f); + Py_DECREF(f); + 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); + } + }else{ /*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); + } + } + + 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); +} +/*------------------------coerce(obj, obj)----------------------- + coercion of unknown types to type MatrixObject for numeric protocols. + + Coercion() is called whenever a math operation has 2 operands that + it doesn't understand how to evaluate. 2+Matrix for example. We want to + evaluate some of these operations like: (vector * 2), however, for math + to proceed, the unknown operand must be cast to a type that python math will + understand. (e.g. in the case above case, 2 must be cast to a vector and + then call vector.multiply(vector, scalar_cast_as_vector)*/ +static int Matrix_coerce(PyObject ** m1, PyObject ** m2) +{ + if(VectorObject_Check(*m2) || PyFloat_Check(*m2) || PyLong_Check(*m2)) { + PyObject *coerced = (PyObject *)(*m2); + Py_INCREF(coerced); + *m2 = newMatrixObject(NULL,3,3,Py_NEW); + ((MatrixObject*)*m2)->coerced_object = coerced; + Py_INCREF (*m1); + return 0; + } + + PyErr_SetString(PyExc_TypeError, "matrix.coerce(): unknown operand - can't coerce for numeric protocols"); + return -1; +} +/*-----------------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__ */ +#if 0 // XXX 2.5 + (coercion) Matrix_coerce, /* __coerce__ */ +#else + 0, +#endif + (unaryfunc) 0, /* __int__ */ + (unaryfunc) 0, /* __long__ */ + (unaryfunc) 0, /* __float__ */ + (unaryfunc) 0, /* __oct__ */ + (unaryfunc) 0, /* __hex__ */ +}; +/*------------------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*/ + (getattrfunc)Matrix_getattr, /*tp_getattr*/ + (setattrfunc) Matrix_setattr, /*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*/ + 0, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*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*/ + 0, /*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; + self->coerced_object = NULL; + + 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..fd51d99c455 --- /dev/null +++ b/source/blender/python/generic/matrix.h @@ -0,0 +1,77 @@ +/* + * $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 + +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?*/ + PyObject *coerced_object; +} MatrixObject; +/*coerced_object is a pointer to the object that it was +coerced from when a dummy vector needs to be created from +the coerce() function for numeric protocol operations*/ + +/*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 *Matrix_Zero( MatrixObject * self ); +PyObject *Matrix_Identity( MatrixObject * self ); +PyObject *Matrix_Transpose( MatrixObject * self ); +PyObject *Matrix_Determinant( MatrixObject * self ); +PyObject *Matrix_Invert( MatrixObject * self ); +PyObject *Matrix_TranslationPart( MatrixObject * self ); +PyObject *Matrix_RotationPart( MatrixObject * self ); +PyObject *Matrix_scalePart( MatrixObject * self ); +PyObject *Matrix_Resize4x4( MatrixObject * self ); +PyObject *Matrix_toEuler( MatrixObject * self, PyObject *args ); +PyObject *Matrix_toQuat( MatrixObject * self ); +PyObject *Matrix_copy( MatrixObject * self ); +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..ca703f12907 --- /dev/null +++ b/source/blender/python/generic/quat.c @@ -0,0 +1,765 @@ +/* + * $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 --------------------------- +char Quaternion_Identity_doc[] = "() - set the quaternion to it's identity (1, vector)"; +char Quaternion_Negate_doc[] = "() - set all values in the quaternion to their negative"; +char Quaternion_Conjugate_doc[] = "() - set the quaternion to it's conjugate"; +char Quaternion_Inverse_doc[] = "() - set the quaternion to it's inverse"; +char Quaternion_Normalize_doc[] = "() - normalize the vector portion of the quaternion"; +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."; +char Quaternion_ToMatrix_doc[] = "() - return a rotation matrix representing the quaternion"; +char Quaternion_Cross_doc[] = "(other) - return the cross product between this quaternion and another"; +char Quaternion_Dot_doc[] = "(other) - return the dot product between this quaternion and another"; +char Quaternion_copy_doc[] = "() - return a copy of the quat"; +//-----------------------METHOD DEFINITIONS ---------------------- +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} +}; +//-----------------------------METHODS------------------------------ +//----------------------------Quaternion.toEuler()------------------ +//return the quat as a euler +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 +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 +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 +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] +PyObject *Quaternion_Normalize(QuaternionObject * self) +{ + NormalQuat(self->quat); + Py_INCREF(self); + return (PyObject*)self; +} +//----------------------------Quaternion.inverse()------------------ +//invert the quat +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 +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 +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 +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 +PyObject *Quaternion_copy(QuaternionObject * self) +{ + return newQuaternionObject(self->quat, Py_NEW); +} + +//----------------------------dealloc()(internal) ------------------ +//free the py_object +static void Quaternion_dealloc(QuaternionObject * self) +{ + Py_XDECREF(self->coerced_object); + //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; + + quat1 = (QuaternionObject*)q1; + quat2 = (QuaternionObject*)q2; + + if(quat1->coerced_object || quat2->coerced_object){ + PyErr_SetString(PyExc_AttributeError, "Quaternion addition: arguments not valid for this operation....\n"); + return NULL; + } + 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; + + quat1 = (QuaternionObject*)q1; + quat2 = (QuaternionObject*)q2; + + if(quat1->coerced_object || quat2->coerced_object){ + PyErr_SetString(PyExc_AttributeError, "Quaternion addition: arguments not valid for this operation....\n"); + return NULL; + } + 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; + PyObject *f = NULL; + VectorObject *vec = NULL; + + quat1 = (QuaternionObject*)q1; + quat2 = (QuaternionObject*)q2; + + if(quat1->coerced_object){ + if (PyFloat_Check(quat1->coerced_object) || + PyLong_Check(quat1->coerced_object)){ // FLOAT/INT * QUAT + f = PyNumber_Float(quat1->coerced_object); + if(f == NULL) { // parsed item not a number + PyErr_SetString(PyExc_TypeError, "Quaternion multiplication: arguments not acceptable for this operation\n"); + return NULL; + } + + scalar = (float)PyFloat_AS_DOUBLE(f); + Py_DECREF(f); + for(x = 0; x < 4; x++) { + quat[x] = quat2->quat[x] * scalar; + } + return newQuaternionObject(quat, Py_NEW); + } + }else{ + if(quat2->coerced_object){ + if (PyFloat_Check(quat2->coerced_object) || + PyLong_Check(quat2->coerced_object)){ // QUAT * FLOAT/INT + f = PyNumber_Float(quat2->coerced_object); + if(f == NULL) { // parsed item not a number + PyErr_SetString(PyExc_TypeError, "Quaternion multiplication: arguments not acceptable for this operation\n"); + return NULL; + } + + scalar = (float)PyFloat_AS_DOUBLE(f); + Py_DECREF(f); + for(x = 0; x < 4; x++) { + quat[x] = quat1->quat[x] * scalar; + } + return newQuaternionObject(quat, Py_NEW); + }else if(VectorObject_Check(quat2->coerced_object)){ //QUAT * VEC + vec = (VectorObject*)quat2->coerced_object; + 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); + } + }else{ //QUAT * QUAT (dot product) + for(x = 0; x < 4; x++) { + dot += quat1->quat[x] * quat1->quat[x]; + } + return PyFloat_FromDouble(dot); + } + } + + PyErr_SetString(PyExc_TypeError, "Quaternion multiplication: arguments not acceptable for this operation\n"); + return NULL; +} +//------------------------coerce(obj, obj)----------------------- +//coercion of unknown types to type QuaternionObject for numeric protocols +/*Coercion() is called whenever a math operation has 2 operands that + it doesn't understand how to evaluate. 2+Matrix for example. We want to + evaluate some of these operations like: (vector * 2), however, for math + to proceed, the unknown operand must be cast to a type that python math will + understand. (e.g. in the case above case, 2 must be cast to a vector and + then call vector.multiply(vector, scalar_cast_as_vector)*/ +static int Quaternion_coerce(PyObject ** q1, PyObject ** q2) +{ + if(VectorObject_Check(*q2) || PyFloat_Check(*q2) || PyLong_Check(*q2)) { + PyObject *coerced = (PyObject *)(*q2); + Py_INCREF(coerced); + + *q2 = newQuaternionObject(NULL,Py_NEW); + ((QuaternionObject*)*q2)->coerced_object = coerced; + Py_INCREF (*q1); + return 0; + } + + PyErr_SetString(PyExc_TypeError, "quaternion.coerce(): unknown operand - can't coerce for numeric protocols"); + return -1; +} +//-----------------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__ */ +#if 0 //XXX 2.5 + (coercion) Quaternion_coerce, /* __coerce__ */ +#else + 0, +#endif + (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 + 0, //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; + self->coerced_object = 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..f98665ded55 --- /dev/null +++ b/source/blender/python/generic/quat.h @@ -0,0 +1,72 @@ +/* + * $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 + +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? + PyObject *coerced_object; +} QuaternionObject; +/*coerced_object is a pointer to the object that it was +coerced from when a dummy vector needs to be created from +the coerce() function for numeric protocol operations*/ + +/*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 *Quaternion_Identity( QuaternionObject * self ); +PyObject *Quaternion_Negate( QuaternionObject * self ); +PyObject *Quaternion_Conjugate( QuaternionObject * self ); +PyObject *Quaternion_Inverse( QuaternionObject * self ); +PyObject *Quaternion_Normalize( QuaternionObject * self ); +PyObject *Quaternion_ToEuler( QuaternionObject * self, PyObject *args ); +PyObject *Quaternion_ToMatrix( QuaternionObject * self ); +PyObject *Quaternion_Cross( QuaternionObject * self, QuaternionObject * value ); +PyObject *Quaternion_Dot( QuaternionObject * self, QuaternionObject * value ); +PyObject *Quaternion_copy( QuaternionObject * self ); +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..86ce5c21217 --- /dev/null +++ b/source/blender/python/generic/vector.c @@ -0,0 +1,1838 @@ +/* + * $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 ---------------------------*/ +char Vector_Zero_doc[] = "() - set all values in the vector to 0"; +char Vector_Normalize_doc[] = "() - normalize the vector"; +char Vector_Negate_doc[] = "() - changes vector to it's additive inverse"; +char Vector_Resize2D_doc[] = "() - resize a vector to [x,y]"; +char Vector_Resize3D_doc[] = "() - resize a vector to [x,y,z]"; +char Vector_Resize4D_doc[] = "() - resize a vector to [x,y,z,w]"; +char Vector_ToTrackQuat_doc[] = "(track, up) - extract a quaternion from the vector and the track and up axis"; +char Vector_Reflect_doc[] = "(mirror) - return a vector reflected on the mirror normal"; +char Vector_Cross_doc[] = "(other) - return the cross product between this vector and another"; +char Vector_Dot_doc[] = "(other) - return the dot product between this vector and another"; +char Vector_copy_doc[] = "() - return a copy of the vector"; +char Vector_swizzle_doc[] = "Swizzle: Get or set axes in specified order"; +/*-----------------------METHOD DEFINITIONS ----------------------*/ +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} +}; + +/*-----------------------------METHODS---------------------------- */ +/*----------------------------Vector.zero() ---------------------- + set the vector data to 0,0,0 */ +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 */ +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 */ +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 */ +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 */ +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 */ +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 */ +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); +} + +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; +} + +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 */ +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) +{ + + if(!(PyNumber_Check(ob))) { /* 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] = (float)PyFloat_AsDouble(ob); + 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]; + 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; + } + + if(!PyNumber_Check(v)) { /* 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] = (float)PyFloat_AsDouble(v); + 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; + + 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 (PyNumber_Check(v2)) { + /* VEC * NUM */ + int i; + float vec[4]; + float scalar = (float)PyFloat_AsDouble( v2 ); + + for(i = 0; i < vec1->size; i++) { + vec[i] = vec1->vec[i] * scalar; + } + return newVectorObject(vec, vec1->size, Py_NEW); + + } else if (MatrixObject_Check(v2)) { + /* VEC * MATRIX */ + if (v1==v2) /* mat*vec, we have swapped the order */ + return column_vector_multiplication((MatrixObject*)v2, vec1); + else /* vec*mat */ + 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); + } + + 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; + + /* only support vec*=float and vec*=mat + vec*=vec result is a float so that wont work */ + if (PyNumber_Check(v2)) { + /* VEC * NUM */ + float scalar = (float)PyFloat_AsDouble( v2 ); + + for(i = 0; i < vec->size; i++) { + vec->vec[i] *= scalar; + } + + Py_INCREF( v1 ); + return v1; + + } else 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; + } + 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, size; + 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 */ + + if(!PyNumber_Check(v2)) { /* parsed item not a number */ + PyErr_SetString(PyExc_TypeError, "Vector division: Vector must be divided by a float\n"); + return NULL; + } + scalar = (float)PyFloat_AsDouble(v2); + + if(scalar==0.0) { /* not a vector */ + PyErr_SetString(PyExc_ZeroDivisionError, "Vector division: divide by zero error.\n"); + return NULL; + } + size = vec1->size; + for(i = 0; i < size; i++) { + vec[i] = vec1->vec[i] / scalar; + } + return newVectorObject(vec, size, Py_NEW); +} + +/*------------------------obj / obj------------------------------ + divide*/ +static PyObject *Vector_idiv(PyObject * v1, PyObject * v2) +{ + int i, size; + 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 */ + + if(!PyNumber_Check(v2)) { /* parsed item not a number */ + PyErr_SetString(PyExc_TypeError, "Vector division: Vector must be divided by a float\n"); + return NULL; + } + + scalar = (float)PyFloat_AsDouble(v2); + + if(scalar==0.0) { /* not a vector */ + PyErr_SetString(PyExc_ZeroDivisionError, "Vector division: divide by zero error.\n"); + return NULL; + } + size = vec1->size; + for(i = 0; i < 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); +} +/*------------------------coerce(obj, obj)----------------------- + coercion of unknown types to type VectorObject for numeric protocols + Coercion() is called whenever a math operation has 2 operands that + it doesn't understand how to evaluate. 2+Matrix for example. We want to + evaluate some of these operations like: (vector * 2), however, for math + to proceed, the unknown operand must be cast to a type that python math will + understand. (e.g. in the case above case, 2 must be cast to a vector and + then call vector.multiply(vector, scalar_cast_as_vector)*/ + + +static int Vector_coerce(PyObject ** v1, PyObject ** v2) +{ + /* Just incref, each functon must raise errors for bad types */ + Py_INCREF (*v1); + Py_INCREF (*v2); + return 0; +} + + +/*------------------------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; isize != 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 */ +}; + + +/* For numbers without flag bit Py_TPFLAGS_CHECKTYPES set, all + arguments are guaranteed to be of the object's type (modulo + coercion hacks -- i.e. if the type's coercion function + returns other types, then these are allowed as well). Numbers that + have the Py_TPFLAGS_CHECKTYPES flag bit set should check *both* + arguments for proper type and implement the necessary conversions + in the slot functions themselves. */ + +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__ */ +#if 0 //XXX 2.5 + (coercion) Vector_coerce, /* __coerce__ */ +#else + 0, +#endif + (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; + + if (!PyNumber_Check(value)) { + PyErr_SetString( PyExc_TypeError, "expected a number for the vector axis" ); + return -1; + } + param= PyFloat_AsDouble( value ); + + 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); + if (!PyNumber_Check(item)) + { + PyErr_SetString(PyExc_AttributeError, "Error: vector does not have specified axis.\n"); + return -1; + } + scalarVal = (float)PyFloat_AsDouble(item); + + 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 (PyNumber_Check(value)) + { + /* Assign the same value to each axis. */ + scalarVal = (float)PyFloat_AsDouble(value); + 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)<= 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)<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)<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)<= 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 "." */ + "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 ***/ +#if 0 //XXX 2.5 + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, /* long tp_flags; */ +#else + Py_TPFLAGS_DEFAULT, +#endif + + 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; */ + NULL, /* 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 */ +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..e53a0c1f24b --- /dev/null +++ b/source/blender/python/generic/vector.h @@ -0,0 +1,60 @@ +/* $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 + +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 *Vector_Zero( VectorObject * self ); +PyObject *Vector_Normalize( VectorObject * self ); +PyObject *Vector_Negate( VectorObject * self ); +PyObject *Vector_Resize2D( VectorObject * self ); +PyObject *Vector_Resize3D( VectorObject * self ); +PyObject *Vector_Resize4D( VectorObject * self ); +PyObject *Vector_ToTrackQuat( VectorObject * self, PyObject * args ); +PyObject *Vector_Reflect( VectorObject * self, PyObject * value ); +PyObject *Vector_Cross( VectorObject * self, VectorObject * value ); +PyObject *Vector_Dot( VectorObject * self, VectorObject * value ); +PyObject *Vector_copy( VectorObject * self ); +PyObject *newVectorObject(float *vec, int size, int type); + +#endif /* EXPP_vector_h */ diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 5c33c63028a..0c063c0192b 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -36,7 +36,8 @@ #include "BPY_extern.h" -static void bpy_init_syspath(); +#include "../generic/bpy_internal_import.h" // our own imports + void BPY_free_compiled_text( struct Text *text ) { @@ -60,7 +61,6 @@ static void bpy_init_modules( void ) PyModule_AddObject( mod, "types", BPY_rna_types() ); 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 - PyModule_AddObject( mod, "props", BPY_rna_props() ); /* add the module so we can import it */ PyDict_SetItemString(PySys_GetObject("modules"), "bpy", mod); @@ -96,6 +96,21 @@ static PyObject *CreateGlobalDictionary( bContext *C ) // XXX - evil, need to access context BPy_SetContext(C); + // XXX - put somewhere more logical + { + PyMethodDef *ml; + static PyMethodDef bpy_prop_meths[] = { + {"FloatProperty", (PyCFunction)BPy_FloatProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {"IntProperty", (PyCFunction)BPy_IntProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {"BoolProperty", (PyCFunction)BPy_BoolProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {NULL, NULL, 0, NULL} + }; + + for(ml = bpy_prop_meths; ml->ml_name; ml++) { + PyDict_SetItemString( dict, ml->ml_name, PyCFunction_New(ml, NULL)); + } + } + /* add bpy to global namespace */ mod= PyImport_ImportModuleLevel("bpy", NULL, NULL, NULL, 0); PyDict_SetItemString( dict, "bpy", mod ); @@ -115,11 +130,18 @@ void BPY_start_python( int argc, char **argv ) /* Initialize thread support (also acquires lock) */ PyEval_InitThreads(); + /* bpy.* and lets us import it */ bpy_init_modules(); - /* init sys.path */ - bpy_init_syspath(); + { /* 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); @@ -137,62 +159,8 @@ void BPY_end_python( void ) return; } -void syspath_append(char *dirname) -{ - PyObject *mod_sys= NULL, *dict= NULL, *path= NULL, *dir= NULL; - short ok=1; - - mod_sys = PyImport_ImportModule( "sys" ); /* new ref */ - - if (mod_sys) { - dict = PyModule_GetDict( mod_sys ); /* borrowed ref */ - path = PyDict_GetItemString( dict, "path" ); /* borrowed ref */ - if ( !PyList_Check( path ) ) { - ok = 0; - } - } else { - /* cant get the sys module */ - /* PyErr_Clear(); is called below */ - ok = 0; - } - -#if PY_MAJOR_VERSION >= 3 - dir = PyUnicode_FromString( dirname ); -#else - dir = PyString_FromString( dirname ); -#endif - - if (ok && PySequence_Contains(path, dir)==0) { /* Only add if we need to */ - if (PyList_Append( path, dir ) != 0) /* decref below */ - ok = 0; /* append failed */ - } - - if( (ok==0) || PyErr_Occurred( ) ) - fprintf(stderr, "Warning: could import or build sys.path\n" ); - - PyErr_Clear(); - Py_DECREF( dir ); - Py_XDECREF( mod_sys ); -} - -/* Adds bpymodules to sys.path */ -static void bpy_init_syspath() -{ - char *dir; - char mod_dir[FILE_MAX]; - - // make path to [home]/scripts/bpymodules - dir = BLI_gethome_folder("scripts"); - BLI_make_file_string("/", mod_dir, dir, "bpymodules"); - - if (BLI_exists(mod_dir)) { - syspath_append(mod_dir); - fprintf(stderr, "'%s' has been added to sys.path\n", mod_dir); - } -} - /* 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; @@ -206,6 +174,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); @@ -220,7 +189,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; @@ -236,13 +205,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; @@ -263,7 +233,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'; @@ -292,7 +262,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; @@ -371,7 +341,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 ); @@ -429,6 +399,7 @@ void BPY_run_ui_scripts(bContext *C, int reload) // XXX - evil, need to access context BPy_SetContext(C); + bpy_import_main_set(CTX_data_main(C)); while((de = readdir(dir)) != NULL) { /* We could stat the file but easier just to let python @@ -452,7 +423,7 @@ void BPY_run_ui_scripts(bContext *C, int reload) if(mod) { Py_DECREF(mod); /* could be NULL from reloading */ } else { - PyErr_Print(); PyErr_Clear(); + BPy_errors_to_report(NULL); // TODO - reports fprintf(stderr, "unable to import \"%s\" %s/%s\n", path, dirname, de->d_name); } } @@ -463,6 +434,8 @@ void BPY_run_ui_scripts(bContext *C, int reload) PySys_SetObject("path", sys_path_orig); Py_DECREF(sys_path_orig); + bpy_import_main_set(NULL); + PyGILState_Release(gilstate); #ifdef TIME_REGISTRATION printf("script time %f\n", (PIL_check_seconds_timer()-time)); @@ -572,7 +545,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; } @@ -631,7 +604,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 c0fac17dd97..7c011b26487 100644 --- a/source/blender/python/intern/bpy_operator_wrap.c +++ b/source/blender/python/intern/bpy_operator_wrap.c @@ -137,54 +137,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) -{ - const char *string; - PyObject *exception, *v, *tb; - PyErr_Fetch(&exception, &v, &tb); - if (exception == NULL) - return; - - /* get the string from the exception */ - if(v==NULL) { - string= "py exception not set"; - } - else if(string = _PyUnicode_AsString(v)) { - /* do nothing */ - } - else { /* a valid PyObject but not a string, try get its string value */ - PyObject *repr; - - Py_INCREF(v); /* incase clearing the error below somehow frees this */ - PyErr_Clear(); - - repr= PyObject_Repr(v); - - if(repr==NULL) { - PyErr_Clear(); - string= "py exception found but can't be converted"; - } - else { - string = _PyUnicode_AsString(repr); - Py_DECREF(repr); - - if(string==NULL) { /* unlikely to happen */ - PyErr_Clear(); - string= "py exception found but can't be converted"; - } - } - - Py_DECREF(v); /* finished dealing with v, PyErr_Clear isnt called anymore so can decref it */ - } - /* done getting the string */ - - /* Now we know v != NULL too */ - BKE_report(reports, RPT_ERROR, string); - - PyErr_Print(); -} - static struct BPY_flag_def pyop_ret_flags[] = { {"RUNNING_MODAL", OPERATOR_RUNNING_MODAL}, {"CANCELLED", OPERATOR_CANCELLED}, @@ -301,13 +253,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; @@ -315,7 +267,7 @@ 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; } diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index d1c06802f0a..55a3604e3f9 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -482,7 +482,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 @@ -1210,8 +1212,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; } diff --git a/source/blender/python/intern/bpy_util.c b/source/blender/python/intern/bpy_util.c index 2c7626fea7f..d837892fb4d 100644 --- a/source/blender/python/intern/bpy_util.c +++ b/source/blender/python/intern/bpy_util.c @@ -172,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, ""); } fprintf(stderr, "\n"); } @@ -333,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(); @@ -362,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/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/creator.c b/source/creator/creator.c index 5617435049d..a19e5d0718c 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -710,7 +710,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 +719,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 diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index a70790ef2a0..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]); } @@ -342,7 +359,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, } // 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) @@ -424,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) { @@ -432,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(); @@ -558,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; @@ -597,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; @@ -650,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); } @@ -661,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; @@ -724,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 #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 @@ -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/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index e4dd588f06a..131d48aed4f 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 #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 @@ -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; - } - else { + if (!string) { + PyErr_SetString(PyExc_TypeError, "expected a single string"); return NULL; } - Py_RETURN_NONE; -} + 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); + + 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)) + if(PyTuple_Size(args)==2) { + if (!PyArg_ParseTuple(args,"sO:setChannel", &string, &pymat)) // matrix + return NULL; + } + 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 (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; - } - } - 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; - } } - if (!error) - { - -/* DO IT HERE */ - bPoseChannel *pchan= verify_pose_channel(m_userpose, string); - - Mat4ToQuat(matrix, pchan->quat); - Mat4ToSize(matrix, pchan->size); - VECCOPY (pchan->loc, matrix[3]); + if(pymat) { + float matrix[4][4]; + MT_Matrix4x4 mat; - pchan->flag |= POSE_ROT|POSE_LOC|POSE_SIZE; - - if (!m_userpose){ - m_userpose = (bPose*)MEM_callocN(sizeof(bPose), "userPose"); + 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; + + 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/KX_BlenderScalarInterpolator.cpp b/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp index 17bb3dedd36..20829524558 100644 --- a/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp +++ b/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp @@ -28,32 +28,27 @@ #include "KX_BlenderScalarInterpolator.h" +#include + 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) { + 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 +59,13 @@ BL_InterpolatorList::~BL_InterpolatorList() { } } - -KX_IScalarInterpolator *BL_InterpolatorList::GetScalarInterpolator(BL_IpoChannel channel) { - BL_InterpolatorList::iterator i = begin(); - while (!(i == end()) && - (static_cast(*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(*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 { 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 >::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; itotipo; 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 m_map_blender_to_gameactuator; GEN_Map m_map_blender_to_gamecontroller; - GEN_Map m_map_blender_to_gameipolist; + GEN_Map 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); - + 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_LOC_Y); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetPosition()[1]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_LOC_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_LOC_Z); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetPosition()[2]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_LOC_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); + } } - - // 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); + 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_DLOC_Y); - if (ipo) { - KX_IInterpolator *interpolator = - new KX_ScalarInterpolator( - &(ipocontr->GetIPOTransform().GetDeltaPosition()[1]), - ipo); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetIPOChannelActive(OB_DLOC_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_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); - } - 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); - } - 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); - } - - // 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); - } - 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); - } - 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()); + + 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[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()); - } - 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); + 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_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); - } - - 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; + + KX_IInterpolator *interpolator; + KX_IScalarInterpolator *sinterp; // -- - ipo = ipoList->GetScalarInterpolator(MA_COL_R); - 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[0], - ipo); - ipocontr->AddInterpolator(interpolator); } - ipo = ipoList->GetScalarInterpolator(MA_COL_G); - 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[1], - ipo); - ipocontr->AddInterpolator(interpolator); - } - - ipo = ipoList->GetScalarInterpolator(MA_COL_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_rgba[2], - ipo); - ipocontr->AddInterpolator(interpolator); - } - - ipo = ipoList->GetScalarInterpolator(MA_ALPHA); - 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[3], - ipo); - 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()); - } - 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 (!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_rgba[3], sinterp); ipocontr->AddInterpolator(interpolator); } - ipo = ipoList->GetScalarInterpolator(MA_SPEC); - if (ipo) { + 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); + } + } + + 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_spec, - ipo); + interpolator= new KX_ScalarInterpolator(&ipocontr->m_hard, sinterp); + ipocontr->AddInterpolator(interpolator); + } + + if ((sinterp = adtList->GetScalarInterpolator("specularity", 0))) { + if (!ipocontr) { + ipocontr = new KX_MaterialIpoController(matname_hash); + gameobj->GetSGNode()->AddSGController(ipocontr); + ipocontr->SetObject(gameobj->GetSGNode()); + } + 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/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/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; im_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 -#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;itotbind;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; yx]; - 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/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/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_PythonSeq.cpp b/source/gameengine/Ketsji/KX_PythonSeq.cpp index cc8021fc2e4..524d957a80c 100644 --- a/source/gameengine/Ketsji/KX_PythonSeq.cpp +++ b/source/gameengine/Ketsji/KX_PythonSeq.cpp @@ -57,7 +57,7 @@ static Py_ssize_t KX_PythonSeq_len( PyObject * self ) PyObjectPlus *self_plus= BGE_PROXY_REF(((KX_PythonSeq *)self)->base); if(self_plus==NULL) { - PyErr_SetString(PyExc_SystemError, BGE_PROXY_ERROR_MSG); + PyErr_SetString(PyExc_SystemError, "len(seq): "BGE_PROXY_ERROR_MSG); return -1; } @@ -84,7 +84,7 @@ static PyObject *KX_PythonSeq_getIndex(PyObject* self, int index) PyObjectPlus *self_plus= BGE_PROXY_REF(((KX_PythonSeq *)self)->base); if(self_plus==NULL) { - PyErr_SetString(PyExc_SystemError, BGE_PROXY_ERROR_MSG); + PyErr_SetString(PyExc_SystemError, "val = seq[i]: "BGE_PROXY_ERROR_MSG); return NULL; } @@ -145,25 +145,9 @@ static PyObject *KX_PythonSeq_getIndex(PyObject* self, int index) return NULL; } - -static PyObject * KX_PythonSeq_subscript(PyObject * self, PyObject *key) +static PyObjectPlus * KX_PythonSeq_subscript__internal(PyObject *self, char *key) { PyObjectPlus *self_plus= BGE_PROXY_REF(((KX_PythonSeq *)self)->base); - char *name = NULL; - - if(self_plus==NULL) { - PyErr_SetString(PyExc_SystemError, BGE_PROXY_ERROR_MSG); - return NULL; - } - - if (PyInt_Check(key)) { - return KX_PythonSeq_getIndex(self, PyInt_AS_LONG( key )); - } else if ( PyString_Check(key) ) { - name = PyString_AsString( key ); - } else { - PyErr_SetString( PyExc_TypeError, "expected a string or an index" ); - return NULL; - } switch(((KX_PythonSeq *)self)->type) { case KX_PYGENSEQ_CONT_TYPE_SENSORS: @@ -172,8 +156,9 @@ static PyObject * KX_PythonSeq_subscript(PyObject * self, PyObject *key) SCA_ISensor* sensor; for (unsigned int index=0;indexGetName() == name) - return sensor->GetProxy(); + if (sensor->GetName() == key) + return static_cast(sensor); + } break; } @@ -183,8 +168,8 @@ static PyObject * KX_PythonSeq_subscript(PyObject * self, PyObject *key) SCA_IActuator* actuator; for (unsigned int index=0;indexGetName() == name) - return actuator->GetProxy(); + if (actuator->GetName() == key) + return static_cast(actuator); } break; } @@ -194,8 +179,8 @@ static PyObject * KX_PythonSeq_subscript(PyObject * self, PyObject *key) SCA_ISensor *sensor; for (unsigned int index=0;indexGetName() == name) - return sensor->GetProxy(); + if (sensor->GetName() == key) + return static_cast(sensor); } break; } @@ -205,8 +190,8 @@ static PyObject * KX_PythonSeq_subscript(PyObject * self, PyObject *key) SCA_IController *controller; for (unsigned int index=0;indexGetName() == name) - return controller->GetProxy(); + if (controller->GetName() == key) + return static_cast(controller); } break; } @@ -216,23 +201,105 @@ static PyObject * KX_PythonSeq_subscript(PyObject * self, PyObject *key) SCA_IActuator *actuator; for (unsigned int index=0;indexGetName() == name) - return actuator->GetProxy(); + if (actuator->GetName() == key) + return static_cast(actuator); } break; } } - PyErr_Format( PyExc_KeyError, "requested item \"%s\" does not exist", name); return NULL; } + +static PyObject * KX_PythonSeq_subscript(PyObject * self, PyObject *key) +{ + PyObjectPlus *self_plus= BGE_PROXY_REF(((KX_PythonSeq *)self)->base); + + if(self_plus==NULL) { + PyErr_SetString(PyExc_SystemError, "val = seq[key], KX_PythonSeq: "BGE_PROXY_ERROR_MSG); + return NULL; + } + + if (PyInt_Check(key)) { + return KX_PythonSeq_getIndex(self, PyInt_AS_LONG( key )); + } + else if ( PyString_Check(key) ) { + char *name = PyString_AsString(key); + PyObjectPlus *ret = KX_PythonSeq_subscript__internal(self, name); + + if(ret) { + return ret->GetProxy(); + } else { + PyErr_Format( PyExc_KeyError, "requested item \"%s\" does not exist", name); + return NULL; + } + } + else { + PyErr_SetString( PyExc_TypeError, "expected a string or an index" ); + return NULL; + } +} + + +static int KX_PythonSeq_contains(PyObject *self, PyObject *key) +{ + PyObjectPlus *self_plus= BGE_PROXY_REF(((KX_PythonSeq *)self)->base); + + if(self_plus==NULL) { + PyErr_SetString(PyExc_SystemError, "key in seq, KX_PythonSeq: "BGE_PROXY_ERROR_MSG); + return -1; + } + if(!PyString_Check(key)) { + PyErr_SetString(PyExc_SystemError, "key in seq, KX_PythonSeq: key must be a string"); + return -1; + } + + if(KX_PythonSeq_subscript__internal(self, PyString_AsString(key))) + return 1; + + return 0; +} + +/* Matches python dict.get(key, [default]) */ +PyObject* KX_PythonSeq_get(PyObject * self, PyObject *args) +{ + char *key; + PyObject* def = Py_None; + PyObjectPlus* ret_plus; + + if (!PyArg_ParseTuple(args, "s|O:get", &key, &def)) + return NULL; + + if((ret_plus = KX_PythonSeq_subscript__internal(self, key))) + return ret_plus->GetProxy(); + + Py_INCREF(def); + return def; +} + +PySequenceMethods KX_PythonSeq_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)KX_PythonSeq_contains, /* sq_contains */ +}; + static PyMappingMethods KX_PythonSeq_as_mapping = { KX_PythonSeq_len, /* mp_length */ KX_PythonSeq_subscript, /* mp_subscript */ 0, /* mp_ass_subscript */ }; +PyMethodDef KX_PythonSeq_methods[] = { + // dict style access for props + {"get",(PyCFunction) KX_PythonSeq_get, METH_VARARGS}, + {NULL,NULL} //Sentinel +}; /* * Initialize the interator index @@ -241,7 +308,7 @@ static PyMappingMethods KX_PythonSeq_as_mapping = { static PyObject *KX_PythonSeq_getIter(KX_PythonSeq *self) { if(BGE_PROXY_REF(self->base)==NULL) { - PyErr_SetString(PyExc_SystemError, BGE_PROXY_ERROR_MSG); + PyErr_SetString(PyExc_SystemError, "for i in seq: "BGE_PROXY_ERROR_MSG); return NULL; } @@ -313,13 +380,17 @@ PyTypeObject KX_PythonSeq_Type = { NULL, /* printfunc tp_print; */ NULL, /* getattrfunc tp_getattr; */ NULL, /* setattrfunc tp_setattr; */ +#if PY_VERSION_HEX >= 0x03000000 // TODO - richcmp + NULL, +#else ( cmpfunc ) KX_PythonSeq_compare, /* cmpfunc tp_compare; */ +#endif ( reprfunc ) KX_PythonSeq_repr, /* reprfunc tp_repr; */ /* Method suites for standard classes */ NULL, /* PyNumberMethods *tp_as_number; */ - NULL, /* PySequenceMethods *tp_as_sequence; */ + &KX_PythonSeq_as_sequence, /* PySequenceMethods *tp_as_sequence; */ &KX_PythonSeq_as_mapping, /* PyMappingMethods *tp_as_mapping; */ /* More standard operations (here for binary compatibility) */ @@ -357,7 +428,7 @@ PyTypeObject KX_PythonSeq_Type = { ( iternextfunc ) KX_PythonSeq_nextIter, /* iternextfunc tp_iternext; */ /*** Attribute descriptor and subclassing stuff ***/ - NULL, /* struct PyMethodDef *tp_methods; */ + KX_PythonSeq_methods, /* struct PyMethodDef *tp_methods; */ NULL, /* struct PyMemberDef *tp_members; */ NULL, /* struct PyGetSetDef *tp_getset; */ NULL, /* struct _typeobject *tp_base; */ 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 3e20203a4cc..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"); diff --git a/source/gameengine/PyDoc/API_intro.py b/source/gameengine/PyDoc/API_intro.py index ad37e34fbac..578b56eb2b0 100644 --- a/source/gameengine/PyDoc/API_intro.py +++ b/source/gameengine/PyDoc/API_intro.py @@ -6,22 +6,29 @@ The Blender Game Engine Python API Reference See U{release notes} for updates, changes and new functionality in the Game Engine Python API. - Top Module: - ----------- - - - L{GameLogic} - - L{GameKeys} - - L{GameTypes} - - L{Mathutils} - - L{Geometry} - - L{BGL} + Blender Game Engine Modules: + ---------------------------- + + Modules that include methods for accessing GameEngine data and functions. + + - L{GameLogic} utility functons for game logic. + - L{GameKeys} keyboard input and event conversion. + - L{Rasterizer} display and rendering. + - L{GameTypes} contains all the python types spesific to the GameEngine. Undocumented modules: --------------------- - VideoTexture - - CValue - - Expression - PhysicsConstraints + + Additional Modules: + ------------------- + + These modules have no GameEngine spesific functionality but are useful in many cases. + + - L{Mathutils} + - L{Geometry} + - L{BGL} Introduction: 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/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.",