Code cleanup: move PBVH/PBVHNode structs into new header file

git-svn-id: https://svn.blender.org/svnroot/bf-blender/trunk/blender@53437 954f8c5b-7b00-dc11-b283-0030488c597c
Move layer displacements from SculptUndoNode to PBVHNode

* This doesn't make much difference for regular mesh/multires
  sculpting, but for dynamic topology sculpting the undo stack isn't
  split up by PBVH nodes, so it's more convenient to store the layer
  data in PBVH nodes.

* Note that the life cycle of the layer displacement data is
  unchanged -- it's only valid during a stroke with the layer brush,
  gets free'd when the undo step ends.

git-svn-id: https://svn.blender.org/svnroot/bf-blender/trunk/blender@53438 954f8c5b-7b00-dc11-b283-0030488c597c
Add DNA/RNA/BKE infrastructure for dynamic-topology sculpt mode

* Add a detail_size field to the Sculpt struct, two new sculpt flags,
  and a Mesh flag for dynamic-topology mode; that's it for file-level
  changes needed by dynamic topology

* Add RNA for the new DNA field and flags

* Add a new icon for dynamic-topology created by Julio Iglesias. TODO:
  update the icon for the new SVG icon format

* Add a SculptSession function for converting from BMesh to Mesh,
  handles reordering mesh elements and setting face shading

git-svn-id: https://svn.blender.org/svnroot/bf-blender/trunk/blender@53439 954f8c5b-7b00-dc11-b283-0030488c597c
Add BLI_buffer, an alternative to BLI_array

BLI_buffer is a dynamic homogeneous array similar to BLI_array, but it
allocates a structure that can be passed around making it possible to
resize the array outside the function it was declared in.

git-svn-id: https://svn.blender.org/svnroot/bf-blender/trunk/blender@53440 954f8c5b-7b00-dc11-b283-0030488c597c
Add dynamic topology support to the PBVH

* Add BLI_pbvh_build_bmesh(), similar to the other PBVH builders but
  specialized for BMesh. Whereas the PBVH leaf nodes for mesh and
  grids only store a start-index and count into the primitive indices
  array, the BMesh version uses GHashes to store the full set of faces
  and vertices in leaf nodes

* Update PBVH iterator to handle BMesh

* Make some of the pbvh.c functions non-static so they can be used by
  the new pbvh_bmesh code

* The BLI_pbvh_bmesh_update_topology() function is the main reason for
  adding BMesh support to the PBVH. This function is used during a
  sculpt stroke to dynamically collapse edges that are particular
  short and subdivide edges that are particularly long.

git-svn-id: https://svn.blender.org/svnroot/bf-blender/trunk/blender@53441 954f8c5b-7b00-dc11-b283-0030488c597c
Add dynamic topology support to sculpt mode

* User documentation:
  wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.66/Dynamic_Topology_Sculpting

* Code review for this and the other dynamic-topology commits:
  https://codereview.appspot.com/6947064/
  Thanks to Sergey for doing code review!

* Add SCULPT_OT_dynamic_topology_toggle operator to enable or disable
  dynamic topology mode

* Most brushes need little modification for dynamic topology, but for
  some it won't work well and is disabled. This decision is made in
  sculpt_stroke_dynamic_topology().

* For brushes that need original data (e.g. grab brush) the topology
  is not updated during the stroke, but some changes to original
  vertex data is accessed were made since BMesh works a little
  differently from mesh/multires. This is abstracted with
  SculptOrigVertData and associated functions.

* Smooth brush gets yet another set of functions, for mesh and
  multires and dynamic topology and, separetely, masking

* For most brushes, the topology is updated during the stroke right
  before the regular brush action takes place. This is handled in
  sculpt_topology_update().

* Exiting sculpt mode also disables dynamic topology

* Sculpt undo works differently with BMesh. Since the contents of
  nodes in the PBVH do not remain static during a sculpt session, the
  SculptUndoNodes do not correspond with PBVHNodes if dynamic topology
  is enabled. Rather, each SculptUndoNode is associated with a
  BMLogEntry.

* Sculpt undo gets a few new cases: entering and exiting dynamic
  topology does an undo push of all mesh data. Symmetrize will
  similarly push a full copy of BMesh data, although it does so
  through the BMLog API.

* Undo and redo in dynamic-topology mode will do a full recalculation
  of the PBVH.

* Add some documentation to doc/sculpt.org. This could stand to be
  expanded a lot more, for now it mostly contains test cases for the
  undo system.

* Add SCULPT_OT_optimize operator to recalculate the BVH. The BVH gets
  less optimal more quickly with dynamic topology than regular
  sculpting. There is no doubt more clever stuff we can do to optimize
  it on the fly, but for now this gives the user a nicer way to
  recalculate it than toggling modes.

git-svn-id: https://svn.blender.org/svnroot/bf-blender/trunk/blender@53442 954f8c5b-7b00-dc11-b283-0030488c597c
Modify info stats for dynamic-topology sculpt mode

Format is like this: "Verts:8 | Tris:12 | Cube"

git-svn-id: https://svn.blender.org/svnroot/bf-blender/trunk/blender@53443 954f8c5b-7b00-dc11-b283-0030488c597c
Update DerivedMesh for dynamic-topology sculpt mode

* Build bmesh PBVH in CDDM when dyntopo is enabled

* Disable all modifiers when dyntopo is enabled

git-svn-id: https://svn.blender.org/svnroot/bf-blender/trunk/blender@53444 954f8c5b-7b00-dc11-b283-0030488c597c
Hiding support for dynamic topology

git-svn-id: https://svn.blender.org/svnroot/bf-blender/trunk/blender@53445 954f8c5b-7b00-dc11-b283-0030488c597c