[Bf-committers] Shrinkwrap constraint

André Pinto andresusanopinto at gmail.com
Sun Dec 14 22:03:01 CET 2008


http://pasteall.org/3494/diff

This is part of the code developed during GSoC 2008,

Shrinkwrap was imported to trunk in parts, first only BVHTree,
then Shrinkwrap Modifier, then SimpleDeform modifier and now Shrinkwrap
Constraint!

The other GSoC code merged nicely and without any modifications on remaining
code,
thought the case is slightly different with this constraint:

Constraints suffer an evaluation (_get_tarmat) every time the interface is
draw,
this might be OK for simple constraints, but shrinkwrap needs to build a
BVHTree of a target mesh.
And its just not possible to build a BVH tree every interface draw, since it
just slow.
The work arround was to create a BVH cache.

The cache was chosen to be implemented at DerivedMesh level (since vertex
and face data is on there),
Each object's derived mesh is already destroyed and rebuild each time the
vertex and face data changes,
so there is no need for additional control mechanisms.

Using BVHTree cache is very simple..
A BVHTree is build using bvhtree_from_mesh_tri/faces (as it was already done
before) and its freed when the respective DerivedMesh is released.

Other code that builds BVH's from DerivedMesh can also benefit with this
cache (being that another of the reasons to implement cache at derivedmesh
level)
(example is for example having 1000 shrinkwrap constraints applied with the
same target).

Its implementation was also very simple:
An attribute "BVHCache" was added to the DerivedMesh struct
(source/blender/blenkernel/BKE_DerivedMesh.h)
And calls to bvhcache_init/free were added on DerivedMesh creation and
release (source/blender/blenkernel/intern/DerivedMesh.c)


There are the files that are modified by the patch:
source/blender/blenkernel/BKE_shrinkwrap.h
source/blender/blenkernel/intern/shrinkwrap.c
source/blender/blenkernel/BKE_bvhutils.h
source/blender/blenkernel/intern/bvhutils.c
 Shrinkwrap and BVH code


source/blender/blenkernel/intern/constraint.c
source/blender/makesdna/DNA_constraint_types.h
source/blender/src/buttons_object.c
source/blender/blenloader/intern/readfile.c
  Shrinkwrap constraint code

source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/BKE_DerivedMesh.h
  Link of BVHCache and DerivedMesh



If everything is alright..and Aligorith positively reviews the patch I will
commit it to trunk.
Besides vacations are coming, so I will have time if any problems show up :)

---
André Susano Pinto (jaguarandi)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.blender.org/pipermail/bf-committers/attachments/20081214/af81cfd7/attachment.htm 


More information about the Bf-committers mailing list