1
1

Compare commits

...

231 Commits

Author SHA1 Message Date
360f831339 Apricot Branch
==============

Various changes from trunk that were somehow missed with merges, and
small code cleanups and fixes.
2008-09-04 15:45:25 +00:00
7e8a3aa0b1 svn merge -r 16334:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender 2008-09-04 00:32:15 +00:00
0d5ec24a05 Apricot Branch:
* Fix for wrong bone parent transform with duplis (multiplayer).
* Fix for crash on export when the bone in a bone parent relation
  does not exist anymore.
2008-09-04 00:16:34 +00:00
36d3ae12c6 svn merge -r 16328:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender 2008-09-02 06:36:19 +00:00
546127d964 svn merge -r 16297:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender 2008-09-01 07:03:09 +00:00
bb57536018 Apricot Branch: bugfix, setting manual glsl shaders did not release
displaylists, resulted in missing texture coordinates sometimes.
2008-08-29 14:13:26 +00:00
12200c39df Apricot Branch: better support for multiple scenes with glsl,
now it keeps shaders and lamps per scene.
2008-08-29 13:23:33 +00:00
87b7ba70a1 svn merge -r 16295:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender 2008-08-29 06:36:11 +00:00
4d368cb298 svn merge -r 16293:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender 2008-08-29 03:18:02 +00:00
7e4eb371fe svn merge -r 16287:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender still getting errors compiling blenderplayer 2008-08-28 23:12:29 +00:00
2b1c7fe4f9 Apricot Branch: didn't add these file in the last merge commit. 2008-08-28 11:26:40 +00:00
ce70b6bf3b Apricot Branch:
svn merge -r 16266:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender
2008-08-28 11:22:06 +00:00
1aa359ab7b Apricot Branch: bugfix for crash in shadow buffer rendering
combined with the shadow option for texfaces.
2008-08-27 19:12:08 +00:00
3a5b40d8f5 Apricot Branch: another fix for obcolor alpha - i can't seem
to get this right :).
2008-08-27 14:18:52 +00:00
7c9e742dce Apricot Branch: bugfix, broke bone parenting with yesterday's commit. 2008-08-27 13:10:16 +00:00
b5f48d78b4 Apricot Branch: still didn't get the glsl obcolor mixing right,
forgot why I did it the other way around before (because of alpha),
should work correct now.

Also, noticed I committed a bugfix before without knowing related
to creating material buckets with > 65k faces. The fix was provided
by Samuel Anjam, thanks!
2008-08-27 11:56:11 +00:00
b4680f5ca1 divide by zero for texture animation when start and end frames are the same 2008-08-27 07:12:07 +00:00
3b8ed715b6 svn merge -r 16246:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender 2008-08-27 03:41:29 +00:00
76f35a1e9a Apricot Branch: apply glsl object color before mist, makes more sense. 2008-08-26 17:53:04 +00:00
76d03839ac Apricot Branch: fix for a change I made to avoid doing where_is_pose
too often, didn't work correct for multiple objects sharing the same
armature.
2008-08-26 17:38:39 +00:00
4988a1b7f9 Apricot Branch: bugfix, crash in lights switching blender files,
accidentally removed a line of code that should have been kept.
2008-08-26 12:38:05 +00:00
01ba073f46 svn merge -r 16239:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender 2008-08-25 10:11:43 +00:00
b766ff4a00 svn merge -r 16227:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender
Thanks for bens state level commit will be able to clean up duplicate sensors a bit :)
http://members.optusnet.com.au/cjbarton/frank_logic.png
2008-08-24 02:46:03 +00:00
468b25e0f5 Apricot Branch: svn merge -r 16194:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender 2008-08-22 11:51:56 +00:00
8eedcfcc3f error in last commit 2008-08-22 02:33:19 +00:00
93fc6cb680 missing NULL check when game text meshes had no vertex colors 2008-08-22 00:54:22 +00:00
2d428a4061 partial merge because of conflicts
svn merge -16186:16194 https://svn.blender.org/svnroot/bf-blender/trunk/blender
2008-08-21 23:41:08 +00:00
2febacefe2 Apricot Branch: bugfix: glsl materials didn't get correct lights
when switching between blend files. Also took advantage of this
to remove some duplicate code related to accessing blender scenes.
2008-08-21 15:44:29 +00:00
c98ae55666 Apricot Branch: fix for bug #17435, only first 3 texture slots were
being used for finding second uv coordinate layer.
2008-08-21 13:40:40 +00:00
c594a6f25c Apricot Branch
==============

* Make lights and shadows work better with dupligroups, also in
  the game engine. Previously only one dupli would be created,
  and shadows didn't work well at all.
* Make normal maps + stencil work.
* Some glsl refresh and default material fixes.
2008-08-20 16:29:55 +00:00
2a9a2825f5 Apricot Branch: two bugfixes for issues with game engine draw
state switching textures and object color, showed as flickering.
2008-08-19 17:08:20 +00:00
10af2a3cd5 svn merge -r16186:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender 2008-08-19 12:19:38 +00:00
75570d9410 svn merge -r16170:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender 2008-08-19 04:00:22 +00:00
f98d21ca84 Apricot Branch
==============

* Added support for the realtime image "Anim" option for GLSL textures.
  Note that "Tiles" is not supported, i.e. it doesn't scale the texture
  for you, but that may even be desirable.
* Further there was some refactoring to remove duplicated and unused
  opengl texture code for GLSL.
2008-08-18 18:16:32 +00:00
9873352b02 Apricot Branch: fix some missing updates for GLSL materials
when changing world settings. Thanks Pablo for the patch,
though I implemented it a bit differently.
2008-08-18 13:25:27 +00:00
d535770c18 small error, stopped apricot building on linux-32bit 2008-08-18 13:06:33 +00:00
e174b34eef Apricot Branch
==============

svn merge -r16142:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender
2008-08-18 12:09:33 +00:00
9ffc3d065d Apricot Branch: bugfix, some meshes were not deforming anymore
after a recent commit.
2008-08-18 10:27:48 +00:00
009f826006 svn merge -r16106:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender 2008-08-17 01:24:40 +00:00
46131fbcd4 Apricot branch: a fix for flickering alpha, with multi-material
objects. Note that sorting is only between polygons with the same
material, so which material draws first is still arbitrary, but
consistent.
2008-08-14 17:12:40 +00:00
9cc4173c60 svn merge -r16064:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender 2008-08-14 09:18:57 +00:00
15fd22c6bd Apricot Branch
==============

svn merge -r16064:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender
2008-08-13 17:42:58 +00:00
b5fcdc4074 Apricot Branch
==============

Various cleanups and optimizations in the game engine:
* Remove some duplication in the RAS_RenderTools, and sync the blender
  and game player versions. Also avoid some opengl state changes.
* Don't make separate materials for triangles and quads, this distinction
  was moved to the mesh level. Also don't take some other irrelevant tface
  settings into account to avoid making more materials.
* Refactoring of mesh storage, should fix wrong normals on meshes that are
  reused. It also allows for joining together nearby meshes for speed, though
  that's disabled still because it doesn't work together correct yet with 
  ome features.
* Added a distinction for game objects to be either culled or set invisible,
  previously there was only one flag, which couldn't work correct.
* For parenting to bones, where_is_pose was executed multiple times per
  frame, now should be once per armature.
* Fix uninitialized intertia value in the physics system.
* Various warning fixes.
* Removed some conditionals in GLSL and other minor optimizations in the
  code. Also cache opengl uniform locations, and fix an invalid memory read.
* Avoid doing some math for GLSL lamps if it is not required.
2008-08-13 17:37:37 +00:00
17c81efced svn merge -r16009:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender 2008-08-12 12:57:18 +00:00
4043226064 svn merge -r15983:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender 2008-08-07 20:00:58 +00:00
81602d9b85 svn merge -r15968:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender 2008-08-06 00:37:27 +00:00
cd6cec0ebb svn merge -r15932:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender 2008-08-05 10:39:13 +00:00
56d3bfc28a apricot branch: fix a bug with the export of the second uv layer
to the game engine for GLSL.
2008-08-03 16:02:56 +00:00
0253b73fcb apricot branch: svn merge -r15868:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender 2008-08-03 14:46:34 +00:00
b818016d77 Apricot Branch
==============

svn merge -r15866:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender

Alpha blending and sorting changes, but also include some initial
support for GLSL lamps in dupligroups (only one duplicate works at
the moment).
2008-07-29 16:25:20 +00:00
c235327152 svn merge -r15780:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender 2008-07-29 15:27:03 +00:00
3131858792 svn merge -r15780:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender 2008-07-28 14:35:56 +00:00
42f957f910 svn merge -r15774:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender 2008-07-26 15:38:05 +00:00
b059a3c765 svn merge -r15731:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender 2008-07-26 04:36:09 +00:00
ad27c65d02 Apricot Branch: bugfix, don't let material ipo's update the
obcolor in the game engine, otherwise there's two ipo's
updating the same value, and which one is the final value is
undefined.
2008-07-25 10:55:10 +00:00
3801120669 Apricot Branch: GLSL
====================

* Added ObColor support, though it works different than for TexFaces.
  It used a new ObColor option in the materials, which will modulate
  the final color/alpha with the object color and alpha, also works
  in the render engine.
* Made GLSL check the ZTransp flag. A material is now only drawn
  transparent if this flag is enabled, a bit more consistent with the
  render engine.
* Fix for bug #17359: crash related subsurf + editmode GLSL.
2008-07-24 18:00:46 +00:00
848694370e svn merge -r15708:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender 2008-07-24 07:06:27 +00:00
3bb931789d Apricot Branch: fix for typo, no idea how this compiled with gcc.. 2008-07-23 22:23:28 +00:00
c6d799a3dc svn merge -r15698:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender 2008-07-23 07:17:20 +00:00
8c5249d9e1 these files missed the merge 2008-07-22 18:48:28 +00:00
788befdb57 svn merge -r15669:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender 2008-07-22 17:49:15 +00:00
2e695226d6 Apricot Branch: GLSL
====================

Added support for some world settings, updated docs.
* Ambient color
* Exposure/Range
* Mist (implementation should be optimized)

http://www.blender.org/development/current-projects/changes-since-246/realtime-glsl-materials/
2008-07-22 14:33:10 +00:00
c44670f6cd Apricot Branch
==============

* Made GLSL respect opaque/add/alpha/clip flags.
* Fix bug for all material types to correctly deal with
  different transp flags in a single mesh.
* Also made 3d view material alpha code a bit easier to
  understand.
2008-07-21 22:07:51 +00:00
4dc1ac2a7c Apricot Branch
==============

* More refactoring related to opengl lights, material state switching.
  Also moved init_gl_stuff into the gpu module and removed the copy in
  the game engine code.
* Fixed some issues with alpha drawing of GLSL materials in the 3d
  viewport, and fix a bug with alpha + xray drawing in the same scene,
  it should first do alpha, then xray, otherwise alpha doesn't blend
  correct with solid.
2008-07-21 19:27:59 +00:00
706c784b4c Apricot branch: missed file in last commit. 2008-07-21 15:56:42 +00:00
2b1c790951 Apricot Branch
==============

* Fix for crashes in last commit.
* Added "Refl" map input for textures.
2008-07-21 15:53:53 +00:00
63408f4e02 Apricot Branch
==============

* Refactoring in the texture and material drawing code, moving
  code into the gpu module, removing the duplicated versions
  in the game engine.
* Made game engine text drawing work with GLSL. It works based
  on filling in the default uv layer, so it requires a texture
  with the text image and mapped as uv's to work.
2008-07-21 15:35:11 +00:00
d09ce02613 svn merge -r15657:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blende 2008-07-21 13:11:56 +00:00
2c436f660b svn merge -r15643:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender 2008-07-20 17:25:12 +00:00
31cbb6060c svn merge -r15622:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender 2008-07-19 13:07:47 +00:00
d3758828b8 svn merge -r15608:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender 2008-07-18 13:06:49 +00:00
1a8fa0dd2a svn merge -r15597:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender 2008-07-16 23:02:23 +00:00
3e7c57098a Apricot: GLSL
=============

* Moved GLSL setting switching functions into the game engine
  python API so they work in the blender player, and can do
  better state switching.
* Also fixes bug #17331, error compiling with cmake.

* For the makers of test builds: it would be great if builds of
  this revision or newer for various platforms could be made
  available. We want to release a file to test and benchmark
  GLSL on different graphics cards, and we need test builds for
  this. Thanks!
2008-07-16 16:20:52 +00:00
42459bad2e Apricot Branch
==============

Fix for bug #17326: normal and tangents in the game engine
were computed different than other parts of Blender, this
makes the game engine use the same code as Blender.

Fix for part of bug #17307: normal maps not working correct
in editmode in some cases.

Fix for bug #17339: a crash on ATI cards in glTexSubImage1D
due to a mistake in the code. A patch to fix this was provided
by Yong Ch, thanks!
2008-07-16 13:53:39 +00:00
af4262d03f svn merge -r15566:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender 2008-07-16 07:10:33 +00:00
1c2fd65ddb Apricot Branch
==============

* Made in game switching of GLSL options work. There is still
  a one frame flicker that needs to be fixed.
* Added access to the estimated average framerate in the game
  engine: GameLogic.getAverageFrameRate().
* Added acces to the blender build info from python:
  Blender.Get("buildinfo")
* Various GLSL optimizations to allow more constant folding in
  the glsl compiler, use glsl shadow functions to do shadow,
  instead of own code, and fix an issue with opengl texture
  color range.
2008-07-15 21:59:46 +00:00
95fbf83423 Apricot: GLSL
=============

* Added options to disable lights, shaders, shadows, ramps,
  nodes and textures other than col/alpha for GLSL, in the
  Game menu.
* These have python access too to switch them in game, but
  it doesn't work correct yet with display lists enabled.
* Fix issue with light lagging behind, debug stats drawing in
  wrong color, and a number of other small fixes.
2008-07-14 23:26:38 +00:00
a1fea54c18 svn merge -r15560:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender
Also topology mirror crashed when using smooth + mirror. use eve->hash rather them eve->tmp.l for storing edit vert indices's.
2008-07-14 13:39:48 +00:00
00c4265bda svn merge -r15549:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender
- mainly to fix the free() crash with the file selector
2008-07-13 21:07:44 +00:00
151c8cc864 svn merge -r15528:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender 2008-07-12 13:41:18 +00:00
e84b2bd948 svn merge -r15518:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender
Also made shadow mesh draw in texture paint (venomGFX request)
2008-07-11 11:10:32 +00:00
06354f7f75 Apricot Branch
==============

svn merge -r15501:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender
2008-07-10 12:49:55 +00:00
ad103954e6 Apricot Branch: GLSL
====================

ATI fixes:
* Fix crash in glBitmap when rendering shadow buffers, it doesn't
  seem to like using that function with only a depth buffer.
* Workaround either a bug in the driver or Blender, but I couldn't
  find anything wrong, glVertexAttribPointerARB doesn't seem to
  work inside display lists, so now it uses immediate mode to
  create the list.
* Making deformable object for the game engine didn't check properly
  if there was actually a vertex group, causing some static objects
  to not use display lists.
* Also some cleanup in the game engine drawing code, replacing magic
  numbers with an enum.

The apricot demo seems to runs slightly faster on a ATI HD3750 than
NVidia 8800 GTS.
2008-07-09 19:15:15 +00:00
64e584fc0a svn merge -r15491:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender 2008-07-09 12:51:53 +00:00
437b207d3a Apricot Branch: GLSL
====================

* Some optimizations in the glsl shader code to avoid some
  matrix multiplications, and other floating point ops.
* Optimized game engine mesh deforming code a bit, and
  removed a bunch of unneeded/duplicated code.
* Fix for bugs #17289 and #17295, glsl compile errors.
2008-07-08 22:30:54 +00:00
f43c66f384 svn merge -r15478:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender/ 2008-07-08 18:32:42 +00:00
178be13f65 Apricot Branch: GLSL
====================

* Second attemp at solving exp/log incompatibility, some compilers
  don't seem to properly support preprocessor defines?
* Some simple optimizations to skip diffuse/specular/emit if they
  are set to zero.
2008-07-07 21:25:10 +00:00
9bf054b7a9 svn merge -r14639:14688 https://svn.blender.org/svnroot/bf-blender/trunk/blender/ 2008-07-07 21:18:30 +00:00
f26485d28d Apricot Branch: two minor optimizations to avoid unneeded shader
and opengl light state changes.
2008-07-07 17:14:44 +00:00
e232ea3a4f Apricot Branch:
Bugfix to make custom glsl shaders work with blender glsl shaders.
2008-07-07 15:12:42 +00:00
00703cc507 Apricot Branch
==============

Some optimizations:
* Only Apply mesh deformer if the mesh is actually modified, once
  per frame, this was done too often before.
* GLSL shader binding is now faster, only goes over dynamics inputs
  instead of all of them, and frees more memory after compiling too.
2008-07-07 13:57:29 +00:00
6f9c6e5c80 Apricot Branch: GLSL
====================

* Forgot to add/remove file in list commit.
* Game engine shadow optimization, don't use shaders for
  drawing into shadow buffer.
2008-07-07 11:58:09 +00:00
f78fb5d232 Apricot Branch: GLSL
====================

* Added a separate "Layer" option for lamp shadows, that only
  restricts which objects cast shadow, instead of receive light
  and shadow.
* Added exp/log compatibility for GLSL versions < 1.10.
* Check for depth texture extension before using it.
2008-07-07 10:52:09 +00:00
264546961a these escaped the merge 2008-07-06 15:02:21 +00:00
68927fdeb6 svn merge -r15426:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender/ 2008-07-06 14:38:27 +00:00
7499860e80 svn merge -r15399:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender/
manually merged source/gameengine
2008-07-04 10:31:21 +00:00
9907889c8f svn merge -r15389:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender/ 2008-07-01 17:01:14 +00:00
f7d704fcf9 svn merge -r15360:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender/ 2008-06-29 22:08:23 +00:00
bca0d2d3e8 svn merge -r15355:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender/ 2008-06-26 12:43:10 +00:00
3282d85627 svn merge -r15339:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender/ 2008-06-25 16:25:01 +00:00
cf8807581e svn merge -r15309:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender/
Note the mail message failed to come through for 15309 which was just a merge from trunk.
2008-06-24 05:02:01 +00:00
8a7eab4e56 Apricot Branch: bug in GLSL code generation for nodes. 2008-06-23 18:09:51 +00:00
Nathan Letwory
0a92399afd * 22:51 < ideasman-42> jesterKing, dude you totally over did it :0
- the solution was longer than needed. A simple letter addition (r) would've been enough.
2008-06-22 20:24:27 +00:00
Nathan Letwory
ef8d649815 * fix path problems when running .py scripts through menus
- \'s were not escaped, confusing execfile()
* small indentation fix in btools.py
2008-06-22 19:49:48 +00:00
deabd2a280 svn merge -r15265:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender/ 2008-06-22 18:12:46 +00:00
3afb8c19a3 Apricot Branch: fix bug with shaders going black. 2008-06-21 14:31:38 +00:00
b474283367 Apricot Branch: GLSL
====================

* Added initial support for shadow buffers, works in the 3d view and the
  game engine, but has known issues still:
	* Shadow buffers are made again for each 3d viewport unnecessarily.
	* No filtering.
	* There was a bug with some shaders going black, but can't reproduce
	  it anymore?

* Added support for layer lamps, though they're still always computed
  in the shader, this needs to be optimized.
* Added support for animating lamp position/rotation in the game engine.

* Fix issue with lamps giving negative light on the backside.
* Fix issue with specular + orthographic camera.
* Fix square spotlights.
* Potential workaround for a bug in the nvidia drivers with shader linking.
2008-06-21 10:33:12 +00:00
c302bfcb7c length of matrix was incorrect, some scripts may depend on this not sure if we can make the change in trunk. 2008-06-20 16:58:41 +00:00
13d00b5dcd Apricot Branch: issue in last commit with disabling/enabling GLSL
shaders, now it remembers the last one, should be more reliable.
2008-06-18 14:56:12 +00:00
ccc58f4491 Apricot Branch: Various Fixes
=============================

* Make GLSL shaders work in the game player.
* In the game engine with GLSL and no material assigned, it now falls
  back to texface materials. Not in the 3d view yet ..
* Fix memory when using the default material for GLSL.
* Fix another use of the builtin "smooth" name as a variable in the
  GLSL code, gives issue on ATI.
* Fix problem with the armature deform being applied to only one
  material bucket, gave floating triangles.
* Fix crash when setting .timeOffset through python without a parent.
* Use only gl*ARB functions so that GLSL also works on graphics cards
  that do not have opengl 2.0 but do have the extensions.
* Fix use of unitialized variable for render memory usage stats.
2008-06-18 13:44:29 +00:00
a790d75dc8 Apricot Branch: missed some files in last commit. 2008-06-18 11:16:40 +00:00
00b742cf20 Apricot Branch: svn merge -r 15249:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender/
(game engine shape keys!)
2008-06-18 11:04:30 +00:00
dc8776cafb Apricot Branch: GLSL
====================

* Added GLSL vertex color support in the game engine.
* Added VCol Paint and VCol Light options.
2008-06-17 23:25:20 +00:00
8fd0b50602 Apricot Branch: GLSL
====================

* GLSL in the game engine now uses the second uv layer too.
2008-06-17 22:03:17 +00:00
a379a50f2b Apricot Branch: GLSL
====================

* Added support for the Material and Extended Material nodes.
* Added support for node groups.
* All nodes except Dynamic are now supported.
2008-06-17 21:23:51 +00:00
0fc753cfc5 Apricot Branch: GLSL
====================

* Internal change only: now it compiles the functions separately
  once and then links them together with the generated code, instead
  of appending the code and compiling them again for each material.
  Gives only slight compilation speedup unfortunately.
2008-06-17 18:36:29 +00:00
0b02b01892 Apricot Branch: GLSL
====================

* Added support for Ramps, diffuse + specular, all inputs
  and blending methods are supported.
2008-06-17 17:32:12 +00:00
3caa27fa24 Apricot Branch: GLSL
====================

* Added support for the ColorRamp node.
* Added less than / greather than in the Math node.
* Added support for all blend modes of the Mix node and
  all blend modes in the texture stack.
* Added more Map To support, now available:
  Col, Nor, Csp, Ref, Spec, Amb, Hard, Alpha, Emit.

* Possible fix for a GLEW / opengl include conflict on
  Mac OS X in playanim.c
2008-06-17 14:21:33 +00:00
e414d79808 Apricot Branch: svn merge -r 15241:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender/ 2008-06-17 10:16:52 +00:00
39cecc6044 Apricot Branch
==============

Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.

The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.

For uses: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.

* The game engine now also uses GLEW for extensions, replacing the
  custom opengl extensions code that was there. This means also that
  all extensions will now always be compiled in, regardless of the
  glext.h on the platform where compilation happens. Removes a lot
  of #ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
  work around a specific bug and only disabled multitexturing anyway.
  It might also have caused a slowdown since it was retrieving the
  environment variable for every vertex in immediate mode (bug #13680).

* Refactored the code to allow drawing skinned meshes with vertex
  arrays too, removing some specific immediate mode drawing functions
  for this that only did extra normal calculation. Now it always splits
  vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
  required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
  attributes for vertex arrays. These were not being enabled/disabled
  correct according to the opengl spec, leading to crashes. Also tangent
  attributes used an immediate mode call for vertex arrays, which can't
  work.
* Fixed use of uninitialized variable in RAS_TexVert.

* Also in the GLSL shaders, removed conditional returns since some
  graphics cards don't support this. And fix a bug with orco's not
  being created in textured mode.
2008-06-16 16:58:12 +00:00
9725cb1186 svn merge -r15232:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender/ 2008-06-16 09:23:14 +00:00
6df6d6be72 Fix msvc compile error, reported by Wahooney 2008-06-15 17:55:23 +00:00
f1aa2edca3 svn merge -r15228:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender/ 2008-06-15 09:49:18 +00:00
38fa819cbd Apricot Branch:
Some optimizations to decrease game engine startup time:
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
  deform weights, now uses same trick as regular meshes.
* Share GLSL shaders with the game engine so they don't have to be
  recompiled. This required changes to the rasterization in the game
  engine to add an option to use attributes instead of texture 
  coordinates.
* Some small optimizations in bullet BVH building, though could be
  improved more, since it takes about 50% of startup time still in
  my test .blend.
2008-06-14 23:51:01 +00:00
07e5dc0b96 svn merge -r15223:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender/ 2008-06-14 22:37:33 +00:00
38fe96e1ad svn merge -r15209:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender/ 2008-06-14 18:13:02 +00:00
6d62a18a51 Apricot Branch: GLSL
====================

* Added support for lamps and shaders. All material diffuse and
  specular shaders are supported, for lamps especially area light
  support is not there yet.

* Added support for these GLSL shaders in the game engine, though
  it is incomplete and somewhat of a hack. Specifically all the
  variables are completely static, which means moving lights, or
  animating material properties will not work.

* Enabling GLSL shaders is now different. They work in textured
  drawmode, and can be enabled in the Game menu with the option
  "Blender GLSL Materials"

Known issues:
* The GLSL shaders don't always update correct on light changes.
* The game player appears to crash with these GLSL shaders, while
  regular blender works fine.
2008-06-13 21:24:21 +00:00
9fb4cbc668 missing call to EM_free_index_arrays() 2008-06-13 12:54:44 +00:00
a40c48ce78 Topology Mirror. Find mirror verts based on topology, ignoring vertex location,
Currently works with transform and weight painting.
Tested with 5 peach characters and Suzanne (without eyes), rely's on both verts being uniquely positioned in relation to the surrounding edge topology. useful when weight painting asymmetric characters.
2008-06-13 12:33:35 +00:00
82863827ca svn merge -r15173:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender/ 2008-06-12 15:05:52 +00:00
8a84639207 moved uv_center from drawimage.c to editface.c, removed extern defines needed for transform, also replaced G.vd->around with t->around 2008-06-11 05:46:10 +00:00
02ca9d55e6 fix for some errors with UV mirror when the face/vertex connection map could not be generated. 2008-06-10 10:32:16 +00:00
3304f85e0a UV Mirror now detects the bounding box of UV islands to get the mirror center
Access mirror now from the UVs menu (dont use mesh mirror)
Added vertical mirroring (can only do U or V mirror)
 - mirror dosnt work with quad constrained or PET yet.
2008-06-10 09:42:33 +00:00
88dd8e21d1 svn merge -r15165:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender/ 2008-06-09 15:55:04 +00:00
a2147e1089 ipo ghosting option, request from venomgfx to help adjusting ipos with a reference to the original (enable in the view menu -> Ghost Editmode) 2008-06-08 20:47:34 +00:00
e7fc44da7e svn merge -r15150:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender/ 2008-06-08 20:43:22 +00:00
3ac5c5e770 edge loop side/del uv only worked with a maximum of 4 faces connected to a vert.
now make a list that can have any number of face/uvs.
2008-06-08 02:38:38 +00:00
326f7060f3 evil tri-count stats, game people want, counts tri's while drawing, but no other fast way to do this. 2008-06-08 01:00:09 +00:00
444318431b flag name should be UVCALC_TRANSFORM_CORRECT rather then UVCALC_NO_TRANSFORM_CORRECT 2008-06-07 18:19:27 +00:00
e6c26fbb4e Option to correct for UV distortion when edge sliding when the surrounding faces share the same UV location (else uv interpolation is ignored for that vert).
Enable this from the UV Calculation panel, "Transform Correction" button.
This also means deleting edge loops keeps uvs where possible (even when Transform Correction isnt enabled).
Works for multiple UV layers.
2008-06-07 17:48:35 +00:00
dafafabc7c svn merge -r15143:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender/ 2008-06-07 17:39:01 +00:00
94a087ce54 missed this file 2008-06-05 23:01:03 +00:00
516635ea76 svn merge -r15122:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender/ 2008-06-05 22:18:13 +00:00
beafbe21f4 Apricot Branch: add -fvisibility=hidden if supported, to prevent conflicts
with bullet symbols used by b2cs. Note msvc does this already. Support was
added to Make/CMake/Scons, though it's pretty ugly code with shell commands,
couldn't figure out how to do it nicer.
2008-06-04 21:29:47 +00:00
449dc4951c svn merge -r15115:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender/ 2008-06-04 16:41:09 +00:00
fedaaa1629 venomgfx needs a center other then 0.5 for some UV maps, use the 2d cursor as a temp soluition 2008-06-04 15:06:24 +00:00
d3f6b7e6a7 UV transform X axis mirror 2008-06-04 14:57:06 +00:00
dfbdaabef8 svn merge -r15095:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender/ 2008-06-04 12:32:47 +00:00
6b4d33b634 experemental support for key up events with space handelers. 2008-06-04 12:27:32 +00:00
7e714967e9 undo temp change to try and solve [#13605] GameEngine corrupts Pose data 2008-06-03 10:05:09 +00:00
3a4f0bcda2 svn merge -r15057:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender/ 2008-06-03 09:42:18 +00:00
1911f3f8ed bugfix, one texture was placed in the list twice 2008-06-02 16:29:48 +00:00
72166c2192 Remove extra semi-colon (MSVC was shocking on that, probably thinking it was a null instruction mixed with variables or some other silly reasons). 2008-05-31 11:11:51 +00:00
2ae427d55f Apricot Branch: refactoring of the glsl code, removing unused code
and changing code generation to require fewer function calls.
2008-05-30 14:56:23 +00:00
555dff358f svn merge -r14995:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender/ 2008-05-30 09:20:34 +00:00
39da0b7619 Apricot Branch: basic material texture alpha support. 2008-05-29 13:07:45 +00:00
0d44ba56bb Transform Snap
Editmode snapping to derived mesh.

Now all the fun snapping options (snapping to faces, verts, edges) are supported inside edit mode and you can also snap to subsurfed faces, virtual array copies, ... from inside edit mode.
2008-05-29 10:51:10 +00:00
1aff5de748 Small fix to derivedmesh for snapping: don't create origindex for
editmesh derivedmesh since it's not being filled correct anyway.
2008-05-29 09:23:18 +00:00
0b01c20bed fixes from trunk 2008-05-27 15:15:50 +00:00
81cbfc5c9e Fixing snapping normal alignment for non-uniformly scaled objects. 2008-05-27 14:31:29 +00:00
c5cc2d8fc2 Fix for #12633: crash with scaling of non power of two textures in
the apricot glsl code.
2008-05-27 10:17:25 +00:00
6ab7d3e1b1 svn merge -r14980:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender/
also removed some old transform snap stuff that isnt needed now.
2008-05-27 09:22:59 +00:00
1a91266864 uv snapping feature for venomgfx, this snaps selected UV coords to
visible,unselected coords. access from the shift+s menu
2008-05-26 14:38:51 +00:00
f36b06e17a svn merge -r14921:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender/ 2008-05-26 13:14:19 +00:00
ff0833412c added uvlayer and material support for grid reduction, (for apricot
terrain)
2008-05-24 22:38:02 +00:00
9c8bec4aec fix for triangle lightmap packing and remove some prints 2008-05-23 00:04:31 +00:00
d34091386e added a fairly spesific function to Mesh.c that gets the contrast of the texture under a face (should move to Image.c)
added an option for lightmap UV packer that scales down faces with low light contrast for 2Pass-Adaptive-ShadowMapsTM :)
2008-05-22 23:25:32 +00:00
3dcdf75f50 object: ray - boundbox intersection test
snap: use the above instead (giving up padding but getting rid of stupid projection problems)
2008-05-22 15:20:14 +00:00
3f303b092b experemental ID versioning to know what data has changed to avoid re-exporting entire levels. (with py api)
also scriptlinks for lamps and material updates.
2008-05-22 13:32:51 +00:00
2bab988b85 merge from trunk for venomgfx 2008-05-22 09:29:42 +00:00
59fd401ddf Apricot Branch: svn merge -r 14899:HEAD 2008-05-22 09:11:52 +00:00
829ad0e999 tool to interactively propotype animations using python and the NLA 2008-05-22 09:07:37 +00:00
4dd421204b Snaping
Bypass boundbox test if camera is inside bounding box
2008-05-21 16:42:46 +00:00
06cee7fef9 mesh check for duplis, when snapping 2008-05-21 13:43:39 +00:00
10f7cb934f Snapping on duplis 2008-05-21 12:57:22 +00:00
baf0b79446 +comment 2008-05-21 10:44:25 +00:00
61fa2043e5 Apricot Branch
==============

Fixes for compiling on Windows related to glew, snprintf
and the outliner, tested with CMake + MSVC 2008.
2008-05-20 13:31:31 +00:00
edbd5d9d42 Apricot Branch
==============

- CMake build system support for GLSL.
2008-05-20 12:45:54 +00:00
94028bc126 Apricot Branch: svn merge -r 14875:HEAD 2008-05-19 18:41:13 +00:00
30142a3b92 Apricot Branch
==============

- Memory usage limit for undo, specified in megabytes, the default 0
  means unlimited.
- Multiple undo levels for image painting. Works separate from global
  undo similar to editmode undo, and undo for multiple images is
  supported.
2008-05-19 18:37:31 +00:00
c29a95acf9 Snappy stuff
* Align rotation with snapping target: rotate the object, aligning it with the target (object mode only - temporarily)

* Snap to different mesh elements (face, edge, vertice): snapping target slide on faces and edge or use exact position of vertice. When using Align rotation with edge snapping, the normal is interpolated as you slide along.

Removing ugly apricot hack for drop to ground (YAY!)
2008-05-19 14:16:18 +00:00
ee74a440eb Arith:
- axis angle to quat conversion function
	- short to float / float to short normals conversion function (eventually, we could go over the go and replace copy/pasted code everywhere)
	- ray triangle intersection (to complement the line triangle intersection function)
	
View:
	- viewray / viewline (get near plane point under mouse and ray normal/far point)


Particles:
	- extract viewline from brush_add function
2008-05-19 10:13:16 +00:00
ee1bb9e26d added option to apply a spacialy divided grid of images and UV's per mesh. useful for baking terrain in apricot 2008-05-17 00:02:08 +00:00
b8f1393d4e Apricot Branch: svn merge -r 14866:HEAD 2008-05-16 21:38:51 +00:00
fe78d082bd added library loading where you can select many libraries or a directory of libs and load them without appending or linking anything.
This is so the outliner can be used to link in data from existing libraries without having to open each blend file.
2008-05-16 20:21:40 +00:00
7861cd7c1b Centralize handling of individual center for rotations 2008-05-16 15:00:21 +00:00
c3bb4e1961 Apricot Branch: svn merge -r 14842:HEAD 2008-05-16 11:05:50 +00:00
03d1ef41c7 Merging libmp3lamp from trunk (slipped between the cracks) 2008-05-16 10:43:49 +00:00
defc4d2dc7 first layer icon displayed lighter 2008-05-16 10:23:18 +00:00
d721c743cb added a menu for selecting which types to draw for outliner library members 2008-05-16 09:30:07 +00:00
f9b0ba6ef3 basic support for browsing libraries from the outliner, clicking on a group links it in and applies it to the active object as a dupli or adds the object if none are
active.
also made dupligroup drawing use the most basic drawtype from teh dupli of the object that instances it. this is so apricot can have low poly objects as lods but not 
have overlaping rendering.
2008-05-15 23:49:43 +00:00
56cba0bb76 Apricot Branch
==============

svn merge -r 14780:HEAD
2008-05-14 16:59:17 +00:00
e66002841d make smooth work with mirror option 2008-05-12 21:41:00 +00:00
cff63412cc fix for error when resolving conflicts 2008-05-12 21:19:24 +00:00
8e4f1a7705 merge 14760:HEAD 2008-05-10 17:32:31 +00:00
6546305b60 merge from trunk 2008-05-09 11:10:37 +00:00
3181fcb984 svn merge -r14718:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender/ 2008-05-08 07:57:39 +00:00
7d7991ccaf apricot request layer colors for active/used/empty color channels, colors are not that nice at the moment, so lucky we have artists! 2008-05-07 21:21:48 +00:00
f969d560c0 svn merge -r 14688:HEAD 2008-05-07 08:59:43 +00:00
7fbf8080e6 Apricot Branch
==============

svn merge -r 14688:14706

Also, use vertex arrays for drawing points, and a temporary hack to
reduce the number of points.
2008-05-06 16:01:31 +00:00
70f7b998fc Apricot branch bugfix: texture slots changes had a bug that could make
drawing them crash.
2008-05-05 19:19:27 +00:00
63b73469d8 raised maximum texture slots to 18 2008-05-05 15:40:16 +00:00
7bb6187209 merge from trunk 2008-05-05 13:35:12 +00:00
5c97dfbca1 moved snap button to ground into header until it can be integrated with snap or put elsewhere.
needed to move KX_BlenderGL.cpp include to compile
2008-05-01 13:02:16 +00:00
c97975e879 Apricot Branch
==============

svn merge -r 14561:14620
2008-04-30 12:27:13 +00:00
5e0e27a180 make translate view zoom use grid size 2008-04-28 12:22:28 +00:00
4b7c271311 fixes from trunk 2008-04-27 20:43:45 +00:00
9e07b7fdfd Apricot Branch
==============

svn merge -r 14561:14567
2008-04-27 18:45:33 +00:00
8999c3d6dd changes from trunk 2008-04-27 15:00:31 +00:00
2ff5edc2a0 changes from trunk 2008-04-26 14:02:41 +00:00
6bfa99e695 Apricot Branch
==============

- Added basic cook-torrance specular to the GLSL material.
2008-04-25 17:39:40 +00:00
79280bb4c7 Apricot Branch
==============

GLSL materials:
- Basic support for normal maps, though it looks quite flat with
  the current solid mode lighting.
2008-04-25 16:58:32 +00:00
228132ca55 Apricot Branch
==============

GLSL materials:
- Added the beginning of texture stack evaluation, only a few options
  are supported.
- Added a few lines of code to display non-node materials, with solid
  mode lighting to at least see something.
2008-04-25 13:46:14 +00:00
7a23da05d3 caedes needed this fix for exporting 2008-04-25 10:25:17 +00:00
0821fc4377 Apricot Branch: material GLSL shaders
=====================================

- Currently only supports node-based materials, with some nodes,
  main purpose of this commit is to get the infrastructure in
  place, more material options will be added in the following weeks.
- Supported shader nodes: camera, curves, geometry (everything
  except global and front/back), curves (partially), huesatval,
  invert, mapping, math, mix/add/mult/sub/div, math, vector math,
  normal, output, rgb, separate/combine rgb, squeeze, basic image
  textures, value and output.
- Lights and shaders are still missing, but since the SoC project
  had these working quite far it should be possible to reuse that
  code.

- Enable using "GL Shaded Mode" in the user preferences. It will
  replace regular shaded mode with glsl shaders.
- If the material is not node based or has an error in it, it will
  revert to solid shading. Need to do this kind of error handling
  better and make it posssible to still run even with some
  functionality not supported.
- Integration with texture loading in textured mode is very poor,
  needs to be revised.

- Only added support for Scons and Makefiles.
- Added GLEW in extern/. There were some conflicts with the game
  engine opengl extensions but managed to solve them. Still, it
  would be good to use single mechanism for opengl extensions.
- Added a "gpu" module in source/blender. It has quite a lot of
  code with much of it uncommented as well, some of that will
  become used and some it will be removed later.
- OpenGL shader code is currently converted to a C file with
  datatoc (which now 0-terminates the arrays), but this has to
  be done manually still, need to figure out a better way or
  integrate it into the build systems.
2008-04-24 20:21:33 +00:00
9fdd01d3e5 changes from trunk 2008-04-23 21:11:02 +00:00
35536cfc48 dupliGroup instance offset, so a library of objects can be stored on 1 layer without placing each groups members over the world 0,0,0 point. 2008-04-23 11:38:10 +00:00
5644546c5a Request from Chris Plush, poly reduction tool that maintains face loops and gives pradictable results for terrain, this could evolve into an UnSubsurf tool.
Currently face flipping is incorrect and UV's are lost.
2008-04-23 10:16:59 +00:00
41bf809327 merge from trunk 2008-04-22 14:40:24 +00:00
071c679093 added comments for bad transform stuff 2008-04-21 09:50:26 +00:00
5333d4855d ground clamp during transform for speedy level editing,
The way this is integrated into transform code is really unacceptable, tried making this integrate into snap and retopo, but neither are good fits. - Will discuss with Theeth how this might best fit in.
2008-04-21 09:13:56 +00:00
e3ebe509e2 merge from trunk + some own stuff commented 2008-04-20 18:26:06 +00:00
1f1fdf1d7b changes from trunk 2008-04-19 11:26:51 +00:00
3a14f1d601 fix for last commit, inverted zoom 2008-04-18 21:33:38 +00:00
c44bffaf90 apricot request, continues view translates the offset (like fly mode) when auto depth enabled, probably will need a nicer solution for this in trunk. 2008-04-18 21:28:41 +00:00
7fd7d080a2 changes from trunk as well as ipo transform bugfix with NLA scale 2008-04-18 20:54:17 +00:00
f6a2f47cfe warning fix from trunk 2008-04-17 21:15:53 +00:00
fa66376e36 Make scripts stay in the windows when LOAD UI is disabled 2008-04-17 16:28:29 +00:00
1d03d93e39 Auto Depth didnt work in ortho perspective 2008-04-17 12:51:22 +00:00
67a506401a Option improved view navigation with large scenes. - "Auto Depth" in the view settings.
This works around the annoying problem where you cant zoom in any further by using the depth under the mouse to set the zoom endpoint.
It also sets the view rotation pivot to be under the mouse and works well with "Zoom to Mouse Position"
2008-04-17 09:49:15 +00:00
9a86799f1d branch for the apricot project 2008-04-17 08:35:47 +00:00
716 changed files with 51154 additions and 20011 deletions

View File

@@ -38,6 +38,8 @@ MACRO(BLENDERLIB
ENDMACRO(BLENDERLIB)
MACRO(SETUP_LIBDIRS)
# see "cmake --help-policy CMP0003"
CMAKE_POLICY(SET CMP0003 NEW)
LINK_DIRECTORIES(${PYTHON_LIBPATH} ${SDL_LIBPATH} ${JPEG_LIBPATH} ${PNG_LIBPATH} ${ZLIB_LIBPATH} ${ICONV_LIBPATH} ${OPENEXR_LIBPATH} ${QUICKTIME_LIBPATH} ${FFMPEG_LIBPATH})
IF(WITH_INTERNATIONAL)
LINK_DIRECTORIES(${GETTEXT_LIBPATH})

View File

@@ -63,7 +63,6 @@ OPTION(WITH_QUICKTIME "Enable Quicktime Support" OFF)
OPTION(WITH_OPENEXR "Enable OpenEXR Support (http://www.openexr.com)" ON)
OPTION(WITH_FFMPEG "Enable FFMPeg Support (http://ffmpeg.mplayerhq.hu/)" OFF)
OPTION(WITH_OPENAL "Enable OpenAL Support (http://www.openal.org)" ON)
OPTION(YESIAMSTUPID "Enable execution on 64-bit platforms" OFF)
OPTION(WITH_OPENMP "Enable OpenMP (has to be supported by the compiler)" OFF)
IF(NOT WITH_GAMEENGINE AND WITH_PLAYER)
@@ -183,24 +182,38 @@ IF(UNIX)
SET(LLIBS "-lXi -lutil -lc -lm -lpthread -lstdc++")
IF(WITH_OPENMP)
SET(LLIBS "${LLIBS} -lgomp ")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp ")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp ")
SET(LLIBS "${LLIBS} -lgomp")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
ENDIF(WITH_OPENMP)
SET(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing -DXP_UNIX -Wno-char-subscripts")
SET(PLATFORM_LINKFLAGS "-pthread")
INCLUDE_DIRECTORIES(/usr/include /usr/local/include)
# msvc already hides symbols, for others do it if the compiler supports it
EXECUTE_PROCESS(COMMAND echo "int main() { return 0; }" COMMAND ${CMAKE_C_COMPILER} -fvisibility=hidden -o /dev/null -xc - RESULT_VARIABLE VISIBILITY_RESULT OUTPUT_QUIET ERROR_QUIET)
IF(NOT VISIBILITY_RESULT)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -DGCC_HASCLASSVISIBILITY")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -DGCC_HASCLASSVISIBILITY")
ENDIF(NOT VISIBILITY_RESULT)
ENDIF(UNIX)
IF(WIN32)
INCLUDE(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake)
INCLUDE(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake)
SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/windows)
# Setup 64bit and 64bit windows systems
IF(CMAKE_CL_64)
message("64 bit compiler detected.")
SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/win64)
ENDIF(CMAKE_CL_64)
SET(PYTHON ${LIBDIR}/python)
SET(PYTHON_VERSION 2.5)
SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}")
@@ -214,12 +227,20 @@ IF(WIN32)
SET(OPENAL_LIB openal_static)
SET(OPENAL_LIBPATH ${OPENAL}/lib)
SET(PNG_LIB libpng_st)
IF(CMAKE_CL_64)
SET(PNG_LIB libpng)
ELSE(CMAKE_CL_64)
SET(PNG_LIB libpng_st)
ENDIF(CMAKE_CL_64)
SET(JPEG_LIB libjpeg)
SET(ZLIB ${LIBDIR}/zlib)
SET(ZLIB_INC ${ZLIB}/include)
SET(ZLIB_LIB libz)
IF(CMAKE_CL_64)
SET(ZLIB_LIB zlib)
ELSE(CMAKE_CL_64)
SET(ZLIB_LIB libz)
ENDIF(CMAKE_CL_64)
SET(ZLIB_LIBPATH ${ZLIB}/lib)
SET(PTHREADS ${LIBDIR}/pthreads)
@@ -234,7 +255,11 @@ IF(WIN32)
SET(GETTEXT ${LIBDIR}/gettext)
SET(GETTEXT_INC ${GETTEXT}/include)
SET(GETTEXT_LIB gnu_gettext)
IF(CMAKE_CL_64)
SET(GETTEXT_LIB gettextlib)
ELSE(CMAKE_CL_64)
SET(GETTEXT_LIB gnu_gettext)
ENDIF(CMAKE_CL_64)
SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
SET(FREETYPE ${LIBDIR}/freetype)
@@ -265,7 +290,12 @@ IF(WIN32)
SET(FFMPEG_LIB avcodec-51 avformat-52 avdevice-52 avutil-49 swscale-0)
SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
IF(CMAKE_CL_64)
SET(LLIBS kernel32 user32 vfw32 winmm ws2_32 )
ELSE(CMAKE_CL_64)
SET(LLIBS kernel32 user32 gdi32 comdlg32 advapi32 shell32 ole32 oleaut32 uuid ws2_32 vfw32 winmm)
ENDIF(CMAKE_CL_64)
IF(WITH_OPENAL)
SET(LLIBS ${LLIBS} dxguid)
ENDIF(WITH_OPENAL)
@@ -302,7 +332,11 @@ IF(WIN32)
SET(WINTAB_INC ${LIBDIR}/wintab/include)
SET(PLATFORM_LINKFLAGS "/NODEFAULTLIB:libc.lib")
IF(CMAKE_CL_64)
SET(PLATFORM_LINKFLAGS "/MACHINE:X64 /NODEFAULTLIB:libc.lib;MSVCRT.lib ")
ELSE(CMAKE_CL_64)
SET(PLATFORM_LINKFLAGS "/NODEFAULTLIB:libc.lib ")
ENDIF(CMAKE_CL_64)
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt.lib;libc.lib ")
ENDIF(WIN32)
@@ -384,6 +418,14 @@ IF(APPLE)
SET(TIFF_INC ${TIFF}/include)
SET(EXETYPE MACOSX_BUNDLE)
# msvc already hides symbols, for others do it if the compiler supports it
EXECUTE_PROCESS(COMMAND echo "int main() { return 0; }" COMMAND ${CMAKE_C_COMPILER} -fvisibility=hidden -o /dev/null -xc - RESULT_VARIABLE VISIBILITY_RESULT OUTPUT_QUIET ERROR_QUIET)
IF(NOT VISIBILITY_RESULT)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -DGCC_HASCLASSVISIBILITY")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -DGCC_HASCLASSVISIBILITY")
ENDIF(NOT VISIBILITY_RESULT)
ENDIF(APPLE)
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")

14
README
View File

@@ -24,22 +24,22 @@ dir to one of these locations (your home directory being recommended).
-------------------------------------Links--------------------------------------
Getting Involved:
http://www.blender.org/docs/get_involved.html
http://www.blender.org/community/get-involved
Community:
http://www.blender3d.org/Community/
http://www.blender.org/Community
Main blender development site:
http://www.blender.org/
http://www.blender.org
The Blender project homepage:
http://projects.blender.org/projects/bf-blender/
http://projects.blender.org/projects/bf-blender
Documentation:
http://www.blender.org/modules.php?op=modload&name=documentation&file=index
http://www.blender.org/education-help
Bug tracker:
http://projects.blender.org/tracker/?atid=125&group_id=9&func=browse
http://www.blender.org/development/report-a-bug
Feature request tracker:
http://projects.blender.org/tracker/?atid=128&group_id=9&func=browse
http://wiki.blender.org/index.php/Requests

View File

@@ -36,6 +36,7 @@ import string
import shutil
import glob
import re
import commands
from tempfile import mkdtemp
import tools.Blender
@@ -184,15 +185,16 @@ if env['WITH_BF_OPENMP'] == 1:
env['CPPFLAGS'].append('/openmp')
env['CXXFLAGS'].append('/openmp')
else:
if env['CC'] == 'icc':
if env['CC'][-3:] == 'icc': # to be able to handle CC=/opt/bla/icc case
env.Append(LINKFLAGS=['-openmp', '-static-intel'])
env['CCFLAGS'].append('-openmp')
env['CPPFLAGS'].append('-openmp')
env['CXXFLAGS'].append('-openmp')
else:
env['CCFLAGS'].append('-fopenmp')
env['CPPFLAGS'].append('-fopenmp')
env['CXXFLAGS'].append('-fopenmp')
env.Append(CCFLAGS=['-fopenmp'])
env.Append(CPPFLAGS=['-fopenmp'])
env.Append(CXXFLAGS=['-fopenmp'])
# env.Append(LINKFLAGS=['-fprofile-generate'])
#check for additional debug libnames
@@ -235,6 +237,18 @@ if env['OURPLATFORM'] == 'linux2' :
os.rmdir(os.path.join(root, name))
if root: os.rmdir(root)
# msvc already hides symbols, for others do it if the compiler supports it
if env['OURPLATFORM'] != 'win32-vc':
def check_option(cc, option):
cmd = "echo \"int main() { return 0; }\" | " + cc + " " + option + " -o /dev/null -xc -"
return (commands.getstatusoutput(cmd)[0] == 0)
if check_option(env['CC'], '-fvisibility=hidden'):
env['CPPFLAGS'].extend(['-fvisibility=hidden', '-DGCC_HASCLASSVISIBILITY'])
env['CXXFLAGS'].extend(['-fvisibility=hidden', '-DGCC_HASCLASSVISIBILITY'])
env['CCFLAGS'].extend(['-fvisibility=hidden', '-DGCC_HASCLASSVISIBILITY'])
if len(B.quickdebug) > 0 and printdebug != 0:
print B.bc.OKGREEN + "Buildings these libs with debug symbols:" + B.bc.ENDC
for l in B.quickdebug:

View File

@@ -20,3 +20,4 @@ Romanian:ro
Arabic:ar
Bulgarian:bg
Greek:el
Korean:kr

View File

@@ -90,6 +90,7 @@ IF(UNIX)
bf_soundsystem
bf_kernel
bf_nodes
bf_gpu
bf_imbuf
bf_avi
kx_network

View File

@@ -143,7 +143,6 @@ BF_FTGL_LIB = 'extern_ftgl'
WITH_BF_GAMEENGINE='true'
WITH_BF_PLAYER='true'
WITH_BF_GLEXT= '1'
WITH_BF_ODE = 'false'
BF_ODE = LIBDIR + '/ode'

View File

@@ -139,7 +139,7 @@ BF_OPENJPEG_LIB = ''
BF_OPENJPEG_INC = '${BF_OPENJPEG}/include'
BF_OPENJPEG_LIBPATH='${BF_OPENJPEG}/lib'
WITH_BF_REDCODE = 'true'
WITH_BF_REDCODE = 'false'
BF_REDCODE = '#extern/libredcode'
BF_REDCODE_LIB = ''
# Uncomment the following two lines to use system's ffmpeg

View File

@@ -181,7 +181,9 @@ void btCollisionWorld::rayTestSingle(const btTransform& rayFromTrans,const btTra
btCollisionObject* collisionObject,
const btCollisionShape* collisionShape,
const btTransform& colObjWorldTransform,
RayResultCallback& resultCallback,short int collisionFilterMask)
RayResultCallback& resultCallback,
short int collisionFilterMask,
bool faceNormal)
{
btSphereShape pointShape(btScalar(0.0));
@@ -191,14 +193,16 @@ void btCollisionWorld::rayTestSingle(const btTransform& rayFromTrans,const btTra
collisionObject,
collisionShape,
colObjWorldTransform,
resultCallback,collisionFilterMask);
resultCallback,collisionFilterMask,faceNormal);
}
void btCollisionWorld::objectQuerySingle(const btConvexShape* castShape,const btTransform& rayFromTrans,const btTransform& rayToTrans,
btCollisionObject* collisionObject,
const btCollisionShape* collisionShape,
const btTransform& colObjWorldTransform,
RayResultCallback& resultCallback,short int collisionFilterMask)
RayResultCallback& resultCallback,
short int collisionFilterMask,
bool faceNormal)
{
@@ -257,9 +261,9 @@ void btCollisionWorld::objectQuerySingle(const btConvexShape* castShape,const bt
btCollisionObject* m_collisionObject;
btTriangleMeshShape* m_triangleMesh;
BridgeTriangleRaycastCallback( const btVector3& from,const btVector3& to,
btCollisionWorld::RayResultCallback* resultCallback, btCollisionObject* collisionObject,btTriangleMeshShape* triangleMesh):
btTriangleRaycastCallback(from,to),
BridgeTriangleRaycastCallback( const btVector3& from,const btVector3& to,bool faceNormal,
btCollisionWorld::RayResultCallback* resultCallback, btCollisionObject* collisionObject,btTriangleMeshShape* triangleMesh):
btTriangleRaycastCallback(from,to,faceNormal),
m_resultCallback(resultCallback),
m_collisionObject(collisionObject),
m_triangleMesh(triangleMesh)
@@ -272,6 +276,7 @@ void btCollisionWorld::objectQuerySingle(const btConvexShape* castShape,const bt
btCollisionWorld::LocalShapeInfo shapeInfo;
shapeInfo.m_shapePart = partId;
shapeInfo.m_triangleIndex = triangleIndex;
shapeInfo.m_triangleShape = m_triangleMesh;
btCollisionWorld::LocalRayResult rayResult
(m_collisionObject,
@@ -287,7 +292,7 @@ void btCollisionWorld::objectQuerySingle(const btConvexShape* castShape,const bt
};
BridgeTriangleRaycastCallback rcb(rayFromLocal,rayToLocal,&resultCallback,collisionObject,triangleMesh);
BridgeTriangleRaycastCallback rcb(rayFromLocal,rayToLocal,faceNormal,&resultCallback,collisionObject,triangleMesh);
rcb.m_hitFraction = resultCallback.m_closestHitFraction;
btVector3 rayAabbMinLocal = rayFromLocal;
@@ -313,7 +318,7 @@ void btCollisionWorld::objectQuerySingle(const btConvexShape* castShape,const bt
collisionObject,
childCollisionShape,
childWorldTrans,
resultCallback, collisionFilterMask);
resultCallback, collisionFilterMask, faceNormal);
}
@@ -323,7 +328,7 @@ void btCollisionWorld::objectQuerySingle(const btConvexShape* castShape,const bt
}
}
void btCollisionWorld::rayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, RayResultCallback& resultCallback,short int collisionFilterMask)
void btCollisionWorld::rayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, RayResultCallback& resultCallback,short int collisionFilterMask, bool faceNormal)
{
@@ -350,11 +355,17 @@ void btCollisionWorld::rayTest(const btVector3& rayFromWorld, const btVector3& r
btVector3 hitNormal;
if (btRayAabb(rayFromWorld,rayToWorld,collisionObjectAabbMin,collisionObjectAabbMax,hitLambda,hitNormal))
{
rayTestSingle(rayFromTrans,rayToTrans,
collisionObject,
collisionObject->getCollisionShape(),
collisionObject->getWorldTransform(),
resultCallback);
// before testing this object, verify that it is not filtered out
if (resultCallback.NeedRayCast(collisionObject))
{
rayTestSingle(rayFromTrans,rayToTrans,
collisionObject,
collisionObject->getCollisionShape(),
collisionObject->getWorldTransform(),
resultCallback,
collisionFilterMask,
faceNormal);
}
}
}
}

View File

@@ -125,8 +125,8 @@ public:
{
int m_shapePart;
int m_triangleIndex;
//const btCollisionShape* m_shapeTemp;
// needed in case of compound shape
const btCollisionShape* m_triangleShape;
//const btTransform* m_shapeLocalTransform;
};
@@ -166,6 +166,10 @@ public:
:m_closestHitFraction(btScalar(1.))
{
}
virtual bool NeedRayCast(btCollisionObject* object)
{
return true;
}
virtual btScalar AddSingleResult(LocalRayResult& rayResult) = 0;
};
@@ -209,7 +213,7 @@ public:
/// rayTest performs a raycast on all objects in the btCollisionWorld, and calls the resultCallback
/// This allows for several queries: first hit, all hits, any hit, dependent on the value returned by the callback.
void rayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, RayResultCallback& resultCallback, short int collisionFilterMask=-1);
void rayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, RayResultCallback& resultCallback, short int collisionFilterMask=-1, bool faceNormal=false);
/// rayTestSingle performs a raycast call and calls the resultCallback. It is used internally by rayTest.
/// In a future implementation, we consider moving the ray test as a virtual method in btCollisionShape.
@@ -218,14 +222,18 @@ public:
btCollisionObject* collisionObject,
const btCollisionShape* collisionShape,
const btTransform& colObjWorldTransform,
RayResultCallback& resultCallback, short int collisionFilterMask=-1);
RayResultCallback& resultCallback,
short int collisionFilterMask=-1,
bool faceNormal=false);
/// objectQuerySingle performs a collision detection query and calls the resultCallback. It is used internally by rayTest.
static void objectQuerySingle(const btConvexShape* castShape, const btTransform& rayFromTrans,const btTransform& rayToTrans,
btCollisionObject* collisionObject,
const btCollisionShape* collisionShape,
const btTransform& colObjWorldTransform,
RayResultCallback& resultCallback, short int collisionFilterMask=-1);
RayResultCallback& resultCallback,
short int collisionFilterMask=-1,
bool faceNormal=false);
void addCollisionObject(btCollisionObject* collisionObject,short int collisionFilterGroup=1,short int collisionFilterMask=1);

View File

@@ -334,6 +334,10 @@ void btOptimizedBvh::setQuantizationValues(const btVector3& bvhAabbMin,const btV
m_bvhAabbMax = bvhAabbMax + clampValue;
btVector3 aabbSize = m_bvhAabbMax - m_bvhAabbMin;
m_bvhQuantization = btVector3(btScalar(65535.0),btScalar(65535.0),btScalar(65535.0)) / aabbSize;
m_bvhQuantizationInv = btVector3(
btScalar(1.0)/m_bvhQuantization.getX(),
btScalar(1.0)/m_bvhQuantization.getY(),
btScalar(1.0)/m_bvhQuantization.getZ());
}
@@ -384,7 +388,7 @@ void btOptimizedBvh::buildTree (int startIndex,int endIndex)
#endif //DEBUG_TREE_BUILDING
int splitAxis, splitIndex, i;
int splitIndex, i;
int numIndices =endIndex-startIndex;
int curIndex = m_curNodeIndex;
@@ -403,9 +407,7 @@ void btOptimizedBvh::buildTree (int startIndex,int endIndex)
}
//calculate Best Splitting Axis and where to split it. Sort the incoming 'leafNodes' array within range 'startIndex/endIndex'.
splitAxis = calcSplittingAxis(startIndex,endIndex);
splitIndex = sortAndCalcSplittingIndex(startIndex,endIndex,splitAxis);
splitIndex = sortAndCalcSplittingIndex(startIndex,endIndex);
int internalNodeIndex = m_curNodeIndex;
@@ -482,27 +484,33 @@ void btOptimizedBvh::updateSubtreeHeaders(int leftChildNodexIndex,int rightChild
}
int btOptimizedBvh::sortAndCalcSplittingIndex(int startIndex,int endIndex,int splitAxis)
int btOptimizedBvh::sortAndCalcSplittingIndex(int startIndex,int endIndex)
{
int i;
int i, splitAxis;
int splitIndex =startIndex;
int numIndices = endIndex - startIndex;
btScalar splitValue;
btVector3 means(btScalar(0.),btScalar(0.),btScalar(0.));
for (i=startIndex;i<endIndex;i++)
{
btVector3 center = btScalar(0.5)*(getAabbMax(i)+getAabbMin(i));
means+=center;
}
means+=getAabbCenter(i);
means *= (btScalar(1.)/(btScalar)numIndices);
btVector3 variance(btScalar(0.),btScalar(0.),btScalar(0.));
for (i=startIndex;i<endIndex;i++)
{
btVector3 diff2 = getAabbCenter(i)-means;
diff2 = diff2 * diff2;
variance += diff2;
}
splitAxis = variance.maxAxis();
splitValue = means[splitAxis];
//sort leafNodes so all values larger then splitValue comes first, and smaller values start from 'splitIndex'.
for (i=startIndex;i<endIndex;i++)
{
btVector3 center = btScalar(0.5)*(getAabbMax(i)+getAabbMin(i));
btVector3 center = getAabbCenter(i);
if (center[splitAxis] > splitValue)
{
//swap
@@ -535,35 +543,6 @@ int btOptimizedBvh::sortAndCalcSplittingIndex(int startIndex,int endIndex,int sp
}
int btOptimizedBvh::calcSplittingAxis(int startIndex,int endIndex)
{
int i;
btVector3 means(btScalar(0.),btScalar(0.),btScalar(0.));
btVector3 variance(btScalar(0.),btScalar(0.),btScalar(0.));
int numIndices = endIndex-startIndex;
for (i=startIndex;i<endIndex;i++)
{
btVector3 center = btScalar(0.5)*(getAabbMax(i)+getAabbMin(i));
means+=center;
}
means *= (btScalar(1.)/(btScalar)numIndices);
for (i=startIndex;i<endIndex;i++)
{
btVector3 center = btScalar(0.5)*(getAabbMax(i)+getAabbMin(i));
btVector3 diff2 = center-means;
diff2 = diff2 * diff2;
variance += diff2;
}
variance *= (btScalar(1.)/ ((btScalar)numIndices-1) );
return variance.maxAxis();
}
void btOptimizedBvh::reportAabbOverlappingNodex(btNodeOverlapCallback* nodeCallback,const btVector3& aabbMin,const btVector3& aabbMax) const
{
//either choose recursive traversal (walkTree) or stackless (walkStacklessTree)
@@ -810,13 +789,31 @@ btVector3 btOptimizedBvh::unQuantize(const unsigned short* vecIn) const
{
btVector3 vecOut;
vecOut.setValue(
(btScalar)(vecIn[0]) / (m_bvhQuantization.getX()),
(btScalar)(vecIn[1]) / (m_bvhQuantization.getY()),
(btScalar)(vecIn[2]) / (m_bvhQuantization.getZ()));
(btScalar)(vecIn[0]) * (m_bvhQuantizationInv.getX()),
(btScalar)(vecIn[1]) * (m_bvhQuantizationInv.getY()),
(btScalar)(vecIn[2]) * (m_bvhQuantizationInv.getZ()));
vecOut += m_bvhAabbMin;
return vecOut;
}
btVector3 btOptimizedBvh::unQuantizeCenter(const unsigned short* vecMin, const unsigned short *vecMax) const
{
btVector3 vecOut;
unsigned int center[3];
center[0]= (unsigned int)vecMin[0] + (unsigned int)vecMax[0];
center[1]= (unsigned int)vecMin[1] + (unsigned int)vecMax[1];
center[2]= (unsigned int)vecMin[2] + (unsigned int)vecMax[2];
vecOut.setValue(
(btScalar)(center[0]) * (m_bvhQuantizationInv.getX()),
(btScalar)(center[1]) * (m_bvhQuantizationInv.getY()),
(btScalar)(center[2]) * (m_bvhQuantizationInv.getZ()));
vecOut = m_bvhAabbMin + btScalar(0.5)*vecOut;
return vecOut;
}
void btOptimizedBvh::swapLeafNodes(int i,int splitIndex)
{

View File

@@ -144,6 +144,7 @@ ATTRIBUTE_ALIGNED16(class) btOptimizedBvh
btVector3 m_bvhAabbMin;
btVector3 m_bvhAabbMax;
btVector3 m_bvhQuantization;
btVector3 m_bvhQuantizationInv;
enum btTraversalMode
{
@@ -204,6 +205,17 @@ ATTRIBUTE_ALIGNED16(class) btOptimizedBvh
return m_leafNodes[nodeIndex].m_aabbMaxOrg;
}
btVector3 getAabbCenter(int nodeIndex) const
{
if (m_useQuantization)
{
const btQuantizedBvhNode& node = m_quantizedLeafNodes[nodeIndex];
return unQuantizeCenter(node.m_quantizedAabbMin, node.m_quantizedAabbMax);
}
//non-quantized
return btScalar(0.5)*(m_leafNodes[nodeIndex].m_aabbMinOrg+m_leafNodes[nodeIndex].m_aabbMaxOrg);
}
void setQuantizationValues(const btVector3& bvhAabbMin,const btVector3& bvhAabbMax,btScalar quantizationMargin=btScalar(1.0));
@@ -255,9 +267,7 @@ protected:
void buildTree (int startIndex,int endIndex);
int calcSplittingAxis(int startIndex,int endIndex);
int sortAndCalcSplittingIndex(int startIndex,int endIndex,int splitAxis);
int sortAndCalcSplittingIndex(int startIndex,int endIndex);
void walkStacklessTree(btNodeOverlapCallback* nodeCallback,const btVector3& aabbMin,const btVector3& aabbMax) const;
@@ -298,6 +308,8 @@ public:
void quantizeWithClamp(unsigned short* out, const btVector3& point) const;
btVector3 unQuantize(const unsigned short* vecIn) const;
btVector3 unQuantizeCenter(const unsigned short* vecMin, const unsigned short *vecMax) const;
btVector3 unQuantize(const unsigned int* vecIn) const;
///setTraversalMode let's you choose between stackless, recursive or stackless cache friendly tree traversal. Note this is only implemented for quantized trees.
void setTraversalMode(btTraversalMode traversalMode)

View File

@@ -16,10 +16,11 @@ subject to the following restrictions:
#include "btRaycastCallback.h"
btTriangleRaycastCallback::btTriangleRaycastCallback(const btVector3& from,const btVector3& to)
btTriangleRaycastCallback::btTriangleRaycastCallback(const btVector3& from,const btVector3& to,bool faceNormal)
:
m_from(from),
m_to(to),
m_faceNormal(faceNormal),
m_hitFraction(btScalar(1.))
{
@@ -84,8 +85,7 @@ void btTriangleRaycastCallback::processTriangle(btVector3* triangle,int partId,
if ( (btScalar)(cp2.dot(triangleNormal)) >=edge_tolerance)
{
if ( dist_a > 0 )
if (m_faceNormal || dist_a > 0)
{
m_hitFraction = reportHit(triangleNormal,distance,partId,triangleIndex);
}

View File

@@ -27,10 +27,11 @@ public:
//input
btVector3 m_from;
btVector3 m_to;
bool m_faceNormal;
btScalar m_hitFraction;
btTriangleRaycastCallback(const btVector3& from,const btVector3& to);
btTriangleRaycastCallback(const btVector3& from,const btVector3& to,bool faceNormal);
virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex);

View File

@@ -856,10 +856,26 @@ void btDiscreteDynamicsWorld::debugDrawObject(const btTransform& worldTransform,
btScalar radius = coneShape->getRadius();//+coneShape->getMargin();
btScalar height = coneShape->getHeight();//+coneShape->getMargin();
btVector3 start = worldTransform.getOrigin();
getDebugDrawer()->drawLine(start+worldTransform.getBasis() * btVector3(btScalar(0.),btScalar(0.),btScalar(0.5)*height),start+worldTransform.getBasis() * btVector3(radius,btScalar(0.),btScalar(-0.5)*height),color);
getDebugDrawer()->drawLine(start+worldTransform.getBasis() * btVector3(btScalar(0.),btScalar(0.),btScalar(0.5)*height),start+worldTransform.getBasis() * btVector3(-radius,btScalar(0.),btScalar(-0.5)*height),color);
getDebugDrawer()->drawLine(start+worldTransform.getBasis() * btVector3(btScalar(0.),btScalar(0.),btScalar(0.5)*height),start+worldTransform.getBasis() * btVector3(btScalar(0.),radius,btScalar(-0.5)*height),color);
getDebugDrawer()->drawLine(start+worldTransform.getBasis() * btVector3(btScalar(0.),btScalar(0.),btScalar(0.5)*height),start+worldTransform.getBasis() * btVector3(btScalar(0.),-radius,btScalar(-0.5)*height),color);
// insert here Bullet 2.69 that fixes representation of cone
int upAxis= coneShape->getConeUpIndex();
btVector3 offsetHeight(0,0,0);
offsetHeight[upAxis] = height * btScalar(0.5);
btVector3 offsetRadius(0,0,0);
offsetRadius[(upAxis+1)%3] = radius;
btVector3 offset2Radius(0,0,0);
offset2Radius[(upAxis+2)%3] = radius;
getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight),start+worldTransform.getBasis() * (-offsetHeight+offsetRadius),color);
getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight),start+worldTransform.getBasis() * (-offsetHeight-offsetRadius),color);
getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight),start+worldTransform.getBasis() * (-offsetHeight+offset2Radius),color);
getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight),start+worldTransform.getBasis() * (-offsetHeight-offset2Radius),color);
// buggy code that does not take into account the direction of the cone
//getDebugDrawer()->drawLine(start+worldTransform.getBasis() * btVector3(btScalar(0.),btScalar(0.),btScalar(0.5)*height),start+worldTransform.getBasis() * btVector3(radius,btScalar(0.),btScalar(-0.5)*height),color);
//getDebugDrawer()->drawLine(start+worldTransform.getBasis() * btVector3(btScalar(0.),btScalar(0.),btScalar(0.5)*height),start+worldTransform.getBasis() * btVector3(-radius,btScalar(0.),btScalar(-0.5)*height),color);
//getDebugDrawer()->drawLine(start+worldTransform.getBasis() * btVector3(btScalar(0.),btScalar(0.),btScalar(0.5)*height),start+worldTransform.getBasis() * btVector3(btScalar(0.),radius,btScalar(-0.5)*height),color);
//getDebugDrawer()->drawLine(start+worldTransform.getBasis() * btVector3(btScalar(0.),btScalar(0.),btScalar(0.5)*height),start+worldTransform.getBasis() * btVector3(btScalar(0.),-radius,btScalar(-0.5)*height),color);
break;
}

View File

@@ -9,4 +9,4 @@ sources = ['src/glew.c']
defs = ''
incs = 'include'
env.BlenderLib ( 'extern_glew', sources, Split(incs), Split(defs), libtype=['intern', 'player'], priority=[25, 50])
env.BlenderLib ( 'extern_glew', sources, Split(incs), Split(defs), libtype=['blender', 'player'], priority=[50, 50])

View File

@@ -58,8 +58,11 @@
** version 1.2.1 Specification.
*/
/* added this here for blender, should be moved elsewhere */
#define BLENDER_CHANGES
#ifdef BLENDER_CHANGES
#define GLEW_STATIC
#endif
#ifndef __glew_h__
#define __glew_h__
@@ -1805,6 +1808,7 @@ typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuin
typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort* v);
typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* pointer);
#ifndef BLENDER_CHANGES
#define glAttachShader GLEW_GET_FUN(__glewAttachShader)
#define glBindAttribLocation GLEW_GET_FUN(__glewBindAttribLocation)
#define glBlendEquationSeparate GLEW_GET_FUN(__glewBlendEquationSeparate)
@@ -1898,6 +1902,7 @@ typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint si
#define glVertexAttrib4uiv GLEW_GET_FUN(__glewVertexAttrib4uiv)
#define glVertexAttrib4usv GLEW_GET_FUN(__glewVertexAttrib4usv)
#define glVertexAttribPointer GLEW_GET_FUN(__glewVertexAttribPointer)
#endif
#define GLEW_VERSION_2_0 GLEW_GET_VAR(__GLEW_VERSION_2_0)

View File

@@ -1836,6 +1836,7 @@ static GLboolean _glewInit_GL_VERSION_2_0 (GLEW_CONTEXT_ARG_DEF_INIT)
{
GLboolean r = GL_FALSE;
#ifndef BLENDER_CHANGES
r = ((glAttachShader = (PFNGLATTACHSHADERPROC)glewGetProcAddress((const GLubyte*)"glAttachShader")) == NULL) || r;
r = ((glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)glewGetProcAddress((const GLubyte*)"glBindAttribLocation")) == NULL) || r;
r = ((glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC)glewGetProcAddress((const GLubyte*)"glBlendEquationSeparate")) == NULL) || r;
@@ -1929,6 +1930,7 @@ static GLboolean _glewInit_GL_VERSION_2_0 (GLEW_CONTEXT_ARG_DEF_INIT)
r = ((glVertexAttrib4uiv = (PFNGLVERTEXATTRIB4UIVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4uiv")) == NULL) || r;
r = ((glVertexAttrib4usv = (PFNGLVERTEXATTRIB4USVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4usv")) == NULL) || r;
r = ((glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribPointer")) == NULL) || r;
#endif
return r;
}

View File

@@ -8,7 +8,7 @@ incs += ' ../../source/blender/makesdna ../../intern/guardedalloc'
incs += ' ../../source/blender/blenlib'
if (env['OURPLATFORM'] == 'win32-mingw'):
env.BlenderLib ('blender_bop', sources, Split(incs) , [], libtype=['common','intern'], priority = [5,50] )
env.BlenderLib ('blender_bop', sources, Split(incs) , [], libtype=['common','intern'], priority = [30,85] )
else:
env.BlenderLib ('blender_bop', sources, Split(incs) , [], libtype='common', priority = 5 )

View File

@@ -75,4 +75,47 @@ void BOP_Edge::replaceVertexIndex(BOP_Index oldIndex, BOP_Index newIndex)
else if (m_vertexs[1] == oldIndex) m_vertexs[1] = newIndex;
}
#ifdef BOP_NEW_MERGE
/**
* Returns if this edge contains the specified face index.
* @param i face index
* @return true if this edge contains the specified face index, false otherwise
*/
bool BOP_Edge::removeFace(BOP_Index i)
{
int pos=0;
for(BOP_IT_Indexs it = m_faces.begin();it!=m_faces.end();pos++,it++) {
if ((*it) == i) {
m_faces.erase(it);
return true;
}
}
return false;
}
#endif
#ifdef BOP_DEBUG
#include <iostream>
using namespace std;
/**
* Implements operator <<.
*/
ostream &operator<<(ostream &stream, BOP_Edge *e)
{
stream << "Edge[" << e->getVertex1() << "," << e->getVertex2();
#ifdef BOP_NEW_MERGE
if(e->m_used)
stream << "] (used)";
else
stream << "] (unused)";
#endif
return stream;
}
#endif

View File

@@ -29,12 +29,16 @@
#define BOP_EDGE_H
#include "BOP_Indexs.h"
#include "BOP_Misc.h"
class BOP_Edge
{
private:
BOP_Index m_vertexs[2];
BOP_Indexs m_faces;
#ifdef BOP_NEW_MERGE
bool m_used;
#endif
bool containsFace(BOP_Index i);
@@ -47,6 +51,15 @@ public:
inline unsigned int getNumFaces(){return m_faces.size();};
inline BOP_Indexs &getFaces(){return m_faces;};
void addFace(BOP_Index face);
#ifdef BOP_NEW_MERGE
bool removeFace(BOP_Index i);
bool getUsed() { return m_used;};
void setUsed(bool setting) { m_used=setting;};
#endif
#ifdef BOP_DEBUG
friend ostream &operator<<(ostream &stream, BOP_Edge *e);
#endif
};
#endif

View File

@@ -402,6 +402,7 @@ bool BOP_Face4::getEdgeIndex(BOP_Index v1, BOP_Index v2, unsigned int &e)
return true;
}
#ifdef BOP_DEBUG
/**
* Implements operator <<.
*/
@@ -421,3 +422,4 @@ ostream &operator<<(ostream &stream, BOP_Face *f)
return stream;
}
#endif

View File

@@ -32,6 +32,7 @@
#include "MT_Plane3.h"
#include "BOP_Indexs.h"
#include "BOP_BBox.h"
#include "BOP_Misc.h"
#include <iostream>
#include <vector>
using namespace std;
@@ -80,7 +81,9 @@ public:
virtual void replaceVertexIndex(BOP_Index oldIndex, BOP_Index newIndex) = 0;
virtual bool containsVertex(BOP_Index v) = 0;
#ifdef BOP_DEBUG
friend ostream &operator<<(ostream &stream, BOP_Face *f);
#endif
};
class BOP_Face3: public BOP_Face

View File

@@ -33,9 +33,12 @@
#include "BOP_Mesh.h"
#include "BOP_Face2Face.h"
#include "BOP_Merge.h"
#include "BOP_Merge2.h"
#include "BOP_Chrono.h"
//#define DEBUG
#if defined(BOP_ORIG_MERGE) && defined(BOP_NEW_MERGE)
#include "../../../source/blender/blenkernel/BKE_global.h"
#endif
BoolOpState BOP_intersectionBoolOp(BOP_Mesh* meshC,
BOP_Faces* facesA,
@@ -208,7 +211,32 @@ BoolOpState BOP_intersectionBoolOp(BOP_Mesh* meshC,
#endif
// Merge faces
#ifdef BOP_ORIG_MERGE
#ifndef BOP_NEW_MERGE
BOP_Merge::getInstance().mergeFaces(meshC,numVertices);
#endif
#endif
#ifdef BOP_NEW_MERGE
#ifndef BOP_ORIG_MERGE
BOP_Merge2::getInstance().mergeFaces(meshC,numVertices);
#else
static int state = -1;
if (G.rt == 100) {
if( state != 1 ) {
cout << "Boolean code using old merge technique." << endl;
state = 1;
}
BOP_Merge::getInstance().mergeFaces(meshC,numVertices);
} else {
if( state != 0 ) {
cout << "Boolean code using new merge technique." << endl;
state = 0;
}
BOP_Merge2::getInstance().mergeFaces(meshC,numVertices);
}
#endif
#endif
#ifdef DEBUG
c = chrono.stamp(); t += c;

View File

@@ -30,6 +30,7 @@
#include "BOP_Merge.h"
#ifdef BOP_ORIG_MERGE
#ifdef _MSC_VER
#if _MSC_VER < 1300
@@ -802,3 +803,5 @@ void BOP_Merge::getFaces(BOP_LFaces &facesByOriginalFace, BOP_Indexs vertices, B
}
}
}
#endif /* BOP_ORIG_MERGE */

View File

@@ -28,6 +28,9 @@
#ifndef BOP_MERGE_H
#define BOP_MERGE_H
#include "BOP_Misc.h"
#ifdef BOP_ORIG_MERGE
#include "BOP_Mesh.h"
#include "BOP_Tag.h"
#include "BOP_MathUtils.h"
@@ -68,4 +71,6 @@ class BOP_Merge {
void mergeFaces(BOP_Mesh *m, BOP_Index v);
};
#endif /* BOP_ORIG_MERGE */
#endif

View File

@@ -0,0 +1,944 @@
/**
*
* $Id: BOP_Merge22.cpp 14444 2008-04-16 22:40:48Z hos $
*
* ***** 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): Marc Freixas, Ken Hughes
*
* ***** END GPL LICENSE BLOCK *****
*/
#include "BOP_Merge2.h"
#ifdef BOP_NEW_MERGE
static void deleteFace(BOP_Mesh *m, BOP_Face *face);
/**
* SINGLETON (use method BOP_Merge2.getInstance).
*/
BOP_Merge2 BOP_Merge2::SINGLETON;
#ifdef BOP_DEBUG
void dumpmesh ( BOP_Mesh *m, bool force )
{
unsigned int nonmanifold = 0;
{
BOP_Edges edges = m->getEdges();
int count = 0;
for (BOP_IT_Edges edge = edges.begin(); edge != edges.end();
++count, ++edge) {
if (!(*edge)->getUsed() && (*edge)->getFaces().size() == 0 ) continue;
BOP_Vertex * v1 = m->getVertex((*edge)->getVertex1());
BOP_Vertex * v2 = m->getVertex((*edge)->getVertex2());
if(v1->getTAG()!= BROKEN || v2->getTAG()!= BROKEN ) {
int fcount = 0;
BOP_Indexs faces = (*edge)->getFaces();
for (BOP_IT_Indexs face = faces.begin(); face != faces.end(); face++) {
BOP_Face *f = m->getFace(*face);
if(f->getTAG()== UNCLASSIFIED) ++fcount;
}
if(fcount !=0 && fcount !=2 ) {
++nonmanifold;
}
}
}
if (!force && nonmanifold == 0) return;
}
if( nonmanifold )
cout << nonmanifold << " edges detected" << endl;
#ifdef DEBUG
cout << "---------------------------" << endl;
BOP_Edges edges = m->getEdges();
int count = 0;
for (BOP_IT_Edges edge = edges.begin(); edge != edges.end();
++count, ++edge) {
BOP_Vertex * v1 = m->getVertex((*edge)->getVertex1());
BOP_Vertex * v2 = m->getVertex((*edge)->getVertex2());
if(v1->getTAG()!= BROKEN || v2->getTAG()!= BROKEN ) {
int fcount = 0;
BOP_Indexs faces = (*edge)->getFaces();
cout << count << ", " << (*edge) << ", " << faces.size() << endl;
for (BOP_IT_Indexs face = faces.begin(); face != faces.end(); face++) {
BOP_Face *f = m->getFace(*face);
if(f->getTAG()== UNCLASSIFIED) ++fcount;
cout << " face " << f << endl;
}
if(fcount !=0 && fcount !=2 )
cout << " NON-MANIFOLD" << endl;
}
}
BOP_Faces faces = m->getFaces();
count = 0;
for (BOP_IT_Faces face = faces.begin(); face != faces.end(); face++) {
if( count < 12*2 || (*face)->getTAG() != BROKEN ) {
cout << count << ", " << *face << endl;
}
++count;
}
BOP_Vertexs verts = m->getVertexs();
count = 0;
for (BOP_IT_Vertexs vert = verts.begin(); vert != verts.end(); vert++) {
cout << count++ << ", " << *vert << " " << (*vert)->getNumEdges() << endl;
BOP_Indexs edges = (*vert)->getEdges();
for( BOP_IT_Indexs it = edges.begin(); it != edges.end(); ++it) {
BOP_Edge *edge = m->getEdge(*it);
cout << " " << edge << endl;
}
}
cout << "===========================" << endl;
#endif
}
#endif
/**
* Simplifies a mesh, merging its faces.
* @param m mesh
* @param v index of the first mergeable vertex (can be removed by merge)
*/
void BOP_Merge2::mergeFaces(BOP_Mesh *m, BOP_Index v)
{
m_mesh = m;
#ifdef DEBUG
cout << "##############################" << endl;
#endif
cleanup( );
m_firstVertex = v;
bool cont = false;
// Merge faces
mergeFaces();
do {
// Add quads ...
cont = createQuads();
// ... and merge new faces
if( cont ) cont = mergeFaces();
#ifdef DEBUG
cout << "called mergeFaces " << cont << endl;
#endif
// ... until the merge is not succesful
} while(cont);
}
void clean_nonmanifold( BOP_Mesh *m )
{
return;
BOP_Edges nme;
BOP_Edges e = m->getEdges();
for( BOP_IT_Edges it = e.begin(); it != e.end(); ++it ) {
BOP_Indexs faces = (*it)->getFaces();
if( faces.size() & ~2 )
nme.push_back(*it);
}
if (nme.size() == 0) return;
for( BOP_IT_Edges it = nme.begin(); it != nme.end(); ++it ) {
if( (*it)->getFaces().size() > 1 ) {
BOP_Indexs faces = (*it)->getFaces();
for( BOP_IT_Indexs face = faces.begin(); face != faces.end(); ++face ) {
MT_Point3 vertex1 = m->getVertex(m->getFace(*face)->getVertex(0))->getPoint();
MT_Point3 vertex2 = m->getVertex(m->getFace(*face)->getVertex(1))->getPoint();
MT_Point3 vertex3 = m->getVertex(m->getFace(*face)->getVertex(2))->getPoint();
if (BOP_collinear(vertex1,vertex2,vertex3)) // collinear triangle
deleteFace(m,m->getFace(*face));
}
continue;
}
BOP_Face *oface1 = m->getFace((*it)->getFaces().front());
BOP_Face *oface2, *tmpface;
BOP_Index first =(*it)->getVertex1();
BOP_Index next =(*it)->getVertex2();
BOP_Index last = first;
unsigned short facecount = 0;
bool found = false;
BOP_Indexs vertList;
#ifdef DEBUG
cout << " first edge is " << (*it) << endl;
#endif
vertList.push_back(first);
BOP_Edge *edge;
while(true) {
BOP_Vertex *vert = m->getVertex(next);
BOP_Indexs edges = vert->getEdges();
edge = NULL;
for( BOP_IT_Indexs eit = edges.begin(); eit != edges.end(); ++eit) {
edge = m->getEdge(*eit);
if( edge->getFaces().size() > 1) {
edge = NULL;
continue;
}
if( edge->getVertex1() == next && edge->getVertex2() != last ) {
last = next;
next = edge->getVertex2();
break;
}
if( edge->getVertex2() == next && edge->getVertex1() != last ) {
last = next;
next = edge->getVertex1();
break;
}
edge = NULL;
}
if( !edge ) break;
#ifdef DEBUG
cout << " next edge is " << edge << endl;
#endif
tmpface = m->getFace(edge->getFaces().front());
if( oface1->getOriginalFace() != tmpface->getOriginalFace() )
oface2 = tmpface;
else
++facecount;
vertList.push_back(last);
if( vertList.size() > 3 ) break;
if( next == first ) {
found = true;
break;
}
}
if(found) {
edge = *it;
#ifdef DEBUG
cout << " --> found a loop" << endl;
#endif
if( vertList.size() == 3 ) {
BOP_Face3 *face = (BOP_Face3 *)m->getFace(edge->getFaces().front());
face->getNeighbours(first,last,next);
} else if( vertList.size() == 4 ) {
BOP_Face4 *face = (BOP_Face4 *)m->getFace(edge->getFaces().front());
face->getNeighbours(first,last,next,last);
} else {
#ifdef DEBUG
cout << "loop has " << vertList.size() << "verts";
#endif
continue;
}
if(facecount == 1) oface1 = oface2;
next = vertList[1];
last = vertList[2];
if( edge->getVertex2() == next ) {
BOP_Face3 *f = new BOP_Face3(next,first,last,
oface1->getPlane(),oface1->getOriginalFace());
m->addFace( f );
#ifdef DEBUG
cout << " face is backward: " << f << endl;
#endif
} else {
BOP_Face3 *f = new BOP_Face3(last,first,next,
oface1->getPlane(),oface1->getOriginalFace());
m->addFace( f );
#ifdef DEBUG
cout << " face is forward: " << f << endl;
#endif
}
}
}
}
/**
* Runs through mesh and makes sure vert/face/edge data is consistent. Most
* importantly:
* (1) mark edges which are no longer used
* (2) remove broken faces from edges
* (3) remove faces from mesh which have a single edge belonging to no other
* face (non-manifold edges)
*/
void BOP_Merge2::cleanup( void )
{
BOP_Edges edges = m_mesh->getEdges();
for (BOP_IT_Edges edge = edges.begin(); edge != edges.end(); ++edge) {
BOP_Indexs faces = (*edge)->getFaces();
for (BOP_IT_Indexs face = faces.begin(); face != faces.end(); ++face) {
BOP_Face *f = m_mesh->getFace(*face);
if(f->getTAG()== UNCLASSIFIED) ;
else (*edge)->removeFace(*face);
}
if( (*edge)->getFaces().size() == 0) (*edge)->setUsed(false);
}
BOP_Vertexs v = m_mesh->getVertexs();
for( BOP_IT_Vertexs it = v.begin(); it != v.end(); ++it ) {
if( (*it)->getTAG() != BROKEN) {
BOP_Indexs edges = (*it)->getEdges();
for(BOP_IT_Indexs i = edges.begin();i!=edges.end();i++)
if( m_mesh->getEdge((*i))->getUsed( ) == false) (*it)->removeEdge( *i );
if( (*it)->getEdges().size() == 0 ) (*it)->setTAG(BROKEN);
}
}
// clean_nonmanifold( m_mesh );
}
/**
* Simplifies a mesh, merging its faces.
*/
bool BOP_Merge2::mergeFaces()
{
BOP_Indexs mergeVertices;
BOP_Vertexs vertices = m_mesh->getVertexs();
BOP_IT_Vertexs v = vertices.begin();
const BOP_IT_Vertexs verticesEnd = vertices.end();
// Advance to first mergeable vertex
advance(v,m_firstVertex);
BOP_Index pos = m_firstVertex;
// Add unbroken vertices to the list
while(v!=verticesEnd) {
if ((*v)->getTAG() != BROKEN) {
mergeVertices.push_back(pos);
}
v++;
pos++;
}
// Merge faces with that vertices
return mergeFaces(mergeVertices);
}
/**
* remove edges from vertices when the vertex is removed
*/
void BOP_Merge2::freeVerts(BOP_Index v, BOP_Vertex *vert)
{
BOP_Indexs edges = vert->getEdges();
BOP_Vertex *other;
for( BOP_IT_Indexs it = edges.begin(); it != edges.end(); ++it) {
BOP_Edge *edge = m_mesh->getEdge(*it);
BOP_Indexs edges2;
if( edge->getVertex1() != v )
other = m_mesh->getVertex( edge->getVertex1() );
else
other = m_mesh->getVertex( edge->getVertex2() );
other->removeEdge(*it);
vert->removeEdge(*it);
}
}
/**
* Simplifies a mesh, merging the faces with the specified vertices.
* @param mergeVertices vertices to test
* @return true if a face merge was performed
*/
bool BOP_Merge2::mergeFaces(BOP_Indexs &mergeVertices)
{
// Check size > 0!
if (mergeVertices.size() == 0) return false;
bool didMerge = false;
for( BOP_Index i = 0; i < mergeVertices.size(); ++i ) {
BOP_LFaces facesByOriginalFace;
BOP_Index v = mergeVertices[i];
BOP_Vertex *vert = m_mesh->getVertex(v);
#ifdef DEBUG
cout << "i = " << i << ", v = " << v << ", vert = " << vert << endl;
if (v==48)
cout << "found vert 48" << endl;
#endif
if ( vert->getTAG() != BROKEN ) {
getFaces(facesByOriginalFace,v);
switch (facesByOriginalFace.size()) {
case 0:
// v has no unbroken faces (so it's a new BROKEN vertex)
freeVerts( v, vert );
vert->setTAG(BROKEN);
break;
case 2: {
#ifdef DEBUG
cout << "size of fBOF = " << facesByOriginalFace.size() << endl;
#endif
BOP_Faces ff = facesByOriginalFace.front();
BOP_Faces fb = facesByOriginalFace.back();
BOP_Index eindexs[2];
int ecount = 0;
// look for two edges adjacent to v which contain both ofaces
BOP_Indexs edges = vert->getEdges();
#ifdef DEBUG
cout << " ff has " << ff.size() << " faces" << endl;
cout << " fb has " << fb.size() << " faces" << endl;
cout << " v has " << edges.size() << " edges" << endl;
#endif
for(BOP_IT_Indexs it = edges.begin(); it != edges.end();
++it ) {
BOP_Edge *edge = m_mesh->getEdge(*it);
BOP_Indexs faces = edge->getFaces();
#ifdef DEBUG
cout << " " << edge << " has " << edge->getFaces().size() << " faces" << endl;
#endif
if( faces.size() == 2 ) {
BOP_Face *f0 = m_mesh->getFace(faces[0]);
BOP_Face *f1 = m_mesh->getFace(faces[1]);
if( f0->getOriginalFace() != f1->getOriginalFace() ) {
#ifdef DEBUG
cout << " " << f0 << endl;
cout << " " << f1 << endl;
#endif
eindexs[ecount++] = (*it);
}
}
}
if(ecount == 2) {
#ifdef DEBUG
cout << " edge indexes are " << eindexs[0];
cout << " and " << eindexs[1] << endl;
#endif
BOP_Edge *edge = m_mesh->getEdge(eindexs[0]);
BOP_Index N = edge->getVertex1();
if(N == v) N = edge->getVertex2();
#ifdef DEBUG
cout << " ## OK, replace "<<v<<" with "<<N << endl;
#endif
mergeVertex(ff , v, N );
mergeVertex(fb , v, N );
// now remove v and its edges
vert->setTAG(BROKEN);
for(BOP_IT_Indexs it = edges.begin(); it != edges.end();
++it ) {
BOP_Edge *edge = m_mesh->getEdge(*it);
edge->setUsed(false);
}
didMerge = true;
}
#ifdef DEBUG
else {
cout << " HUH: ecount was " << ecount << endl;
}
#endif
}
break;
default:
break;
}
}
}
return didMerge;
}
void BOP_Merge2::mergeVertex(BOP_Faces &faces, BOP_Index v1, BOP_Index v2)
{
for(BOP_IT_Faces face=faces.begin();face!=faces.end();face++) {
if( (*face)->size() == 3)
mergeVertex((BOP_Face3 *) *face, v1, v2);
else
mergeVertex((BOP_Face4 *) *face, v1, v2);
(*face)->setTAG(BROKEN);
#ifdef DEBUG
cout << " breaking " << (*face) << endl;
#endif
}
}
/*
* Remove a face from the mesh and from each edges's face list
*/
static void deleteFace(BOP_Mesh *m, BOP_Face *face)
{
BOP_Index l2 = face->getVertex(0);
BOP_Faces faces = m->getFaces();
for(int i = face->size(); i-- ; ) {
BOP_Indexs edges = m->getVertex(l2)->getEdges();
BOP_Index l1 = face->getVertex(i);
for(BOP_IT_Indexs it1 = edges.begin(); it1 != edges.end(); ++it1 ) {
BOP_Edge *edge = m->getEdge(*it1);
if( ( edge->getVertex1() == l1 && edge->getVertex2() == l2 ) ||
( edge->getVertex1() == l2 && edge->getVertex2() == l1 ) ) {
BOP_Indexs ef = edge->getFaces();
for(BOP_IT_Indexs it = ef.begin(); it != ef.end(); ++it ) {
if( m->getFace(*it) == face) {
edge->removeFace(*it);
break;
}
}
break;
}
}
l2 = l1;
}
face->setTAG(BROKEN);
}
void BOP_Merge2::mergeVertex(BOP_Face3 *face, BOP_Index v1, BOP_Index v2)
{
BOP_Index next, prev;
face->getNeighbours(v1,prev,next);
// if new vertex is not already in the tri, make a new tri
if( prev != v2 && next != v2 ) {
m_mesh->addFace( new BOP_Face3(prev,v2,next,
face->getPlane(),face->getOriginalFace()) );
#ifdef DEBUG
cout << "mv3: add " << prev << "," << v2 << "," << next << endl;
} else {
cout << "mv3: vertex already in tri: doing nothing" << endl;
#endif
}
deleteFace(m_mesh, face);
}
void BOP_Merge2::mergeVertex(BOP_Face4 *face, BOP_Index v1, BOP_Index v2)
{
BOP_Index next, prev, opp;
face->getNeighbours(v1,prev,next,opp);
// if new vertex is already in the quad, replace quad with new tri
if( prev == v2 || next == v2 ) {
m_mesh->addFace( new BOP_Face3(prev,next,opp,
face->getPlane(),face->getOriginalFace()) );
#ifdef DEBUG
cout << "mv4a: add " << prev << "," << next << "," << opp << endl;
#endif
}
// otherwise make a new quad
else {
m_mesh->addFace( new BOP_Face4(prev,v2,next,opp,
face->getPlane(),face->getOriginalFace()) );
#ifdef DEBUG
cout << "mv4b: add "<<prev<<","<<v2<<","<<next<<","<<opp<<endl;
#endif
}
deleteFace(m_mesh, face);
}
// #define OLD_QUAD
/**
* Simplifies the mesh, merging the pairs of triangles that come frome the
* same original face and define a quad.
* @return true if a quad was added, false otherwise
*/
bool BOP_Merge2::createQuads()
{
BOP_Faces quads;
// Get mesh faces
BOP_Faces faces = m_mesh->getFaces();
// Merge mesh triangles
const BOP_IT_Faces facesIEnd = (faces.end()-1);
const BOP_IT_Faces facesJEnd = faces.end();
for(BOP_IT_Faces faceI=faces.begin();faceI!=facesIEnd;faceI++) {
#ifdef OLD_QUAD
if ((*faceI)->getTAG() == BROKEN || (*faceI)->size() != 3) continue;
for(BOP_IT_Faces faceJ=(faceI+1);faceJ!=facesJEnd;faceJ++) {
if ((*faceJ)->getTAG() == BROKEN || (*faceJ)->size() != 3 ||
(*faceJ)->getOriginalFace() != (*faceI)->getOriginalFace()) continue;
BOP_Face *faceK = createQuad((BOP_Face3*)*faceI,(BOP_Face3*)*faceJ);
if (faceK != NULL) {
// Set triangles to BROKEN
deleteFace(m_mesh, *faceI);
deleteFace(m_mesh, *faceJ);
#ifdef DEBUG
cout << "createQuad: del " << *faceI << endl;
cout << "createQuad: del " << *faceJ << endl;
cout << "createQuad: add " << faceK << endl;
#endif
quads.push_back(faceK);
break;
}
}
#else
if ((*faceI)->getTAG() == BROKEN ) continue;
for(BOP_IT_Faces faceJ=(faceI+1);faceJ!=facesJEnd;faceJ++) {
if ((*faceJ)->getTAG() == BROKEN ||
(*faceJ)->getOriginalFace() != (*faceI)->getOriginalFace()) continue;
BOP_Face *faceK = NULL;
if((*faceI)->size() == 3) {
if((*faceJ)->size() == 3)
faceK = createQuad((BOP_Face3*)*faceI,(BOP_Face3*)*faceJ);
else
faceK = createQuad((BOP_Face3*)*faceI,(BOP_Face4*)*faceJ);
} else {
if((*faceJ)->size() == 3)
faceK = createQuad((BOP_Face3*)*faceJ,(BOP_Face4*)*faceI);
else
faceK = createQuad((BOP_Face4*)*faceI,(BOP_Face4*)*faceJ);
}
if (faceK != NULL) {
// Set triangles to BROKEN
deleteFace(m_mesh, *faceI);
deleteFace(m_mesh, *faceJ);
#ifdef DEBUG
cout << "createQuad: del " << *faceI << endl;
cout << "createQuad: del " << *faceJ << endl;
cout << "createQuad: add " << faceK << endl;
#endif
quads.push_back(faceK);
break;
}
}
#endif
}
// Add quads to mesh
const BOP_IT_Faces quadsEnd = quads.end();
for(BOP_IT_Faces quad=quads.begin();quad!=quadsEnd;quad++) m_mesh->addFace(*quad);
return (quads.size() > 0);
}
/**
* Returns a new quad (convex) from the merge of two triangles that share the
* vertex index v.
* @param faceI mesh triangle
* @param faceJ mesh triangle
* @param v vertex index shared by both triangles
* @return a new convex quad if the merge is possible
*/
BOP_Face* BOP_Merge2::createQuad(BOP_Face3 *faceI, BOP_Face3 *faceJ)
{
// Test if both triangles share a vertex index
BOP_Index v;
unsigned int i;
for(i=0;i<3 ;i++) {
v = faceI->getVertex(i);
if( faceJ->containsVertex(v) ) break;
}
if (i == 3) return NULL;
BOP_Face *faceK = NULL;
// Get faces data
BOP_Index prevI, nextI, prevJ, nextJ;
faceI->getNeighbours(v,prevI,nextI);
faceJ->getNeighbours(v,prevJ,nextJ);
MT_Point3 vertex = m_mesh->getVertex(v)->getPoint();
MT_Point3 vPrevI = m_mesh->getVertex(prevI)->getPoint();
MT_Point3 vNextI = m_mesh->getVertex(nextI)->getPoint();
MT_Point3 vPrevJ = m_mesh->getVertex(prevJ)->getPoint();
MT_Point3 vNextJ = m_mesh->getVertex(nextJ)->getPoint();
// Quad test
if (prevI == nextJ) {
if (!BOP_collinear(vNextI,vertex,vPrevJ) && !BOP_collinear(vNextI,vPrevI,vPrevJ) &&
BOP_convex(vertex,vNextI,vPrevI,vPrevJ)) {
faceK = new BOP_Face4(v,nextI,prevI,prevJ,faceI->getPlane(),faceI->getOriginalFace());
faceK->setTAG(faceI->getTAG());
BOP_Index edge;
m_mesh->getIndexEdge(v,prevI,edge);
m_mesh->getVertex(v)->removeEdge(edge);
m_mesh->getVertex(prevI)->removeEdge(edge);
}
}
else if (nextI == prevJ) {
if (!BOP_collinear(vPrevI,vertex,vNextJ) && !BOP_collinear(vPrevI,vNextI,vNextJ) &&
BOP_convex(vertex,vNextJ,vNextI,vPrevI)) {
faceK = new BOP_Face4(v,nextJ,nextI,prevI,faceI->getPlane(),faceI->getOriginalFace());
faceK->setTAG(faceI->getTAG());
BOP_Index edge;
m_mesh->getIndexEdge(v,nextI,edge);
m_mesh->getVertex(v)->removeEdge(edge);
m_mesh->getVertex(nextI)->removeEdge(edge);
}
}
return faceK;
}
/**
* Returns a new quad (convex) from the merge of two triangles that share the
* vertex index v.
* @param faceI mesh triangle
* @param faceJ mesh triangle
* @param v vertex index shared by both triangles
* @return a new convex quad if the merge is possible
*/
BOP_Face* BOP_Merge2::createQuad(BOP_Face3 *faceI, BOP_Face4 *faceJ)
{
// Test if triangle and quad share a vertex index
BOP_Index v;
unsigned int i;
for(i=0;i<3 ;i++) {
v = faceI->getVertex(i);
if( faceJ->containsVertex(v) ) break;
}
if (i == 3) return NULL;
BOP_Face *faceK = NULL;
// Get faces data
BOP_Index prevI, nextI, prevJ, nextJ, oppJ;
faceI->getNeighbours(v,prevI,nextI);
faceJ->getNeighbours(v,prevJ,nextJ,oppJ);
// Quad test
BOP_Index edge;
if (nextI == prevJ) {
if (prevI == nextJ) { // v is in center
faceK = new BOP_Face3(nextJ,oppJ,prevJ,faceI->getPlane(),faceI->getOriginalFace());
faceK->setTAG(faceI->getTAG());
m_mesh->getIndexEdge(v,prevI,edge);
m_mesh->getVertex(v)->removeEdge(edge);
m_mesh->getVertex(prevI)->removeEdge(edge);
m_mesh->getIndexEdge(v,nextI,edge);
m_mesh->getVertex(v)->removeEdge(edge);
m_mesh->getVertex(nextI)->removeEdge(edge);
freeVerts(v, m_mesh->getVertex(v));
} else if (prevI == oppJ) { // nextI is in center
faceK = new BOP_Face3(v,nextJ,oppJ,faceI->getPlane(),faceI->getOriginalFace());
faceK->setTAG(faceI->getTAG());
m_mesh->getIndexEdge(v,nextI,edge);
m_mesh->getVertex(v)->removeEdge(edge);
m_mesh->getVertex(nextI)->removeEdge(edge);
m_mesh->getIndexEdge(prevI,nextI,edge);
m_mesh->getVertex(prevI)->removeEdge(edge);
m_mesh->getVertex(nextI)->removeEdge(edge);
freeVerts(nextI, m_mesh->getVertex(nextI));
}
} else if (nextI == oppJ && prevI == nextJ ) { // prevI is in center
faceK = new BOP_Face3(prevJ,v,oppJ,faceI->getPlane(),faceI->getOriginalFace());
faceK->setTAG(faceI->getTAG());
m_mesh->getIndexEdge(v,prevI,edge);
m_mesh->getVertex(v)->removeEdge(edge);
m_mesh->getVertex(prevI)->removeEdge(edge);
m_mesh->getIndexEdge(nextI,prevI,edge);
m_mesh->getVertex(nextI)->removeEdge(edge);
m_mesh->getVertex(prevI)->removeEdge(edge);
freeVerts(prevI, m_mesh->getVertex(prevI));
}
return faceK;
}
/**
* Returns a new quad (convex) from the merge of two triangles that share the
* vertex index v.
* @param faceI mesh triangle
* @param faceJ mesh triangle
* @param v vertex index shared by both triangles
* @return a new convex quad if the merge is possible
*/
BOP_Face* BOP_Merge2::createQuad(BOP_Face4 *faceI, BOP_Face4 *faceJ)
{
BOP_Face *faceK = NULL;
//
// Test if both quads share a vertex index
//
BOP_Index v;
unsigned int i;
for(i=0;i<4 ;i++) {
v = faceI->getVertex(i);
if( faceJ->containsVertex(v) ) break;
}
if (i == 3) return NULL;
// Get faces data
BOP_Index prevI, nextI, oppI, prevJ, nextJ, oppJ;
faceI->getNeighbours(v,prevI,nextI,oppI);
faceJ->getNeighbours(v,prevJ,nextJ,oppJ);
// Quad test
BOP_Index edge;
if (nextI == prevJ) {
if (prevI == nextJ) { // v is in center
faceK = new BOP_Face4(nextI,oppI,nextJ,oppJ,faceI->getPlane(),faceI->getOriginalFace());
faceK->setTAG(faceI->getTAG());
m_mesh->getIndexEdge(v,prevI,edge);
m_mesh->getVertex(v)->removeEdge(edge);
m_mesh->getVertex(prevI)->removeEdge(edge);
m_mesh->getIndexEdge(v,nextI,edge);
m_mesh->getVertex(v)->removeEdge(edge);
m_mesh->getVertex(nextI)->removeEdge(edge);
freeVerts(v, m_mesh->getVertex(v));
} else if (oppI == oppJ) { // nextI is in center
faceK = new BOP_Face4(v,nextJ,oppJ,prevI,faceI->getPlane(),faceI->getOriginalFace());
faceK->setTAG(faceI->getTAG());
m_mesh->getIndexEdge(v,nextI,edge);
m_mesh->getVertex(v)->removeEdge(edge);
m_mesh->getVertex(nextI)->removeEdge(edge);
m_mesh->getIndexEdge(prevI,nextI,edge);
m_mesh->getVertex(prevI)->removeEdge(edge);
m_mesh->getVertex(nextI)->removeEdge(edge);
freeVerts(nextI, m_mesh->getVertex(nextI));
}
} else if (prevI == nextJ && oppI == oppJ) { // prevI is in center
faceK = new BOP_Face4(v,nextI,oppJ,prevJ,faceI->getPlane(),faceI->getOriginalFace());
faceK->setTAG(faceI->getTAG());
m_mesh->getIndexEdge(v,prevI,edge);
m_mesh->getVertex(v)->removeEdge(edge);
m_mesh->getVertex(prevI)->removeEdge(edge);
m_mesh->getIndexEdge(nextI,prevI,edge);
m_mesh->getVertex(nextI)->removeEdge(edge);
m_mesh->getVertex(prevI)->removeEdge(edge);
freeVerts(prevI, m_mesh->getVertex(prevI));
}
return faceK;
}
/**
* Returns if a index is inside a set of indexs.
* @param indexs set of indexs
* @param i index
* @return true if the index is inside the set, false otherwise
*/
bool BOP_Merge2::containsIndex(BOP_Indexs indexs, BOP_Index i)
{
const BOP_IT_Indexs indexsEnd = indexs.end();
for(BOP_IT_Indexs it=indexs.begin();it!=indexsEnd;it++) {
if (*it == i) return true;
}
return false;
}
/**
* Creates a list of lists L1, L2, ... LN where
* LX = mesh faces with vertex v that come from the same original face
* @param facesByOriginalFace list of faces lists
* @param v vertex index
*/
void BOP_Merge2::getFaces(BOP_LFaces &facesByOriginalFace, BOP_Index v)
{
// Get edges with vertex v
BOP_Indexs edgeIndexs = m_mesh->getVertex(v)->getEdges();
const BOP_IT_Indexs edgeEnd = edgeIndexs.end();
for(BOP_IT_Indexs edgeIndex = edgeIndexs.begin();edgeIndex != edgeEnd;edgeIndex++) {
// For each edge, add its no broken faces to the output list
BOP_Edge* edge = m_mesh->getEdge(*edgeIndex);
BOP_Indexs faceIndexs = edge->getFaces();
const BOP_IT_Indexs faceEnd = faceIndexs.end();
for(BOP_IT_Indexs faceIndex=faceIndexs.begin();faceIndex!=faceEnd;faceIndex++) {
BOP_Face* face = m_mesh->getFace(*faceIndex);
if (face->getTAG() != BROKEN) {
bool found = false;
// Search if we already have created a list for the
// faces that come from the same original face
const BOP_IT_LFaces lfEnd = facesByOriginalFace.end();
for(BOP_IT_LFaces facesByOriginalFaceX=facesByOriginalFace.begin();
facesByOriginalFaceX!=lfEnd; facesByOriginalFaceX++) {
if (((*facesByOriginalFaceX)[0])->getOriginalFace() == face->getOriginalFace()) {
// Search that the face has not been added to the list before
for(unsigned int i = 0;i<(*facesByOriginalFaceX).size();i++) {
if ((*facesByOriginalFaceX)[i] == face) {
found = true;
break;
}
}
if (!found) {
// Add the face to the list
if (face->getTAG()==OVERLAPPED) facesByOriginalFaceX->insert(facesByOriginalFaceX->begin(),face);
else facesByOriginalFaceX->push_back(face);
found = true;
}
break;
}
}
if (!found) {
// Create a new list and add the current face
BOP_Faces facesByOriginalFaceX;
facesByOriginalFaceX.push_back(face);
facesByOriginalFace.push_back(facesByOriginalFaceX);
}
}
}
}
}
/**
* Creates a list of lists L1, L2, ... LN where
* LX = mesh faces with vertex v that come from the same original face
* and without any of the vertices that appear before v in vertices
* @param facesByOriginalFace list of faces lists
* @param vertices vector with vertices indexs that contains v
* @param v vertex index
*/
void BOP_Merge2::getFaces(BOP_LFaces &facesByOriginalFace, BOP_Indexs vertices, BOP_Index v)
{
// Get edges with vertex v
BOP_Indexs edgeIndexs = m_mesh->getVertex(v)->getEdges();
const BOP_IT_Indexs edgeEnd = edgeIndexs.end();
for(BOP_IT_Indexs edgeIndex = edgeIndexs.begin();edgeIndex != edgeEnd;edgeIndex++) {
// Foreach edge, add its no broken faces to the output list
BOP_Edge* edge = m_mesh->getEdge(*edgeIndex);
BOP_Indexs faceIndexs = edge->getFaces();
const BOP_IT_Indexs faceEnd = faceIndexs.end();
for(BOP_IT_Indexs faceIndex=faceIndexs.begin();faceIndex!=faceEnd;faceIndex++) {
BOP_Face* face = m_mesh->getFace(*faceIndex);
if (face->getTAG() != BROKEN) {
// Search if the face contains any of the forbidden vertices
bool found = false;
for(BOP_IT_Indexs vertex = vertices.begin();*vertex!= v;vertex++) {
if (face->containsVertex(*vertex)) {
// face contains a forbidden vertex!
found = true;
break;
}
}
if (!found) {
// Search if we already have created a list with the
// faces that come from the same original face
const BOP_IT_LFaces lfEnd = facesByOriginalFace.end();
for(BOP_IT_LFaces facesByOriginalFaceX=facesByOriginalFace.begin();
facesByOriginalFaceX!=lfEnd; facesByOriginalFaceX++) {
if (((*facesByOriginalFaceX)[0])->getOriginalFace() == face->getOriginalFace()) {
// Search that the face has not been added to the list before
for(unsigned int i = 0;i<(*facesByOriginalFaceX).size();i++) {
if ((*facesByOriginalFaceX)[i] == face) {
found = true;
break;
}
}
if (!found) {
// Add face to the list
if (face->getTAG()==OVERLAPPED) facesByOriginalFaceX->insert(facesByOriginalFaceX->begin(),face);
else facesByOriginalFaceX->push_back(face);
found = true;
}
break;
}
}
if (!found) {
// Create a new list and add the current face
BOP_Faces facesByOriginalFaceX;
facesByOriginalFaceX.push_back(face);
facesByOriginalFace.push_back(facesByOriginalFaceX);
}
}
}
}
}
}
#endif /* BOP_NEW_MERGE */

View File

@@ -0,0 +1,99 @@
/**
* ***** 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 BOP_MERGE2_H
#define BOP_MERGE2_H
#include "BOP_Misc.h"
#ifdef BOP_NEW_MERGE
#include "BOP_Mesh.h"
#include "BOP_Tag.h"
#include "BOP_MathUtils.h"
#include "MEM_SmartPtr.h"
typedef vector< BOP_Faces > BOP_LFaces;
typedef vector< BOP_Faces >::iterator BOP_IT_LFaces;
class BOP_Merge2 {
private:
BOP_Mesh* m_mesh;
BOP_Index m_firstVertex;
static BOP_Merge2 SINGLETON;
BOP_Merge2() {};
bool mergeFaces();
bool mergeFaces(BOP_Indexs &mergeVertices);
bool mergeFaces(BOP_Faces &oldFaces, BOP_Faces &newFaces, BOP_Indexs &vertices, BOP_Index v);
bool mergeFaces(BOP_Faces &faces, BOP_Faces &oldFaces, BOP_Faces &newFaces, BOP_Indexs &vertices, BOP_Index v);
BOP_Face *mergeFaces(BOP_Face *faceI, BOP_Face *faceJ, BOP_Index v);
BOP_Face *mergeFaces(BOP_Face *faceI, BOP_Face *faceJ, BOP_Indexs &pending, BOP_Index v);
BOP_Face *mergeFaces(BOP_Face3 *faceI, BOP_Face3 *faceJ, BOP_Index v);
BOP_Face *mergeFaces(BOP_Face4 *faceI, BOP_Face3 *faceJ, BOP_Index v);
BOP_Face *mergeFaces(BOP_Face4 *faceI, BOP_Face3 *faceJ, BOP_Indexs &pending, BOP_Index v);
BOP_Face *mergeFaces(BOP_Face4 *faceI, BOP_Face4 *faceJ, BOP_Indexs &pending, BOP_Index v);
bool createQuads();
bool containsIndex(BOP_Indexs indexs, BOP_Index index);
void getFaces(BOP_LFaces &facesByOriginalFace, BOP_Index v);
void getFaces(BOP_LFaces &facesByOriginalFace, BOP_Indexs vertices, BOP_Index v);
BOP_Face *createQuad(BOP_Face3 *faceI, BOP_Face3 *faceJ);
BOP_Face *createQuad(BOP_Face3 *faceI, BOP_Face4 *faceJ);
BOP_Face *createQuad(BOP_Face4 *faceI, BOP_Face4 *faceJ);
bool mergeVertex(BOP_Face *faceI, BOP_Face *faceJ, BOP_Index v,
BOP_Indexs &mergeVertices);
bool mergeVertex(BOP_Face *faceI, BOP_Face *faceJ, BOP_Index v,
BOP_Indexs &pending, BOP_Faces &oldFaces, BOP_Faces &newFaces );
BOP_Face *find3Neighbor(BOP_Face *faceI, BOP_Face *faceJ,
BOP_Index X, BOP_Index I, BOP_Index P, BOP_Index N );
BOP_Face *find4Neighbor(BOP_Face *faceI, BOP_Face *faceJ,
BOP_Index X, BOP_Index I, BOP_Index P, BOP_Index N,
BOP_Face **faceL, BOP_Index &O);
BOP_Face3 *collapse(BOP_Face4 *faceC, BOP_Index X);
void mergeFaces(BOP_Face *A, BOP_Face *B, BOP_Index X,
BOP_Index I, BOP_Index N, BOP_Index P, BOP_Faces &newFaces );
void freeVerts(BOP_Index v, BOP_Vertex *vert);
void mergeVertex(BOP_Faces&, BOP_Index, BOP_Index);
void mergeVertex(BOP_Face3 *, BOP_Index, BOP_Index);
void mergeVertex(BOP_Face4 *, BOP_Index, BOP_Index);
void cleanup( void );
public:
static BOP_Merge2 &getInstance() {
return SINGLETON;
}
void mergeFaces(BOP_Mesh *m, BOP_Index v);
};
void dumpmesh(BOP_Mesh *, bool);
#endif /* BOP_NEW_MERGE2 */
#endif

View File

@@ -449,6 +449,13 @@ bool BOP_Mesh::getIndexEdge(BOP_Index v1, BOP_Index v2, BOP_Index &e)
printf ("found edge (%d %d)\n",v1,v2);
#endif
e = edge->index;
#ifdef BOP_NEW_MERGE
if( m_edges[e]->getUsed() == false ) {
m_edges[e]->setUsed(true);
m_vertexs[v1]->addEdge(e);
m_vertexs[v2]->addEdge(e);
}
#endif
return true;
}
#ifdef HASH_PRINTF_DEBUG
@@ -794,7 +801,8 @@ bool BOP_Mesh::isClosedMesh()
}
/** ***************************************************************************
#ifdef BOP_DEBUG
/******************************************************************************
* DEBUG METHODS *
* This functions are used to test the mesh state and debug program errors. *
******************************************************************************/
@@ -1075,3 +1083,4 @@ void BOP_Mesh::updatePlanes()
}
}
#endif

View File

@@ -1,10 +1,3 @@
/*
* TEMPORARY defines to enable hashing support
*/
#define HASH(x) ((x) >> 5) /* each "hash" covers 32 indices */
// #define HASH_PRINTF_DEBUG /* uncomment to enable debug output */
/**
*
* $Id$

View File

@@ -0,0 +1,54 @@
/**
*
* $Id: BOP_Misc.h 14444 2008-04-16 22:40:48Z khughes $
*
* ***** 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): Ken Hughes
*
* ***** END GPL LICENSE BLOCK *****
*/
/*
* This file contains various definitions used across the modules
*/
/*
* define operator>> for faces, edges and vertices, and also add some
* debugging functions for displaying various internal data structures
*/
// #define BOP_DEBUG
#define HASH(x) ((x) >> 5) /* each "hash" covers 32 indices */
// #define HASH_PRINTF_DEBUG /* uncomment to enable debug output */
/*
* temporary: control which method is used to merge final triangles and
* quads back together after an operation. If both methods are included,
* the "rt" debugging button on the Scene panel (F10) is used to control
* which is active. Setting it to 100 enables the original method, any
* other value enables the new method.
*/
#define BOP_ORIG_MERGE /* include original merge code */
#define BOP_NEW_MERGE /* include new merge code */

View File

@@ -39,7 +39,7 @@
#define OUTON_TAG 0x11 // Above and on the plane
#define UNCLASSIFIED_TAG 0x0F // Expecting to be classified
#define PHANTOM_TAG 0x0C // Phantom face
#define PHANTOM_TAG 0x0C // Phantom face: verts form collinear triangle
#define OVERLAPPED_TAG 0x0D // Overlapped face
#define BROKEN_TAG 0x0B // Splitted and unused ...

View File

@@ -89,3 +89,22 @@ bool BOP_Vertex::containsEdge(BOP_Index i)
return false;
}
#ifdef BOP_DEBUG
/**
* Implements operator <<.
*/
#include <iomanip>
ostream &operator<<(ostream &stream, BOP_Vertex *v)
{
char aux[20];
BOP_stringTAG(v->m_tag,aux);
MT_Point3 point = v->getPoint();
stream << setprecision(6) << showpoint << fixed;
stream << "Vertex[" << point[0] << "," << point[1] << ",";
stream << point[2] << "] (" << aux << ")";
return stream;
}
#endif

View File

@@ -31,6 +31,7 @@
#include "BOP_Tag.h"
#include "BOP_Indexs.h"
#include "MT_Point3.h"
#include "BOP_Misc.h"
class BOP_Vertex
{
@@ -52,6 +53,10 @@ public:
inline MT_Point3 getPoint() const { return m_point;};
inline BOP_TAG getTAG() { return m_tag;};
inline void setTAG(BOP_TAG t) { m_tag = t;};
#ifdef BOP_DEBUG
friend ostream &operator<<(ostream &stream, BOP_Vertex *v);
#endif
};
#endif

View File

@@ -278,6 +278,9 @@ ECHO Done
<File
RelativePath="..\..\intern\BOP_Merge.cpp">
</File>
<File
RelativePath="..\..\intern\BOP_Merge2.cpp">
</File>
<File
RelativePath="..\..\intern\BOP_Mesh.cpp">
</File>
@@ -330,9 +333,15 @@ ECHO Done
<File
RelativePath="..\..\intern\BOP_Merge.h">
</File>
<File
RelativePath="..\..\intern\BOP_Merge2.h">
</File>
<File
RelativePath="..\..\intern\BOP_Mesh.h">
</File>
<File
RelativePath="..\..\intern\BOP_Misc.h">
</File>
<File
RelativePath="..\..\intern\BOP_Segment.h">
</File>

View File

@@ -6,7 +6,7 @@ sources = env.Glob('intern/*.cpp')
incs = 'intern ../container ../moto/include ../memutil'
if (env['OURPLATFORM'] == 'win32-mingw'):
env.BlenderLib ('blender_BSP', sources, Split(incs), [], libtype=['common','intern'], priority=[26,26] )
env.BlenderLib ('blender_BSP', sources, Split(incs), [], libtype=['common','intern'], priority=[26,69] )
else:
env.BlenderLib ('blender_BSP', sources, Split(incs), [], libtype='core', priority=26 )

View File

@@ -197,7 +197,7 @@ BuildEdges(
for (int vert = 0; vert < vertex_num; ++vert) {
BSP_FaceInd fi(f_it - f_it_begin);
BSP_FaceInd fi(size_t (f_it - f_it_begin));
InsertEdge(prev_vi,face.m_verts[vert],fi,dummy);
prev_vi = face.m_verts[vert];
}

View File

@@ -93,6 +93,16 @@ public:
}
#if defined(_WIN64)
CTR_TaggedIndex(
const unsigned __int64 val
) :
m_val ( ((unsigned __int64)val & index_mask)
| ( (empty_tag << tag_shift)
& (~index_mask) ) ) {
}
#endif
CTR_TaggedIndex(
const CTR_TaggedIndex &my_index
):
@@ -124,6 +134,12 @@ public:
return (long int)(m_val & index_mask);
}
#if defined(_WIN64)
operator unsigned __int64 () const {
return (unsigned __int64)(m_val & index_mask);
}
#endif
bool
IsEmpty(
) const {

View File

@@ -477,7 +477,7 @@ DeleteVertex(
return;
}
LOD_VertexInd last = LOD_VertexInd(verts.end() - verts.begin() - 1);
LOD_VertexInd last = LOD_VertexInd(size_t(verts.end() - verts.begin() - 1));
if (!(last == v)) {
@@ -533,7 +533,7 @@ DeleteEdge(
return;
}
LOD_EdgeInd last = LOD_EdgeInd(edges.end() - edges.begin() - 1);
LOD_EdgeInd last = LOD_EdgeInd(size_t(edges.end() - edges.begin() - 1));
if (!(last == e)) {
vector<LOD_EdgeInd> e_verts;
@@ -573,7 +573,7 @@ DeleteFace(
return;
}
LOD_FaceInd last = LOD_FaceInd(faces.end() - faces.begin() - 1);
LOD_FaceInd last = LOD_FaceInd(size_t (faces.end() - faces.begin() - 1));
if (!(last == f)) {

View File

@@ -694,7 +694,7 @@ bool LbmFsgrSolver::initializeSolverMemory()
double maxDefaultMemChunk = 2.*1024.*1024.*1024.;
//std::cerr<<" memEstFine "<< memEstFine <<" maxWin:" <<maxWinMemChunk <<" maxMac:" <<maxMacMemChunk ; // DEBUG
#ifdef WIN32
if(memEstFine> maxWinMemChunk) {
if(sizeof(void *)==4 && memEstFine>maxWinMemChunk) {
memBlockAllocProblem = true;
}
#endif // WIN32

View File

@@ -42,6 +42,14 @@
#include "GHOST_SystemWin32.h"
// win64 doesn't define GWL_USERDATA
#ifdef WIN32
#ifndef GWL_USERDATA
#define GWL_USERDATA GWLP_USERDATA
#define GWL_WNDPROC GWLP_WNDPROC
#endif
#endif
/*
* According to the docs the mouse wheel message is supported from windows 98
* upwards. Leaving WINVER at default value, the WM_MOUSEWHEEL message and the
@@ -909,8 +917,12 @@ GHOST_TUns8* GHOST_SystemWin32::getClipboard(int flag) const
char *buffer;
char *temp_buff;
if ( OpenClipboard(NULL) ) {
if ( IsClipboardFormatAvailable(CF_TEXT) && OpenClipboard(NULL) ) {
HANDLE hData = GetClipboardData( CF_TEXT );
if (hData == NULL) {
CloseClipboard();
return NULL;
}
buffer = (char*)GlobalLock( hData );
temp_buff = (char*) malloc(strlen(buffer)+1);

View File

@@ -48,6 +48,14 @@
#define M_PI 3.1415926536
#endif
// win64 doesn't define GWL_USERDATA
#ifdef WIN32
#ifndef GWL_USERDATA
#define GWL_USERDATA GWLP_USERDATA
#define GWL_WNDPROC GWLP_WNDPROC
#endif
#endif
LPCSTR GHOST_WindowWin32::s_windowClassName = "GHOST_WindowClass";
const int GHOST_WindowWin32::s_maxTitleLength = 128;
HGLRC GHOST_WindowWin32::s_firsthGLRc = NULL;

View File

@@ -0,0 +1,125 @@
/**
* $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 *****
* A platform-independent definition of [u]intXX_t
* Plus the accompanying header include for htonl/ntohl
*
* This file includes <sys/types.h> to define [u]intXX_t types, where
* XX can be 8, 16, 32 or 64. Unfortunately, not all systems have this
* file.
* - Windows uses __intXX compiler-builtin types. These are signed,
* so we have to flip the signs.
* For these rogue platforms, we make the typedefs ourselves.
*
*/
/*
// DG: original BLO_sys_types.h is in source/blender/blenkernel
// but is not allowed be accessed here because of bad-level-call
*/
#ifndef BLO_SYS_TYPES_H
#define BLO_SYS_TYPES_H
#ifdef __cplusplus
extern "C" {
#endif
#if defined(_WIN32) && !defined(FREE_WINDOWS)
/* The __intXX are built-in types of the visual complier! So we don't
* need to include anything else here. */
typedef signed __int8 int8_t;
typedef signed __int16 int16_t;
typedef signed __int32 int32_t;
typedef signed __int64 int64_t;
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;
#ifndef _INTPTR_T_DEFINED
#ifdef _WIN64
typedef __int64 intptr_t;
#else
typedef long intptr_t;
#endif
#define _INTPTR_T_DEFINED
#endif
#ifndef _UINTPTR_T_DEFINED
#ifdef _WIN64
typedef unsigned __int64 uintptr_t;
#else
typedef unsigned long uintptr_t;
#endif
#define _UINTPTR_T_DEFINED
#endif
#elif defined(__linux__)
/* Linux-i386, Linux-Alpha, Linux-ppc */
#include <stdint.h>
#elif defined (__APPLE__)
#include <inttypes.h>
#elif defined(FREE_WINDOWS)
#include <stdint.h>
#else
/* FreeBSD, Irix, Solaris */
#include <sys/types.h>
#endif /* ifdef platform for types */
#ifdef _WIN32
#ifndef htonl
#define htonl(x) correctByteOrder(x)
#endif
#ifndef ntohl
#define ntohl(x) correctByteOrder(x)
#endif
#elif defined (__FreeBSD__) || defined (__OpenBSD__)
#include <sys/param.h>
#elif defined (__APPLE__)
#include <sys/types.h>
#else /* irix sun linux */
#include <netinet/in.h>
#endif /* ifdef platform for htonl/ntohl */
#ifdef __cplusplus
}
#endif
#endif /* eof */

View File

@@ -58,8 +58,8 @@
#ifndef MEM_MALLOCN_H
#define MEM_MALLOCN_H
/* Needed for FILE* */
#include "stdio.h"
#include "stdio.h" /* needed for FILE* */
#include "BLO_sys_types.h" /* needed for uintptr_t */
#ifdef __cplusplus
extern "C" {
@@ -123,6 +123,12 @@ extern "C" {
/** Attempt to enforce OSX (or other OS's) to have malloc and stack nonzero */
void MEM_set_memory_debug(void);
/* Memory usage stats
* - MEM_get_memory_in_use is all memory
* - MEM_get_mapped_memory_in_use is a subset of all memory */
uintptr_t MEM_get_memory_in_use(void);
uintptr_t MEM_get_mapped_memory_in_use(void);
int MEM_get_memory_blocks_in_use(void);
#ifdef __cplusplus
}

View File

@@ -111,8 +111,8 @@ static const char *check_memlist(MemHead *memh);
/* --------------------------------------------------------------------- */
volatile int totblock= 0;
volatile unsigned long mem_in_use= 0, mmap_in_use= 0;
static volatile int totblock= 0;
static volatile uintptr_t mem_in_use= 0, mmap_in_use= 0;
static volatile struct localListBase _membase;
static volatile struct localListBase *membase = &_membase;
@@ -335,7 +335,7 @@ void *MEM_mapallocN(unsigned int len, const char *str)
/* Memory statistics print */
typedef struct MemPrintBlock {
const char *name;
unsigned long len;
uintptr_t len;
int items;
} MemPrintBlock;
@@ -485,14 +485,14 @@ short MEM_freeN(void *vmemh) /* anders compileertie niet meer */
return(-1);
}
if(sizeof(long)==8) {
if (((long) memh) & 0x7) {
if(sizeof(intptr_t)==8) {
if (((intptr_t) memh) & 0x7) {
MemorY_ErroR("free","attempt to free illegal pointer");
return(-1);
}
}
else {
if (((long) memh) & 0x3) {
if (((intptr_t) memh) & 0x3) {
MemorY_ErroR("free","attempt to free illegal pointer");
return(-1);
}
@@ -696,4 +696,19 @@ static const char *check_memlist(MemHead *memh)
return(name);
}
uintptr_t MEM_get_memory_in_use(void)
{
return mem_in_use;
}
uintptr_t MEM_get_mapped_memory_in_use(void)
{
return mmap_in_use;
}
int MEM_get_memory_blocks_in_use(void)
{
return totblock;
}
/* eof */

View File

@@ -151,7 +151,7 @@ void *mmap(void *start, size_t len, int prot, int flags, int fd, off_t offset)
}
/* munmap for windows */
long munmap(void *ptr, long size)
intptr_t munmap(void *ptr, intptr_t size)
{
MemMap *mm = mmap_findlink(mmapbase, ptr);
if (!mm) {

View File

@@ -261,6 +261,9 @@ ECHO Done
<Filter
Name="extern"
Filter="">
<File
RelativePath="..\..\BLO_sys_types.h">
</File>
<File
RelativePath="..\..\MEM_guardedalloc.h">
</File>

View File

@@ -45,8 +45,10 @@
#define MAP_FAILED ((void *)-1)
#include "BLO_sys_types.h" // needed for intptr_t
void *mmap(void *start, size_t len, int prot, int flags, int fd, off_t offset);
long munmap(void *ptr, long size);
intptr_t munmap(void *ptr, intptr_t size);
#endif

View File

@@ -25,6 +25,7 @@
#define __MEM_Allocator_h_included__ 1
#include "guardedalloc/MEM_guardedalloc.h"
#include "guardedalloc/BLO_sys_types.h"
#ifdef _MSC_VER
#if _MSC_VER < 1300 // 1200 == VC++ 6.0 according to boost

View File

@@ -61,11 +61,8 @@ class MEM_CacheLimiter;
#ifndef __MEM_cache_limiter_c_api_h_included__
extern "C" {
extern void MEM_CacheLimiter_set_maximum(int m);
extern int MEM_CacheLimiter_get_maximum();
// this is rather _ugly_!
extern int mem_in_use;
extern int mmap_in_use;
extern void MEM_CacheLimiter_set_maximum(intptr_t m);
extern intptr_t MEM_CacheLimiter_get_maximum();
};
#endif
@@ -141,7 +138,10 @@ public:
delete handle;
}
void enforce_limits() {
int max = MEM_CacheLimiter_get_maximum();
intptr_t max = MEM_CacheLimiter_get_maximum();
intptr_t mem_in_use= MEM_get_memory_in_use();
intptr_t mmap_in_use= MEM_get_mapped_memory_in_use();
if (max == 0) {
return;
}

View File

@@ -27,18 +27,18 @@
#include "MEM_CacheLimiter.h"
#include "MEM_CacheLimiterC-Api.h"
static int & get_max()
static intptr_t & get_max()
{
static int m = 32*1024*1024;
static intptr_t m = 32*1024*1024;
return m;
}
void MEM_CacheLimiter_set_maximum(int m)
void MEM_CacheLimiter_set_maximum(intptr_t m)
{
get_max() = m;
}
int MEM_CacheLimiter_get_maximum()
intptr_t MEM_CacheLimiter_get_maximum()
{
return get_max();
}

View File

@@ -50,6 +50,19 @@ public:
m_buckets[i] = 0;
}
}
GEN_Map(const GEN_Map& map)
{
m_num_buckets = map.m_num_buckets;
m_buckets = new Entry *[m_num_buckets];
for (int i = 0; i < m_num_buckets; ++i) {
m_buckets[i] = 0;
for(Entry *entry = map.m_buckets[i]; entry; entry=entry->m_next)
insert(entry->m_key, entry->m_value);
}
}
int size() {
int count=0;
@@ -82,6 +95,24 @@ public:
}
return 0;
}
Key* getKey(int index) {
int count=0;
for (int i=0;i<m_num_buckets;i++)
{
Entry* bucket = m_buckets[i];
while(bucket)
{
if (count==index)
{
return &bucket->m_key;
}
bucket = bucket->m_next;
count++;
}
}
return 0;
}
void clear() {
for (int i = 0; i < m_num_buckets; ++i) {

View File

@@ -212,6 +212,7 @@ public:
MT_Matrix4x4 transposed() const;
void transpose();
MT_Matrix4x4 inverse() const;
void invert();
protected:

View File

@@ -52,14 +52,14 @@ GEN_INLINE void MT_Matrix4x4::invert() {
}
}
/* We do things slightly different here, because the invert() modifies
* the buffer itself. This makes it impossible to make this op right
* away. Like other, still missing facilities, I will repair this
* later. */
/* GEN_INLINE T_Matrix4x4 MT_Matrix4x4::inverse() const */
/* { */
/* } */
GEN_INLINE MT_Matrix4x4 MT_Matrix4x4::inverse() const
{
MT_Matrix4x4 invmat = *this;
invmat.invert();
return invmat;
}
GEN_INLINE MT_Matrix4x4& MT_Matrix4x4::operator*=(const MT_Matrix4x4& m)
{

View File

@@ -715,6 +715,9 @@ ECHO Done
<Filter
Name="superlu"
Filter="">
<File
RelativePath="..\..\superlu\BLO_sys_types.h">
</File>
<File
RelativePath="..\..\superlu\Cnames.h">
</File>

View File

@@ -0,0 +1,127 @@
/**
* $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 *****
* A platform-independent definition of [u]intXX_t
* Plus the accompanying header include for htonl/ntohl
*
* This file includes <sys/types.h> to define [u]intXX_t types, where
* XX can be 8, 16, 32 or 64. Unfortunately, not all systems have this
* file.
* - Windows uses __intXX compiler-builtin types. These are signed,
* so we have to flip the signs.
* For these rogue platforms, we make the typedefs ourselves.
*
*/
/*
// DG: original BLO_sys_types.h is in source/blender/blenkernel
// but is not allowed be accessed here because of bad-level-call
*/
#ifndef BLO_SYS_TYPES_H
#define BLO_SYS_TYPES_H
#ifdef __cplusplus
extern "C" {
#endif
#if defined(_WIN32) && !defined(FREE_WINDOWS)
/* The __intXX are built-in types of the visual complier! So we don't
* need to include anything else here. */
typedef signed __int8 int8_t;
typedef signed __int16 int16_t;
typedef signed __int32 int32_t;
typedef signed __int64 int64_t;
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;
#ifndef _INTPTR_T_DEFINED
#ifdef _WIN64
typedef __int64 intptr_t;
#else
typedef long intptr_t;
#endif
#define _INTPTR_T_DEFINED
#endif
#ifndef _UINTPTR_T_DEFINED
#ifdef _WIN64
typedef unsigned __int64 uintptr_t;
#else
typedef unsigned long uintptr_t;
#endif
#define _UINTPTR_T_DEFINED
#endif
#elif defined(__linux__)
/* Linux-i386, Linux-Alpha, Linux-ppc */
#include <stdint.h>
#elif defined (__APPLE__)
#include <inttypes.h>
#elif defined(FREE_WINDOWS)
#include <stdint.h>
#else
/* FreeBSD, Irix, Solaris */
#include <sys/types.h>
#endif /* ifdef platform for types */
#ifdef _WIN32
#ifndef htonl
#define htonl(x) correctByteOrder(x)
#endif
#ifndef ntohl
#define ntohl(x) correctByteOrder(x)
#endif
#elif defined (__FreeBSD__) || defined (__OpenBSD__)
#include <sys/param.h>
#elif defined (__APPLE__)
#include <sys/types.h>
#else /* irix sun linux */
#include <netinet/in.h>
#endif /* ifdef platform for htonl/ntohl */
#ifdef __cplusplus
}
#endif
#endif /* eof */

View File

@@ -8,6 +8,8 @@
*/
#include "ssp_defs.h"
#include "BLO_sys_types.h" // needed for intptr_t
/* Constants */
#define NO_MEMTYPE 4 /* 0: lusup;
1: ucol;
@@ -49,8 +51,8 @@ static int no_expand;
/* Macros to manipulate stack */
#define StackFull(x) ( x + stack.used >= stack.size )
#define NotDoubleAlign(addr) ( (long int)addr & 7 )
#define DoubleAlign(addr) ( ((long int)addr + 7) & ~7L )
#define NotDoubleAlign(addr) ( (intptr_t)addr & 7 )
#define DoubleAlign(addr) ( ((intptr_t)addr + 7) & ~7L )
#define TempSpace(m, w) ( (2*w + 4 + NO_MARKER) * m * sizeof(int) + \
(w + 1) * m * sizeof(float) )
#define Reduce(alpha) ((alpha + 1) / 2) /* i.e. (alpha-1)/2 + 1 */
@@ -611,8 +613,8 @@ sStackCompress(GlobalLU_t *Glu)
last = (char*)usub + xusub[ndim] * iword;
fragment = (char*) (((char*)stack.array + stack.top1) - last);
stack.used -= (long int) fragment;
stack.top1 -= (long int) fragment;
stack.used -= (intptr_t) fragment;
stack.top1 -= (intptr_t) fragment;
Glu->ucol = ucol;
Glu->lsub = lsub;

View File

@@ -118,6 +118,114 @@
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="BlenderPlayer Debug|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\bsp\include;..\..\..\..\build\msvc_7\intern\bmfont\include;..\..\..\..\build\msvc_7\intern\iksolver\include;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\lib\windows\ffmpeg\include;..\..\..\source\blender;..\..\..\source\blender\avi;..\..\..\source\blender\img;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\python;..\..\..\source\blender\include;..\..\..\source\blender\blenkernel;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenloader;..\..\..\source\blender\renderconverter;..\..\..\source\blender\render\extern\include;..\..\..\source\blender\radiosity\extern\include;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\SoundSystem"
PreprocessorDefinitions="_DEBUG,WIN32,_LIB;WITH_FFMPEG"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
DisableLanguageExtensions="FALSE"
DefaultCharIsUnsigned="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile="..\..\..\..\build\msvc_7\source\blender\python\debug\BPY_python.pch"
AssemblerListingLocation="..\..\..\..\build\msvc_7\source\blender\python\debug\"
ObjectFile="..\..\..\..\build\msvc_7\source\blender\python\debug\"
ProgramDataBaseFileName="..\..\..\..\build\msvc_7\source\blender\python\debug\"
WarningLevel="4"
SuppressStartupBanner="TRUE"
Detect64BitPortabilityProblems="FALSE"
DebugInformationFormat="3"
CompileAs="0"
DisableSpecificWarnings="4100"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile="..\..\..\..\build\msvc_7\libs\debug\BPY_python.lib"
SuppressStartupBanner="TRUE"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="BlenderPlayer Release|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\bsp\include;..\..\..\..\build\msvc_7\intern\bmfont\include;..\..\..\..\build\msvc_7\intern\iksolver\include;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\blender;..\..\..\source\blender\avi;..\..\..\source\blender\img;..\..\..\source\blender\imbuf;..\..\..\source\blender\blenlib;..\..\..\source\blender\python;..\..\..\source\blender\include;..\..\..\source\blender\blenkernel;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenloader;..\..\..\source\blender\renderconverter;..\..\..\source\blender\render\extern\include;..\..\..\source\blender\radiosity\extern\include;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\SoundSystem;..\..\..\..\lib\windows\ffmpeg\include"
PreprocessorDefinitions="WIN32,NDEBUG,_LIB"
StringPooling="TRUE"
RuntimeLibrary="0"
EnableFunctionLevelLinking="TRUE"
DefaultCharIsUnsigned="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile="..\..\..\..\build\msvc_7\source\blender\python\BPY_python.pch"
AssemblerListingLocation="..\..\..\..\build\msvc_7\source\blender\python\"
ObjectFile="..\..\..\..\build\msvc_7\source\blender\python\"
ProgramDataBaseFileName="..\..\..\..\build\msvc_7\source\blender\python\"
WarningLevel="3"
SuppressStartupBanner="TRUE"
Detect64BitPortabilityProblems="FALSE"
CompileAs="0"
DisableSpecificWarnings="4100"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile="..\..\..\..\build\msvc_7\libs\BPY_python.lib"
SuppressStartupBanner="TRUE"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>

View File

@@ -152,6 +152,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GP_ghost", "..\gameengine\g
{E109F1A5-FDD3-4F56-A1C4-96867EEA4C5B} = {E109F1A5-FDD3-4F56-A1C4-96867EEA4C5B}
{727F90AC-ABE6-40BF-8937-C2F2F1D13DEA} = {727F90AC-ABE6-40BF-8937-C2F2F1D13DEA}
{E90C7BC2-CF30-4A60-A8F2-0050D592E358} = {E90C7BC2-CF30-4A60-A8F2-0050D592E358}
{5A2EA6DC-1A53-4E87-9166-52870CE3B4EA} = {5A2EA6DC-1A53-4E87-9166-52870CE3B4EA}
{32CC75E2-EE85-45E6-8E3D-513F58464F43} = {32CC75E2-EE85-45E6-8E3D-513F58464F43}
{9A307EE5-CD77-47BC-BD87-62508C7E19D8} = {9A307EE5-CD77-47BC-BD87-62508C7E19D8}
{AB590CED-F71F-4A17-A89B-18583ECD633D} = {AB590CED-F71F-4A17-A89B-18583ECD633D}
@@ -248,6 +249,8 @@ Global
Debug = Debug
Release = Release
EndGlobalSection
GlobalSection(ProjectDependencies) = postSolution
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{F78B7FC9-DE32-465E-9F26-BB0B6B7A2EAF}.3D Plugin Debug.ActiveCfg = Blender Debug|Win32
{F78B7FC9-DE32-465E-9F26-BB0B6B7A2EAF}.3D Plugin Release.ActiveCfg = Blender Release|Win32
@@ -387,8 +390,10 @@ Global
{5A2EA6DC-1A53-4E87-9166-52870CE3B4EA}.Blender Debug.Build.0 = Blender Debug|Win32
{5A2EA6DC-1A53-4E87-9166-52870CE3B4EA}.Blender Release.ActiveCfg = Blender Release|Win32
{5A2EA6DC-1A53-4E87-9166-52870CE3B4EA}.Blender Release.Build.0 = Blender Release|Win32
{5A2EA6DC-1A53-4E87-9166-52870CE3B4EA}.BlenderPlayer Debug.ActiveCfg = Blender Debug|Win32
{5A2EA6DC-1A53-4E87-9166-52870CE3B4EA}.BlenderPlayer Release.ActiveCfg = Blender Release|Win32
{5A2EA6DC-1A53-4E87-9166-52870CE3B4EA}.BlenderPlayer Debug.ActiveCfg = BlenderPlayer Debug|Win32
{5A2EA6DC-1A53-4E87-9166-52870CE3B4EA}.BlenderPlayer Debug.Build.0 = BlenderPlayer Debug|Win32
{5A2EA6DC-1A53-4E87-9166-52870CE3B4EA}.BlenderPlayer Release.ActiveCfg = BlenderPlayer Release|Win32
{5A2EA6DC-1A53-4E87-9166-52870CE3B4EA}.BlenderPlayer Release.Build.0 = BlenderPlayer Release|Win32
{5A2EA6DC-1A53-4E87-9166-52870CE3B4EA}.Debug.ActiveCfg = Blender Debug|Win32
{5A2EA6DC-1A53-4E87-9166-52870CE3B4EA}.Debug.Build.0 = Blender Debug|Win32
{5A2EA6DC-1A53-4E87-9166-52870CE3B4EA}.Release.ActiveCfg = Blender Release|Win32

View File

@@ -365,6 +365,9 @@
<File
RelativePath="..\..\..\source\blender\blenkernel\intern\brush.c">
</File>
<File
RelativePath="..\..\..\source\blender\blenkernel\intern\bvhutils.c">
</File>
<File
RelativePath="..\..\..\source\blender\blenkernel\intern\CCGSubSurf.c">
</File>
@@ -491,6 +494,9 @@
<File
RelativePath="..\..\..\source\blender\blenkernel\intern\script.c">
</File>
<File
RelativePath="..\..\..\source\blender\blenkernel\intern\shrinkwrap.c">
</File>
<File
RelativePath="..\..\..\source\blender\blenkernel\intern\softbody.c">
</File>
@@ -500,6 +506,9 @@
<File
RelativePath="..\..\..\source\blender\blenkernel\intern\subsurf_ccg.c">
</File>
<File
RelativePath="..\..\..\source\blender\blenkernel\intern\suggestions.c">
</File>
<File
RelativePath="..\..\..\source\blender\blenkernel\intern\text.c">
</File>
@@ -576,6 +585,9 @@
<File
RelativePath="..\..\..\source\blender\blenkernel\BKE_brush.h">
</File>
<File
RelativePath="..\..\..\source\blender\blenkernel\BKE_bvhutils.h">
</File>
<File
RelativePath="..\..\..\source\blender\blenkernel\BKE_cdderivedmesh.h">
</File>
@@ -702,6 +714,9 @@
<File
RelativePath="..\..\..\source\blender\blenkernel\BKE_script.h">
</File>
<File
RelativePath="..\..\..\source\blender\blenkernel\BKE_shrinkwrap.h">
</File>
<File
RelativePath="..\..\..\source\blender\blenkernel\BKE_softbody.h">
</File>
@@ -711,6 +726,9 @@
<File
RelativePath="..\..\..\source\blender\blenkernel\BKE_subsurf.h">
</File>
<File
RelativePath="..\..\..\source\blender\blenkernel\BKE_suggestions.h">
</File>
<File
RelativePath="..\..\..\source\blender\blenkernel\BKE_text.h">
</File>

View File

@@ -471,6 +471,9 @@ DNA_makesdna.exe dna.c
<File
RelativePath="..\..\..\source\blender\makesdna\DNA_fileglobal_types.h">
</File>
<File
RelativePath="..\..\..\source\blender\makesdna\DNA_gpencil_types.h">
</File>
<File
RelativePath="..\..\..\source\blender\makesdna\DNA_group_types.h">
</File>

View File

@@ -21,7 +21,7 @@
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..\..\..\lib\windows\QTDevWin\CIncludes;..\..\..\..\lib\windows\sdl\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\build\msvc_7\intern\bsp\include;..\..\..\..\build\msvc_7\intern\ghost\include;..\..\..\..\build\msvc_7\intern\elbeem\include;..\..\..\..\build\msvc_7\intern\opennl\include;..\..\..\..\build\msvc_7\intern\bmfont\include;..\..\..\..\build\msvc_7\intern\blenkey\include;..\..\..\..\build\msvc_7\intern\decimation\include;..\..\..\..\build\msvc_7\intern\memutil\include;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\..\build\msvc_7\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\include;..\..\..\source\blender\renderui;..\..\..\source\blender\blenloader;..\..\..\source\blender\quicktime;..\..\..\source\blender\blenkernel;..\..\..\source\blender\makesdna;..\..\..\source\blender\nodes;..\..\..\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_7\extern\verse\include;..\..\..\..\lib\windows\pthreads\include;..\..\..\..\lib\windows\ffmpeg\include"
AdditionalIncludeDirectories="..\..\..\..\lib\windows\QTDevWin\CIncludes;..\..\..\..\lib\windows\sdl\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\build\msvc_7\intern\bsp\include;..\..\..\..\build\msvc_7\intern\ghost\include;..\..\..\..\build\msvc_7\intern\elbeem\include;..\..\..\..\build\msvc_7\intern\opennl\include;..\..\..\..\build\msvc_7\intern\bmfont\include;..\..\..\..\build\msvc_7\intern\blenkey\include;..\..\..\..\build\msvc_7\intern\decimation\include;..\..\..\..\build\msvc_7\intern\memutil\include;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\..\build\msvc_7\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\include;..\..\..\source\blender\renderui;..\..\..\source\blender\blenloader;..\..\..\source\blender\quicktime;..\..\..\source\blender\blenkernel;..\..\..\source\blender\makesdna;..\..\..\source\blender\nodes;..\..\..\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_7\extern\verse\include;..\..\..\..\build\msvc_7\extern\glew\include;..\..\..\..\lib\windows\pthreads\include;..\..\..\..\lib\windows\ffmpeg\include"
PreprocessorDefinitions="NDEBUG;WIN32;_LIB;_CONSOLE;GAMEBLENDER=1;WITH_QUICKTIME;INTERNATIONAL;WITH_VERSE;WITH_OPENEXR;WITH_DDS;WITH_BULLET=1;WITH_FFMPEG"
StringPooling="TRUE"
RuntimeLibrary="0"
@@ -73,7 +73,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\..\lib\windows\QTDevWin\CIncludes;..\..\..\..\lib\windows\sdl\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\build\msvc_7\intern\bsp\include;..\..\..\..\build\msvc_7\intern\ghost\include;..\..\..\..\build\msvc_7\intern\elbeem\include;..\..\..\..\build\msvc_7\intern\opennl\include;..\..\..\..\build\msvc_7\intern\bmfont\include;..\..\..\..\build\msvc_7\intern\blenkey\include;..\..\..\..\build\msvc_7\intern\decimation\include;..\..\..\..\build\msvc_7\intern\memutil\include;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\..\build\msvc_7\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\include;..\..\..\source\blender\renderui;..\..\..\source\blender\blenloader;..\..\..\source\blender\quicktime;..\..\..\source\blender\blenkernel;..\..\..\source\blender\makesdna;..\..\..\source\blender\nodes;..\..\..\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_7\extern\verse\include;..\..\..\..\lib\windows\pthreads\include;..\..\..\..\lib\windows\ffmpeg\include"
AdditionalIncludeDirectories="..\..\..\..\lib\windows\QTDevWin\CIncludes;..\..\..\..\lib\windows\sdl\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\build\msvc_7\intern\bsp\include;..\..\..\..\build\msvc_7\intern\ghost\include;..\..\..\..\build\msvc_7\intern\elbeem\include;..\..\..\..\build\msvc_7\intern\opennl\include;..\..\..\..\build\msvc_7\intern\bmfont\include;..\..\..\..\build\msvc_7\intern\blenkey\include;..\..\..\..\build\msvc_7\intern\decimation\include;..\..\..\..\build\msvc_7\intern\memutil\include;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\..\build\msvc_7\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\include;..\..\..\source\blender\renderui;..\..\..\source\blender\blenloader;..\..\..\source\blender\quicktime;..\..\..\source\blender\blenkernel;..\..\..\source\blender\makesdna;..\..\..\source\blender\nodes;..\..\..\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_7\extern\verse\include;..\..\..\..\lib\windows\pthreads\include;..\..\..\..\lib\windows\ffmpeg\include;..\..\..\..\build\msvc_7\extern\glew\include"
PreprocessorDefinitions="_DEBUG;WIN32;_LIB;_CONSOLE;GAMEBLENDER;WITH_QUICKTIME;INTERNATIONAL;WITH_VERSE;WITH_OPENEXR;WITH_DDS;WITH_BULLET = 1;WITH_FFMPEG"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@@ -181,6 +181,9 @@
<File
RelativePath="..\..\..\source\blender\src\drawdeps.c">
</File>
<File
RelativePath="..\..\..\source\blender\src\drawgpencil.c">
</File>
<File
RelativePath="..\..\..\source\blender\src\drawimage.c">
</File>
@@ -232,6 +235,9 @@
<File
RelativePath="..\..\..\source\blender\src\editaction.c">
</File>
<File
RelativePath="..\..\..\source\blender\src\editaction_gpencil.c">
</File>
<File
RelativePath="..\..\..\source\blender\src\editarmature.c">
</File>
@@ -349,6 +355,9 @@
<File
RelativePath="..\..\..\source\blender\src\glutil.c">
</File>
<File
RelativePath="..\..\..\source\blender\src\gpencil.c">
</File>
<File
RelativePath="..\..\..\source\blender\src\hddaudio.c">
</File>
@@ -617,6 +626,9 @@
<File
RelativePath="..\..\..\source\blender\include\BDR_editobject.h">
</File>
<File
RelativePath="..\..\..\source\blender\include\BDR_gpencil.h">
</File>
<File
RelativePath="..\..\..\source\blender\include\BDR_imagepaint.h">
</File>
@@ -635,6 +647,9 @@
<File
RelativePath="..\..\..\source\blender\include\BIF_cursors.h">
</File>
<File
RelativePath="..\..\..\source\blender\include\BIF_drawgpencil.h">
</File>
<File
RelativePath="..\..\..\source\blender\include\BIF_drawimage.h">
</File>

View File

@@ -142,9 +142,6 @@
<File
RelativePath="..\..\..\source\gameengine\BlenderRoutines\KX_BlenderMouseDevice.cpp">
</File>
<File
RelativePath="..\..\..\source\gameengine\BlenderRoutines\KX_BlenderPolyMaterial.cpp">
</File>
<File
RelativePath="..\..\..\source\gameengine\BlenderRoutines\KX_BlenderRenderTools.cpp">
</File>
@@ -170,9 +167,6 @@
<File
RelativePath="..\..\..\source\gameengine\BlenderRoutines\KX_BlenderMouseDevice.h">
</File>
<File
RelativePath="..\..\..\source\gameengine\BlenderRoutines\KX_BlenderPolyMaterial.h">
</File>
<File
RelativePath="..\..\..\source\gameengine\BlenderRoutines\KX_BlenderRenderTools.h">
</File>

View File

@@ -347,6 +347,9 @@
<File
RelativePath="..\..\..\source\gameengine\GameLogic\SCA_ANDController.cpp">
</File>
<File
RelativePath="..\..\..\source\gameengine\GameLogic\SCA_DelaySensor.cpp">
</File>
<File
RelativePath="..\..\..\source\gameengine\GameLogic\SCA_EventManager.cpp">
</File>
@@ -465,6 +468,9 @@
<File
RelativePath="..\..\..\source\gameengine\GameLogic\SCA_ANDController.h">
</File>
<File
RelativePath="..\..\..\source\gameengine\GameLogic\SCA_DelaySensor.h">
</File>
<File
RelativePath="..\..\..\source\gameengine\GameLogic\SCA_EventManager.h">
</File>

View File

@@ -126,7 +126,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\build\msvc_7\intern\soundsystem\include;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\..\build\msvc_7\extern\bullet\include;..\..\..\..\build\msvc_7\extern\solid\include;..\..\..\..\build\msvc_7\extern\glew\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\blender\imbuf;..\..\..\source\blender\include;..\..\..\source\blender\blenlib;..\..\..\source\blender\python;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenkernel;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\physics;..\..\..\source\gameengine\rasterizer;..\..\..\source\gameengine\network;..\..\..\source\gameengine\Converter;..\..\..\source\gameengine\gamelogic;..\..\..\source\gameengine\scenegraph;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\physics\sumo;..\..\..\source\gameengine\physics\dummy;..\..\..\source\gameengine\physics\BlOde;..\..\..\source\gameengine\ketsji\kxnetwork;..\..\..\source\gameengine\physics\common;..\..\..\source\gameengine\physics\sumo\include;..\..\..\source\gameengine\physics\common\dummy;..\..\..\source\gameengine\Rasterizer\RAS_OpenGLRasterizer;..\..\..\source\gameengine\physics\sumo\fuzzics\include;..\..\..\source\sumo\include;..\..\..\source\sumo\fuzzics\include;..\..\..\source\gameengine\physics\bullet"
AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\build\msvc_7\intern\soundsystem\include;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\..\build\msvc_7\extern\bullet\include;..\..\..\..\build\msvc_7\extern\solid\include;..\..\..\..\build\msvc_7\extern\glew\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\lib\windows\sdl\include;..\..\..\source\blender\imbuf;..\..\..\source\blender\include;..\..\..\source\blender\blenlib;..\..\..\source\blender\python;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenkernel;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\physics;..\..\..\source\gameengine\rasterizer;..\..\..\source\gameengine\network;..\..\..\source\gameengine\Converter;..\..\..\source\gameengine\gamelogic;..\..\..\source\gameengine\scenegraph;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\physics\sumo;..\..\..\source\gameengine\physics\dummy;..\..\..\source\gameengine\physics\BlOde;..\..\..\source\gameengine\ketsji\kxnetwork;..\..\..\source\gameengine\physics\common;..\..\..\source\gameengine\physics\sumo\include;..\..\..\source\gameengine\physics\common\dummy;..\..\..\source\gameengine\Rasterizer\RAS_OpenGLRasterizer;..\..\..\source\gameengine\physics\sumo\fuzzics\include;..\..\..\source\sumo\include;..\..\..\source\sumo\fuzzics\include;..\..\..\source\gameengine\physics\bullet;..\..\..\source\blender\python\api2_2x"
PreprocessorDefinitions="JANCODEPANCO;WIN32;_LIB;EXP_PYTHON_EMBEDDING;_DEBUG;USE_SUMO_SOLID;WITH_GLEXT"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@@ -179,7 +179,7 @@
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\build\msvc_7\intern\soundsystem\include;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\..\build\msvc_7\extern\bullet\include;..\..\..\..\build\msvc_7\extern\solid\include;..\..\..\..\build\msvc_7\extern\glew\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\blender\imbuf;..\..\..\source\blender\include;..\..\..\source\blender\blenlib;..\..\..\source\blender\python;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenkernel;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\physics;..\..\..\source\gameengine\rasterizer;..\..\..\source\gameengine\network;..\..\..\source\gameengine\Converter;..\..\..\source\gameengine\gamelogic;..\..\..\source\gameengine\scenegraph;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\physics\sumo;..\..\..\source\gameengine\physics\dummy;..\..\..\source\gameengine\physics\BlOde;..\..\..\source\gameengine\ketsji\kxnetwork;..\..\..\source\gameengine\physics\common;..\..\..\source\gameengine\physics\sumo\include;..\..\..\source\gameengine\physics\common\dummy;..\..\..\source\gameengine\Rasterizer\RAS_OpenGLRasterizer;..\..\..\source\gameengine\physics\sumo\fuzzics\include;..\..\..\source\sumo\include;..\..\..\source\sumo\fuzzics\include;..\..\..\source\gameengine\physics\bullet"
AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\build\msvc_7\intern\soundsystem\include;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\..\build\msvc_7\extern\bullet\include;..\..\..\..\build\msvc_7\extern\solid\include;..\..\..\..\build\msvc_7\extern\glew\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\lib\windows\sdl\include;..\..\..\source\blender\imbuf;..\..\..\source\blender\include;..\..\..\source\blender\blenlib;..\..\..\source\blender\python;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenkernel;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\physics;..\..\..\source\gameengine\rasterizer;..\..\..\source\gameengine\network;..\..\..\source\gameengine\Converter;..\..\..\source\gameengine\gamelogic;..\..\..\source\gameengine\scenegraph;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\physics\sumo;..\..\..\source\gameengine\physics\dummy;..\..\..\source\gameengine\physics\BlOde;..\..\..\source\gameengine\ketsji\kxnetwork;..\..\..\source\gameengine\physics\common;..\..\..\source\gameengine\physics\sumo\include;..\..\..\source\gameengine\physics\common\dummy;..\..\..\source\gameengine\Rasterizer\RAS_OpenGLRasterizer;..\..\..\source\gameengine\physics\sumo\fuzzics\include;..\..\..\source\sumo\include;..\..\..\source\sumo\fuzzics\include;..\..\..\source\gameengine\physics\bullet;..\..\..\source\blender\python\api2_2x"
PreprocessorDefinitions="NDEBUG;WIN32;_LIB;USE_SUMO_SOLID;WITH_GLEXT"
StringPooling="TRUE"
RuntimeLibrary="0"
@@ -232,11 +232,12 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\build\msvc_7\intern\soundsystem\include;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\..\build\msvc_7\extern\bullet\include;..\..\..\..\build\msvc_7\extern\solid\include;..\..\..\..\build\msvc_7\extern\glew\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\blender\imbuf;..\..\..\source\blender\include;..\..\..\source\blender\blenlib;..\..\..\source\blender\python;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenkernel;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\physics;..\..\..\source\gameengine\rasterizer;..\..\..\source\gameengine\network;..\..\..\source\gameengine\Converter;..\..\..\source\gameengine\gamelogic;..\..\..\source\gameengine\scenegraph;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\physics\sumo;..\..\..\source\gameengine\physics\dummy;..\..\..\source\gameengine\physics\BlOde;..\..\..\source\gameengine\ketsji\kxnetwork;..\..\..\source\gameengine\physics\common;..\..\..\source\gameengine\physics\sumo\include;..\..\..\source\gameengine\physics\common\dummy;..\..\..\source\gameengine\Rasterizer\RAS_OpenGLRasterizer;..\..\..\source\gameengine\physics\sumo\fuzzics\include;..\..\..\source\sumo\include;..\..\..\source\sumo\fuzzics\include;..\..\..\source\gameengine\physics\bullet"
AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\build\msvc_7\intern\soundsystem\include;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\..\build\msvc_7\extern\bullet\include;..\..\..\..\build\msvc_7\extern\solid\include;..\..\..\..\build\msvc_7\extern\glew\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\lib\windows\sdl\include;..\..\..\source\blender\imbuf;..\..\..\source\blender\include;..\..\..\source\blender\blenlib;..\..\..\source\blender\python;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenkernel;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\physics;..\..\..\source\gameengine\rasterizer;..\..\..\source\gameengine\network;..\..\..\source\gameengine\Converter;..\..\..\source\gameengine\gamelogic;..\..\..\source\gameengine\scenegraph;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\physics\sumo;..\..\..\source\gameengine\physics\dummy;..\..\..\source\gameengine\physics\BlOde;..\..\..\source\gameengine\ketsji\kxnetwork;..\..\..\source\gameengine\physics\common;..\..\..\source\gameengine\physics\sumo\include;..\..\..\source\gameengine\physics\common\dummy;..\..\..\source\gameengine\Rasterizer\RAS_OpenGLRasterizer;..\..\..\source\gameengine\physics\sumo\fuzzics\include;..\..\..\source\sumo\include;..\..\..\source\sumo\fuzzics\include;..\..\..\source\gameengine\physics\bullet;..\..\..\source\blender\python\api2_2x"
PreprocessorDefinitions="JANCODEPANCO;WIN32;_LIB;EXP_PYTHON_EMBEDDING;_DEBUG;USE_SUMO_SOLID;WITH_GLEXT"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
DefaultCharIsUnsigned="TRUE"
RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile="..\..\..\..\build\msvc_7\source\gameengine\ketsji\debug\KX_ketsji.pch"
AssemblerListingLocation="..\..\..\..\build\msvc_7\source\gameengine\ketsji\debug\"
@@ -284,7 +285,7 @@
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\build\msvc_7\intern\soundsystem\include;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\..\build\msvc_7\extern\bullet\include;..\..\..\..\build\msvc_7\extern\solid\include;..\..\..\..\build\msvc_7\extern\glew\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\source\blender\imbuf;..\..\..\source\blender\include;..\..\..\source\blender\blenlib;..\..\..\source\blender\python;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenkernel;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\physics;..\..\..\source\gameengine\rasterizer;..\..\..\source\gameengine\network;..\..\..\source\gameengine\Converter;..\..\..\source\gameengine\gamelogic;..\..\..\source\gameengine\scenegraph;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\physics\sumo;..\..\..\source\gameengine\physics\dummy;..\..\..\source\gameengine\physics\BlOde;..\..\..\source\gameengine\ketsji\kxnetwork;..\..\..\source\gameengine\physics\common;..\..\..\source\gameengine\physics\sumo\include;..\..\..\source\gameengine\physics\common\dummy;..\..\..\source\gameengine\Rasterizer\RAS_OpenGLRasterizer;..\..\..\source\gameengine\physics\sumo\fuzzics\include;..\..\..\source\sumo\include;..\..\..\source\sumo\fuzzics\include;..\..\..\source\gameengine\physics\bullet"
AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\build\msvc_7\intern\soundsystem\include;..\..\..\..\build\msvc_7\intern\guardedalloc\include;..\..\..\..\build\msvc_7\extern\bullet\include;..\..\..\..\build\msvc_7\extern\solid\include;..\..\..\..\build\msvc_7\extern\glew\include;..\..\..\..\lib\windows\python\include\python2.5;..\..\..\..\lib\windows\sdl\include;..\..\..\source\blender\imbuf;..\..\..\source\blender\include;..\..\..\source\blender\blenlib;..\..\..\source\blender\python;..\..\..\source\blender\makesdna;..\..\..\source\blender\blenkernel;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\physics;..\..\..\source\gameengine\rasterizer;..\..\..\source\gameengine\network;..\..\..\source\gameengine\Converter;..\..\..\source\gameengine\gamelogic;..\..\..\source\gameengine\scenegraph;..\..\..\source\gameengine\expressions;..\..\..\source\gameengine\physics\sumo;..\..\..\source\gameengine\physics\dummy;..\..\..\source\gameengine\physics\BlOde;..\..\..\source\gameengine\ketsji\kxnetwork;..\..\..\source\gameengine\physics\common;..\..\..\source\gameengine\physics\sumo\include;..\..\..\source\gameengine\physics\common\dummy;..\..\..\source\gameengine\Rasterizer\RAS_OpenGLRasterizer;..\..\..\source\gameengine\physics\sumo\fuzzics\include;..\..\..\source\sumo\include;..\..\..\source\sumo\fuzzics\include;..\..\..\source\gameengine\physics\bullet;..\..\..\source\blender\python\api2_2x"
PreprocessorDefinitions="NDEBUG;WIN32;_LIB;USE_SUMO_SOLID;WITH_GLEXT"
StringPooling="TRUE"
RuntimeLibrary="0"
@@ -393,6 +394,9 @@
<File
RelativePath="..\..\..\source\gameengine\Ketsji\KX_PolygonMaterial.cpp">
</File>
<File
RelativePath="..\..\..\source\gameengine\Ketsji\KX_PolyProxy.cpp">
</File>
<File
RelativePath="..\..\..\source\gameengine\Ketsji\KX_PyConstraintBinding.cpp">
</File>
@@ -620,6 +624,9 @@
<File
RelativePath="..\..\..\source\gameengine\Ketsji\KX_PolygonMaterial.h">
</File>
<File
RelativePath="..\..\..\source\gameengine\Ketsji\KX_PolyProxy.h">
</File>
<File
RelativePath="..\..\..\source\gameengine\Ketsji\KX_PyConstraintBinding.h">
</File>

View File

@@ -19,7 +19,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\..\..\build\msvc_7\extern\bullet\include;..\..\..\..\..\source\gameengine\Physics\common;..\..\..\..\..\source\gameengine\Physics\Bullet"
AdditionalIncludeDirectories="..\..\..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\..\..\build\msvc_7\extern\bullet\include;..\..\..\..\..\source\gameengine\Physics\common;..\..\..\..\..\source\gameengine\Physics\Bullet;..\..\..\..\..\source\kernel\gen_system;..\..\..\..\..\source\gameengine\Rasterizer"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="FALSE"
BasicRuntimeChecks="3"
@@ -64,7 +64,7 @@
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\..\..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\..\..\build\msvc_7\extern\bullet\include;..\..\..\..\..\source\gameengine\Physics\common;..\..\..\..\..\source\gameengine\Physics\Bullet"
AdditionalIncludeDirectories="..\..\..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\..\..\build\msvc_7\extern\bullet\include;..\..\..\..\..\source\gameengine\Physics\common;..\..\..\..\..\source\gameengine\Physics\Bullet;..\..\..\..\..\source\kernel\gen_system;..\..\..\..\..\source\gameengine\Rasterizer"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
RuntimeLibrary="0"
UsePrecompiledHeader="2"
@@ -107,7 +107,7 @@
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\..\..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\..\..\build\msvc_7\extern\bullet\include;..\..\..\..\..\source\gameengine\Physics\common;..\..\..\..\..\source\gameengine\Physics\Bullet"
AdditionalIncludeDirectories="..\..\..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\..\..\build\msvc_7\extern\bullet\include;..\..\..\..\..\source\gameengine\Physics\common;..\..\..\..\..\source\gameengine\Physics\Bullet;..\..\..\..\..\source\kernel\gen_system;..\..\..\..\..\source\gameengine\Rasterizer"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
RuntimeLibrary="0"
UsePrecompiledHeader="2"
@@ -151,7 +151,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\..\..\build\msvc_7\extern\bullet\include;..\..\..\..\..\source\gameengine\Physics\common;..\..\..\..\..\source\gameengine\Physics\Bullet"
AdditionalIncludeDirectories="..\..\..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\..\..\build\msvc_7\extern\bullet\include;..\..\..\..\..\source\gameengine\Physics\common;..\..\..\..\..\source\gameengine\Physics\Bullet;..\..\..\..\..\source\gameengine\Rasterizer;..\..\..\..\..\source\kernel\gen_system"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="FALSE"
BasicRuntimeChecks="3"

View File

@@ -171,6 +171,7 @@
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile="..\..\..\..\..\..\build\msvc_7\source\gameengine\physics\sumo\debug\PHY_Sumo.pch"
AssemblerListingLocation="..\..\..\..\..\..\build\msvc_7\source\gameengine\physics\sumo\debug\"

View File

@@ -21,7 +21,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\extern\glew\include;..\..\..\source\kernel\gen_system"
AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\extern\glew\include;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\Expressions;..\..\..\..\lib\windows\python\include\python2.5"
PreprocessorDefinitions="_DEBUG;WIN32;_LIB;WITH_GLEXT"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@@ -125,7 +125,7 @@
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\extern\glew\include;..\..\..\source\kernel\gen_system"
AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\extern\glew\include;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\Expressions;..\..\..\..\lib\windows\python\include\python2.5"
PreprocessorDefinitions="NDEBUG;WIN32;_LIB;WITH_GLEXT"
StringPooling="TRUE"
RuntimeLibrary="0"
@@ -229,7 +229,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\extern\glew\include;..\..\..\source\kernel\gen_system"
AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\extern\glew\include;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\Expressions;..\..\..\..\lib\windows\python\include\python2.5"
PreprocessorDefinitions="_DEBUG;WIN32;_LIB;WITH_GLEXT"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@@ -281,7 +281,7 @@
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\extern\glew\include;..\..\..\source\kernel\gen_system"
AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\extern\glew\include;..\..\..\source\kernel\gen_system;..\..\..\source\gameengine\Expressions;..\..\..\..\lib\windows\python\include\python2.5"
PreprocessorDefinitions="NDEBUG;WIN32;_LIB;WITH_GLEXT"
StringPooling="TRUE"
RuntimeLibrary="0"

View File

@@ -125,7 +125,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\intern\moto\include"
AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\build\msvc_7\intern\guardedalloc\include"
PreprocessorDefinitions="_DEBUG,WIN32,_LIB"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@@ -177,7 +177,7 @@
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\intern\moto\include"
AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\build\msvc_7\intern\guardedalloc\include"
PreprocessorDefinitions="NDEBUG,WIN32,_LIB"
StringPooling="TRUE"
RuntimeLibrary="0"
@@ -229,7 +229,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\intern\moto\include"
AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\build\msvc_7\intern\guardedalloc\include"
PreprocessorDefinitions="_DEBUG,WIN32,_LIB"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
@@ -281,7 +281,7 @@
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\intern\moto\include"
AdditionalIncludeDirectories="..\..\..\..\build\msvc_7\intern\string\include;..\..\..\..\build\msvc_7\intern\moto\include;..\..\..\..\build\msvc_7\intern\guardedalloc\include"
PreprocessorDefinitions="NDEBUG,WIN32,_LIB"
StringPooling="TRUE"
RuntimeLibrary="0"

View File

@@ -1 +1 @@
2.46
2.47

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 66 KiB

View File

@@ -35,7 +35,7 @@ int main(int argc, char**argv) {
FILE *fpin, *fpout;
char cname[256];
char sizest[256];
long size;
size_t size;
int i;
if (argc<1) {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 93 KiB

After

Width:  |  Height:  |  Size: 50 KiB

View File

@@ -0,0 +1,431 @@
#!BPY
"""
Name: 'NLA Prototype...'
Blender: 246
Group: 'Animation'
Tip: 'Interactivly prototype the NLA'
"""
__author__ = "Campbell Barton"
__url__ = ("blender.org", "blenderartists.org")
__version__ = "0.01 05/22/2008"
__bpydoc__ = """\
"""
# --------------------------------------------------------------------------
# Anim Prototype v0.01 by Campbell Barton (AKA Ideasman42)
# --------------------------------------------------------------------------
# ***** 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.
#
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------
import bpy
import Blender
from Blender import Window, Draw
FLAG_IS_STATE = 1<<0 # Is this a switch state
FLAG_IS_LOOP = 1<<1 # Is this a switch state
IDLE = 'Frankie_Idle1'
KMKEY = 0
KMNAME = 1
KMFLAG = 2
KMSTATE = 3
KMPRIORITY = 4
# key, actionName, flags, pressed?
KEYMAP = [\
[Draw.UPARROWKEY, 'Frankie_Walk', FLAG_IS_STATE|FLAG_IS_LOOP, False, 10],\
[Draw.LEFTARROWKEY, IDLE, FLAG_IS_STATE|FLAG_IS_LOOP, False, 0],\
[Draw.RIGHTARROWKEY, IDLE, FLAG_IS_STATE|FLAG_IS_LOOP, False, 0],\
[Draw.DOWNARROWKEY, 'Frankie_Runs', FLAG_IS_STATE|FLAG_IS_LOOP, False, 10],\
[Draw.SPACEKEY, 'Frankie_StandJump', FLAG_IS_STATE, False, 20],\
[Draw.RETKEY, 'Frankie_Throw1', FLAG_IS_STATE, False, 10],\
]
ESC = Draw.ESCKEY
def recalcRepeat(s):
actlen= s.actionEnd-s.actionStart
s.repeat = ((s.stripEnd-s.stripStart) / actlen)
def setStripStart(s, frame):
stripStart = s.stripStart
stripEnd = s.stripEnd
if frame == stripStart:
return
stripLen = stripEnd - stripStart
if frame < stripStart:
s.stripStart = frame
s.stripEnd = frame + stripLen
else:
s.stripEnd = frame + stripLen
s.stripStart = frame
def setStripEnd(s, frame):
stripStart = s.stripStart
stripEnd = s.stripEnd
if frame == stripEnd:
return
stripLen = stripEnd - stripStart
if frame < stripEnd:
s.stripStart = frame-stripLen
s.stripEnd = frame
else:
s.stripEnd = frame
s.stripStart = frame-stripLen
def setStripInf(s):
s.stripEnd = s.stripStart + 1000
recalcRepeat(s)
def setStripOnce(s):
actlen= s.actionEnd-s.actionStart
s.stripEnd = s.stripStart + actlen
recalcRepeat(s)
def fadeIn(s, frame):
#setStripStart(s, frame)
setStripStart(s, frame)
setStripInf(s)
def fadeOut(s, frame):
'''
length = s.actionEnd - s.actionStart
setStripEnd(s, frame + int(s.blendOut))
'''
if s.stripStart > frame:
return
stripStartNew = s.stripStart
stripLenNew = frame - stripStartNew
actlen = s.actionEnd-s.actionStart
while stripLenNew - (s.blendIn+s.blendOut) < 0:
stripStartNew -= actlen
stripLenNew = frame - stripStartNew
#print "make way!", s.action.name
#print frame,stripLenNew
s.stripStart = stripStartNew
s.stripEnd = frame
recalcRepeat(s)
#s.stripEnd = frame - s.blendOut
#recalcRepeat(s)
#setStripEnd(s, frame)
def animloop(sce, rend, ob):
jump_momentum = None
def IS_ACTIVE_STATE(km_context):
for km in KEYMAP:
if km_context != km and km[KMSTATE] and km[KMFLAG] & FLAG_IS_STATE:
return True
return False
cfra = rend.cFrame
strips = []
def BUILD_STRIPS():
strips[:] = [(s,s.action) for s in ob.actionStrips]
BUILD_STRIPS()
def GET_PRIORITY(flag):
priority = -1
for km in KEYMAP:
if km[KMSTATE]: # Make sure this wasnt set
if km[KMFLAG] & flag:
priority = max(priority, km[KMPRIORITY])
return priority
def TEST_STRIP(frame):
for s,a in strips:
if not (s.flag & Blender.Armature.NLA.Flags.MUTE):
if s.stripStart+s.blendIn <= frame and s.stripEnd-s.blendOut >= frame:
# print s.action.name
return True
# print "NBOPATHC"
return False
def SET_ACTIVE(km):
blend = 0
ok = False
for s,a in strips:
if a.name == km[KMNAME]:
ok = True
break
if ok:
# blend = s.blendOut
fadeIn(s, cfra)
s.flag &= ~Blender.Armature.NLA.Flags.MUTE
if not (km[KMFLAG] & FLAG_IS_LOOP):
setStripOnce(s)
for i in xrange(len(strips)):
ob.actionStrips.moveUp(s)
BUILD_STRIPS()
for s,a in strips:
if a.name != km[KMNAME]:
fadeOut(s, cfra + s.blendOut)
def SET_IDLE():
blend = 0
ok = False
for s,a in strips:
# print a.name
if a.name == IDLE:
# setStripStart(s, cfra)
ok = True
break
if ok:
blend = s.blendOut
fadeIn(s, cfra)
s.flag &= ~Blender.Armature.NLA.Flags.MUTE
for i in xrange(len(strips)):
ob.actionStrips.moveUp(s)
BUILD_STRIPS()
for s,a in strips:
if a.name != IDLE:
fadeOut(s, cfra+s.blendOut)
for s,a in strips:
# print a.name
if a.name == IDLE:
setStripStart(s, cfra)
setStripInf(s)
s.flag &= ~Blender.Armature.NLA.Flags.MUTE
else:
setStripOnce(s)
setStripEnd(s, 0)
s.flag |= Blender.Armature.NLA.Flags.MUTE
context_act = IDLE
while 1:
cfra = rend.cFrame
# sce.update()
#print "cfra", cfra
while Window.QTest():
evt, val = Window.QRead()
if evt == Draw.MOUSEX or evt == Draw.MOUSEY:
pass
else:
print evt, val
priority = GET_PRIORITY(FLAG_IS_STATE)
for km in KEYMAP:
if km[0] == evt:
if val:
if not km[KMSTATE]: # Make sure this wasnt set
if km[KMFLAG] & FLAG_IS_STATE and priority <= km[KMPRIORITY]:
if context_act != km[KMNAME]:
context_act = km[KMNAME]
SET_ACTIVE(km)
km[KMSTATE] = val
else:
if km[KMFLAG] & FLAG_IS_STATE and (km[KMFLAG] & FLAG_IS_LOOP):
if not IS_ACTIVE_STATE(km):
if context_act != IDLE:
# print "SETTING IDLE1"
context_act = IDLE
SET_IDLE()
context_act = IDLE
km[KMSTATE] = val
# In some cases we want to keep km[KMSTATE] even if the key is off
if evt == ESC:
return
for s,a in strips:
if s.stripEnd < cfra:
s.flag |= Blender.Armature.NLA.Flags.MUTE
# End all loops that are active but have finished
for km in KEYMAP:
if km[KMSTATE] and not (km[KMFLAG] & FLAG_IS_LOOP):
for s,a in strips:
if a.name == km[KMNAME]:
if s.stripEnd - s.blendOut <= cfra:
# print s.stripEnd, cfra
km[KMSTATE] = False
# print "TEST!!!"
# Set Idle if none are active
if not IS_ACTIVE_STATE(None):
if context_act != IDLE:
context_act = IDLE
SET_IDLE()
context_act = IDLE
else:
priority = GET_PRIORITY(FLAG_IS_STATE | FLAG_IS_LOOP)
if not TEST_STRIP(cfra):
for km in KEYMAP:
if km[KMSTATE]:
if km[KMFLAG] & FLAG_IS_STATE and km[KMFLAG] & FLAG_IS_LOOP and priority <= km[KMPRIORITY]:
context_act = km[KMNAME]
SET_ACTIVE(km)
for km in KEYMAP:
if km[KMSTATE]: # This key is held
if km[KMKEY] == Draw.LEFTARROWKEY:
ob.RotZ-=0.1
elif km[KMKEY] == Draw.RIGHTARROWKEY:
ob.RotZ+=0.1
elif km[KMKEY] == Draw.UPARROWKEY or km[KMKEY] == Draw.DOWNARROWKEY:
mat = ob.matrixWorld.rotationPart()
if km[KMKEY] == Draw.DOWNARROWKEY:
ofs = Blender.Mathutils.Vector(0,0.04,0) * mat
else:
ofs = Blender.Mathutils.Vector(0,0.02,0) * mat
ob.LocX += ofs.x
ob.LocY += ofs.y
#ob.LocZ += ofs.z
elif km[KMKEY] == Draw.SPACEKEY:
if jump_momentum == None:
jump_momentum = 0.15
if jump_momentum != None:
ob.LocZ += jump_momentum
if ob.LocZ < 0:
ob.LocZ = 0
jump_momentum = None
# Force the key off
for km in KEYMAP:
if km[KMKEY] == Draw.SPACEKEY:
km[KMSTATE] = False
else:
jump_momentum -= 0.01
rend.cFrame = cfra+1
ob.makeDisplayList()
Window.RedrawAll()
def main():
sce = bpy.data.scenes.active
rend = sce.render
ob = sce.objects.active
back_cfra = rend.cFrame
back_sfra = rend.sFrame
back_efra = rend.eFrame
rend.sFrame = 1
rend.eFrame = 300000
if not ob:
print 'No Active Object'
return
animloop(sce, rend, ob)
rend.cFrame = back_cfra
rend.sFrame = back_sfra
rend.eFrame = back_efra
Window.RedrawAll()
'''
def debug():
sce = bpy.data.scenes.active
rend = sce.render
ob = sce.objects.active
for s in ob.actionStrips:
# print s.action.name
pass
#recalcRepeat(s)
#setStripEnd(s, 100)
#setStripEnd(s, 100)
#setStripEnd(s, 200)
#setStripEnd(s, 100)
#setStripEnd(s, 100)
Window.RedrawAll()
ob.makeDisplayList()
'''
if __name__ == '__main__':
main()
#debug()

View File

@@ -0,0 +1,814 @@
"""The BPyTextPlugin Module
Use get_cached_descriptor(txt) to retrieve information about the script held in
the txt Text object.
Use print_cache_for(txt) to print the information to the console.
Use line, cursor = current_line(txt) to get the logical line and cursor position
Use get_targets(line, cursor) to find out what precedes the cursor:
aaa.bbb.cc|c.ddd -> ['aaa', 'bbb', 'cc']
Use resolve_targets(txt, targets) to turn a target list into a usable object if
one is found to match.
"""
import bpy, sys, os
import __builtin__, tokenize
from Blender.sys import time
from tokenize import generate_tokens, TokenError, \
COMMENT, DEDENT, INDENT, NAME, NEWLINE, NL, STRING, NUMBER
class Definition():
"""Describes a definition or defined object through its name, line number
and docstring. This is the base class for definition based descriptors.
"""
def __init__(self, name, lineno, doc=''):
self.name = name
self.lineno = lineno
self.doc = doc
class ScriptDesc():
"""Describes a script through lists of further descriptor objects (classes,
defs, vars) and dictionaries to built-in types (imports). If a script has
not been fully parsed, its incomplete flag will be set. The time of the last
parse is held by the time field and the name of the text object from which
it was parsed, the name field.
"""
def __init__(self, name, imports, classes, defs, vars, incomplete=False):
self.name = name
self.imports = imports
self.classes = classes
self.defs = defs
self.vars = vars
self.incomplete = incomplete
self.parse_due = 0
def set_delay(self, delay):
self.parse_due = time() + delay
class ClassDesc(Definition):
"""Describes a class through lists of further descriptor objects (defs and
vars). The name of the class is held by the name field and the line on
which it is defined is held in lineno.
"""
def __init__(self, name, parents, defs, vars, lineno, doc=''):
Definition.__init__(self, name, lineno, doc)
self.parents = parents
self.defs = defs
self.vars = vars
class FunctionDesc(Definition):
"""Describes a function through its name and list of parameters (name,
params) and the line on which it is defined (lineno).
"""
def __init__(self, name, params, lineno, doc=''):
Definition.__init__(self, name, lineno, doc)
self.params = params
class VarDesc(Definition):
"""Describes a variable through its name and type (if ascertainable) and the
line on which it is defined (lineno). If no type can be determined, type
will equal None.
"""
def __init__(self, name, type, lineno):
Definition.__init__(self, name, lineno)
self.type = type # None for unknown (supports: dict/list/str)
# Context types
CTX_UNSET = -1
CTX_NORMAL = 0
CTX_SINGLE_QUOTE = 1
CTX_DOUBLE_QUOTE = 2
CTX_COMMENT = 3
# Python keywords
KEYWORDS = ['and', 'del', 'from', 'not', 'while', 'as', 'elif', 'global',
'or', 'with', 'assert', 'else', 'if', 'pass', 'yield',
'break', 'except', 'import', 'print', 'class', 'exec', 'in',
'raise', 'continue', 'finally', 'is', 'return', 'def', 'for',
'lambda', 'try' ]
# Module file extensions
MODULE_EXTS = ['.py', '.pyc', '.pyo', '.pyw', '.pyd']
ModuleType = type(__builtin__)
NoneScriptDesc = ScriptDesc('', dict(), dict(), dict(), dict(), True)
_modules = {}
_modules_updated = 0
_parse_cache = dict()
def _load_module_names():
"""Searches the sys.path for module files and lists them, along with
sys.builtin_module_names, in the global dict _modules.
"""
global _modules
for n in sys.builtin_module_names:
_modules[n] = None
for p in sys.path:
if p == '': p = os.curdir
if not os.path.isdir(p): continue
for f in os.listdir(p):
for ext in MODULE_EXTS:
if f.endswith(ext):
_modules[f[:-len(ext)]] = None
break
_load_module_names()
def _trim_doc(doc):
"""Trims the quotes from a quoted STRING token (eg. "'''text'''" -> "text")
"""
l = len(doc)
i = 0
while i < l/2 and (doc[i] == "'" or doc[i] == '"'):
i += 1
return doc[i:-i]
def resolve_targets(txt, targets):
"""Attempts to return a useful object for the locally or externally defined
entity described by targets. If the object is local (defined in txt), a
Definition instance is returned. If the object is external (imported or
built in), the object itself is returned. If no object can be found, None is
returned.
"""
count = len(targets)
if count==0: return None
obj = None
local = None
i = 1
desc = get_cached_descriptor(txt)
b = targets[0].find('(')
if b==-1: b = None # Trick to let us use [:b] and get the whole string
if desc.classes.has_key(targets[0][:b]):
local = desc.classes[targets[0][:b]]
elif desc.defs.has_key(targets[0]):
local = desc.defs[targets[0]]
elif desc.vars.has_key(targets[0]):
obj = desc.vars[targets[0]].type
if local:
while i < count:
b = targets[i].find('(')
if b==-1: b = None
if hasattr(local, 'classes') and local.classes.has_key(targets[i][:b]):
local = local.classes[targets[i][:b]]
elif hasattr(local, 'defs') and local.defs.has_key(targets[i]):
local = local.defs[targets[i]]
elif hasattr(local, 'vars') and local.vars.has_key(targets[i]):
obj = local.vars[targets[i]].type
local = None
i += 1
break
else:
local = None
break
i += 1
if local: return local
if not obj:
if desc.imports.has_key(targets[0]):
obj = desc.imports[targets[0]]
else:
builtins = get_builtins()
if builtins.has_key(targets[0]):
obj = builtins[targets[0]]
while obj and i < count:
if hasattr(obj, targets[i]):
obj = getattr(obj, targets[i])
else:
obj = None
break
i += 1
return obj
def get_cached_descriptor(txt, force_parse=0):
"""Returns the cached ScriptDesc for the specified Text object 'txt'. If the
script has not been parsed in the last 'period' seconds it will be reparsed
to obtain this descriptor.
Specifying TP_AUTO for the period (default) will choose a period based on the
size of the Text object. Larger texts are parsed less often.
"""
global _parse_cache
parse = True
key = hash(txt)
if not force_parse and _parse_cache.has_key(key):
desc = _parse_cache[key]
if desc.parse_due > time():
parse = desc.incomplete
if parse:
desc = parse_text(txt)
return desc
def parse_text(txt):
"""Parses an entire script's text and returns a ScriptDesc instance
containing information about the script.
If the text is not a valid Python script (for example if brackets are left
open), parsing may fail to complete. However, if this occurs, no exception
is thrown. Instead the returned ScriptDesc instance will have its incomplete
flag set and information processed up to this point will still be accessible.
"""
start_time = time()
txt.reset()
tokens = generate_tokens(txt.readline) # Throws TokenError
curl, cursor = txt.getCursorPos()
linen = curl + 1 # Token line numbers are one-based
imports = dict()
imp_step = 0
classes = dict()
cls_step = 0
defs = dict()
def_step = 0
vars = dict()
var1_step = 0
var2_step = 0
var3_step = 0
var_accum = dict()
var_forflag = False
indent = 0
prev_type = -1
prev_text = ''
incomplete = False
while True:
try:
type, text, start, end, line = tokens.next()
except StopIteration:
break
except (TokenError, IndentationError):
incomplete = True
break
# Skip all comments and line joining characters
if type == COMMENT or type == NL:
continue
#################
## Indentation ##
#################
if type == INDENT:
indent += 1
elif type == DEDENT:
indent -= 1
#########################
## Module importing... ##
#########################
imp_store = False
# Default, look for 'from' or 'import' to start
if imp_step == 0:
if text == 'from':
imp_tmp = []
imp_step = 1
elif text == 'import':
imp_from = None
imp_tmp = []
imp_step = 2
# Found a 'from', create imp_from in form '???.???...'
elif imp_step == 1:
if text == 'import':
imp_from = '.'.join(imp_tmp)
imp_tmp = []
imp_step = 2
elif type == NAME:
imp_tmp.append(text)
elif text != '.':
imp_step = 0 # Invalid syntax
# Found 'import', imp_from is populated or None, create imp_name
elif imp_step == 2:
if text == 'as':
imp_name = '.'.join(imp_tmp)
imp_step = 3
elif type == NAME or text == '*':
imp_tmp.append(text)
elif text != '.':
imp_name = '.'.join(imp_tmp)
imp_symb = imp_name
imp_store = True
# Found 'as', change imp_symb to this value and go back to step 2
elif imp_step == 3:
if type == NAME:
imp_symb = text
else:
imp_store = True
# Both imp_name and imp_symb have now been populated so we can import
if imp_store:
# Handle special case of 'import *'
if imp_name == '*':
parent = get_module(imp_from)
imports.update(parent.__dict__)
else:
# Try importing the name as a module
try:
if imp_from:
module = get_module(imp_from +'.'+ imp_name)
else:
module = get_module(imp_name)
except (ImportError, ValueError, AttributeError, TypeError):
# Try importing name as an attribute of the parent
try:
module = __import__(imp_from, globals(), locals(), [imp_name])
imports[imp_symb] = getattr(module, imp_name)
except (ImportError, ValueError, AttributeError, TypeError):
pass
else:
imports[imp_symb] = module
# More to import from the same module?
if text == ',':
imp_tmp = []
imp_step = 2
else:
imp_step = 0
###################
## Class parsing ##
###################
# If we are inside a class then def and variable parsing should be done
# for the class. Otherwise the definitions are considered global
# Look for 'class'
if cls_step == 0:
if text == 'class':
cls_name = None
cls_lineno = start[0]
cls_indent = indent
cls_step = 1
# Found 'class', look for cls_name followed by '(' parents ')'
elif cls_step == 1:
if not cls_name:
if type == NAME:
cls_name = text
cls_sline = False
cls_parents = dict()
cls_defs = dict()
cls_vars = dict()
elif type == NAME:
if classes.has_key(text):
parent = classes[text]
cls_parents[text] = parent
cls_defs.update(parent.defs)
cls_vars.update(parent.vars)
elif text == ':':
cls_step = 2
# Found 'class' name ... ':', now check if it's a single line statement
elif cls_step == 2:
if type == NEWLINE:
cls_sline = False
else:
cls_sline = True
cls_doc = ''
cls_step = 3
elif cls_step == 3:
if not cls_doc and type == STRING:
cls_doc = _trim_doc(text)
if cls_sline:
if type == NEWLINE:
classes[cls_name] = ClassDesc(cls_name, cls_parents, cls_defs, cls_vars, cls_lineno, cls_doc)
cls_step = 0
else:
if type == DEDENT and indent <= cls_indent:
classes[cls_name] = ClassDesc(cls_name, cls_parents, cls_defs, cls_vars, cls_lineno, cls_doc)
cls_step = 0
#################
## Def parsing ##
#################
# Look for 'def'
if def_step == 0:
if text == 'def':
def_name = None
def_lineno = start[0]
def_step = 1
# Found 'def', look for def_name followed by '('
elif def_step == 1:
if type == NAME:
def_name = text
def_params = []
elif def_name and text == '(':
def_step = 2
# Found 'def' name '(', now identify the parameters upto ')'
# TODO: Handle ellipsis '...'
elif def_step == 2:
if type == NAME:
def_params.append(text)
elif text == ':':
def_step = 3
# Found 'def' ... ':', now check if it's a single line statement
elif def_step == 3:
if type == NEWLINE:
def_sline = False
else:
def_sline = True
def_doc = ''
def_step = 4
elif def_step == 4:
if type == STRING:
def_doc = _trim_doc(text)
newdef = None
if def_sline:
if type == NEWLINE:
newdef = FunctionDesc(def_name, def_params, def_lineno, def_doc)
else:
if type == NAME:
newdef = FunctionDesc(def_name, def_params, def_lineno, def_doc)
if newdef:
if cls_step > 0: # Parsing a class
cls_defs[def_name] = newdef
else:
defs[def_name] = newdef
def_step = 0
##########################
## Variable assignation ##
##########################
if cls_step > 0: # Parsing a class
# Look for 'self.???'
if var1_step == 0:
if text == 'self':
var1_step = 1
elif var1_step == 1:
if text == '.':
var_name = None
var1_step = 2
else:
var1_step = 0
elif var1_step == 2:
if type == NAME:
var_name = text
if cls_vars.has_key(var_name):
var_step = 0
else:
var1_step = 3
elif var1_step == 3:
if text == '=':
var1_step = 4
elif text != ',':
var1_step = 0
elif var1_step == 4:
var_type = None
if type == NUMBER:
close = end[1]
if text.find('.') != -1: var_type = float
else: var_type = int
elif type == STRING:
close = end[1]
var_type = str
elif text == '[':
close = line.find(']', end[1])
var_type = list
elif text == '(':
close = line.find(')', end[1])
var_type = tuple
elif text == '{':
close = line.find('}', end[1])
var_type = dict
elif text == 'dict':
close = line.find(')', end[1])
var_type = dict
if var_type and close+1 < len(line):
if line[close+1] != ' ' and line[close+1] != '\t':
var_type = None
cls_vars[var_name] = VarDesc(var_name, var_type, start[0])
var1_step = 0
elif def_step > 0: # Parsing a def
# Look for 'global ???[,???]'
if var2_step == 0:
if text == 'global':
var2_step = 1
elif var2_step == 1:
if type == NAME:
if not vars.has_key(text):
vars[text] = VarDesc(text, None, start[0])
elif text != ',' and type != NL:
var2_step == 0
else: # In global scope
if var3_step == 0:
# Look for names
if text == 'for':
var_accum = dict()
var_forflag = True
elif text == '=' or (var_forflag and text == 'in'):
var_forflag = False
var3_step = 1
elif type == NAME:
if prev_text != '.' and not vars.has_key(text):
var_accum[text] = VarDesc(text, None, start[0])
elif not text in [',', '(', ')', '[', ']']:
var_accum = dict()
var_forflag = False
elif var3_step == 1:
if len(var_accum) != 1:
var_type = None
vars.update(var_accum)
else:
var_name = var_accum.keys()[0]
var_type = None
if type == NUMBER:
if text.find('.') != -1: var_type = float
else: var_type = int
elif type == STRING: var_type = str
elif text == '[': var_type = list
elif text == '(': var_type = tuple
elif text == '{': var_type = dict
vars[var_name] = VarDesc(var_name, var_type, start[0])
var3_step = 0
#######################
## General utilities ##
#######################
prev_type = type
prev_text = text
desc = ScriptDesc(txt.name, imports, classes, defs, vars, incomplete)
desc.set_delay(10 * (time()-start_time) + 0.05)
global _parse_cache
_parse_cache[hash(txt)] = desc
return desc
def get_modules(since=1):
"""Returns the set of built-in modules and any modules that have been
imported into the system upto 'since' seconds ago.
"""
global _modules, _modules_updated
t = time()
if _modules_updated < t - since:
_modules.update(sys.modules)
_modules_updated = t
return _modules.keys()
def suggest_cmp(x, y):
"""Use this method when sorting a list of suggestions.
"""
return cmp(x[0].upper(), y[0].upper())
def get_module(name):
"""Returns the module specified by its name. The module itself is imported
by this method and, as such, any initialization code will be executed.
"""
mod = __import__(name)
components = name.split('.')
for comp in components[1:]:
mod = getattr(mod, comp)
return mod
def type_char(v):
"""Returns the character used to signify the type of a variable. Use this
method to identify the type character for an item in a suggestion list.
The following values are returned:
'm' if the parameter is a module
'f' if the parameter is callable
'v' if the parameter is variable or otherwise indeterminable
"""
if isinstance(v, ModuleType):
return 'm'
elif callable(v):
return 'f'
else:
return 'v'
def get_context(txt):
"""Establishes the context of the cursor in the given Blender Text object
Returns one of:
CTX_NORMAL - Cursor is in a normal context
CTX_SINGLE_QUOTE - Cursor is inside a single quoted string
CTX_DOUBLE_QUOTE - Cursor is inside a double quoted string
CTX_COMMENT - Cursor is inside a comment
"""
l, cursor = txt.getCursorPos()
lines = txt.asLines(0, l+1)
# FIXME: This method is too slow in large files for it to be called as often
# as it is. So for lines below the 1000th line we do this... (quorn)
if l > 1000: return CTX_NORMAL
# Detect context (in string or comment)
in_str = CTX_NORMAL
for line in lines:
if l == 0:
end = cursor
else:
end = len(line)
l -= 1
# Comments end at new lines
if in_str == CTX_COMMENT:
in_str = CTX_NORMAL
for i in range(end):
if in_str == 0:
if line[i] == "'": in_str = CTX_SINGLE_QUOTE
elif line[i] == '"': in_str = CTX_DOUBLE_QUOTE
elif line[i] == '#': in_str = CTX_COMMENT
else:
if in_str == CTX_SINGLE_QUOTE:
if line[i] == "'":
in_str = CTX_NORMAL
# In again if ' escaped, out again if \ escaped, and so on
for a in range(i-1, -1, -1):
if line[a] == '\\': in_str = 1-in_str
else: break
elif in_str == CTX_DOUBLE_QUOTE:
if line[i] == '"':
in_str = CTX_NORMAL
# In again if " escaped, out again if \ escaped, and so on
for a in range(i-1, -1, -1):
if line[i-a] == '\\': in_str = 2-in_str
else: break
return in_str
def current_line(txt):
"""Extracts the Python script line at the cursor in the Blender Text object
provided and cursor position within this line as the tuple pair (line,
cursor).
"""
lineindex, cursor = txt.getCursorPos()
lines = txt.asLines()
line = lines[lineindex]
# Join previous lines to this line if spanning
i = lineindex - 1
while i > 0:
earlier = lines[i].rstrip()
if earlier.endswith('\\'):
line = earlier[:-1] + ' ' + line
cursor += len(earlier)
i -= 1
# Join later lines while there is an explicit joining character
i = lineindex
while i < len(lines)-1 and lines[i].rstrip().endswith('\\'):
later = lines[i+1].strip()
line = line + ' ' + later[:-1]
i += 1
return line, cursor
def get_targets(line, cursor):
"""Parses a period separated string of valid names preceding the cursor and
returns them as a list in the same order.
"""
brk = 0
targets = []
j = cursor
i = j-1
while i >= 0:
if line[i] == ')': brk += 1
elif brk:
if line[i] == '(': brk -= 1
else:
if line[i] == '.':
targets.insert(0, line[i+1:j]); j=i
elif not (line[i].isalnum() or line[i] == '_' or line[i] == '.'):
break
i -= 1
targets.insert(0, line[i+1:j])
return targets
def get_defs(txt):
"""Returns a dictionary which maps definition names in the source code to
a list of their parameter names.
The line 'def doit(one, two, three): print one' for example, results in the
mapping 'doit' : [ 'one', 'two', 'three' ]
"""
return get_cached_descriptor(txt).defs
def get_vars(txt):
"""Returns a dictionary of variable names found in the specified Text
object. This method locates all names followed directly by an equal sign:
'a = ???' or indirectly as part of a tuple/list assignment or inside a
'for ??? in ???:' block.
"""
return get_cached_descriptor(txt).vars
def get_imports(txt):
"""Returns a dictionary which maps symbol names in the source code to their
respective modules.
The line 'from Blender import Text as BText' for example, results in the
mapping 'BText' : <module 'Blender.Text' (built-in)>
Note that this method imports the modules to provide this mapping as as such
will execute any initilization code found within.
"""
return get_cached_descriptor(txt).imports
def get_builtins():
"""Returns a dictionary of built-in modules, functions and variables."""
return __builtin__.__dict__
#################################
## Debugging utility functions ##
#################################
def print_cache_for(txt, period=sys.maxint):
"""Prints out the data cached for a given Text object. If no period is
given the text will not be reparsed and the cached version will be returned.
Otherwise if the period has expired the text will be reparsed.
"""
desc = get_cached_descriptor(txt, period)
print '================================================'
print 'Name:', desc.name, '('+str(hash(txt))+')'
print '------------------------------------------------'
print 'Defs:'
for name, ddesc in desc.defs.items():
print ' ', name, ddesc.params, ddesc.lineno
print ' ', ddesc.doc
print '------------------------------------------------'
print 'Vars:'
for name, vdesc in desc.vars.items():
print ' ', name, vdesc.type, vdesc.lineno
print '------------------------------------------------'
print 'Imports:'
for name, item in desc.imports.items():
print ' ', name.ljust(15), item
print '------------------------------------------------'
print 'Classes:'
for clsnme, clsdsc in desc.classes.items():
print ' *********************************'
print ' Name:', clsnme
print ' ', clsdsc.doc
print ' ---------------------------------'
print ' Defs:'
for name, ddesc in clsdsc.defs.items():
print ' ', name, ddesc.params, ddesc.lineno
print ' ', ddesc.doc
print ' ---------------------------------'
print ' Vars:'
for name, vdesc in clsdsc.vars.items():
print ' ', name, vdesc.type, vdesc.lineno
print ' *********************************'
print '================================================'

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,835 @@
#!BPY
"""
Name: 'FLT DOF Editor'
Blender: 240
Group: 'Misc'
Tooltip: 'Degree of Freedom editor for FLT nodes'
"""
__author__ = "Geoffrey Bantle"
__version__ = "1.0 11/21/07"
__email__ = ('scripts', 'Author, ')
__url__ = ('blender', 'blenderartists.org')
__bpydoc__ ="""\
This script provides tools for working with OpenFlight databases in Blender. OpenFlight is a
registered trademark of MultiGen-Paradigm, Inc.
Feature overview and more availible at:
http://wiki.blender.org/index.php/Scripts/Manual/FLTools
"""
# --------------------------------------------------------------------------
# flt_palettemanager.py version 0.1 2005/04/08
# --------------------------------------------------------------------------
# ***** BEGIN GPL LICENSE BLOCK *****
#
# Copyright (C) 2007: Blender Foundation
#
# 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.
#
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------
import Blender.Draw as Draw
from Blender.BGL import *
import Blender
import flt_properties
reload(flt_properties)
from flt_properties import *
#event codes
evcode = {
"DOF_MAKE" : 100,
"DOF_UPDATE" : 138,
"DOF_DELETE" : 101,
"DOF_TRANSX" : 102,
"DOF_TRANSY" : 103,
"DOF_TRANSZ" : 104,
"DOF_ROTX" : 105,
"DOF_ROTY" : 106,
"DOF_ROTZ" : 107,
"DOF_SCALEX" : 108,
"DOF_SCALEY" : 109,
"DOF_SCALEZ" : 110,
"DOF_MIN_TRANSX" : 111,
"DOF_MIN_TRANSY" : 112,
"DOF_MIN_TRANSZ" : 113,
"DOF_MIN_ROTX" : 114,
"DOF_MIN_ROTY" : 115,
"DOF_MIN_ROTZ" : 116,
"DOF_MIN_SCALEX" : 117,
"DOF_MIN_SCALEY" : 118,
"DOF_MIN_SCALEZ" : 119,
"DOF_MAX_TRANSX" : 120,
"DOF_MAX_TRANSY" : 121,
"DOF_MAX_TRANSZ" : 122,
"DOF_MAX_ROTX" : 123,
"DOF_MAX_ROTY" : 124,
"DOF_MAX_ROTZ" : 125,
"DOF_MAX_SCALEX" : 126,
"DOF_MAX_SCALEY" : 127,
"DOF_MAX_SCALEZ" : 128,
"DOF_STEP_TRANSX" : 129,
"DOF_STEP_TRANSY" : 130,
"DOF_STEP_TRANSZ" : 131,
"DOF_STEP_ROTX" : 132,
"DOF_STEP_ROTY" : 133,
"DOF_STEP_ROTZ" : 134,
"DOF_STEP_SCALEX" : 135,
"DOF_STEP_SCALEY" : 136,
"DOF_STEP_SCALEZ" : 137
}
#system
DOF_MAKE = None
DOF_UPDATE = None
DOF_DELETE = None
#toggle buttons
DOF_TRANSX = None
DOF_TRANSY = None
DOF_TRANSZ = None
DOF_ROTX = None
DOF_ROTY = None
DOF_ROTZ = None
DOF_SCALEX = None
DOF_SCALEY = None
DOF_SCALEZ = None
#Minimums
DOF_MIN_TRANSX = None
DOF_MIN_TRANSY = None
DOF_MIN_TRANSZ = None
DOF_MIN_ROTX = None
DOF_MIN_ROTY = None
DOF_MIN_ROTZ = None
DOF_MIN_SCALEX = None
DOF_MIN_SCALEY = None
DOF_MIN_SCALEZ = None
#maximums
DOF_MAX_TRANSX = None
DOF_MAX_TRANSY = None
DOF_MAX_TRANSZ = None
DOF_MAX_ROTX = None
DOF_MAX_ROTY = None
DOF_MAX_ROTZ = None
DOF_MAX_SCALEX = None
DOF_MAX_SCALEY = None
DOF_MAX_SCALEZ = None
#step
DOF_STEP_TRANSX = None
DOF_STEP_TRANSY = None
DOF_STEP_TRANSZ = None
DOF_STEP_ROTX = None
DOF_STEP_ROTY = None
DOF_STEP_ROTZ = None
DOF_STEP_SCALEX = None
DOF_STEP_SCALEY = None
DOF_STEP_SCALEZ = None
#labels
DOF_ROTSTRING = None
DOF_TRANSTRING = None
DOF_SCALESTRING = None
DOF_EDITLABEL = None
#make ID props easier/morereadable
zmin = '14d!ZMIN'
zmax = '15d!ZMAX'
zcur = '16d!ZCUR'
zstep = '17d!ZSTEP'
ymin = '18d!YMIN'
ymax = '19d!YMAX'
ycur = '20d!YCUR'
ystep = '21d!YSTEP'
xmin = '22d!XMIN'
xmax = '23d!XMAX'
xcur = '24d!XCUR'
xstep = '25d!XSTEP'
pitchmin = '26d!PITCH-MIN'
pitchmax = '27d!PITCH-MAX'
pitchcur = '28d!PITCH-CUR'
pitchstep = '29d!PITCH-STEP'
rollmin = '30d!ROLL-MIN'
rollmax = '31d!ROLL-MAX'
rollcur = '32d!ROLL-CUR'
rollstep = '33d!ROLL-STEP'
yawmin = '34d!YAW-MIN'
yawmax = '35d!YAW-MAX'
yawcur = '36d!YAW-CUR'
yawstep = '37d!YAW-STEP'
zscalemin = '38d!ZSIZE-MIN'
zscalemax = '39d!ZSIZE-MAX'
zscalecur = '40d!ZSIZE-CUR'
zscalestep = '41d!ZSIZE-STEP'
yscalemin = '42d!YSIZE-MIN'
yscalemax = '43d!YSIZE-MAX'
yscalecur = '44d!YSIZE-CUR'
yscalestep = '45d!YSIZE-STEP'
xscalemin = '46d!XSIZE-MIN'
xscalemax = '47d!XSIZE-MAX'
xscalecur = '48d!XSIZE-CUR'
xscalestep = '49d!XSIZE-STEP'
def update_state():
state = dict()
state["activeScene"] = Blender.Scene.GetCurrent()
state["activeObject"] = state["activeScene"].objects.active
if state["activeObject"] and not state["activeObject"].sel:
state["activeObject"] = None
state["activeMesh"] = None
if state["activeObject"] and state["activeObject"].type == 'Mesh':
state["activeMesh"] = state["activeObject"].getData(mesh=True)
state["activeFace"] = None
if state["activeMesh"]:
if state["activeMesh"].faceUV and state["activeMesh"].activeFace != None:
state["activeFace"] = state["activeMesh"].faces[state["activeMesh"].activeFace]
#update editmode
state["editmode"] = Blender.Window.EditMode()
return state
def idprops_append(object, typecode, props):
object.properties["FLT"] = dict()
object.properties["FLT"]['type'] = typecode
for prop in props:
object.properties["FLT"][prop] = props[prop]
object.properties["FLT"]['3t8!id'] = object.name
def idprops_kill():
state = update_state()
if state["activeObject"] and state["activeObject"].properties.has_key('FLT'):
state["activeObject"].properties.pop('FLT')
def idprops_copy(source):
state = update_state()
if source.properties.has_key('FLT'):
for object in state["activeScene"].objects:
if object.sel and object != source and (state["activeScene"].Layers & object.Layers):
idprops_kill(object)
object.properties['FLT'] = dict()
for key in source.properties['FLT']:
object.properties['FLT'][key] = source.properties['FLT'][key]
def select_by_typecode(typecode):
state = update_state()
for object in state["activeScene"].objects:
if object.properties.has_key('FLT') and object.properties['FLT']['type'] == typecode and state["activeScene"].Layers & object.Layers:
object.select(1)
def DOF_get_frame():
state = update_state()
if not state["activeObject"] and not id_props_type(state["activeObject"], 14):
return
#Warning! assumes 1 BU == 10 meters.
#do origin
state["activeObject"].properties['FLT']['5d!ORIGX'] = state["activeObject"].getLocation('worldspace')[0]*10.0
state["activeObject"].properties['FLT']['6d!ORIGY'] = state["activeObject"].getLocation('worldspace')[1]*10.0
state["activeObject"].properties['FLT']['7d!ORIGZ'] = state["activeObject"].getLocation('worldspace')[2]*10.0
#do X axis
x = Blender.Mathutils.Vector(1.0,0.0,0.0)
x = x * state["activeObject"].getMatrix('worldspace')
x = x * 10.0
state["activeObject"].properties['FLT']['8d!XAXIS-X'] = x[0]
state["activeObject"].properties['FLT']['9d!XAXIS-Y'] = x[1]
state["activeObject"].properties['FLT']['10d!XAXIS-Z'] = x[2]
#do X/Y plane
x = Blender.Mathutils.Vector(0.0,1.0,0.0)
x.normalize()
x = x * state["activeObject"].getMatrix('worldspace')
x = x * 10.0
state["activeObject"].properties['FLT']['11d!XYPLANE-X'] = x[0]
state["activeObject"].properties['FLT']['12d!XYPLANE-Y'] = x[1]
state["activeObject"].properties['FLT']['13d!XZPLANE-Z'] = x[2]
def idprops_type(object, typecode):
if object.properties.has_key('FLT') and object.properties['FLT'].has_key('type') and object.properties['FLT']['type'] == typecode:
return True
return False
#ui type code
def get_prop(typecode, prop):
state = update_state()
if state["activeObject"] and idprops_type(state["activeObject"], typecode):
props = state["activeObject"].properties['FLT']
else:
props = flt_properties.FLTDOF
return props[prop]
def set_prop(typecode, prop, value):
state = update_state()
if state["activeObject"] and idprops_type(state["activeObject"],typecode):
state["activeObject"].properties['FLT'][prop] = value
lockxtrans = (1 << 31)
lockytrans = (1 << 30)
lockztrans = (1 << 29)
lockxrot = (1 << 28)
lockyrot = (1 << 27)
lockzrot = (1 << 26)
lockxscale = (1 << 25)
lockyscale = (1 << 24)
lockzscale = (1 << 23)
def get_lockmask(mask):
state = update_state()
if state["activeObject"]:
flag = get_prop(14,'50I!FLAG')
if flag & mask:
return True
return False
def set_lockmask(mask):
state = update_state()
if state["activeObject"] and idprops_type(state["activeObject"], 14):
oldvalue = state["activeObject"].properties['FLT']['50I!FLAG']
oldvalue = struct.unpack('>I', struct.pack('>i', oldvalue))[0]
oldvalue |= mask
state["activeObject"].properties['FLT']['50I!FLAG'] = struct.unpack('>i', struct.pack(">I", oldvalue))[0]
def clear_lockmask(mask):
state = update_state()
if state["activeObject"] and idprops_type(state["activeObject"], 14):
oldvalue = state["activeObject"].properties['FLT']['50I!FLAG']
oldvalue = struct.unpack('>I', struct.pack('>i', oldvalue))[0]
oldvalue &= ~mask
state["activeObject"].properties['FLT']['50I!FLAG'] = struct.unpack('>i',struct.pack('>I',oldvalue))[0]
def create_dof():
state = update_state()
actobj = state["activeObject"]
if actobj and not idprops_type(actobj, 14):
idprops_kill()
idprops_append(actobj,14, flt_properties.FLTDOF)
DOF_get_frame()
def event(evt,val):
if evt == Draw.ESCKEY:
Draw.Exit()
def but_event(evt):
global DOF_MAKE
global DOF_UPDATE
global DOF_DELETE
global DOF_TRANSX
global DOF_TRANSY
global DOF_TRANSZ
global DOF_ROTX
global DOF_ROTY
global DOF_ROTZ
global DOF_SCALEX
global DOF_SCALEY
global DOF_SCALEZ
global DOF_MIN_TRANSX
global DOF_MIN_TRANSY
global DOF_MIN_TRANSZ
global DOF_MIN_ROTX
global DOF_MIN_ROTY
global DOF_MIN_ROTZ
global DOF_MIN_SCALEX
global DOF_MIN_SCALEY
global DOF_MIN_SCALEZ
global DOF_MAX_TRANSX
global DOF_MAX_TRANSY
global DOF_MAX_TRANSZ
global DOF_MAX_ROTX
global DOF_MAX_ROTY
global DOF_MAX_ROTZ
global DOF_MAX_SCALEX
global DOF_MAX_SCALEY
global DOF_MAX_SCALEZ
global DOF_STEP_TRANSX
global DOF_STEP_TRANSY
global DOF_STEP_TRANSZ
global DOF_STEP_ROTX
global DOF_STEP_ROTY
global DOF_STEP_ROTZ
global DOF_STEP_SCALEX
global DOF_STEP_SCALEY
global DOF_STEP_SCALEZ
#labels
global DOF_ROTSTRING
global DOF_TRANSTRING
global DOF_SCALESTRING
#masks
global lockxtrans
global lockytrans
global lockztrans
global lockxrot
global lockyrot
global lockzrot
global lockxscale
global lockyscale
global lockzscale
global zmin
global zmax
global zcur
global zstep
global ymin
global ymax
global ycur
global ystep
global xmin
global xmax
global xcur
global xstep
global pitchmin
global pitchmax
global pitchcur
global pitchstep
global rollmin
global rollmax
global rollcur
global rollstep
global yawmin
global yawmax
global yawcur
global yawstep
global zscalemin
global zscalemax
global zscalecur
global zscalestep
global yscalemin
global yscalemax
global yscalecur
global yscalestep
global xscalemin
global xscalemax
global xscalecur
global xscalestep
#do "system" events
if evt == evcode["DOF_MAKE"]:
create_dof()
if evt == evcode["DOF_UPDATE"]:
DOF_get_frame()
if evt == evcode["DOF_DELETE"]:
idprops_kill()
#do translation lock events
if evt == evcode["DOF_TRANSX"]:
if DOF_TRANSX.val == True:
set_lockmask(lockxtrans)
else:
clear_lockmask(lockxtrans)
if evt == evcode["DOF_TRANSY"]:
if DOF_TRANSY.val == True:
set_lockmask(lockytrans)
else:
clear_lockmask(lockytrans)
if evt == evcode["DOF_TRANSZ"]:
if DOF_TRANSZ.val == True:
set_lockmask(lockztrans)
else:
clear_lockmask(lockztrans)
#do rotation lock events
if evt == evcode["DOF_ROTX"]:
if DOF_ROTX.val == True:
set_lockmask(lockxrot)
else:
clear_lockmask(lockxrot)
if evt == evcode["DOF_ROTY"]:
if DOF_ROTY.val == True:
set_lockmask(lockyrot)
else:
clear_lockmask(lockyrot)
if evt == evcode["DOF_ROTZ"]:
if DOF_ROTZ.val == True:
set_lockmask(lockzrot)
else:
clear_lockmask(lockzrot)
#do scale lock events
if evt == evcode["DOF_SCALEX"]:
if DOF_SCALEX.val == True:
set_lockmask(lockxscale)
else:
clear_lockmask(lockxscale)
if evt == evcode["DOF_SCALEY"]:
if DOF_SCALEY.val == True:
set_lockmask(lockyscale)
else:
clear_lockmask(lockyscale)
if evt == evcode["DOF_SCALEZ"]:
if DOF_SCALEZ.val == True:
set_lockmask(lockzscale)
else:
clear_lockmask(lockzscale)
#do translation buttons
if evt == evcode["DOF_MIN_TRANSX"]:
set_prop(14, xmin, DOF_MIN_TRANSX.val)
if evt == evcode["DOF_MAX_TRANSX"]:
set_prop(14,xmax, DOF_MAX_TRANSX.val)
if evt == evcode["DOF_STEP_TRANSX"]:
set_prop(14,xstep, DOF_STEP_TRANSX.val)
if evt == evcode["DOF_MIN_TRANSY"]:
set_prop(14, ymin, DOF_MIN_TRANSY.val)
if evt == evcode["DOF_MAX_TRANSY"]:
set_prop(14,ymax, DOF_MAX_TRANSY.val)
if evt == evcode["DOF_STEP_TRANSY"]:
set_prop(14,ystep, DOF_STEP_TRANSY.val)
if evt == evcode["DOF_MIN_TRANSZ"]:
set_prop(14, zmin, DOF_MIN_TRANSZ.val)
if evt == evcode["DOF_MAX_TRANSZ"]:
set_prop(14, zmax, DOF_MAX_TRANSZ.val)
if evt == evcode["DOF_STEP_TRANSZ"]:
set_prop(14, zstep, DOF_STEP_TRANSZ.val)
#do rotation buttons
if evt == evcode["DOF_MIN_ROTX"]:
set_prop(14, pitchmin, DOF_MIN_ROTX.val)
if evt == evcode["DOF_MAX_ROTX"]:
set_prop(14, pitchmax, DOF_MAX_ROTX.val)
if evt == evcode["DOF_STEP_ROTX"]:
set_prop(14, pitchstep, DOF_STEP_ROTX.val)
if evt == evcode["DOF_MIN_ROTY"]:
set_prop(14, rollmin, DOF_MIN_ROTY.val)
if evt == evcode["DOF_MAX_ROTY"]:
set_prop(14, rollmax, DOF_MAX_ROTY.val)
if evt == evcode["DOF_STEP_ROTY"]:
set_prop(14, rollstep, DOF_STEP_ROTY.val)
if evt == evcode["DOF_MIN_ROTZ"]:
set_prop(14, yawmin, DOF_MIN_ROTZ.val)
if evt == evcode["DOF_MAX_ROTZ"]:
set_prop(14, yawmax, DOF_MAX_ROTZ.val)
if evt == evcode["DOF_STEP_ROTZ"]:
set_prop(14, yawstep, DOF_STEP_ROTZ.val)
#do scale buttons
if evt == evcode["DOF_MIN_SCALEX"]:
set_prop(14, xscalemin, DOF_MIN_SCALEX.val)
if evt == evcode["DOF_MAX_SCALEX"]:
set_prop(14, xscalemax, DOF_MAX_SCALEX.val)
if evt == evcode["DOF_STEP_SCALEX"]:
set_prop(14, xscalestep, DOF_STEP_SCALEX.val)
if evt == evcode["DOF_MIN_SCALEY"]:
set_prop(14, yscalemin, DOF_MIN_SCALEY.val)
if evt == evcode["DOF_MAX_SCALEY"]:
set_prop(14, yscalemax, DOF_MAX_SCALEY.val)
if evt == evcode["DOF_STEP_SCALEY"]:
set_prop(14, yscalestep, DOF_STEP_SCALEY.val)
if evt == evcode["DOF_MIN_SCALEZ"]:
set_prop(14, zscalemin, DOF_MIN_SCALEZ.val)
if evt == evcode["DOF_MAX_SCALEZ"]:
set_prop(14, zscalemax, DOF_MAX_SCALEZ.val)
if evt == evcode["DOF_STEP_SCALEZ"]:
set_prop(14, zscalestep, DOF_STEP_SCALEZ.val)
Draw.Redraw(1)
Blender.Window.RedrawAll()
def draw_propsheet(x,y):
#UI buttons
global DOF_MAKE
global DOF_UPDATE
global DOF_DELETE
global DOF_TRANSX
global DOF_TRANSY
global DOF_TRANSZ
global DOF_ROTX
global DOF_ROTY
global DOF_ROTZ
global DOF_SCALEX
global DOF_SCALEY
global DOF_SCALEZ
global DOF_MIN_TRANSX
global DOF_MIN_TRANSY
global DOF_MIN_TRANSZ
global DOF_MIN_ROTX
global DOF_MIN_ROTY
global DOF_MIN_ROTZ
global DOF_MIN_SCALEX
global DOF_MIN_SCALEY
global DOF_MIN_SCALEZ
global DOF_MAX_TRANSX
global DOF_MAX_TRANSY
global DOF_MAX_TRANSZ
global DOF_MAX_ROTX
global DOF_MAX_ROTY
global DOF_MAX_ROTZ
global DOF_MAX_SCALEX
global DOF_MAX_SCALEY
global DOF_MAX_SCALEZ
global DOF_STEP_TRANSX
global DOF_STEP_TRANSY
global DOF_STEP_TRANSZ
global DOF_STEP_ROTX
global DOF_STEP_ROTY
global DOF_STEP_ROTZ
global DOF_STEP_SCALEX
global DOF_STEP_SCALEY
global DOF_STEP_SCALEZ
#labels
global DOF_ROTSTRING
global DOF_TRANSTRING
global DOF_SCALESTRING
global DOF_EDITLABEL
#masks
global lockxtrans
global lockytrans
global lockztrans
global lockxrot
global lockyrot
global lockzrot
global lockxscale
global lockyscale
global lockzscale
global zmin
global zmax
global zcur
global zstep
global ymin
global ymax
global ycur
global ystep
global xmin
global xmax
global xcur
global xstep
global pitchmin
global pitchmax
global pitchcur
global pitchstep
global rollmin
global rollmax
global rollcur
global rollstep
global yawmin
global yawmax
global yawcur
global yawstep
global zscalemin
global zscalemax
global zscalecur
global zscalestep
global yscalemin
global yscalemax
global yscalecur
global yscalestep
global xscalemin
global xscalemax
global xscalecur
global xscalestep
global evcode
state = update_state()
row_height = 20
toggle_width = 50
input_width = 100
pad = 10
origx = x
origy = (row_height * 15) + (pad * 15)
#editor label
x = origx
y = origy
#y = y - (row_height + pad)
DOF_EDITLABEL = Blender.Draw.Label("FLT Degree of Freedom Editor", x, y, 200, row_height)
#draw Translation limits
x = origx
y = y- (row_height + pad)
DOF_TRANSTRING = Blender.Draw.Label("Translation Limits", x, y, input_width, row_height)
#X limits
x = origx
y = y- (row_height + pad)
DOF_TRANSX = Blender.Draw.Toggle("LimX", evcode["DOF_TRANSX"], x, y, toggle_width, row_height, get_lockmask(lockxtrans), "")
x = x + (toggle_width + pad)
DOF_MIN_TRANSX = Blender.Draw.Number("MinX", evcode["DOF_MIN_TRANSX"], x, y, input_width, row_height,get_prop(14,xmin), -1000000.0, 1000000.0, "")
x = x + (input_width + pad)
DOF_MAX_TRANSX = Blender.Draw.Number("MaxX", evcode["DOF_MAX_TRANSX"], x, y, input_width, row_height,get_prop(14,xmax), -1000000.0, 1000000.0, "")
x = x + (input_width + pad)
DOF_STEP_TRANSX = Blender.Draw.Number("StepX", evcode["DOF_STEP_TRANSX"], x, y, input_width, row_height,get_prop(14,xstep), -1000000.0, 1000000.0, "")
#Y limits
x = origx
y = y- (row_height + pad)
DOF_TRANSY = Blender.Draw.Toggle("LimY", evcode["DOF_TRANSY"], x, y, toggle_width, row_height, get_lockmask(lockytrans), "")
x = x + (toggle_width + pad)
DOF_MIN_TRANSY = Blender.Draw.Number("MinY", evcode["DOF_MIN_TRANSY"], x, y, input_width, row_height, get_prop(14,ymin), -1000000.0, 1000000.0, "")
x = x + (input_width + pad)
DOF_MAX_TRANSY = Blender.Draw.Number("MaxY", evcode["DOF_MAX_TRANSY"], x, y, input_width, row_height, get_prop(14,ymax), -1000000.0, 1000000.0, "")
x = x + (input_width + pad)
DOF_STEP_TRANSY = Blender.Draw.Number("StepY", evcode["DOF_STEP_TRANSY"], x, y, input_width, row_height, get_prop(14,ystep), -1000000.0, 1000000.0, "")
#Z limits
x = origx
y = y- (row_height + pad)
DOF_TRANSZ = Blender.Draw.Toggle("LimZ", evcode["DOF_TRANSZ"], x, y, toggle_width, row_height, get_lockmask(lockztrans), "")
x = x + (toggle_width + pad)
DOF_MIN_TRANSZ = Blender.Draw.Number("MinZ", evcode["DOF_MIN_TRANSZ"], x, y, input_width, row_height, get_prop(14,zmin), -1000000.0, 1000000.0, "")
x = x + (input_width + pad)
DOF_MAX_TRANSZ = Blender.Draw.Number("MaxZ", evcode["DOF_MAX_TRANSZ"], x, y, input_width, row_height, get_prop(14,zmax), -1000000.0, 1000000.0, "")
x = x + (input_width + pad)
DOF_STEP_TRANSZ = Blender.Draw.Number("StepZ", evcode["DOF_STEP_TRANSZ"], x, y, input_width, row_height, get_prop(14,zstep), -1000000.0, 1000000.0, "")
#draw Rotation limits
x = origx
y = y- (row_height + pad)
DOF_ROTSTRING = Blender.Draw.Label("Rotation Limits", x, y, input_width, row_height)
#draw Rotation limits
#X limits
x = origx
y = y- (row_height + pad)
DOF_ROTX = Blender.Draw.Toggle("LimX", evcode["DOF_ROTX"], x, y, toggle_width, row_height, get_lockmask(lockxrot), "")
x = x + (toggle_width + pad)
DOF_MIN_ROTX = Blender.Draw.Number("MinX", evcode["DOF_MIN_ROTX"], x, y, input_width, row_height, get_prop(14,pitchmin), -1000000.0, 1000000.0, "")
x = x + (input_width + pad)
DOF_MAX_ROTX = Blender.Draw.Number("MaxX", evcode["DOF_MAX_ROTX"], x, y, input_width, row_height, get_prop(14,pitchmax), -1000000.0, 1000000.0, "")
x = x + (input_width + pad)
DOF_STEP_ROTX = Blender.Draw.Number("StepX", evcode["DOF_STEP_ROTX"], x, y, input_width, row_height, get_prop(14,pitchstep), -1000000.0, 1000000.0, "")
#Y limits
x = origx
y = y- (row_height + pad)
DOF_ROTY = Blender.Draw.Toggle("LimY", evcode["DOF_ROTY"], x, y, toggle_width, row_height, get_lockmask(lockyrot), "")
x = x + (toggle_width + pad)
DOF_MIN_ROTY = Blender.Draw.Number("MinY", evcode["DOF_MIN_ROTY"], x, y, input_width, row_height, get_prop(14,rollmin), -1000000.0, 1000000.0, "")
x = x + (input_width + pad)
DOF_MAX_ROTY = Blender.Draw.Number("MaxY", evcode["DOF_MAX_ROTY"], x, y, input_width, row_height, get_prop(14,rollmax), -1000000.0, 1000000.0, "")
x = x + (input_width + pad)
DOF_STEP_ROTY = Blender.Draw.Number("StepY", evcode["DOF_STEP_ROTY"], x, y, input_width, row_height, get_prop(14,rollstep), -1000000.0, 1000000.0, "")
#Z limits
x = origx
y = y- (row_height + pad)
DOF_ROTZ = Blender.Draw.Toggle("LimZ", evcode["DOF_ROTZ"], x, y, toggle_width, row_height, get_lockmask(lockzrot), "")
x = x + (toggle_width + pad)
DOF_MIN_ROTZ = Blender.Draw.Number("MinZ", evcode["DOF_MIN_ROTZ"], x, y, input_width, row_height, get_prop(14, yawmin), -1000000.0, 1000000.0, "")
x = x + (input_width + pad)
DOF_MAX_ROTZ = Blender.Draw.Number("MaxZ", evcode["DOF_MAX_ROTZ"], x, y, input_width, row_height, get_prop(14, yawmax), -1000000.0, 1000000.0, "")
x = x + (input_width + pad)
DOF_STEP_ROTZ = Blender.Draw.Number("StepZ", evcode["DOF_STEP_ROTZ"], x, y, input_width, row_height, get_prop(14, yawstep), -1000000.0, 1000000.0, "")
#draw Scale limits
x = origx
y = y- (row_height + pad)
DOF_SCALESTRING = Blender.Draw.Label("Scale Limits", x, y, input_width, row_height)
#draw Scale limits
#X limits
x = origx
y = y- (row_height + pad)
DOF_SCALEX = Blender.Draw.Toggle("LimX", evcode["DOF_SCALEX"], x, y, toggle_width, row_height, get_lockmask(lockxscale), "")
x = x + (toggle_width + pad)
DOF_MIN_SCALEX = Blender.Draw.Number("MinX", evcode["DOF_MIN_SCALEX"], x, y, input_width, row_height, get_prop(14, xscalemin), -1000000.0, 1000000.0, "")
x = x + (input_width + pad)
DOF_MAX_SCALEX = Blender.Draw.Number("MaxX", evcode["DOF_MAX_SCALEX"], x, y, input_width, row_height, get_prop(14, xscalemax), -1000000.0, 1000000.0, "")
x = x + (input_width + pad)
DOF_STEP_SCALEX = Blender.Draw.Number("StepX", evcode["DOF_STEP_SCALEX"], x, y, input_width, row_height, get_prop(14, xscalestep), -1000000.0, 1000000.0, "")
#Y limits
x = origx
y = y- (row_height + pad)
DOF_SCALEY = Blender.Draw.Toggle("LimY", evcode["DOF_SCALEY"], x, y, toggle_width, row_height, get_lockmask(lockyscale), "")
x = x + (toggle_width + pad)
DOF_MIN_SCALEY = Blender.Draw.Number("MinY", evcode["DOF_MIN_SCALEY"], x, y, input_width, row_height, get_prop(14, yscalemin), -1000000.0, 1000000.0, "")
x = x + (input_width + pad)
DOF_MAX_SCALEY = Blender.Draw.Number("MaxY", evcode["DOF_MAX_SCALEY"], x, y, input_width, row_height, get_prop(14, yscalemax), -1000000.0, 1000000.0, "")
x = x + (input_width + pad)
DOF_STEP_SCALEY = Blender.Draw.Number("StepY", evcode["DOF_STEP_SCALEY"], x, y, input_width, row_height, get_prop(14, yscalestep), -1000000.0, 1000000.0, "")
#Z limits
x = origx
y = y- (row_height + pad)
DOF_SCALEZ = Blender.Draw.Toggle("LimZ", evcode["DOF_SCALEZ"], x, y, toggle_width, row_height, get_lockmask(lockzscale), "")
x = x + (toggle_width + pad)
DOF_MIN_SCALEZ = Blender.Draw.Number("MinZ", evcode["DOF_MIN_SCALEZ"], x, y, input_width, row_height, get_prop(14, zscalemin), -1000000.0, 1000000.0, "")
x = x + (input_width + pad)
DOF_MAX_SCALEZ = Blender.Draw.Number("MaxZ", evcode["DOF_MAX_SCALEZ"], x, y, input_width, row_height, get_prop(14, zscalemax), -1000000.0, 1000000.0, "")
x = x + (input_width + pad)
DOF_STEP_SCALEZ = Blender.Draw.Number("StepZ", evcode["DOF_STEP_SCALEZ"], x, y, input_width, row_height, get_prop(14, zscalestep), -1000000.0, 1000000.0, "")
#System
x = origx
y = y - (row_height + (pad)*3)
DOF_MAKE = Blender.Draw.PushButton("Make DOF", evcode["DOF_MAKE"], x, y, input_width, row_height, "Make a Dof Node out of Active Object")
x = x + (input_width + pad)
DOF_UPDATE = Blender.Draw.PushButton("Grab Loc/Rot", evcode["DOF_UPDATE"], x, y, input_width, row_height, "Update the Dof Node position/orientation")
x = x + (input_width + pad)
DOF_DELETE = Blender.Draw.PushButton("Delete DOF", evcode["DOF_DELETE"], x, y, input_width, row_height, "Delete the Dof Node properties")
def gui():
#draw the propsheet/toolbox.
psheety = 800
#psheetx = psheety + 10
draw_propsheet(20,psheety)
Draw.Register(gui,event,but_event)

View File

@@ -525,8 +525,8 @@ class FaceDesc:
def __init__(self):
self.vertex_index_lst = []
self.mface = None
self.texture_index = -1
self.material_index = -1
self.texture_index = 65535
self.material_index = 65535
self.color_index = 127
self.renderstyle = 0
self.twoside = 0
@@ -979,8 +979,14 @@ class FLTNode(Node):
self.header.fw.write_char(0) # Reserved
self.header.fw.write_char(alpha) # Template
self.header.fw.write_short(-1) # Detail tex pat index
self.header.fw.write_short(face_desc.texture_index) # Tex pattern index
self.header.fw.write_short(face_desc.material_index) # material index
if face_desc.texture_index == -1:
self.header.fw.write_ushort(65535)
else:
self.header.fw.write_ushort(face_desc.texture_index) # Tex pattern index
if face_desc.material_index == -1:
self.header.fw.write_ushort(65535)
else:
self.header.fw.write_ushort(face_desc.material_index) # material index
self.header.fw.write_short(0) # SMC code
self.header.fw.write_short(0) # Feature code
self.header.fw.write_int(0) # IR material code
@@ -1015,7 +1021,10 @@ class FLTNode(Node):
self.header.fw.write_ushort(8 + (mtex * 8)) # Length
self.header.fw.write_uint(uvmask) # UV mask
for i in xrange(mtex):
self.header.fw.write_ushort(face_desc.images[i]) # Tex pattern index
if face_desc.images[i] == -1:
self.header.fw.write_ushort(65535)
else:
self.header.fw.write_ushort(face_desc.images[i]) # Tex pattern index
self.header.fw.write_ushort(0) # Tex effect
self.header.fw.write_ushort(0) # Tex Mapping index
self.header.fw.write_ushort(0) # Tex data. User defined
@@ -1070,7 +1079,7 @@ class FLTNode(Node):
if self.opcode == 63 and options.state['externalspath']:
try:
exportdict['3t200!filename'] = os.path.join(options.state['externalspath'],self.object.DupGroup.name+'.flt')
exportdict['3t200!filename'] = os.path.join(options.state['externalspath'],self.object.DupGroup.name+'.flt').replace("\\", "/")
self.header.xrefnames.append(self.object.DupGroup.name)
except:
pass
@@ -1092,7 +1101,7 @@ class FLTNode(Node):
write_prop(self.header.fw,ftype,self.object.properties['FLT']['EXT'][propname],length)
#write extension data
for i in xrange(datalen):
self.header.fw.write_char(self.object.properties['FLT']['EXT']['data'][i])
self.header.fw.write_uchar(struct.unpack('>B', struct.pack('>B', self.object.properties['FLT']['EXT']['data'][i]))[0])
self.write_pop_extension()
@@ -1180,8 +1189,8 @@ class Database(Node):
desc = self.GRR.request_vertex_desc(i)
self.fw.write_short(70) # Vertex with color normal and uv opcode.
self.fw.write_ushort(64) # Length of record
self.fw.write_ushort(0) # Color name index
self.fw.write_short(0x20000000) # Flags
self.fw.write_ushort(0) # Color name index
self.fw.write_short(1 << 14) # Frozen Normal
self.fw.write_double(desc.x)
self.fw.write_double(desc.y)
self.fw.write_double(desc.z)
@@ -1245,7 +1254,7 @@ class Database(Node):
cpalette = defaultp.pal
count = len(cpalette)
for i in xrange(count):
color = struct.unpack('>BBBB',struct.pack('>I',cpalette[i]))
color = struct.unpack('>BBBB',struct.pack('>i',cpalette[i]))
self.fw.write_uchar(color[3]) # alpha
self.fw.write_uchar(color[2]) # b
self.fw.write_uchar(color[1]) # g

View File

@@ -0,0 +1,502 @@
#!BPY
"""
Name: 'FLT LOD Editor'
Blender: 240
Group: 'Misc'
Tooltip: 'Level of Detail Edtior for FLT nodes'
"""
__author__ = "Geoffrey Bantle"
__version__ = "1.0 11/21/07"
__email__ = ('scripts', 'Author, ')
__url__ = ('blender', 'blenderartists.org')
__bpydoc__ ="""\
This script provides tools for working with OpenFlight databases in Blender. OpenFlight is a
registered trademark of MultiGen-Paradigm, Inc.
Feature overview and more availible at:
http://wiki.blender.org/index.php/Scripts/Manual/FLTools
"""
# --------------------------------------------------------------------------
# flt_palettemanager.py version 0.1 2005/04/08
# --------------------------------------------------------------------------
# ***** BEGIN GPL LICENSE BLOCK *****
#
# Copyright (C) 2007: Blender Foundation
#
# 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.
#
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------
import Blender.Draw as Draw
from Blender.BGL import *
import Blender
import flt_properties
reload(flt_properties)
from flt_properties import *
#event codes
evcode = {
"LOD_MAKE" : 100,
"LOD_DELETE" : 101,
"LOD_CALC_CENTER" : 102,
"LOD_GRAB_CENTER" : 103,
"LOD_X" : 104,
"LOD_Y" : 105,
"LOD_Z" : 106,
"LOD_FREEZE" : 107,
"LOD_SIG" : 108,
"LOD_IN" : 109,
"LOD_OUT" : 110,
"LOD_TRANS" : 111,
"LOD_PREVIOUS" : 112
}
#system
LOD_MAKE = None #PushButton
LOD_DELETE = None #PushButton
LOD_CALC_CENTER = None #PushButton
LOD_GRAB_CENTER = None #Pushbutton
LOD_FREEZE = None #Toggle
LOD_PREVIOUS = None #Toggle
LOD_X = None #Input
LOD_Y = None #Input
LOD_Z = None #Input
LOD_SIG = None #Input
LOD_IN = None #Input
LOD_OUT = None #Input
LOD_TRANS = None #Input
#labels
LOD_EDITLABEL = None
LOD_SWITCHLABEL = None
LOD_CENTERLABEL = None
LOD_XLABEL = None
LOD_YLABEL = None
LOD_ZLABEL = None
LOD_SIGLABEL = None
LOD_INLABEL = None
LOD_OUTLABEL = None
LOD_TRANSLABEL = None
#ID Props
switch_in = '5d!switch in'
switch_out = '6d!switch out'
xco = '10d!X co'
yco = '11d!Y co'
zco = '12d!Z co'
trans = '13d!Transition'
sig_size = '14d!Sig Size'
#Flags
lodflag = '9I!flags'
previous_mask = (1 << 31)
freeze_mask = (1 << 29)
def update_state():
state = dict()
state["activeScene"] = Blender.Scene.GetCurrent()
state["activeObject"] = state["activeScene"].objects.active
if state["activeObject"] and not state["activeObject"].sel:
state["activeObject"] = None
state["activeMesh"] = None
if state["activeObject"] and state["activeObject"].type == 'Mesh':
state["activeMesh"] = state["activeObject"].getData(mesh=True)
state["activeFace"] = None
if state["activeMesh"]:
if state["activeMesh"].faceUV and state["activeMesh"].activeFace != None:
state["activeFace"] = state["activeMesh"].faces[state["activeMesh"].activeFace]
#update editmode
state["editmode"] = Blender.Window.EditMode()
return state
def idprops_append(object, typecode, props):
object.properties["FLT"] = dict()
object.properties["FLT"]['type'] = typecode
for prop in props:
object.properties["FLT"][prop] = props[prop]
object.properties["FLT"]['3t8!id'] = object.name
def idprops_kill():
state = update_state()
if state["activeObject"] and state["activeObject"].properties.has_key('FLT'):
state["activeObject"].properties.pop('FLT')
def idprops_copy(source):
state = update_state()
if source.properties.has_key('FLT'):
for object in state["activeScene"].objects:
if object.sel and object != source and (state["activeScene"].Layers & object.Layers):
idprops_kill(object)
object.properties['FLT'] = dict()
for key in source.properties['FLT']:
object.properties['FLT'][key] = source.properties['FLT'][key]
def select_by_typecode(typecode):
state = update_state()
for object in state["activeScene"].objects:
if object.properties.has_key('FLT') and object.properties['FLT']['type'] == typecode and state["activeScene"].Layers & object.Layers:
object.select(1)
def idprops_type(object, typecode):
if object.properties.has_key('FLT') and object.properties['FLT'].has_key('type') and object.properties['FLT']['type'] == typecode:
return True
return False
#ui type code
def get_prop(typecode, prop):
state = update_state()
if state["activeObject"] and idprops_type(state["activeObject"], typecode):
props = state["activeObject"].properties['FLT']
else:
props = flt_properties.FLTLOD
return props[prop]
def set_prop(typecode, prop, value):
state = update_state()
if state["activeObject"] and idprops_type(state["activeObject"],typecode):
state["activeObject"].properties['FLT'][prop] = value
def get_lockmask(mask):
global lodflag
state = update_state()
if state["activeObject"]:
flag = get_prop(73,lodflag)
if flag & mask:
return True
return False
def set_lockmask(mask):
state = update_state()
if state["activeObject"] and idprops_type(state["activeObject"], 73):
oldvalue = state["activeObject"].properties['FLT'][lodflag]
oldvalue = struct.unpack('>I', struct.pack('>i', oldvalue))[0]
oldvalue |= mask
state["activeObject"].properties['FLT'][lodflag] = struct.unpack('>i', struct.pack(">I", oldvalue))[0]
def clear_lockmask(mask):
state = update_state()
if state["activeObject"] and idprops_type(state["activeObject"], 73):
oldvalue = state["activeObject"].properties['FLT'][lodflag]
oldvalue = struct.unpack('>I', struct.pack('>i', oldvalue))[0]
oldvalue &= ~mask
state["activeObject"].properties['FLT'][lodflag] = struct.unpack('>i',struct.pack('>I',oldvalue))[0]
def findchildren(object):
state = update_state()
children = list()
for candidate in state["activeScene"].objects:
if candidate.parent == object:
children.append(candidate)
retlist = list(children)
for child in children:
retlist = retlist + findchildren(child)
return retlist
def get_object_center(object):
bbox = object.getBoundBox(1)
average = Blender.Mathutils.Vector(0.0, 0.0, 0.0)
for point in bbox:
average[0] += point[0]
average[1] += point[1]
average[2] += point[2]
average[0] = average[0] / 8.0
average[1] = average[1] / 8.0
average[2] = average[2] / 8.0
return average
def calc_center():
global xco
global yco
global zco
state = update_state()
if state["activeObject"] and idprops_type(state["activeObject"], 73):
average = Blender.Mathutils.Vector(0.0, 0.0, 0.0)
children = findchildren(state["activeObject"]) #get children objects
if children:
for child in children:
center = get_object_center(child)
average[0] += center[0]
average[1] += center[1]
average[2] += center[2]
average[0] = average[0] / len(children)
average[1] = average[1] / len(children)
average[2] = average[2] / len(children)
set_prop(73, xco, average[0])
set_prop(73, yco, average[1])
set_prop(73, zco, average[2])
def grab_center():
global xco
global yco
global zco
state = update_state()
if state["activeObject"] and idprops_type(state["activeObject"], 73):
center = Blender.Window.GetCursorPos()
set_prop(73, xco, center[0])
set_prop(73, yco, center[1])
set_prop(73, zco, center[2])
def create_lod():
state = update_state()
actobj = state["activeObject"]
if actobj and not idprops_type(actobj, 73):
idprops_kill()
idprops_append(actobj,73, flt_properties.FLTLOD)
calc_center()
def event(evt,val):
if evt == Draw.ESCKEY:
Draw.Exit()
def but_event(evt):
global LOD_MAKE
global LOD_DELETE
global LOD_CALC_CENTER
global LOD_GRAB_CENTER
global LOD_FREEZE
global LOD_PREVIOUS
global LOD_X
global LOD_Y
global LOD_Z
global LOD_SIG
global LOD_IN
global LOD_OUT
global LOD_TRANS
global switch_in
global switch_out
global xco
global yco
global zco
global trans
global sig_size
global lodflag
global previous_mask
global freeze_mask
global evcode
#do "system" events
if evt == evcode["LOD_MAKE"]:
create_lod()
if evt == evcode["LOD_CALC_CENTER"]:
calc_center()
if evt == evcode["LOD_DELETE"]:
idprops_kill()
if evt == evcode["LOD_GRAB_CENTER"]:
grab_center()
#do mask events
if evt == evcode["LOD_FREEZE"]:
if LOD_FREEZE.val == True:
set_lockmask(freeze_mask)
else:
clear_lockmask(freeze_mask)
if evt == evcode["LOD_PREVIOUS"]:
if LOD_PREVIOUS.val == True:
set_lockmask(previous_mask)
else:
clear_lockmask(previous_mask)
#do input events
if evt == evcode["LOD_X"]:
set_prop(73, xco, LOD_X.val)
if evt == evcode["LOD_Y"]:
set_prop(73, yco, LOD_Y.val)
if evt == evcode["LOD_Z"]:
set_prop(73, zco, LOD_Z.val)
if evt == evcode["LOD_SIG"]:
set_prop(73, sig_size, LOD_SIG.val)
if evt == evcode["LOD_IN"]:
set_prop(73, switch_in, LOD_IN.val)
if evt == evcode["LOD_OUT"]:
set_prop(73, switch_out, LOD_OUT.val)
if evt == evcode["LOD_TRANS"]:
set_prop(73, trans, LOD_TRANS.val)
Draw.Redraw(1)
Blender.Window.RedrawAll()
def draw_propsheet(x,y):
global LOD_MAKE
global LOD_DELETE
global LOD_CALC_CENTER
global LOD_GRAB_CENTER
global LOD_FREEZE
global LOD_PREVIOUS
global LOD_X
global LOD_Y
global LOD_Z
global LOD_SIG
global LOD_IN
global LOD_OUT
global LOD_TRANS
#labels
global LOD_EDITLABEL
global LOD_SWITCHLABEL
global LOD_CENTERLABEL
global LOD_XLABEL
global LOD_YLABEL
global LOD_ZLABEL
global LOD_SIGLABEL
global LOD_INLABEL
global LOD_OUTLABEL
global LOD_TRANSLABEL
global switch_in
global switch_out
global xco
global yco
global zco
global trans
global sig_size
global lodflag
global previous_mask
global freeze_mask
global evcode
global evcode
state = update_state()
label_width = 100
row_height = 20
toggle_width = 50
input_width = 100
pad = 10
origx = x
origy = (row_height * 16) + (pad * 16)
#editor label
x = origx
y = origy
LOD_EDITLABEL = Blender.Draw.Label("FLT Level of Detail Editor", x, y, 250, row_height)
#Center inputs
x = origx
y = y- (row_height + pad)
LOD_CENTERLABEL = Blender.Draw.Label("LOD center", x, y, label_width, row_height)
y = y- (row_height + pad)
LOD_XLABEL = Blender.Draw.Label("X Coordinate", x, y, label_width, row_height)
x = origx + (label_width + pad)
LOD_X = Blender.Draw.Number("", evcode["LOD_X"], x, y, input_width, row_height,get_prop(73,xco), -1000000.0, 1000000.0, "")
x = origx
y = y- (row_height + pad)
LOD_YLABEL = Blender.Draw.Label("Y Coordinate", x, y, label_width, row_height)
x = origx + (label_width + pad)
LOD_Y = Blender.Draw.Number("", evcode["LOD_Y"], x, y, input_width, row_height,get_prop(73,yco), -1000000.0, 1000000.0, "")
x = origx
y = y- (row_height + pad)
LOD_ZLABEL = Blender.Draw.Label("Z Coordinate", x, y, label_width, row_height)
x = origx + (label_width + pad)
LOD_Z = Blender.Draw.Number("", evcode["LOD_Z"], x, y, input_width, row_height,get_prop(73,zco), -1000000.0, 1000000.0, "")
#Switch inputs
x = origx
y = y- (row_height + pad)
LOD_SWITCHLABEL = Blender.Draw.Label("Switch Settings", x, y, input_width, row_height)
y = y- (row_height + pad)
LOD_SIGLABEL = Blender.Draw.Label("Significant Size", x, y, label_width, row_height)
x = origx + (label_width + pad)
LOD_SIG = Blender.Draw.Number("", evcode["LOD_SIG"], x, y, input_width, row_height, get_prop(73,sig_size), -1000000.0, 1000000.0, "")
x = origx
y = y- (row_height + pad)
LOD_INLABEL = Blender.Draw.Label("Switch In", x, y, label_width, row_height)
x = origx + (label_width + pad)
LOD_IN = Blender.Draw.Number("", evcode["LOD_IN"], x, y, input_width, row_height, get_prop(73,switch_in), -1000000.0, 1000000.0, "")
x = origx
y = y- (row_height + pad)
LOD_OUTLABEL = Blender.Draw.Label("Switch Out", x, y, label_width, row_height)
x = origx + (label_width + pad)
LOD_OUT = Blender.Draw.Number("", evcode["LOD_OUT"], x, y, input_width, row_height, get_prop(73,switch_out), -1000000.0, 1000000.0, "")
x = origx
y = y- (row_height + pad)
LOD_TRANSLABEL = Blender.Draw.Label("Transition", x, y, label_width, row_height)
x = origx + (label_width + pad)
LOD_TRANS = Blender.Draw.Number("", evcode["LOD_TRANS"], x, y, input_width, row_height, get_prop(73,trans), -1000000.0, 1000000.0, "")
x = origx
y = y - (row_height + pad)
LOD_MAKE = Blender.Draw.PushButton("Make LOD", evcode["LOD_MAKE"], x, y, input_width + label_width + pad, row_height, "Make a LOD Node out of Active Object")
y = y - (row_height + pad)
LOD_DELETE = Blender.Draw.PushButton("Delete LOD", evcode["LOD_DELETE"], x, y, input_width + label_width + pad, row_height, "Delete the LOD Node properties")
y = y - (row_height + pad)
LOD_CALC_CENTER = Blender.Draw.PushButton("Calculate Center", evcode["LOD_CALC_CENTER"], x, y, input_width + label_width + pad, row_height, "Calculate the center of this LOD")
y = y - (row_height + pad)
LOD_GRAB_CENTER = Blender.Draw.PushButton("Grab Center", evcode["LOD_GRAB_CENTER"], x, y, input_width + label_width + pad, row_height, "Grab center from 3d cursor")
y = y - (row_height + pad)
LOD_FREEZE = Blender.Draw.Toggle("Freeze Center", evcode["LOD_FREEZE"], x, y, input_width + label_width + pad, row_height, get_lockmask(freeze_mask), "")
y = y - (row_height + pad)
LOD_PREVIOUS = Blender.Draw.Toggle("Previous Range", evcode["LOD_PREVIOUS"], x, y, input_width + label_width + pad, row_height, get_lockmask(previous_mask), "")
def gui():
#draw the propsheet/toolbox.
psheety = 800
#psheetx = psheety + 10
draw_propsheet(20,psheety)
Draw.Register(gui,event,but_event)

View File

@@ -25,7 +25,7 @@ http://wiki.blender.org/index.php/Scripts/Manual/FLTools
"""
# --------------------------------------------------------------------------
# flt_palettemanager.py version 0.1 2005/04/08
# flt_palettemanager.py version 1.0 2005/04/08
# --------------------------------------------------------------------------
# ***** BEGIN GPL LICENSE BLOCK *****
#
@@ -55,6 +55,75 @@ import flt_properties
import flt_defaultp as defaultp
from flt_properties import *
def RGBtoHSV( r, g, b):
minc = min( r, g, b )
maxc = max( r, g, b )
v = maxc
delta = maxc - minc
if( max != 0 ):
s = delta / maxc
else:
s = 0
h = -1
return (h,s,v)
if( r == maxc ):
h = ( g - b ) / delta
elif( g == maxc ):
h = 2 + ( b - r ) / delta
else:
h = 4 + ( r - g ) / delta
h *= 60
if( h < 0 ):
h += 360
return(h,s,v)
def HSVtoRGB(h,s,v):
if( s == 0 ):
return (v,v,v)
h /= 60
i = math.floor( h)
f = h - i
p = v * ( 1 - s )
q = v * ( 1 - s * f )
t = v * ( 1 - s * ( 1 - f ) )
if i == 0:
r = v
g = t
b = p
elif i == 1:
r = q
g = v
b = p
elif i== 2:
r = p
g = v
b = t
elif i==3:
r = p
g = q
b = v
elif i==4:
r = t
g = p
b = v
else:
r = v
g = p
b = q
return(r,g,b)
palette_size = 12
palette_x = 0
@@ -68,6 +137,14 @@ cinc = 1.0 / 1024.0
cstep = 0.0
picker = None
ptt = ""
ts1=None
ts2=None
ts3=None
ts4=None
ts5=None
for i in xrange(1024):
colors.append([cstep,cstep,cstep])
cstep = cstep + cinc
@@ -128,7 +205,7 @@ def event(evt,val):
Draw.Redraw(1)
#copy current color and intensity to selected faces.
elif evt == Draw.CKEY:
elif evt == Draw.VKEY:
if Blender.Window.EditMode():
Blender.Window.EditMode(0)
@@ -136,7 +213,7 @@ def event(evt,val):
state = update_state()
#retrieve color from palette
color = struct.unpack('>BBBB',struct.pack('>I',colors[curswatch]))
color = struct.unpack('>BBBB',struct.pack('>i',colors[curswatch]))
actmesh = state["activeMesh"]
if actmesh:
if(Blender.Window.GetKeyQualifiers() != Blender.Window.Qual["CTRL"]):
@@ -182,7 +259,7 @@ def event(evt,val):
Blender.Window.RedrawAll()
#grab color and intensity from active face
elif evt == Draw.VKEY:
elif evt == Draw.CKEY:
if Blender.Window.EditMode():
Blender.Window.EditMode(0)
editmode = 1
@@ -211,6 +288,23 @@ def event(evt,val):
Blender.Window.EditMode(1)
Blender.Window.RedrawAll()
elif evt == Draw.GKEY:
if Blender.Window.EditMode():
Blender.Window.EditMode(0)
editmode =1
state = update_state()
actmesh = state["activeMesh"]
activeFace = state["activeFace"]
if activeFace and "FLT_COL" in actmesh.faces.properties:
(index,intensity) = unpack_face_index(activeFace.getProperty("FLT_COL"))
for face in actmesh.faces:
(index2, intensity2) = unpack_face_index(face.getProperty("FLT_COL"))
if index == index2:
face.sel = 1
elif evt == Draw.ESCKEY:
Draw.Exit()
@@ -225,11 +319,11 @@ def update_all():
for object in state["activeScene"].objects:
if object.type == "Mesh":
mesh = object.getData(mesh=True)
if 'FLT_COL' in mesh.faces.properties:
if 'FLT_COL' in mesh.faces.properties and "FLT_Fcol" in mesh.getColorLayerNames():
mesh.activeColorLayer = "FLT_Fcol"
for face in mesh.faces:
(index,intensity) = unpack_face_index(face.getProperty('FLT_COL'))
color = struct.unpack('>BBBB',struct.pack('>I',colors[index]))
color = struct.unpack('>BBBB',struct.pack('>i',colors[index]))
#update the vertex colors for this face
for col in face.col:
col.r = int(color[0] * intensity)
@@ -284,8 +378,13 @@ def draw_palette():
global colors
global curint
global curswatch
global picker
global picker
global ts1
global ts2
global ts3
global ts4
global ts5
state = update_state()
init_pal()
@@ -297,7 +396,7 @@ def draw_palette():
for x in xrange(32):
ypos = palette_y
for y in xrange(32):
color = struct.unpack('>BBBB',struct.pack('>I',colors[cid]))
color = struct.unpack('>BBBB',struct.pack('>i',colors[cid]))
glColor3f(color[0]/255.0,color[1]/255.0,color[2]/255.0)
glBegin(GL_POLYGON)
glVertex2i(xpos,ypos)
@@ -328,7 +427,7 @@ def draw_palette():
xpos = xpos + ssize
#draw intensity gradient
color = struct.unpack('>BBBB',struct.pack('>I',colors[curswatch]))
color = struct.unpack('>BBBB',struct.pack('>i',colors[curswatch]))
color = [color[0]/255.0,color[1]/255.0,color[2]/255.0]
colsteps = [color[0]/255.0,color[1]/255.0,color[2]/255.0]
stripwidth = (palette_size * 32.0) / 256
@@ -355,15 +454,15 @@ def draw_palette():
xpos = ((palette_size*32) * (1.0 - curint)) + palette_x
glColor3f(1.0,1.0,1.0)
glBegin(GL_LINE_LOOP)
glVertex2i(xpos-6,grady-1)
glVertex2i(xpos+6,grady-1)
glVertex2i(xpos+6,grady+palette_size+1)
glVertex2i(xpos-6,grady+palette_size+1)
glVertex2i(int(xpos-6),int(grady-1))
glVertex2i(int(xpos+6),int(grady-1))
glVertex2i(int(xpos+6),int(grady+palette_size+1))
glVertex2i(int(xpos-6),int(grady+palette_size+1))
#glVertex2i(xpos-6,grady+7)
glEnd()
#draw color picker
color = struct.unpack('>BBBB',struct.pack('>I',colors[curswatch]))
color = struct.unpack('>BBBB',struct.pack('>i',colors[curswatch]))
pickcol = (color[0]/255.0,color[1]/255.0,color[2]/255.0)
picker = Blender.Draw.ColorPicker(1,highlight[0][0]+1,highlight[0][1]+1,ssize-2,ssize-2,pickcol,ptt)
@@ -377,6 +476,24 @@ def draw_palette():
glVertex2i(highlight[0][0],highlight[0][1])
glEnd()
#draw text string explanations
xpos = palette_size*32+20
ypos = palette_size*32+10
glRasterPos2d(xpos,ypos)
ts1 = Blender.Draw.Text("FLT Palette Manager V 1.0")
ypos = ypos - 20
glRasterPos2d(xpos,ypos)
ts3 = Blender.Draw.Text("CKEY - Copy Active Face Color*")
ypos = ypos - 20
glRasterPos2d(xpos,ypos)
ts2 = Blender.Draw.Text("VKEY - Paste Color to Selected Faces")
ypos = ypos - 20
glRasterPos2d(xpos,ypos)
ts4 = Blender.Draw.Text("GKEY - Select Faces With Same Color")
ypos = ypos - 15
glRasterPos2d(xpos,ypos)
ts5 = Blender.Draw.Text("(*Requires mesh with UV coordinates)", 'small')
def gui():
glClearColor(0.5,0.5,0.5,1.0)
glClear(GL_COLOR_BUFFER_BIT)
@@ -385,4 +502,4 @@ def gui():
init_pal()
Draw.Register(gui,event,but_event)

View File

@@ -197,7 +197,10 @@ def write_prop(fw,type,value,length):
elif type == 'i':
fw.write_int(value)
elif type == 'I':
fw.write_uint(value)
#NOTE!:
#there is no unsigned int type in python, but we can only store signed ints in ID props
newvalue = struct.unpack('>I', struct.pack('>i', value))[0]
fw.write_uint(newvalue)
elif type == 'd':
fw.write_double(value)
elif type == 'f':
@@ -267,16 +270,16 @@ FLTObjectDisplay = [10]
FLTLOD = {
'3t8!id' : 'L',
'4i!reserved' : 0,
'5d!switch in' : 0,
'6d!switch out' : 0,
'5d!switch in' : 0.0,
'6d!switch out' : 0.0,
'7s!sfx ID1' : 0,
'8s!sfx ID2' : 0,
'9I!flags' : 0,
'10d!X co' : 0,
'11d!Y co' : 0,
'12d!Z co' : 0,
'13d!Transition' : 0,
'14d!Sig Size' : 0
'10d!X co' : 0.0,
'11d!Y co' : 0.0,
'12d!Z co' : 0.0,
'13d!Transition' : 0.0,
'14d!Sig Size' : 0.0
}
FLTLODDisplay = [4]

File diff suppressed because it is too large Load Diff

View File

@@ -121,25 +121,29 @@ def rem_unused_materials(me):
material_users= dict( [(i,0) for i in xrange(len_materials)] )
for f in me.faces:
f_mat = f.mat
# Make sure the face index isnt too big. this happens sometimes.
if f.mat >= len_materials:
f.mat=0
material_users[f.mat] += 1
if f_mat >= len_materials:
f_mat = f.mat = 0
material_users[f_mat] += 1
mat_idx_subtract= 0
reindex_mapping= dict( [(i,0) for i in xrange(len_materials)] )
i= len_materials
while i:
i-=1
# mat_idx_subtract= 0
# reindex_mapping= dict( [(i,0) for i in xrange(len_materials)] )
reindex_mapping_ls = range(len_materials)
for i in range(len_materials-1, -1, -1):
if material_users[i] == 0:
mat_idx_subtract+=1
reindex_mapping[i]= mat_idx_subtract
materials.pop(i)
del reindex_mapping_ls[i]
del materials[i]
rem_materials+=1
reindex_mapping= {}
for i, mat in enumerate(reindex_mapping_ls):
reindex_mapping[mat] = i
for f in me.faces:
f.mat= f.mat - reindex_mapping[f.mat]
f.mat= reindex_mapping[f.mat]
me.materials= materials
return rem_materials
@@ -449,4 +453,4 @@ def main():
if __name__ == '__main__':
main()
main()

View File

@@ -0,0 +1,328 @@
#!BPY
"""
Name: 'Poly Reduce Selection (Unsubsurf)'
Blender: 245
Group: 'Mesh'
Tooltip: 'pradictable mesh simplifaction maintaining face loops'
"""
from Blender import Scene, Mesh, Window, sys
import BPyMessages
import bpy
def my_mesh_util(me):
me_verts = me.verts
vert_faces = [ [] for v in me_verts]
vert_faces_corner = [ [] for v in me_verts]
# Ignore topology where there are not 2 faces connected to an edge.
edge_count = {}
for f in me.faces:
for edkey in f.edge_keys:
try:
edge_count[edkey] += 1
except:
edge_count[edkey] = 1
for edkey, count in edge_count.iteritems():
# Ignore verts that connect to edges with more then 2 faces.
if count != 2:
vert_faces[edkey[0]] = None
vert_faces[edkey[1]] = None
# Done
def faces_set_verts(face_ls):
unique_verts = set()
for f in face_ls:
for v in f:
unique_verts.add(v.index)
return unique_verts
for f in me.faces:
for corner, v in enumerate(f):
i = v.index
if vert_faces[i] != None:
vert_faces[i].append(f)
vert_faces_corner[i].append( corner )
grid_data_ls = []
for vi, face_ls in enumerate(vert_faces):
if face_ls != None:
if len(face_ls) == 4:
if face_ls[0].sel and face_ls[1].sel and face_ls[2].sel and face_ls[3].sel:
# Support triangles also
unique_vert_count = len(faces_set_verts(face_ls))
quads = 0
for f in face_ls:
if len(f) ==4:
quads += 1
if unique_vert_count==5+quads: # yay we have a grid
grid_data_ls.append( (vi, face_ls) )
elif len(face_ls) == 3:
if face_ls[0].sel and face_ls[1].sel and face_ls[2].sel:
unique_vert_count = len(faces_set_verts(face_ls))
if unique_vert_count==4: # yay we have 3 triangles to make into a bigger triangle
grid_data_ls.append( (vi, face_ls) )
# Now sort out which grid faces to use
# This list will be used for items we can convert, vertex is key, faces are values
grid_data_dict = {}
if not grid_data_ls:
print "doing nothing"
return
# quick lookup for the opposing corner of a qiad
quad_diag_mapping = 2,3,0,1
verts_used = [0] * len(me_verts) # 0 == untouched, 1==should touch, 2==touched
verts_used[grid_data_ls[0][0]] = 1 # start touching 1!
# From the corner vert, get the 2 edges that are not the corner or its opposing vert, this edge will make a new face
quad_edge_mapping = (1,3), (2,0), (1,3), (0,2) # hi-low, low-hi order is intended
tri_edge_mapping = (1,2), (0,2), (0,1)
done_somthing = True
while done_somthing:
done_somthing = False
grid_data_ls_index = -1
for vi, face_ls in grid_data_ls:
grid_data_ls_index += 1
if len(face_ls) == 3:
grid_data_dict[vi] = face_ls
grid_data_ls.pop( grid_data_ls_index )
break
elif len(face_ls) == 4:
# print vi
if verts_used[vi] == 1:
verts_used[vi] = 2 # dont look at this again.
done_somthing = True
grid_data_dict[vi] = face_ls
# Tag all faces verts as used
for i, f in enumerate(face_ls):
# i == face index on vert, needed to recall which corner were on.
v_corner = vert_faces_corner[vi][i]
fv =f.v
if len(f) == 4:
v_other = quad_diag_mapping[v_corner]
# get the 2 other corners
corner1, corner2 = quad_edge_mapping[v_corner]
if verts_used[fv[v_other].index] == 0:
verts_used[fv[v_other].index] = 1 # TAG for touching!
else:
corner1, corner2 = tri_edge_mapping[v_corner]
verts_used[fv[corner1].index] = 2 # Dont use these, they are
verts_used[fv[corner2].index] = 2
# remove this since we have used it.
grid_data_ls.pop( grid_data_ls_index )
break
if done_somthing == False:
# See if there are any that have not even been tagged, (probably on a different island), then tag them.
for vi, face_ls in grid_data_ls:
if verts_used[vi] == 0:
verts_used[vi] = 1
done_somthing = True
break
# Now we have all the areas we will fill, calculate corner triangles we need to fill in.
new_faces = []
quad_del_vt_map = (1,2,3), (0,2,3), (0,1,3), (0,1,2)
for vi, face_ls in grid_data_dict.iteritems():
for i, f in enumerate(face_ls):
if len(f) == 4:
# i == face index on vert, needed to recall which corner were on.
v_corner = vert_faces_corner[vi][i]
v_other = quad_diag_mapping[v_corner]
fv =f.v
#print verts_used[fv[v_other].index]
#if verts_used[fv[v_other].index] != 2: # DOSNT WORK ALWAYS
if 1: # THIS IS LAzY - some of these faces will be removed after adding.
# Ok we are removing half of this face, add the other half
# This is probably slower
# new_faces.append( [fv[ii].index for ii in (0,1,2,3) if ii != v_corner ] )
# do this instead
new_faces.append( (fv[quad_del_vt_map[v_corner][0]], fv[quad_del_vt_map[v_corner][1]], fv[quad_del_vt_map[v_corner][2]]) )
del grid_data_ls
# me.sel = 0
def faceCombine4(vi, face_ls):
edges = []
for i, f in enumerate(face_ls):
fv = f.v
v_corner = vert_faces_corner[vi][i]
if len(f)==4: ed = quad_edge_mapping[v_corner]
else: ed = tri_edge_mapping[v_corner]
edges.append( [fv[ed[0]].index, fv[ed[1]].index] )
# get the face from the edges
face = edges.pop()
while len(face) != 4:
# print len(edges), edges, face
for ed_idx, ed in enumerate(edges):
if face[-1] == ed[0] and (ed[1] != face[0]):
face.append(ed[1])
elif face[-1] == ed[1] and (ed[0] != face[0]):
face.append(ed[0])
else:
continue
edges.pop(ed_idx) # we used the edge alredy
break
return face
for vi, face_ls in grid_data_dict.iteritems():
if len(face_ls) == 4:
new_faces.append( faceCombine4(vi, face_ls) )
#pass
if len(face_ls) == 3: # 3 triangles
face = list(faces_set_verts(face_ls))
face.remove(vi)
new_faces.append( face )
# Now remove verts surounded by 3 triangles
# print new_edges
# me.faces.extend(new_faces, ignoreDups=True)
'''
faces_remove = []
for vi, face_ls in grid_data_dict.iteritems():
faces_remove.extend(face_ls)
'''
orig_facelen = len(me.faces)
orig_faces = list(me.faces)
me.faces.extend(new_faces, ignoreDups=True)
new_faces = list(me.faces)[len(orig_faces):]
if me.faceUV:
uvnames = me.getUVLayerNames()
act_uvlay = me.activeUVLayer
vert_faces_uvs = []
vert_faces_images = []
act_uvlay = me.activeUVLayer
for uvlay in uvnames:
me.activeUVLayer = uvlay
vert_faces_uvs[:] = [None] * len(me.verts)
vert_faces_images[:] = vert_faces_uvs[:]
for i,f in enumerate(orig_faces):
img = f.image
fv = f.v
uv = f.uv
mat = f.mat
for i,v in enumerate(fv):
vi = v.index
vert_faces_uvs[vi] = uv[i] # no nice averaging
vert_faces_images[vi] = img
# Now copy UVs across
for f in new_faces:
fi = [v.index for v in f.v]
f.image = vert_faces_images[fi[0]]
uv = f.uv
for i,vi in enumerate(fi):
uv[i][:] = vert_faces_uvs[vi]
if len(me.materials) > 1:
vert_faces_mats = [None] * len(me.verts)
for i,f in enumerate(orig_faces):
mat = f.mat
for i,v in enumerate(f.v):
vi = v.index
vert_faces_mats[vi] = mat
# Now copy UVs across
for f in new_faces:
print vert_faces_mats[f.v[0].index]
f.mat = vert_faces_mats[f.v[0].index]
me.verts.delete(grid_data_dict.keys())
# me.faces.delete(1, faces_remove)
if me.faceUV:
me.activeUVLayer = act_uvlay
me.calcNormals()
def main():
# Gets the current scene, there can be many scenes in 1 blend file.
sce = bpy.data.scenes.active
# Get the active object, there can only ever be 1
# and the active object is always the editmode object.
ob_act = sce.objects.active
if not ob_act or ob_act.type != 'Mesh':
BPyMessages.Error_NoMeshActive()
return
is_editmode = Window.EditMode()
if is_editmode: Window.EditMode(0)
Window.WaitCursor(1)
me = ob_act.getData(mesh=1) # old NMesh api is default
t = sys.time()
# Run the mesh editing function
my_mesh_util(me)
# Restore editmode if it was enabled
if is_editmode: Window.EditMode(1)
# Timing the script is a good way to be aware on any speed hits when scripting
print 'My Script finished in %.2f seconds' % (sys.time()-t)
Window.WaitCursor(0)
# This lets you can import the script without running it
if __name__ == '__main__':
main()

View File

@@ -13,7 +13,7 @@ from Blender import Mesh, Scene, Window, sys, Image, Draw
import BPyMesh
__author__ = "Bruce Merry"
__version__ = "0.92"
__version__ = "0.93"
__bpydoc__ = """\
This script exports Stanford PLY files from Blender. It supports normals,
colours, and texture coordinates per face or per vertex.
@@ -37,6 +37,8 @@ Only one mesh can be exported at a time.
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Vector rounding se we can use as keys
#
# Updated on Aug 11, 2008 by Campbell Barton
# - added 'comment' prefix to comments - Needed to comply with the PLY spec.
#
# Updated on Jan 1, 2007 by Gabe Ghearing
# - fixed normals so they are correctly smooth/flat
@@ -162,7 +164,7 @@ def file_callback(filename):
file.write('ply\n')
file.write('format ascii 1.0\n')
file.write('Created by Blender3D %s - www.blender.org, source file: %s\n' % (Blender.Get('version'), Blender.Get('filename').split('/')[-1].split('\\')[-1] ))
file.write('comment Created by Blender3D %s - www.blender.org, source file: %s\n' % (Blender.Get('version'), Blender.Get('filename').split('/')[-1].split('\\')[-1] ))
file.write('element vertex %d\n' % len(verts))
@@ -210,7 +212,6 @@ def file_callback(filename):
if faceUV: uvcoord= rvec2d(uv[j])
elif vertexUV: uvcoord= rvec2d(v.uvco)
if vertexColors: color= col[j].r, col[j].g, col[j].b
co = v.co
file.write('%d ' % vdict[v.index][normal, uvcoord, color])

View File

@@ -14,7 +14,7 @@ __url__ = ("blender", "blenderartists.org",
__version__ = "2007/04/27"
__bpydoc__ = """\
"DEFORM to RVK2" copies deform data (except EDGESPLIT,DECIMATE,SUBSURF,BOOLEAN,
"DEFORM to RVK2" copies deform data (except EDGESPLIT,DECIMATE,SUBSURF,BOOLEAN,
BUILD,MIRROR,ARRAY) of the active object to the RVK (relative vertex key) of
the other selected object.
@@ -25,7 +25,7 @@ key.
The new version of this scrit (Blender 2.43) manages the modifier changes.
There are a lot of modifiers but only the ones which just deforms the shape
can be used : LATTICE, CURVE, WAVE, ARMATURE. You can unset these modifiers
from the script.
from the script.
Usage:
@@ -35,7 +35,7 @@ the 3d View. If the active object has subsurf turned on and nonzero subdiv
level, the script will ask if it should change that. Before copying data to
the rvk it will also ask whether it should replace or add a new vertex group.
"""
#----------------------------------------------
@@ -70,7 +70,7 @@ 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
"""
# Copy the rvk (1, or armature, lattice, or
# any mesh deformation except surface
@@ -83,7 +83,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# download the script :
# http://jmsoler.free.fr/util/blenderfile/py/rvk1_torvk2.py
# Communicate upon problems or errors:
# http://www.zoo-logique.org/3D.Blender/newsportal/thread.php?group=3D.Blender
# http://www.zoo-logique.org/3D.Blender/newsportal/thread.php?group=3D.Blender
#----------------------------------------------
# Page officielle :
# http://jmsoler.free.fr/util/blenderfile/py/rvk1_torvk2.py
@@ -101,22 +101,22 @@ def Value(t):
exec "t=Modifier.Types.%s"%t
return t
def deform2rvk():
def deform2rvk():
POSSMOD_list=['EDGESPLIT',
'DECIMATE',
'SUBSURF',
'BOOLEAN',
'SUBSURF',
'BOOLEAN',
'BUILD',
'MIRROR',
'MIRROR',
'ARRAY']
AUTHMOD_list=['LATTICE',
'CURVE',
'CURVE',
'WAVE',
'ARMATURE']
MODIFIERS=0
BMOD=[['Possible Modifiers'],
['Allowed Modifiers']]
@@ -129,8 +129,8 @@ def deform2rvk():
# =============================================================
# must be 2 meshes ============================================
# =============================================================
if RVK1.getType()=='Mesh' and RVK2.getType()=='Mesh':
FRAME=Blender.Get('curframe')
if RVK1.getType()=='Mesh' and RVK2.getType()=='Mesh':
FRAME=Blender.Get('curframe')
DATA2=RVK2.getData()
if DEBUG: print DATA2.getKey()
# ============================================================
@@ -151,7 +151,7 @@ def deform2rvk():
# === Bloc Menu Modifiers ===1 doc =================
# ===================================================
m=0
for mod in MODRVK1:
for mod in MODRVK1:
if DEBUG: print mod.type
if mod.type in POSSMOD:
BMOD[0].append([Draw.Create(0),mod.type,
@@ -183,7 +183,7 @@ def deform2rvk():
retval = Blender.Draw.PupBlock("MESH 2 RVK", block)
# ===================================================
# === unset Modifiers =============================
# ===================================================
# ===================================================
for B in BMOD[0][1:]:
if DEBUG: print B[2]
MODRVK1[B[2]][Modifier.Settings.RENDER]=0
@@ -193,12 +193,12 @@ def deform2rvk():
# ===================================================
# === update Modifiers =============================
# ===================================================
RVK1.makeDisplayList()
#RVK1.makeDisplayList()
# =======================================================
# === get deformed mesh ================================
# =======================================================
RVK1NAME=Object.GetSelected()[0].getName()
meshrvk1=NMesh.GetRawFromObject(RVK1NAME)
meshrvk1=NMesh.GetRawFromObject(RVK1NAME)
if DEBUG: print len(meshrvk1.verts)
# =======================================================
# === get normal mesh for vertex group =================
@@ -209,18 +209,18 @@ def deform2rvk():
# =======================================================
DATA2=RVK2.getData()
if DEBUG: print len(meshrvk1.verts)
if DEBUG: print len(DATA2.verts)
if DEBUG: print len(DATA2.verts)
# ========================================================
# ===== is there the same number of vertices =============
# ========================================================
if len(meshrvk1.verts)==len(DATA2.verts):
name = "Do you want to replace or add vertex groups ? %t| YES %x1| NO ? %x2 "
if len(meshrvk1.verts)==len(DATA2.verts):
name = "Do you want to replace or add vertex groups ? %t| YES %x1| NO ? %x2 "
result = Draw.PupMenu(name)
if result==1:
if result==1:
# =====================================================
# ===== Do we save vertex groups ? ===================
# =====================================================
GROUPNAME2=DATA2.getVertGroupNames()
GROUPNAME2=DATA2.getVertGroupNames()
if len(GROUPNAME2)!=0:
for GROUP2 in GROUPNAME2:
DATA2.removeVertGroup(GROUP2)
@@ -233,11 +233,11 @@ def deform2rvk():
# ===== now copy the vertices coords =====================
# ========================================================
for v in meshrvk1.verts:
i= meshrvk1.verts.index(v)
i= meshrvk1.verts.index(v)
v1=DATA2.verts[i]
for n in [0,1,2]:
v1.co[n]=v.co[n]
DATA2.update()
DATA2.update()
DATA2.insertKey(FRAME,'relative')
DATA2.update()
RVK2.makeDisplayList()
@@ -251,23 +251,23 @@ def deform2rvk():
if not B[1]:
MODRVK1[B[2]][Modifier.Settings.RENDER]|=B[-2]
else:
name = "Meshes Objects must the same number of vertices %t| Ok. %x1"
name = "Meshes Objects must the same number of vertices %t| Ok. %x1"
result = Draw.PupMenu(name)
return
else:
name = "Second Object must have at least a shape key %t| Ok. %x1"
name = "Second Object must have at least a shape key %t| Ok. %x1"
result = Draw.PupMenu(name)
return
else:
name = "Object must be Meshes %t| Ok. %x1"
else:
name = "Object must be Meshes %t| Ok. %x1"
result = Draw.PupMenu(name)
return
return
else :
name = "At least 2 Meshes as to be selected %t| Ok. %x1"
name = "At least 2 Meshes as to be selected %t| Ok. %x1"
result = Draw.PupMenu(name)
return
Blender.Redraw()
Blender.Redraw()
EDITMODE=Blender.Window.EditMode()
Blender.Window.EditMode(0)
deform2rvk()
Blender.Window.EditMode(EDITMODE)
Blender.Window.EditMode(EDITMODE)

View File

@@ -1,104 +0,0 @@
#!BPY
"""
Name: 'Camera/Object Example'
Blender: 245
Group: 'ScriptTemplate'
Tooltip: 'Script template for setting the camera direction'
"""
from Blender import Window
import bpy
script_data = \
'''#!BPY
"""
Name: 'My Camera script'
Blender: 245
Group: 'Object'
Tooltip: 'Rotate the camera to center on the active object'
"""
import Blender
from Blender import Window, Scene, Draw, Mathutils
# Rotate the camera in such a way that it centers on the currently active object
def RotCamToOb(cam, ob):
# Get the camera matrix
camMat = cam.getMatrix('worldspace');
# Get the location of the camera and object and make sure they're vectors
camLoc = Mathutils.Vector(cam.loc)
obLoc = Mathutils.Vector(ob.loc)
# Get the vector (direction) from the camera to the object
newVec = obLoc - camLoc
# Make a quaternion that points the camera along the vector
newQuat = newVec.toTrackQuat('-z', 'y')
# Convert the new quaternion to a rotation matrix (and resize it to 4x4 so it matches the other matrices)
rotMat = newQuat.toMatrix().resize4x4()
# Make a matrix with only the current location of the camera
transMat = Mathutils.TranslationMatrix(camMat.translationPart());
# Multiply the rotation and translation matrixes to make 1 matrix with all data
newMat = rotMat * transMat
# Now we make this matrix the camera matrix and voila done!
cam.setMatrix(newMat)
#Make sure blender and the objects are in the right state and start doing stuff
def SceneCheck():
# Show a neat waitcursor whilst the script runs
Window.WaitCursor(1)
# If we are in edit mode, go out of edit mode and store the status in a var
emode = int(Window.EditMode())
if emode: Window.EditMode(0)
# Get the scene, the camera and the currently active object
scn = Scene.GetCurrent()
cam = scn.getCurrentCamera()
ob = scn.getActiveObject()
# Lets do some checks to make sure we have everything
# And if we don't then call a return which stops the entire script
if not cam:
Draw.PupMenu('Error, no active camera, aborting.')
return
if not ob:
Draw.PupMenu('Error, no active object, aborting.')
return
if cam == ob:
Draw.PupMenu('Error, select an object other than the camera, aborting.')
return
# Start the main function of the script if we didn't encounter any errors
RotCamToOb(cam, ob)
# Update the scene
scn.update()
# Redraw the 3d view so we can instantly see what was changed
Window.Redraw(Window.Types.VIEW3D)
# If we were in edit mode when the script started, go back into edit mode
if emode: Window.EditMode(1)
# Remove the waitcursor
Window.WaitCursor(0)
# Start the script
SceneCheck()
'''
new_text = bpy.data.texts.new('camobject_template.py')
new_text.write(script_data)
bpy.data.texts.active = new_text
Window.RedrawAll()

View File

@@ -1,92 +0,0 @@
#!BPY
"""
Name: 'Camera/Object Example'
Blender: 245
Group: 'ScriptTemplate'
Tooltip: 'Script template for setting the camera direction'
"""
from Blender import Window
import bpy
script_data = \
'''#!BPY
"""
Name: 'My Ipo Script'
Blender: 245
Group: 'Animation'
Tooltip: 'Put some useful info here'
"""
# Add a licence here if you wish to re-distribute, we recommend the GPL
from Blender import Ipo, Mathutils, Window
import bpy, BPyMessages
def makeRandomIpo(object, firstFrame, numberOfFrames, frameStep):
# Create an new Ipo Curve of name myIpo and type Object
myIpo = bpy.data.ipos.new('myIpo', 'Object')
# Create LocX, LocY, and LocZ Ipo curves in our new Curve Object
# and store them so we can access them later
myIpo_x = myIpo.addCurve('LocX')
myIpo_y = myIpo.addCurve('LocY')
myIpo_z = myIpo.addCurve('LocZ')
# What value we want to scale our random value by
ipoScale = 4
# This Calculates the End Frame for use in an xrange() expression
endFrame = firstFrame + (numberOfFrames * frameStep) + frameStep
for frame in xrange(firstFrame, endFrame, frameStep):
# Use the Mathutils Rand() function to get random numbers
ipoValue_x = Mathutils.Rand(-1, 1) * ipoScale
ipoValue_y = Mathutils.Rand(-1, 1) * ipoScale
ipoValue_z = Mathutils.Rand(-1, 1) * ipoScale
# Append to the Ipo curve at location frame, with the value ipoValue_x
# Note that we should pass the append function a tuple or a BezTriple
myIpo_x.append((frame, ipoValue_x))
# Similar to above
myIpo_y.append((frame, ipoValue_y))
myIpo_z.append((frame, ipoValue_z))
# Link our new Ipo Curve to the passed object
object.setIpo(myIpo)
print object
def main():
# Get the active scene, since there can be multiple ones
sce = bpy.data.scenes.active
# Get the active object
object = sce.objects.active
# If there is no active object, pop up an error message
if not object:
BPyMessages.Error_NoActive()
Window.WaitCursor(1)
# Call our makeRandomIpo function
# Pass it our object, Tell it to keys from the start frame until the end frame, at a step of 10 frames
# between them
makeRandomIpo(object, sce.render.sFrame, sce.render.eFrame, 10)
Window.WaitCursor(0)
if __name__ == '__main__':
main()
'''
new_text = bpy.data.texts.new('ipo_template.py')
new_text.write(script_data)
bpy.data.texts.active = new_text
Window.RedrawAll()

View File

@@ -1,76 +0,0 @@
#!BPY
"""
Name: 'Metaball Generation'
Blender: 245
Group: 'ScriptTemplate'
Tooltip: 'Script template to make metaballs from a mesh'
"""
from Blender import Window
import bpy
script_data = \
'''#!BPY
"""
Name: 'My Metaball Script'
Blender: 245
Group: 'Misc'
Tooltip: 'Put some useful info here'
"""
# Add a license here if you wish to re-disribute, we recommend the GPL
from Blender import Metaball, Mesh, Window
import bpy
def makeMetaSculpture(sce):
#Create a base mesh for our sculpture to use
monkey = Mesh.Primitives.Monkey()
#Create a new meta datablock to use and give it a name
metaObj = Metaball.New()
metaObj.name = "MetaSuzanne"
#Increase the resolution so it looks better
metaObj.wiresize = 0.2
metaObj.rendersize = 0.1
#The radius for our new meta objects to take
metaRadius = 2.0
for f in monkey.faces:
#Create a new metaball as part of the Meta Object Data
newBall = metaObj.elements.add()
#Make the new ball have the same coordinates as a vertex on our Mesh
newBall.co = f.cent
#Assign the same radius to all balls
newBall.radius = f.area * metaRadius
#Create the new object and put our meta data there
sce.objects.new(metaObj, "MetaSuzanne")
def main():
scene = bpy.data.scenes.active #Get the active scene
Window.WaitCursor(1)
#Call the sculpture making function
makeMetaSculpture(scene)
Window.WaitCursor(0)
#Redraw the Screen When Finished
Window.RedrawAll(1)
if __name__ == '__main__':
main()
'''
new_text = bpy.data.texts.new('metaball_template.py')
new_text.write(script_data)
bpy.data.texts.active = new_text
Window.RedrawAll()

View File

@@ -0,0 +1,69 @@
#!BPY
"""
Name: 'Text Plugin'
Blender: 246
Group: 'ScriptTemplate'
Tooltip: 'Add a new text for writing a text plugin'
"""
from Blender import Window
import bpy
script_data = \
'''#!BPY
"""
Name: 'My Plugin Script'
Blender: 246
Group: 'TextPlugin'
Shortcut: 'Ctrl+Alt+U'
Tooltip: 'Put some useful info here'
"""
# Add a licence here if you wish to re-distribute, we recommend the GPL
from Blender import Window, sys
import BPyTextPlugin, bpy
def my_script_util(txt):
# This function prints out statistical information about a script
desc = BPyTextPlugin.get_cached_descriptor(txt)
print '---------------------------------------'
print 'Script Name:', desc.name
print 'Classes:', len(desc.classes)
print ' ', desc.classes.keys()
print 'Functions:', len(desc.defs)
print ' ', desc.defs.keys()
print 'Variables:', len(desc.vars)
print ' ', desc.vars.keys()
def main():
# Gets the active text object, there can be many in one blend file.
txt = bpy.data.texts.active
# Silently return if the script has been run with no active text
if not txt:
return
# Text plug-ins should run quickly so we time it here
Window.WaitCursor(1)
t = sys.time()
# Run our utility function
my_script_util(txt)
# Timing the script is a good way to be aware on any speed hits when scripting
print 'Plugin script finished in %.2f seconds' % (sys.time()-t)
Window.WaitCursor(0)
# This lets you import the script without running it
if __name__ == '__main__':
main()
'''
new_text = bpy.data.texts.new('textplugin_template.py')
new_text.write(script_data)
bpy.data.texts.active = new_text
Window.RedrawAll()

View File

@@ -94,6 +94,8 @@ output = Blender.Text.New(output_filename)
output.write(header + "\n\n")
output.write("%s\n\n" % Blender.Get('buildinfo'))
output.write("Platform: %s\n========\n\n" % sys.platform)
output.write("Python:\n======\n\n")

View File

@@ -0,0 +1,64 @@
#!BPY
"""
Name: 'Function Documentation | Ctrl I'
Blender: 246
Group: 'TextPlugin'
Shortcut: 'Ctrl+I'
Tooltip: 'Attempts to display documentation about the function preceding the cursor.'
"""
# Only run if we have the required modules
try:
import bpy
from BPyTextPlugin import *
except ImportError:
OK = False
else:
OK = True
def main():
txt = bpy.data.texts.active
if not txt:
return
(line, c) = current_line(txt)
# Check we are in a normal context
if get_context(txt) != CTX_NORMAL:
return
# Identify the name under the cursor
llen = len(line)
while c<llen and (line[c].isalnum() or line[c]=='_'):
c += 1
targets = get_targets(line, c)
# If no name under cursor, look backward to see if we're in function parens
if len(targets) == 0 or targets[0] == '':
# Look backwards for first '(' without ')'
b = 0
found = False
for i in range(c-1, -1, -1):
if line[i] == ')': b += 1
elif line[i] == '(':
b -= 1
if b < 0:
found = True
c = i
break
if found: targets = get_targets(line, c)
if len(targets) == 0 or targets[0] == '':
return
obj = resolve_targets(txt, targets)
if not obj: return
if isinstance(obj, Definition): # Local definition
txt.showDocs(obj.doc)
elif hasattr(obj, '__doc__') and obj.__doc__:
txt.showDocs(obj.__doc__)
# Check we are running as a script and not imported as a module
if __name__ == "__main__" and OK:
main()

View File

@@ -0,0 +1,91 @@
#!BPY
"""
Name: 'Import Complete|Space'
Blender: 246
Group: 'TextPlugin'
Shortcut: 'Space'
Tooltip: 'Lists modules when import or from is typed'
"""
# Only run if we have the required modules
try:
import bpy, sys
from BPyTextPlugin import *
except ImportError:
OK = False
else:
OK = True
def main():
txt = bpy.data.texts.active
if not txt:
return
line, c = current_line(txt)
# Check we are in a normal context
if get_context(txt) != CTX_NORMAL:
return
pos = line.rfind('from ', 0, c)
# No 'from' found
if pos == -1:
# Check instead for straight 'import xxxx'
pos2 = line.rfind('import ', 0, c)
if pos2 != -1:
pos2 += 7
for i in range(pos2, c):
if line[i]==',' or (line[i]==' ' and line[i-1]==','):
pos2 = i+1
elif not line[i].isalnum() and line[i] != '_':
return
items = [(m, 'm') for m in get_modules()]
items.sort(cmp = suggest_cmp)
txt.suggest(items, line[pos2:c].strip())
return
# Found 'from xxxxx' before cursor
immediate = True
pos += 5
for i in range(pos, c):
if not line[i].isalnum() and line[i] != '_' and line[i] != '.':
immediate = False
break
# Immediate 'from' followed by at most a module name
if immediate:
items = [(m, 'm') for m in get_modules()]
items.sort(cmp = suggest_cmp)
txt.suggest(items, line[pos:c])
return
# Found 'from' earlier, suggest import if not already there
pos2 = line.rfind('import ', pos, c)
# No 'import' found after 'from' so suggest it
if pos2 == -1:
txt.suggest([('import', 'k')], '')
return
# Immediate 'import' before cursor and after 'from...'
for i in range(pos2+7, c):
if line[i]==',' or (line[i]==' ' and line[i-1]==','):
pass
elif not line[i].isalnum() and line[i] != '_':
return
between = line[pos:pos2-1].strip()
try:
mod = get_module(between)
except ImportError:
return
items = [('*', 'k')]
for (k,v) in mod.__dict__.items():
items.append((k, type_char(v)))
items.sort(cmp = suggest_cmp)
txt.suggest(items, '')
# Check we are running as a script and not imported as a module
if __name__ == "__main__" and OK:
main()

View File

@@ -0,0 +1,90 @@
#!BPY
"""
Name: 'Member Suggest | .'
Blender: 246
Group: 'TextPlugin'
Shortcut: 'Period'
Tooltip: 'Lists members of the object preceding the cursor in the current text space'
"""
# Only run if we have the required modules
try:
import bpy
from BPyTextPlugin import *
except ImportError:
OK = False
else:
OK = True
def main():
txt = bpy.data.texts.active
if not txt:
return
(line, c) = current_line(txt)
# Check we are in a normal context
if get_context(txt) != CTX_NORMAL:
return
targets = get_targets(line, c)
if targets[0] == '': # Check if we are looking at a constant [] {} '' etc.
i = c - len('.'.join(targets)) - 1
if i >= 0:
if line[i] == '"' or line[i] == "'":
targets[0] = 'str'
elif line[i] == '}':
targets[0] = 'dict'
elif line[i] == ']': # Could be array elem x[y] or list [y]
i = line.rfind('[', 0, i) - 1
while i >= 0:
if line[i].isalnum() or line[i] == '_':
break
elif line[i] != ' ' and line[i] != '\t':
i = -1
break
i -= 1
if i < 0:
targets[0] = 'list'
obj = resolve_targets(txt, targets[:-1])
if not obj:
return
items = []
if isinstance(obj, VarDesc):
obj = obj.type
if isinstance(obj, Definition): # Locally defined
if hasattr(obj, 'classes'):
items.extend([(s, 'f') for s in obj.classes.keys()])
if hasattr(obj, 'defs'):
items.extend([(s, 'f') for s in obj.defs.keys()])
if hasattr(obj, 'vars'):
items.extend([(s, 'v') for s in obj.vars.keys()])
else: # Otherwise we have an imported or builtin object
try:
attr = obj.__dict__.keys()
except AttributeError:
attr = dir(obj)
else:
if not attr: attr = dir(obj)
for k in attr:
try:
v = getattr(obj, k)
except (AttributeError, TypeError): # Some attributes are not readable
pass
else:
items.append((k, type_char(v)))
if items != []:
items.sort(cmp = suggest_cmp)
txt.suggest(items, targets[-1])
# Check we are running as a script and not imported as a module
if __name__ == "__main__" and OK:
main()

View File

@@ -0,0 +1,142 @@
#!BPY
"""
Name: 'Code Outline | Ctrl T'
Blender: 246
Group: 'TextPlugin'
Shortcut: 'Ctrl+T'
Tooltip: 'Provides a menu for jumping to class and functions definitions.'
"""
# Only run if we have the required modules
try:
import bpy
from BPyTextPlugin import *
from Blender import Draw
except ImportError:
OK = False
else:
OK = True
def make_menu(items, eventoffs):
n = len(items)
if n < 20:
return [(items[i], i+1+eventoffs) for i in range(len(items))]
letters = []
check = 'abcdefghijklmnopqrstuvwxyz_' # Names cannot start 0-9
for c in check:
for item in items:
if item[0].lower() == c:
letters.append(c)
break
entries = {}
i = 0
for item in items:
i += 1
c = item[0].lower()
entries.setdefault(c, []).append((item, i+eventoffs))
subs = []
for c in letters:
subs.append((c, entries[c]))
return subs
def find_word(txt, word):
i = 0
txt.reset()
while True:
try:
line = txt.readline()
except StopIteration:
break
c = line.find(word)
if c != -1:
txt.setCursorPos(i, c)
break
i += 1
def main():
txt = bpy.data.texts.active
if not txt:
return
# Identify word under cursor
if get_context(txt) == CTX_NORMAL:
line, c = current_line(txt)
start = c-1
end = c
while start >= 0:
if not line[start].lower() in 'abcdefghijklmnopqrstuvwxyz0123456789_':
break
start -= 1
while end < len(line):
if not line[end].lower() in 'abcdefghijklmnopqrstuvwxyz0123456789_':
break
end += 1
word = line[start+1:end]
if word in KEYWORDS:
word = None
else:
word = None
script = get_cached_descriptor(txt)
items = []
desc = None
tmp = script.classes.keys()
tmp.sort(cmp = suggest_cmp)
class_menu = make_menu(tmp, len(items))
class_menu_length = len(tmp)
items.extend(tmp)
tmp = script.defs.keys()
tmp.sort(cmp = suggest_cmp)
defs_menu = make_menu(tmp, len(items))
defs_menu_length = len(tmp)
items.extend(tmp)
tmp = script.vars.keys()
tmp.sort(cmp = suggest_cmp)
vars_menu = make_menu(tmp, len(items))
vars_menu_length = len(tmp)
items.extend(tmp)
menu = [('Script %t', 0),
('Classes', class_menu),
('Functions', defs_menu),
('Variables', vars_menu)]
if word:
menu.extend([None, ('Locate', [(word, -10)])])
i = Draw.PupTreeMenu(menu)
if i == -1:
return
# Chosen to search for word under cursor
if i == -10:
if script.classes.has_key(word):
desc = script.classes[word]
elif script.defs.has_key(word):
desc = script.defs[word]
elif script.vars.has_key(word):
desc = script.vars[word]
else:
find_word(txt, word)
return
else:
i -= 1
if i < class_menu_length:
desc = script.classes[items[i]]
elif i < class_menu_length + defs_menu_length:
desc = script.defs[items[i]]
elif i < class_menu_length + defs_menu_length + vars_menu_length:
desc = script.vars[items[i]]
if desc:
txt.setCursorPos(desc.lineno-1, 0)
# Check we are running as a script and not imported as a module
if __name__ == "__main__" and OK:
main()

View File

@@ -0,0 +1,94 @@
#!BPY
"""
Name: 'Suggest All | Ctrl Space'
Blender: 246
Group: 'TextPlugin'
Shortcut: 'Ctrl+Space'
Tooltip: 'Performs suggestions based on the context of the cursor'
"""
# Only run if we have the required modules
try:
import bpy
from BPyTextPlugin import *
except ImportError:
OK = False
else:
OK = True
def check_membersuggest(line, c):
pos = line.rfind('.', 0, c)
if pos == -1:
return False
for s in line[pos+1:c]:
if not s.isalnum() and s != '_':
return False
return True
def check_imports(line, c):
pos = line.rfind('import ', 0, c)
if pos > -1:
for s in line[pos+7:c]:
if not s.isalnum() and s != '_':
return False
return True
pos = line.rfind('from ', 0, c)
if pos > -1:
for s in line[pos+5:c]:
if not s.isalnum() and s != '_':
return False
return True
return False
def main():
txt = bpy.data.texts.active
if not txt:
return
line, c = current_line(txt)
# Check we are in a normal context
if get_context(txt) != CTX_NORMAL:
return
# Check the character preceding the cursor and execute the corresponding script
if check_membersuggest(line, c):
import textplugin_membersuggest
textplugin_membersuggest.main()
return
elif check_imports(line, c):
import textplugin_imports
textplugin_imports.main()
return
# Otherwise we suggest globals, keywords, etc.
list = []
targets = get_targets(line, c)
desc = get_cached_descriptor(txt)
for k in KEYWORDS:
list.append((k, 'k'))
for k, v in get_builtins().items():
list.append((k, type_char(v)))
for k, v in desc.imports.items():
list.append((k, type_char(v)))
for k, v in desc.classes.items():
list.append((k, 'f'))
for k, v in desc.defs.items():
list.append((k, 'f'))
for k, v in desc.vars.items():
list.append((k, 'v'))
list.sort(cmp = suggest_cmp)
txt.suggest(list, targets[-1])
# Check we are running as a script and not imported as a module
if __name__ == "__main__" and OK:
main()

View File

@@ -0,0 +1,123 @@
#!BPY
"""
Name: 'Template Completion | Tab'
Blender: 246
Group: 'TextPlugin'
Shortcut: 'Tab'
Tooltip: 'Completes templates based on the text preceding the cursor'
"""
# Only run if we have the required modules
try:
import bpy
from BPyTextPlugin import *
from Blender import Text
except ImportError:
OK = False
else:
OK = True
templates = {
'ie':
'if ${1:cond}:\n'
'\t${2}\n'
'else:\n'
'\t${3}\n',
'iei':
'if ${1:cond}:\n'
'\t${2}\n'
'elif:\n'
'\t${3}\n'
'else:\n'
'\t${4}\n',
'def':
'def ${1:name}(${2:params}):\n'
'\t"""(${2}) - ${3:comment}"""\n'
'\t${4}',
'cls':
'class ${1:name}(${2:parent}):\n'
'\t"""${3:docs}"""\n'
'\t\n'
'\tdef __init__(self, ${4:params}):\n'
'\t\t"""Creates a new ${1}"""\n'
'\t\t${5}',
'class':
'class ${1:name}(${2:parent}):\n'
'\t"""${3:docs}"""\n'
'\t\n'
'\tdef __init__(self, ${4:params}):\n'
'\t\t"""Creates a new ${1}"""\n'
'\t\t${5}'
}
def main():
txt = bpy.data.texts.active
if not txt:
return
row, c = txt.getCursorPos()
line = txt.asLines(row, row+1)[0]
indent=0
while indent<c and (line[indent]==' ' or line[indent]=='\t'):
indent += 1
# Check we are in a normal context
if get_context(txt) != CTX_NORMAL:
return
targets = get_targets(line, c-1);
if len(targets) != 1: return
color = (0, 192, 32)
for trigger, template in templates.items():
if trigger != targets[0]: continue
inserts = {}
txt.delete(-len(trigger)-1)
y, x = txt.getCursorPos()
first = None
# Insert template text and parse for insertion points
count = len(template); i = 0
while i < count:
if i<count-1 and template[i]=='$' and template[i+1]=='{':
i += 2
e = template.find('}', i)
item = template[i:e].split(':')
if len(item)<2: item.append('')
if not inserts.has_key(item[0]):
inserts[item[0]] = (item[1], [(x, y)])
else:
inserts[item[0]][1].append((x, y))
item[1] = inserts[item[0]][0]
if not first: first = (item[1], x, y)
txt.insert(item[1])
x += len(item[1])
i = e
else:
txt.insert(template[i])
if template[i] == '\n':
txt.insert(line[:indent])
y += 1
x = indent
else:
x += 1
i += 1
# Insert markers at insertion points
for id, (text, points) in inserts.items():
for x, y in points:
txt.setCursorPos(y, x)
txt.setSelectPos(y, x+len(text))
txt.markSelection((hash(text)+int(id)) & 0xFFFF, color,
Text.TMARK_TEMP | Text.TMARK_EDITALL)
if first:
text, x, y = first
txt.setCursorPos(y, x)
txt.setSelectPos(y, x+len(text))
break
# Check we are running as a script and not imported as a module
if __name__ == "__main__" and OK:
main()

View File

@@ -48,13 +48,14 @@ def AngleBetweenVecs(a1,a2):
return 180.0
class prettyface(object):
__slots__ = 'uv', 'width', 'height', 'children', 'xoff', 'yoff', 'has_parent', 'rot'
def __init__(self, data):
__slots__ = 'uv', 'width', 'height', 'children', 'xoff', 'yoff', 'has_parent', 'rot', 'noarea'
def __init__(self, data, noarea = False):
self.has_parent = False
self.rot = False # only used for triables
self.xoff = 0
self.yoff = 0
self.noarea = noarea
if type(data) == list: # list of data
self.uv = None
@@ -93,14 +94,18 @@ class prettyface(object):
# f, (len_min, len_mid, len_max)
self.uv = data
f1, lens1, lens1ord = data[0]
if data[1]:
f2, lens2, lens2ord = data[1]
self.width = (lens1[lens1ord[0]] + lens2[lens2ord[0]])/2
self.height = (lens1[lens1ord[1]] + lens2[lens2ord[1]])/2
else: # 1 tri :/
self.width = lens1[0]
self.height = lens1[1]
if noarea:
self.width = 0.0
self.height = 0.0
else:
f1, lens1, lens1ord = data[0]
if data[1]:
f2, lens2, lens2ord = data[1]
self.width = (lens1[lens1ord[0]] + lens2[lens2ord[0]])/2
self.height = (lens1[lens1ord[1]] + lens2[lens2ord[1]])/2
else: # 1 tri :/
self.width = lens1[0]
self.height = lens1[1]
self.children = []
@@ -108,9 +113,13 @@ class prettyface(object):
else: # blender face
self.uv = data.uv
cos = [v.co for v in data]
self.width = ((cos[0]-cos[1]).length + (cos[2]-cos[3]).length)/2
self.height = ((cos[1]-cos[2]).length + (cos[0]-cos[3]).length)/2
if noarea:
self.width = 0.0
self.height = 0.0
else:
cos = [v.co for v in data]
self.width = ((cos[0]-cos[1]).length + (cos[2]-cos[3]).length)/2
self.height = ((cos[1]-cos[2]).length + (cos[0]-cos[3]).length)/2
self.children = []
@@ -204,10 +213,13 @@ def lightmap_uvpack( meshes,\
PREF_SEL_ONLY= True,\
PREF_NEW_UVLAYER= False,\
PREF_PACK_IN_ONE= False,\
PREF_PACK_TO_MANY= 0,\
PREF_APPLY_IMAGE= False,\
PREF_IMG_PX_SIZE= 512,\
PREF_BOX_DIV= 8,\
PREF_MARGIN_DIV= 512):
PREF_MARGIN_DIV= 512,
PREF_2PASS= False,\
PREF_2PASS_ERROR= 0.05):
'''
BOX_DIV if the maximum division of the UV map that
a box may be consolidated into.
@@ -215,6 +227,9 @@ PREF_MARGIN_DIV= 512):
and a higher value will have more clumpy boxes but more waisted space
'''
if PREF_PACK_TO_MANY:
PREF_PACK_IN_ONE = False # This cant be true if we are packing to many images
if not meshes:
return
@@ -225,19 +240,22 @@ PREF_MARGIN_DIV= 512):
image = Image.New('lightmap', PREF_IMG_PX_SIZE, PREF_IMG_PX_SIZE, 24)
face_groups = [[]]
else:
face_groups = []
if PREF_PACK_TO_MANY:
face_groups = [[]]
else:
face_groups = []
for me in meshes:
# Add face UV if it does not exist.
# All new faces are selected.
me.faceUV = True
if PREF_SEL_ONLY:
faces = [f for f in me.faces if f.sel]
else:
faces = list(me.faces)
if PREF_PACK_IN_ONE:
if PREF_PACK_IN_ONE or PREF_PACK_TO_MANY: # when PREF_PACK_TO_MANY is used we'll have to seperate these later
face_groups[0].extend(faces)
else:
face_groups.append(faces)
@@ -254,6 +272,66 @@ PREF_MARGIN_DIV= 512):
me.activeUVLayer = uvname
del uvnames, uvname_org, uvname
if PREF_PACK_TO_MANY and len(face_groups[0]) < 4:
PREF_PACK_TO_MANY = False
if PREF_PACK_TO_MANY: # We need to separate these into
if PREF_PACK_TO_MANY < 4:
PREF_PACK_TO_MANY = 4
# Split this into a grid on the shortest axis
# TODO - Take object matricies into account.
# First get the bounds
xmin=ymin=zmin = 1000000000
xmax=ymax=zmax =-1000000000
for f in face_groups[0]:
x,y,z = f.cent
if x<xmin: xmin=x
if y<ymin: ymin=y
if z<zmin: zmin=z
if x>xmax: xmax=x
if y>ymax: ymax=y
if z>zmax: zmax=z
# This is fairly terrain spesific, at least it works best for flat objects.
xdepth = xmax-xmin
ydepth = ymax-ymin
zdepth = zmax-zmin
# print xdepth, ydepth, zdepth
div = PREF_PACK_TO_MANY
if div < 2: div = 2
face_grid = {}
if xdepth <= ydepth and xdepth <= zdepth:
# y/z axis plain
# print 'y/z'
for f in face_groups[0]:
x,y,z = f.cent
face_grid.setdefault( ( int(((y-ymin)/ydepth)*div), int(((z-zmin)/zdepth)*div) ), [] ).append(f)
elif ydepth <= xdepth and ydepth <= zdepth:
# x/z axis plain
# print 'x/z'
for f in face_groups[0]:
x,y,z = f.cent
face_grid.setdefault( ( int(((x-xmin)/xdepth)*div), int(((z-zmin)/zdepth)*div) ), [] ).append(f)
elif zdepth <= xdepth and zdepth <= ydepth:
# x/y axis plain
# print 'x/y'
for f in face_groups[0]:
x,y,z = f.cent
face_grid.setdefault( ( int(((x-xmin)/xdepth)*div), int(((y-ymin)/ydepth)*div) ), [] ).append(f)
# Replace the old face list
face_groups[:] = face_grid.values()
for face_sel in face_groups:
print "\nStarting unwrap"
@@ -262,14 +340,23 @@ PREF_MARGIN_DIV= 512):
print '\tWarning, less then 4 faces, skipping'
continue
pretty_faces = [prettyface(f) for f in face_sel if len(f) == 4]
if PREF_2PASS:
m = int(PREF_2PASS_ERROR*255);
skip_faces = [ f.uvColRange<=m for f in face_sel ]
del m
else:
skip_faces = [False] * len(face_sel)
pretty_faces = [prettyface(f,skip_faces[i]) for i,f in enumerate(face_sel) if len(f) == 4]
# Do we have any tri's
if len(pretty_faces) != len(face_sel):
# Now add tri's, not so simple because we need to pair them up.
def trylens(f):
def trylens(f, noarea):
if noarea:
return (f, [0.0,0.0,0.0], [0,1,2]), noarea
# f must be a tri
cos = [v.co for v in f]
lens = [(cos[0] - cos[1]).length, (cos[1] - cos[2]).length, (cos[2] - cos[0]).length]
@@ -282,9 +369,9 @@ PREF_MARGIN_DIV= 512):
break
lens_order = lens_min, lens_mid, lens_max
return f, lens, lens_order
return (f, lens, lens_order), noarea
tri_lengths = [trylens(f) for f in face_sel if len(f) == 3]
tri_lengths = [trylens(f,skip_faces[i]) for i,f in enumerate(face_sel) if len(f) == 3]
del trylens
def trilensdiff(t1,t2):
@@ -294,33 +381,41 @@ PREF_MARGIN_DIV= 512):
abs(t1[1][t1[2][2]]-t2[1][t2[2][2]])
while tri_lengths:
tri1 = tri_lengths.pop()
tri1, noarea = tri_lengths.pop()
if not tri_lengths:
pretty_faces.append(prettyface((tri1, None)))
pretty_faces.append(prettyface((tri1, None), noarea))
break
best_tri_index = -1
best_tri_diff = 100000000.0
best_noarea = False
for i, tri2 in enumerate(tri_lengths):
i=0
for tri2, noarea in tri_lengths:
diff = trilensdiff(tri1, tri2)
if diff < best_tri_diff:
best_tri_index = i
best_tri_diff = diff
pretty_faces.append(prettyface((tri1, tri_lengths.pop(best_tri_index))))
if diff==0: break
i+=1
tri2, noarea = tri_lengths.pop(best_tri_index)
pretty_faces.append(prettyface((tri1, tri2)) )
# Get the min, max and total areas
max_area = 0.0
min_area = 100000000.0
tot_area = 0
for f in face_sel:
area = f.area
if area > max_area: max_area = area
if area < min_area: min_area = area
tot_area += area
for i,f in enumerate(face_sel):
if skip_faces[i]:
min_area = 0.0
else:
area = f.area
if area > max_area: max_area = area
if area < min_area: min_area = area
tot_area += area
max_len = sqrt(max_area)
min_len = sqrt(min_area)
@@ -355,6 +450,7 @@ PREF_MARGIN_DIV= 512):
l_int*=2
lengths_to_ints = lengths_to_ints.items()
lengths_to_ints.sort()
print 'done'
@@ -531,23 +627,31 @@ def main():
PREF_SEL_ONLY = Draw.Create(1)
PREF_NEW_UVLAYER = Draw.Create(0)
PREF_PACK_IN_ONE = Draw.Create(0)
PREF_PACK_IN_MANY = Draw.Create(0)
PREF_APPLY_IMAGE = Draw.Create(0)
PREF_IMG_PX_SIZE = Draw.Create(512)
PREF_BOX_DIV = Draw.Create(12)
PREF_2PASS = Draw.Create(0)
PREF_2PASS_ERROR = Draw.Create(0.002)
PREF_MARGIN_DIV = Draw.Create(0.1)
if not Draw.PupBlock('Lightmap Pack', [\
'Context...',
('Active Object', PREF_ACT_ONLY, 'If disabled, include other selected objects for packing the lightmap.'),\
('Selected Faces', PREF_SEL_ONLY, 'Use only selected faces from all selected meshes.'),\
'UV Packing...',
('Pack Quality: ', PREF_BOX_DIV, 1, 48, 'Pre Packing before the complex boxpack'),\
('Margin: ', PREF_MARGIN_DIV, 0.001, 1.0, 'Size of the margin as a division of the UV'),\
('2ndPassOptimize', PREF_2PASS, 'Faces with low contrast on the active UV layers image get scaled down.'),\
('Pass Error: ', PREF_2PASS_ERROR, 0.001, 1.0, 'Use with 2nd pass optimize, faces with a contrast lower then this margin will be scaled down'),\
'Image & UVs...',
('Share Tex Space', PREF_PACK_IN_ONE, 'Objects Share texture space, map all objects into 1 uvmap'),\
('Tile Images: ', PREF_PACK_IN_MANY, 0, 16, 'Tile images over one or more mesh, value squared (n*n)'),\
('New UV Layer', PREF_NEW_UVLAYER, 'Create a new UV layer for every mesh packed'),\
('New Image', PREF_APPLY_IMAGE, 'Assign new images for every mesh (only one if shared tex space enabled)'),\
('Image Size', PREF_IMG_PX_SIZE, 64, 5000, 'Width and Height for the new image'),\
'UV Packing...',
('Pack Quality: ', PREF_BOX_DIV, 1, 48, 'Pre Packing before the complex boxpack'),\
('Margin: ', PREF_MARGIN_DIV, 0.001, 1.0, 'Size of the margin as a division of the UV')\
]):
return
@@ -576,10 +680,14 @@ def main():
PREF_SEL_ONLY.val,\
PREF_NEW_UVLAYER.val,\
PREF_PACK_IN_ONE.val,\
PREF_PACK_IN_MANY.val,\
PREF_APPLY_IMAGE.val,\
PREF_IMG_PX_SIZE.val,\
PREF_BOX_DIV.val,\
int(1/(PREF_MARGIN_DIV.val/100)))
int(1/(PREF_MARGIN_DIV.val/100)),\
PREF_2PASS.val,\
PREF_2PASS_ERROR.val,\
)
if is_editmode:
Window.EditMode(1)

View File

@@ -25,7 +25,7 @@ It removes very low weighted verts from the current group with a weight option.
# 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
@@ -51,13 +51,14 @@ def weightClean(me, PREF_THRESH, PREF_KEEP_SINGLE, PREF_OTHER_GROUPS):
for wd in vWeightDict:
l = len(wd)
if not PREF_KEEP_SINGLE or l > 1:
# cant use iteritems because the dict is having items removed
for group in wd.keys():
w= wd[group]
if w <= PREF_THRESH:
# small weight, remove.
del wd[group]
rem_count +=1
l-=1
l-=1
if PREF_KEEP_SINGLE and l == 1:
break
@@ -117,4 +118,4 @@ def main():
Draw.PupMenu('Removed %i verts from groups' % rem_count)
if __name__=='__main__':
main()
main()

View File

@@ -56,7 +56,7 @@
information, claims of third parties, damages as a result of injury to
any person, or any other loss) arising out of or in connection with the
license granted under this License Agreement or the use of or inability
to use the Software, even if VF has been advised of the possibility of
to use the Software, even if BF has been advised of the possibility of
such damages.
5. User warning and indemnification

Some files were not shown because too many files have changed in this diff Show More