svn merge -r 21301:21372 https://svn.blender.org/svnroot/bf-blender/branches/blender2...
authorAndre Susano Pinto <andresusanopinto@gmail.com>
Sun, 5 Jul 2009 15:20:19 +0000 (15:20 +0000)
committerAndre Susano Pinto <andresusanopinto@gmail.com>
Sun, 5 Jul 2009 15:20:19 +0000 (15:20 +0000)
93 files changed:
CMakeLists.txt
release/ui/buttons_data_lattice.py
release/ui/buttons_data_mesh.py
release/ui/buttons_data_modifier.py
release/ui/buttons_particle.py
release/ui/buttons_physic_cloth.py
release/ui/buttons_physics_field.py [new file with mode: 0644]
release/ui/buttons_physics_fluid.py [new file with mode: 0644]
release/ui/buttons_physics_softbody.py [new file with mode: 0644]
release/ui/space_view3d_toolbar.py [new file with mode: 0644]
source/blender/blenfont/BLF_api.h
source/blender/blenfont/intern/blf.c
source/blender/blenkernel/BKE_effect.h
source/blender/blenkernel/BKE_fluidsim.h
source/blender/blenkernel/BKE_modifier.h
source/blender/blenkernel/BKE_particle.h
source/blender/blenkernel/BKE_pointcache.h
source/blender/blenkernel/BKE_screen.h
source/blender/blenkernel/intern/anim.c
source/blender/blenkernel/intern/context.c
source/blender/blenkernel/intern/depsgraph.c
source/blender/blenkernel/intern/effect.c
source/blender/blenkernel/intern/fluidsim.c
source/blender/blenkernel/intern/lattice.c
source/blender/blenkernel/intern/modifier.c
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/particle_system.c
source/blender/blenkernel/intern/pointcache.c
source/blender/blenkernel/intern/screen.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/CMakeLists.txt
source/blender/editors/animation/anim_draw.c
source/blender/editors/animation/anim_markers.c
source/blender/editors/include/ED_fluidsim.h
source/blender/editors/include/ED_markers.h
source/blender/editors/include/ED_object.h
source/blender/editors/include/ED_physics.h [moved from source/blender/editors/include/ED_pointcache.h with 97% similarity]
source/blender/editors/include/ED_screen.h
source/blender/editors/include/UI_interface.h
source/blender/editors/include/UI_view2d.h
source/blender/editors/interface/interface_layout.c
source/blender/editors/interface/interface_panel.c
source/blender/editors/interface/interface_templates.c
source/blender/editors/interface/interface_widgets.c
source/blender/editors/interface/view2d.c
source/blender/editors/interface/view2d_ops.c
source/blender/editors/object/editkey.c
source/blender/editors/object/editlattice.c
source/blender/editors/object/object_edit.c
source/blender/editors/object/object_intern.h
source/blender/editors/object/object_modifier.c
source/blender/editors/object/object_ops.c
source/blender/editors/physics/ed_fluidsim.c
source/blender/editors/physics/ed_pointcache.c
source/blender/editors/screen/area.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/sculpt_paint/sculpt.c
source/blender/editors/space_api/spacetypes.c
source/blender/editors/space_buttons/buttons_context.c
source/blender/editors/space_buttons/buttons_ops.c
source/blender/editors/space_graph/graph_edit.c
source/blender/editors/space_graph/graph_intern.h
source/blender/editors/space_graph/space_graph.c
source/blender/editors/space_text/text_draw.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/space_view3d.c
source/blender/editors/space_view3d/view3d_header.c
source/blender/editors/space_view3d/view3d_intern.h
source/blender/editors/space_view3d/view3d_toolbar.c
source/blender/makesdna/DNA_modifier_types.h
source/blender/makesdna/DNA_object_fluidsim.h
source/blender/makesdna/DNA_object_force.h
source/blender/makesdna/DNA_particle_types.h
source/blender/makesdna/DNA_screen_types.h
source/blender/makesdna/DNA_view2d_types.h
source/blender/makesrna/RNA_access.h
source/blender/makesrna/intern/CMakeLists.txt
source/blender/makesrna/intern/makesrna.c
source/blender/makesrna/intern/rna_fluidsim.c
source/blender/makesrna/intern/rna_internal.h
source/blender/makesrna/intern/rna_key.c
source/blender/makesrna/intern/rna_lattice.c
source/blender/makesrna/intern/rna_modifier.c
source/blender/makesrna/intern/rna_object.c
source/blender/makesrna/intern/rna_object_force.c
source/blender/makesrna/intern/rna_particle.c
source/blender/makesrna/intern/rna_screen.c
source/blender/makesrna/intern/rna_ui_api.c
source/blender/python/intern/bpy_interface.c
source/blender/python/intern/bpy_rna.c
source/blender/render/extern/include/RE_raytrace.h
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/pipeline.c

index 714ec4095af9639a337deec68db1f305ae049bb5..a4796c2eee90555a4c9de5d372a0e1cebab530ca 100644 (file)
@@ -87,7 +87,7 @@ INCLUDE(CMake/macros.cmake)
 #-----------------------------------------------------------------------------
 #Platform specifics
 
-IF(UNIX)
+IF(UNIX AND NOT APPLE)
   IF(WITH_OPENAL)
     FIND_PACKAGE(OpenAL)
     IF(OPENAL_FOUND)
@@ -177,7 +177,7 @@ IF(UNIX)
   SET(C_WARNINGS "-Wall -Wno-char-subscripts -Wpointer-arith -Wcast-align -Wnested-externs -Wdeclaration-after-statement")
 
   INCLUDE_DIRECTORIES(${JPEG_INCLUDE_DIR} ${PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} )
-ENDIF(UNIX)
+ENDIF(UNIX AND NOT APPLE)
 
 IF(WIN32)
 
index bf2aaad5a97865e79177947a649c32df4bc86686..653a638c458db868e75dde58f313dcccfb044134 100644 (file)
@@ -48,7 +48,7 @@ class DATA_PT_lattice(DataButtonsPanel):
                        row.itemR(lat, "interpolation_type_w", expand=True)
                        
                        row = layout.row()
+                       row.itemO("LATTICE_OT_make_regular")
                        row.itemR(lat, "outside")
-                       row.itemR(lat, "shape_keys")
 
 bpy.types.register(DATA_PT_lattice)
index c7e253d5084e5a8174f26959fb0d6932bed46ec6..cb3041d505728f3f361418a20aa9fff89d386ebf 100644 (file)
@@ -131,16 +131,44 @@ class DATA_PT_shape_keys(DataButtonsPanel):
        def draw(self, context):
                layout = self.layout
                ob = context.object
-
-               row = layout.row()
-
                key = ob.data.shape_keys
+               kb = ob.active_shape_key
 
+               row = layout.row()
                row.template_list(key, "keys", ob, "active_shape_key_index")
 
-               col = row.column(align=True)
-               col.itemO("OBJECT_OT_shape_key_add", icon="ICON_ZOOMIN", text="")
-               col.itemO("OBJECT_OT_shape_key_remove", icon="ICON_ZOOMOUT", text="")
+               col = row.column()
+
+               subcol = col.column(align=True)
+               subcol.itemO("OBJECT_OT_shape_key_add", icon="ICON_ZOOMIN", text="")
+               subcol.itemO("OBJECT_OT_shape_key_remove", icon="ICON_ZOOMOUT", text="")
+
+               if kb:
+                       col.itemS()
+
+                       subcol = col.column(align=True)
+                       subcol.itemR(ob, "shape_key_lock", icon="ICON_PINNED", text="")
+                       subcol.itemR(kb, "mute", icon="ICON_MUTE_IPO_ON", text="")
+
+                       if key.relative:
+                               row = layout.row()
+                               row.itemR(key, "relative")
+                               row.itemL()
+
+                               if ob.active_shape_key_index != 0:
+                                       if not ob.shape_key_lock:
+                                               row = layout.row(align=True)
+                                               row.itemR(kb, "value", text="")
+                                               row.itemR(kb, "slider_min", text="Min")
+                                               row.itemR(kb, "slider_max", text="Max")
+
+                                       row = layout.row()
+                                       row.item_pointerR(kb, "vertex_group", ob, "vertex_groups", text="")
+                                       row.item_pointerR(kb, "relative_key", key, "keys", text="")
+                       else:
+                               row = layout.row()
+                               row.itemR(key, "relative")
+                               row.itemR(key, "slurph")
 
                if context.edit_object:
                        layout.enabled = False
index 953fc1f09742c704d401320d9c6e6bff4b003252..10f3efa1ed42d03c21403b1b84de625713844622 100644 (file)
@@ -24,61 +24,63 @@ class DATA_PT_modifiers(DataButtonsPanel):
                        if box:
                                if md.type == 'ARMATURE':
                                        self.armature(box, ob, md)
-                               if md.type == 'ARRAY':
+                               elif md.type == 'ARRAY':
                                        self.array(box, ob, md)
-                               if md.type == 'BEVEL':
+                               elif md.type == 'BEVEL':
                                        self.bevel(box, ob, md)
-                               if md.type == 'BOOLEAN':
+                               elif md.type == 'BOOLEAN':
                                        self.boolean(box, ob, md)
-                               if md.type == 'BUILD':
+                               elif md.type == 'BUILD':
                                        self.build(box, ob, md)
-                               if md.type == 'CAST':
+                               elif md.type == 'CAST':
                                        self.cast(box, ob, md)
-                               if md.type == 'CLOTH':
+                               elif md.type == 'CLOTH':
                                        self.cloth(box, ob, md)
-                               if md.type == 'COLLISION':
+                               elif md.type == 'COLLISION':
                                        self.collision(box, ob, md)
-                               if md.type == 'CURVE':
+                               elif md.type == 'CURVE':
                                        self.curve(box, ob, md)
-                               if md.type == 'DECIMATE':
+                               elif md.type == 'DECIMATE':
                                        self.decimate(box, ob, md)
-                               if md.type == 'DISPLACE':
+                               elif md.type == 'DISPLACE':
                                        self.displace(box, ob, md)
-                               if md.type == 'EDGE_SPLIT':
+                               elif md.type == 'EDGE_SPLIT':
                                        self.edgesplit(box, ob, md)
-                               if md.type == 'EXPLODE':
+                               elif md.type == 'EXPLODE':
                                        self.explode(box, ob, md)
-                               if md.type == 'FLUID_SIMULATION':
+                               elif md.type == 'FLUID_SIMULATION':
                                        self.fluid(box, ob, md)
-                               if md.type == 'HOOK':
+                               elif md.type == 'HOOK':
                                        self.hook(box, ob, md)
-                               if md.type == 'LATTICE':
+                               elif md.type == 'LATTICE':
                                        self.lattice(box, ob, md)
-                               if md.type == 'MASK':
+                               elif md.type == 'MASK':
                                        self.mask(box, ob, md)
-                               if md.type == 'MESH_DEFORM':
+                               elif md.type == 'MESH_DEFORM':
                                        self.mesh_deform(box, ob, md)
-                               if md.type == 'MIRROR':
+                               elif md.type == 'MIRROR':
                                        self.mirror(box, ob, md)
-                               if md.type == 'MULTIRES':
+                               elif md.type == 'MULTIRES':
                                        self.multires(box, ob, md)
-                               if md.type == 'PARTICLE_INSTANCE':
+                               elif md.type == 'PARTICLE_INSTANCE':
                                        self.particleinstance(box, ob, md)
-                               if md.type == 'PARTICLE_SYSTEM':
+                               elif md.type == 'PARTICLE_SYSTEM':
                                        self.particlesystem(box, ob, md)
-                               if md.type == 'SHRINKWRAP':
+                               elif md.type == 'SHRINKWRAP':
                                        self.shrinkwrap(box, ob, md)
-                               if md.type == 'SIMPLE_DEFORM':
+                               elif md.type == 'SIMPLE_DEFORM':
                                        self.simpledeform(box, ob, md)
-                               if md.type == 'SMOOTH':
+                               elif md.type == 'SMOOTH':
                                        self.smooth(box, ob, md)
-                               if md.type == 'SOFTBODY':
+                               elif md.type == 'SOFTBODY':
                                        self.softbody(box, ob, md)
-                               if md.type == 'SUBSURF':
+                               elif md.type == 'SUBSURF':
                                        self.subsurf(box, ob, md)
-                               if md.type == 'UV_PROJECT':
+                               elif md.type == 'SURFACE':
+                                       self.surface(box, ob, md)
+                               elif md.type == 'UV_PROJECT':
                                        self.uvproject(box, ob, md)
-                               if md.type == 'WAVE':
+                               elif md.type == 'WAVE':
                                        self.wave(box, ob, md)
                                                        
        def armature(self, layout, ob, md):
@@ -96,9 +98,9 @@ class DATA_PT_modifiers(DataButtonsPanel):
                layout.itemR(md, "fit_type")
                if md.fit_type == 'FIXED_COUNT':
                        layout.itemR(md, "count")
-               if md.fit_type == 'FIT_LENGTH':
+               elif md.fit_type == 'FIT_LENGTH':
                        layout.itemR(md, "length")
-               if md.fit_type == 'FIT_CURVE':
+               elif md.fit_type == 'FIT_CURVE':
                        layout.itemR(md, "curve")
 
                layout.itemS()
@@ -152,7 +154,7 @@ class DATA_PT_modifiers(DataButtonsPanel):
                if md.limit_method == 'ANGLE':
                        row = layout.row()
                        row.itemR(md, "angle")
-               if md.limit_method == 'WEIGHT':
+               elif md.limit_method == 'WEIGHT':
                        row = layout.row()
                        row.itemR(md, "edge_weight_method", expand=True)
                        
@@ -211,7 +213,7 @@ class DATA_PT_modifiers(DataButtonsPanel):
                layout.itemR(md, "texture_coordinates")
                if md.texture_coordinates == 'OBJECT':
                        layout.itemR(md, "texture_coordinate_object", text="Object")
-               if md.texture_coordinates == 'UV' and ob.type == 'MESH':
+               elif md.texture_coordinates == 'UV' and ob.type == 'MESH':
                        layout.item_pointerR(md, "uv_layer", ob.data, "uv_layers")
        
        def edgesplit(self, layout, ob, md):
@@ -235,7 +237,7 @@ class DATA_PT_modifiers(DataButtonsPanel):
                # Missing: "Refresh" and "Clear Vertex Group" ?
                
        def fluid(self, layout, ob, md):
-               layout.itemL(text="See Fluidsim panel.")
+               layout.itemL(text="See Fluid panel.")
                
        def hook(self, layout, ob, md):
                layout.itemR(md, "falloff")
@@ -252,7 +254,7 @@ class DATA_PT_modifiers(DataButtonsPanel):
                layout.itemR(md, "mode")
                if md.mode == 'ARMATURE':
                        layout.itemR(md, "armature")
-               if md.mode == 'VERTEX_GROUP':
+               elif md.mode == 'VERTEX_GROUP':
                        layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
                layout.itemR(md, "inverse")
                
@@ -297,10 +299,21 @@ class DATA_PT_modifiers(DataButtonsPanel):
                col = layout.column_flow()
                col.itemR(md, "normal")
                col.itemR(md, "children")
+               col.itemR(md, "size")
                col.itemR(md, "path")
+               if md.path:
+                       col.itemR(md, "keep_shape")
                col.itemR(md, "unborn")
                col.itemR(md, "alive")
                col.itemR(md, "dead")
+               col.itemL(md, "")
+               if md.path:
+                       col.itemR(md, "axis", text="")
+               
+               if md.path:
+                       row = layout.row()
+                       row.itemR(md, "position", slider=True)
+                       row.itemR(md, "random_position", text = "Random", slider=True)
                
        def particlesystem(self, layout, ob, md):
                layout.itemL(text="See Particle panel.")
@@ -325,7 +338,7 @@ class DATA_PT_modifiers(DataButtonsPanel):
                        col.itemR(md, "positive")
                        col.itemR(md, "cull_front_faces")
                        col.itemR(md, "cull_back_faces")
-               if md.mode == 'NEAREST_SURFACEPOINT':
+               elif md.mode == 'NEAREST_SURFACEPOINT':
                        layout.itemR(md, "keep_above_surface")
                # To-Do: Validate if structs
                
@@ -353,7 +366,7 @@ class DATA_PT_modifiers(DataButtonsPanel):
                layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
                
        def softbody(self, layout, ob, md):
-               layout.itemL(text="See Softbody panel.")
+               layout.itemL(text="See Soft Body panel.")
        
        def subsurf(self, layout, ob, md):
                layout.itemR(md, "subdivision_type")
@@ -362,6 +375,9 @@ class DATA_PT_modifiers(DataButtonsPanel):
                col.itemR(md, "render_levels", text="Render")
                col.itemR(md, "optimal_draw", text="Optimal Display")
                col.itemR(md, "subsurf_uv")
+
+       def surface(self, layout, ob, md):
+               layout.itemL(text="See Fields panel.")
        
        def uvproject(self, layout, ob, md):
                if ob.type == 'MESH':
@@ -404,7 +420,7 @@ class DATA_PT_modifiers(DataButtonsPanel):
                layout.itemR(md, "texture_coordinates")
                if md.texture_coordinates == 'MAP_UV' and ob.type == 'MESH':
                        layout.item_pointerR(md, "uv_layer", ob.data, "uv_layers")
-               if md.texture_coordinates == 'OBJECT':
+               elif md.texture_coordinates == 'OBJECT':
                        layout.itemR(md, "texture_coordinates_object")
                
                col = layout.column_flow()
index 49ceaf6aae1873ef67bfac4a20918f860abf1709..93ce9c5c74532115601c0038e429da378b613c22 100644 (file)
@@ -353,19 +353,14 @@ class PARTICLE_PT_render(ParticleButtonsPanel):
                        colsub.itemR(part, "adaptive_pix")
                        sub.itemR(part, "hair_bspline")
                        sub.itemR(part, "render_step", text="Steps")
-                       sub = split.column()
-                       sub.itemL(text="Length:")
-                       sub.itemR(part, "abs_length", text="Absolute")
-                       sub.itemR(part, "absolute_length", text="Maximum")
+                       sub = split.column()    
+
+                       sub.itemL(text="Timing:")
+                       sub.itemR(part, "abs_path_time")
+                       sub.itemR(part, "path_start", text="Start", slider= not part.abs_path_time)
+                       sub.itemR(part, "path_end", text="End", slider= not part.abs_path_time)         
                        sub.itemR(part, "random_length", text="Random", slider=True)
                        
-                       #row = layout.row()
-                       #row.itemR(part, "timed_path")
-                       #col = row.column(align=True)
-                       #col.active = part.timed_path == True
-                       #col.itemR(part, "line_length_tail", text="Start")
-                       #col.itemR(part, "line_length_head", text="End")
-                       
                        row = layout.row()
                        col = row.column()
                        
@@ -384,7 +379,6 @@ class PARTICLE_PT_render(ParticleButtonsPanel):
                        
 
                elif part.ren_as == 'OBJECT':
-                       #sub = split.column()
                        sub.itemR(part, "dupli_object")
                elif part.ren_as == 'GROUP':
                        sub.itemR(part, "dupli_group")
@@ -428,7 +422,19 @@ class PARTICLE_PT_render(ParticleButtonsPanel):
                        row.itemR(part, "billboard_animation", expand=True)
                        row.itemL(text="Offset:")
                        row.itemR(part, "billboard_split_offset", expand=True)
-               
+               if part.ren_as == 'HALO' or part.ren_as == 'LINE' or part.ren_as=='BILLBOARD':
+                       row = layout.row()
+                       col = row.column()
+                       col.itemR(part, "trail_count")
+                       if part.trail_count > 1:
+                               col.itemR(part, "abs_path_time", text="Length in frames")
+                               col = row.column()
+                               col.itemR(part, "path_end", text="Length", slider=not part.abs_path_time)
+                               col.itemR(part, "random_length", text="Random", slider=True)
+                       else:
+                               col = row.column()
+                               col.itemL(text="")
+                               
 class PARTICLE_PT_draw(ParticleButtonsPanel):
        __idname__= "PARTICLE_PT_draw"
        __label__ = "Display"
@@ -475,11 +481,12 @@ class PARTICLE_PT_draw(ParticleButtonsPanel):
                        col.itemR(part, "draw_health")
                
                col = row.column()
+               col.itemR(part, "material_color", text="Use material color")
+               
                if (path):
                        box = col.box()                         
                        box.itemR(part, "draw_step")
                else:
-                       col.itemR(part, "material_color", text="Use material color")
                        subcol = col.column()
                        subcol.active = part.material_color==False
                        #subcol.itemL(text="color")
index a06c644322ad8f26e52072b356d29009108da80d..edb778b4dce3694960dd15427809842a55914640 100644 (file)
@@ -7,48 +7,74 @@ class PhysicButtonsPanel(bpy.types.Panel):
        __context__ = "physics"
 
        def poll(self, context):
-               return (context.cloth != None)
+               ob = context.object
+               return (ob and ob.type == 'MESH')
                
-class Physic_PT_cloth(PhysicButtonsPanel):
-       __idname__ = "Physic_PT_cloth"
+class PHYSICS_PT_cloth(PhysicButtonsPanel):
+       __idname__ = "PHYSICS_PT_cloth"
        __label__ = "Cloth"
 
        def draw(self, context):
                layout = self.layout
-               cloth = context.cloth.settings
-               
+               md = context.cloth
+               ob = context.object
+
                split = layout.split()
-               
-               col = split.column()
-               col.itemR(cloth, "quality", slider=True)
-               col.itemR(cloth, "gravity")
-               col.itemR(cloth, "mass")
-               col.itemR(cloth, "mass_vertex_group", text="Vertex Group")
-
-               col = split.column()
-               col.itemL(text="Stiffness:")
-               col.itemR(cloth, "structural_stiffness", text="Structural")
-               col.itemR(cloth, "bending_stiffness", text="Bending")
-               col.itemL(text="Damping:")
-               col.itemR(cloth, "spring_damping", text="Spring")
-               col.itemR(cloth, "air_damping", text="Air")
-               
-               # Disabled for now
-               """
-               if cloth.mass_vertex_group:
-                       layout.itemL(text="Goal:")
-               
-                       col = layout.column_flow()
-                       col.itemR(cloth, "goal_default", text="Default")
-                       col.itemR(cloth, "goal_spring", text="Stiffness")
-                       col.itemR(cloth, "goal_friction", text="Friction")
-               """
+               split.operator_context = "EXEC_DEFAULT"
+
+               if md:
+                       # remove modifier + settings
+                       split.set_context_pointer("modifier", md)
+                       split.itemO("OBJECT_OT_modifier_remove", text="Remove")
+
+                       row = split.row(align=True)
+                       row.itemR(md, "render", text="")
+                       row.itemR(md, "realtime", text="")
+               else:
+                       # add modifier
+                       split.item_enumO("OBJECT_OT_modifier_add", "type", "CLOTH", text="Add")
+                       split.itemL()
+
+               if md:
+                       cloth = md.settings
+
+                       split = layout.split()
+                       
+                       col = split.column()
+                       col.itemR(cloth, "quality", slider=True)
+                       col.itemR(cloth, "gravity")
+
+                       subcol = col.column(align=True)
+                       subcol.itemR(cloth, "mass")
+                       subcol.item_pointerR(cloth, "mass_vertex_group", ob, "vertex_groups", text="")
+
+                       col = split.column()
+                       col.itemL(text="Stiffness:")
+                       col.itemR(cloth, "structural_stiffness", text="Structural")
+                       col.itemR(cloth, "bending_stiffness", text="Bending")
+                       col.itemL(text="Damping:")
+                       col.itemR(cloth, "spring_damping", text="Spring")
+                       col.itemR(cloth, "air_damping", text="Air")
+                       
+                       # Disabled for now
+                       """
+                       if cloth.mass_vertex_group:
+                               layout.itemL(text="Goal:")
+                       
+                               col = layout.column_flow()
+                               col.itemR(cloth, "goal_default", text="Default")
+                               col.itemR(cloth, "goal_spring", text="Stiffness")
+                               col.itemR(cloth, "goal_friction", text="Friction")
+                       """
 
 class PHYSICS_PT_cloth_cache(PhysicButtonsPanel):
        __idname__= "PHYSICS_PT_cloth_cache"
-       __label__ = "Cache"
+       __label__ = "Cloth Cache"
        __default_closed__ = True
 
+       def poll(self, context):
+               return (context.cloth != None)
+
        def draw(self, context):
                layout = self.layout
 
@@ -91,9 +117,12 @@ class PHYSICS_PT_cloth_cache(PhysicButtonsPanel):
                row.itemO("PTCACHE_OT_free_bake_all", text="Free All Bakes")
                layout.itemO("PTCACHE_OT_bake_all", text="Update All Dynamics to current frame")
                
-class Physic_PT_cloth_collision(PhysicButtonsPanel):
-       __idname__ = "Physic_PT_clothcollision"
+class PHYSICS_PT_cloth_collision(PhysicButtonsPanel):
+       __idname__ = "PHYSICS_PT_clothcollision"
        __label__ = "Cloth Collision"
+
+       def poll(self, context):
+               return (context.cloth != None)
        
        def draw_header(self, context):
                layout = self.layout
@@ -120,9 +149,12 @@ class Physic_PT_cloth_collision(PhysicButtonsPanel):
                col.itemR(cloth, "self_collision_quality", slider=True)
                col.itemR(cloth, "self_min_distance", text="MinDistance")
 
-class Physic_PT_cloth_stiffness(PhysicButtonsPanel):
-       __idname__ = "Physic_PT_stiffness"
+class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel):
+       __idname__ = "PHYSICS_PT_stiffness"
        __label__ = "Cloth Stiffness Scaling"
+
+       def poll(self, context):
+               return (context.cloth != None)
        
        def draw_header(self, context):
                layout = self.layout
@@ -132,23 +164,25 @@ class Physic_PT_cloth_stiffness(PhysicButtonsPanel):
 
        def draw(self, context):
                layout = self.layout
+               ob = context.object
                cloth = context.cloth.settings
                
                layout.active = cloth.stiffness_scaling 
                
                split = layout.split()
                
-               sub = split.column()
+               sub = split.column(align=True)
                sub.itemL(text="Structural Stiffness:")
-               sub.column().itemR(cloth, "structural_stiffness_vertex_group", text="VGroup")
+               sub.item_pointerR(cloth, "structural_stiffness_vertex_group", ob, "vertex_groups", text="")
                sub.itemR(cloth, "structural_stiffness_max", text="Max")
                
-               sub = split.column()
+               sub = split.column(align=True)
                sub.itemL(text="Bending Stiffness:")
-               sub.column().itemR(cloth, "bending_vertex_group", text="VGroup")
+               sub.item_pointerR(cloth, "bending_vertex_group", ob, "vertex_groups", text="")
                sub.itemR(cloth, "bending_stiffness_max", text="Max")
                
-bpy.types.register(Physic_PT_cloth)
+bpy.types.register(PHYSICS_PT_cloth)
 bpy.types.register(PHYSICS_PT_cloth_cache)
-bpy.types.register(Physic_PT_cloth_collision)
-bpy.types.register(Physic_PT_cloth_stiffness)
+bpy.types.register(PHYSICS_PT_cloth_collision)
+bpy.types.register(PHYSICS_PT_cloth_stiffness)
+
diff --git a/release/ui/buttons_physics_field.py b/release/ui/buttons_physics_field.py
new file mode 100644 (file)
index 0000000..696de5e
--- /dev/null
@@ -0,0 +1,66 @@
+
+import bpy
+
+class PhysicButtonsPanel(bpy.types.Panel):
+       __space_type__ = "BUTTONS_WINDOW"
+       __region_type__ = "WINDOW"
+       __context__ = "physics"
+
+       def poll(self, context):
+               return (context.object != None)
+               
+class PHYSICS_PT_field(PhysicButtonsPanel):
+       __idname__ = "PHYSICS_PT_field"
+       __label__ = "Field"
+
+       def draw(self, context):
+               layout = self.layout
+               ob = context.object
+               field = ob.field
+
+               layout.itemR(field, "type")
+
+               if field.type != "NONE":
+                       layout.itemR(field, "strength")
+
+               if field.type in ("HARMONIC", "SPHERICAL", "CHARGE", "LENNARDj"):
+                       if ob.type in ("MESH", "SURFACE", "FONT", "CURVE"):
+                               layout.itemR(field, "surface")
+
+class PHYSICS_PT_collision(PhysicButtonsPanel):
+       __idname__ = "PHYSICS_PT_collision"
+       __label__ = "Collision"
+       __default_closed__ = True
+       
+       def poll(self, context):
+               ob = context.object
+               return (ob and ob.type == 'MESH')
+
+       def draw_header(self, context):
+               settings = context.object.collision
+               self.layout.itemR(settings, "enabled", text="")
+
+       def draw(self, context):
+               layout = self.layout
+               md = context.collision
+               settings = context.object.collision
+
+               layout.active = settings.enabled
+               
+               split = layout.split()
+               
+               col = split.column()
+               col.itemL(text="Damping:")
+               col.itemR(settings, "damping_factor", text="Factor");
+               col.itemR(settings, "random_damping", text="Random");
+               
+               col = split.column()
+               col.itemL(text="Friction:")
+               col.itemR(settings, "friction_factor", text="Factor");
+               col.itemR(settings, "random_friction", text="Random");
+               
+               layout.itemR(settings, "permeability");
+               layout.itemR(settings, "kill_particles");
+
+bpy.types.register(PHYSICS_PT_field)
+bpy.types.register(PHYSICS_PT_collision)
diff --git a/release/ui/buttons_physics_fluid.py b/release/ui/buttons_physics_fluid.py
new file mode 100644 (file)
index 0000000..2ab33b4
--- /dev/null
@@ -0,0 +1,223 @@
+
+import bpy
+
+class PhysicButtonsPanel(bpy.types.Panel):
+       __space_type__ = "BUTTONS_WINDOW"
+       __region_type__ = "WINDOW"
+       __context__ = "physics"
+
+       def poll(self, context):
+               ob = context.object
+               return (ob and ob.type == 'MESH')
+               
+class PHYSICS_PT_fluid(PhysicButtonsPanel):
+       __idname__ = "PHYSICS_PT_fluid"
+       __label__ = "Fluid"
+
+       def draw(self, context):
+               layout = self.layout
+               md = context.fluid
+               ob = context.object
+
+               split = layout.split()
+               split.operator_context = "EXEC_DEFAULT"
+
+               if md:
+                       # remove modifier + settings
+                       split.set_context_pointer("modifier", md)
+                       split.itemO("OBJECT_OT_modifier_remove", text="Remove")
+
+                       row = split.row(align=True)
+                       row.itemR(md, "render", text="")
+                       row.itemR(md, "realtime", text="")
+               else:
+                       # add modifier
+                       split.item_enumO("OBJECT_OT_modifier_add", "type", "FLUID_SIMULATION", text="Add")
+                       split.itemL()
+
+               if md:
+                       fluid = md.settings
+
+                       col = layout.column(align=True)
+                       row = col.row()
+                       row.item_enumR(fluid, "type", "DOMAIN")
+                       row.item_enumR(fluid, "type", "FLUID")
+                       row.item_enumR(fluid, "type", "OBSTACLE")
+                       row = col.row()
+                       row.item_enumR(fluid, "type", "INFLOW")
+                       row.item_enumR(fluid, "type", "OUTFLOW")
+                       row.item_enumR(fluid, "type", "PARTICLE")
+                       row.item_enumR(fluid, "type", "CONTROL")
+
+                       if fluid.type == 'DOMAIN':
+                               layout.itemO("FLUID_OT_bake", text="BAKE")
+                               layout.itemL(text="Required Memory: " + fluid.memory_estimate)
+                               
+                               layout.itemL(text="Resolution:")
+                               
+                               split = layout.split()
+                               
+                               col = split.column()
+                               colsub = col.column(align=True)
+                               colsub.itemR(fluid, "resolution", text="Final")
+                               colsub.itemR(fluid, "render_display_mode", text="")
+                               colsub = col.column(align=True)
+                               colsub.itemL(text="Time:")
+                               colsub.itemR(fluid, "start_time", text="Start")
+                               colsub.itemR(fluid, "end_time", text="End")
+                               
+                               col = split.column()
+                               colsub = col.column(align=True)
+                               colsub.itemR(fluid, "preview_resolution", text="Preview", slider=True)
+                               colsub.itemR(fluid, "viewport_display_mode", text="")
+                               colsub = col.column()
+                               colsub.itemR(fluid, "reverse_frames")
+                               colsub.itemR(fluid, "generate_speed_vectors")
+                               colsub.itemR(fluid, "path", text="")
+                               
+                       if fluid.type in ('FLUID', 'OBSTACLE', 'INFLOW', 'OUTFLOW'):
+                               layout.itemR(fluid, "volume_initialization")
+                               
+                       if fluid.type == 'FLUID':
+                               row = layout.row()
+                               row.column().itemR(fluid, "initial_velocity")
+                               row.itemR(fluid, "export_animated_mesh")
+                               
+                       if fluid.type == 'OBSTACLE':
+                               row = layout.row()
+                               row.itemL()
+                               row.itemR(fluid, "export_animated_mesh")
+                               layout.itemR(fluid, "slip_type", expand=True)
+                               if fluid.slip_type == 'PARTIALSLIP':
+                                       layout.itemR(fluid, "partial_slip_amount", text="Amount")
+                                       
+                               layout.itemR(fluid, "impact_factor")
+                               
+                       if fluid.type == 'INFLOW':
+                               row = layout.row()
+                               row.column().itemR(fluid, "inflow_velocity")
+                               row.itemR(fluid, "export_animated_mesh")
+                               layout.itemR(fluid, "local_coordinates")
+                               
+                       if fluid.type == 'OUTFLOW':
+                               row = layout.row()
+                               row.itemL()
+                               row.itemR(fluid, "export_animated_mesh")
+                               
+                       if fluid.type == 'PARTICLE':
+                               split = layout.split()
+                               
+                               col = split.column()
+                               col.itemL(text="Type:")
+                               col.itemR(fluid, "drops")
+                               col.itemR(fluid, "floats")
+                               col.itemR(fluid, "tracer")
+                               
+                               col = split.column()
+                               col.itemL(text="Influence:")
+                               col.itemR(fluid, "particle_influence", text="Particle")
+                               col.itemR(fluid, "alpha_influence", text="Alpha")
+                               
+                               layout.itemR(fluid, "path")
+                               
+                       if fluid.type == 'CONTROL':
+                               split = layout.split()
+                               
+                               col = split.column()
+                               col.itemL(text="Time:")
+                               col.itemR(fluid, "start_time", text="Start")
+                               col.itemR(fluid, "end_time", text="End")
+                               
+                               col = split.column()
+                               col.itemR(fluid, "quality", slider=True)
+                               col.itemR(fluid, "reverse_frames")
+                               
+                               split = layout.split()
+                               
+                               col = split.column()
+                               col.itemL(text="Attraction:")
+                               col.itemR(fluid, "attraction_strength", text="Strength")
+                               col.itemR(fluid, "attraction_radius", text="Radius")
+                               
+                               col = split.column()
+                               col.itemL(text="Velocity:")
+                               col.itemR(fluid, "velocity_strength", text="Strength")
+                               col.itemR(fluid, "velocity_radius", text="Radius")
+
+class PHYSICS_PT_domain_gravity(PhysicButtonsPanel):
+       __idname__ = "PHYSICS_PT_domain_gravity"
+       __label__ = "Domain World/Gravity"
+       __default_closed__ = True
+       
+       def poll(self, context):
+               md = context.fluid
+               if md:
+                       return (md.settings.type == 'DOMAIN')
+
+       def draw(self, context):
+               layout = self.layout
+               fluid = context.fluid.settings
+               
+               split = layout.split()
+               
+               col = split.column()
+               col.itemR(fluid, "gravity")
+               
+               col = split.column(align=True)
+               col.itemL(text="Viscosity:")
+               col.itemR(fluid, "viscosity_preset", text="")
+               if fluid.viscosity_preset == 'MANUAL':
+                       col.itemR(fluid, "viscosity_base", text="Base")
+                       col.itemR(fluid, "viscosity_exponent", text="Exponent")
+                       
+               col = layout.column_flow()
+               col.itemR(fluid, "real_world_size")
+               col.itemR(fluid, "grid_levels")
+               col.itemR(fluid, "compressibility")
+       
+class PHYSICS_PT_domain_boundary(PhysicButtonsPanel):
+       __idname__ = "PHYSICS_PT_domain_boundary"
+       __label__ = "Domain Boundary"
+       __default_closed__ = True
+       
+       def poll(self, context):
+               md = context.fluid
+               if md:
+                       return (md.settings.type == 'DOMAIN')
+
+       def draw(self, context):
+               layout = self.layout
+               fluid = context.fluid.settings
+               
+               layout.itemL(text="Slip:")
+               
+               layout.itemR(fluid, "slip_type", expand=True)
+               if fluid.slip_type == 'PARTIALSLIP':
+                       layout.itemR(fluid, "partial_slip_amount", text="Amount")
+               
+               layout.itemL(text="Surface:")
+               row = layout.row()
+               row.itemR(fluid, "surface_smoothing", text="Smoothing")
+               row.itemR(fluid, "surface_subdivisions", text="Subdivisions")
+               
+class PHYSICS_PT_domain_particles(PhysicButtonsPanel):
+       __idname__ = "PHYSICS_PT_domain_particles"
+       __label__ = "Domain Particles"
+       __default_closed__ = True
+       
+       def poll(self, context):
+               md = context.fluid
+               if md:
+                       return (md.settings.type == 'DOMAIN')
+
+       def draw(self, context):
+               layout = self.layout
+               fluid = context.fluid.settings
+               
+               layout.itemR(fluid, "tracer_particles")
+               layout.itemR(fluid, "generate_particles")
+
+bpy.types.register(PHYSICS_PT_fluid)
+bpy.types.register(PHYSICS_PT_domain_gravity)
+bpy.types.register(PHYSICS_PT_domain_boundary)
+bpy.types.register(PHYSICS_PT_domain_particles)
diff --git a/release/ui/buttons_physics_softbody.py b/release/ui/buttons_physics_softbody.py
new file mode 100644 (file)
index 0000000..a4bfae3
--- /dev/null
@@ -0,0 +1,219 @@
+
+import bpy
+
+class PhysicButtonsPanel(bpy.types.Panel):
+       __space_type__ = "BUTTONS_WINDOW"
+       __region_type__ = "WINDOW"
+       __context__ = "physics"
+
+       def poll(self, context):
+               ob = context.object
+               return (ob and ob.type == 'MESH')
+               
+class PHYSICS_PT_softbody(PhysicButtonsPanel):
+       __idname__ = "PHYSICS_PT_softbody"
+       __label__ = "Soft Body"
+
+       def draw(self, context):
+               layout = self.layout
+               md = context.soft_body
+               ob = context.object
+
+               split = layout.split()
+               split.operator_context = "EXEC_DEFAULT"
+
+               if md:
+                       # remove modifier + settings
+                       split.set_context_pointer("modifier", md)
+                       split.itemO("OBJECT_OT_modifier_remove", text="Remove")
+
+                       row = split.row(align=True)
+                       row.itemR(md, "render", text="")
+                       row.itemR(md, "realtime", text="")
+               else:
+                       # add modifier
+                       split.item_enumO("OBJECT_OT_modifier_add", "type", "SOFTBODY", text="Add")
+                       split.itemL("")
+                       
+               if md:
+                       softbody = md.settings
+
+                       # General
+                       split = layout.split()
+                       
+                       col = split.column()
+                       col.itemL(text="Object:")
+                       col.itemR(softbody, "mass")
+                       col.itemR(softbody, "friction")
+
+                       col = split.column()
+                       col.itemL(text="Simulation:")
+                       col.itemR(softbody, "gravity")
+                       col.itemR(softbody, "speed")
+                       
+                       
+class PHYSICS_PT_softbody_goal(PhysicButtonsPanel):
+       __idname__ = "PHYSICS_PT_softbody_goal"
+       __label__ = "Soft Body Goal"
+       
+       def poll(self, context):
+               return (context.soft_body != None)
+               
+       def draw_header(self, context):
+               layout = self.layout
+               softbody = context.soft_body.settings
+       
+               layout.itemR(softbody, "use_goal", text="")
+               
+       def draw(self, context):
+               layout = self.layout
+               md = context.soft_body
+               ob = context.object
+
+               split = layout.split()
+                       
+               if md:
+                       softbody = md.settings
+                       layout.active = softbody.use_goal
+
+                       # Goal 
+                       split = layout.split()
+
+                       col = split.column()
+                       col.itemL(text="Goal Strengths:")
+                       col.itemR(softbody, "goal_default", text="Default")
+                       subcol = col.column(align=True)
+                       subcol.itemR(softbody, "goal_min", text="Minimum")
+                       subcol.itemR(softbody, "goal_max", text="Maximum")
+                       
+                       col = split.column()
+                       col.itemL(text="Goal Settings:")
+                       col.itemR(softbody, "goal_spring", text="Stiffness")
+                       col.itemR(softbody, "goal_friction", text="Damping")
+                       layout.itemR(softbody, "goal_vertex_group", text="Vertex Group")
+
+class PHYSICS_PT_softbody_edge(PhysicButtonsPanel):
+       __idname__ = "PHYSICS_PT_softbody_edge"
+       __label__ = "Soft Body Edges"
+       
+       def poll(self, context):
+               return (context.soft_body != None)
+               
+       def draw_header(self, context):
+               layout = self.layout
+               softbody = context.soft_body.settings
+       
+               layout.itemR(softbody, "use_edges", text="")
+               
+       def draw(self, context):
+               layout = self.layout
+               md = context.soft_body
+               ob = context.object
+
+               split = layout.split()
+                       
+               if md:
+                       softbody = md.settings
+                       
+                       layout.active = softbody.use_edges
+                       
+                       split = layout.split()
+                       
+                       col = split.column()
+                       col.itemL(text="Springs:")
+                       col.itemR(softbody, "pull")
+                       col.itemR(softbody, "push")
+                       col.itemR(softbody, "damp")
+                       col.itemR(softbody, "plastic")
+                       col.itemR(softbody, "bending")
+                       col.itemR(softbody, "spring_length", text="Length")
+                       
+                       col = split.column()
+                       col.itemR(softbody, "stiff_quads")
+                       subcol = col.column()
+                       subcol.active = softbody.stiff_quads
+                       subcol.itemR(softbody, "shear")
+                       
+                       col.itemR(softbody, "new_aero", text="Aero")
+                       subcol = col.column()
+                       subcol.active = softbody.new_aero
+                       subcol.itemR(softbody, "aero", text="Factor", enabled=softbody.new_aero)
+
+                       col.itemL(text="Collision:")
+                       col.itemR(softbody, "edge_collision", text="Edge")
+                       col.itemR(softbody, "face_collision", text="Face")
+                       
+class PHYSICS_PT_softbody_collision(PhysicButtonsPanel):
+       __idname__ = "PHYSICS_PT_softbody_collision"
+       __label__ = "Soft Body Collision"
+       
+       def poll(self, context):
+               return (context.soft_body != None)
+               
+       def draw_header(self, context):
+               layout = self.layout
+               softbody = context.soft_body.settings
+       
+               layout.itemR(softbody, "self_collision", text="")
+               
+       def draw(self, context):
+               layout = self.layout
+               md = context.soft_body
+               ob = context.object
+
+               split = layout.split()
+                       
+               if md:
+                       softbody = md.settings
+
+                       layout.active = softbody.self_collision
+                       layout.itemL(text="Collision Type:")
+                       layout.itemR(softbody, "collision_type", expand=True)
+                       
+                       col = layout.column(align=True)
+                       col.itemL(text="Ball:")
+                       col.itemR(softbody, "ball_size", text="Size")
+                       col.itemR(softbody, "ball_stiff", text="Stiffness")
+                       col.itemR(softbody, "ball_damp", text="Dampening")
+
+class PHYSICS_PT_softbody_solver(PhysicButtonsPanel):
+       __idname__ = "PHYSICS_PT_softbody_solver"
+       __label__ = "Soft Body Solver"
+       
+       def poll(self, context):
+               return (context.soft_body != None)
+               
+       def draw(self, context):
+               layout = self.layout
+               md = context.soft_body
+               ob = context.object
+
+               split = layout.split()
+                       
+               if md:
+                       softbody = md.settings
+
+                       # Solver
+                       split = layout.split()
+                       
+                       col = split.column(align=True)
+                       col.itemL(text="Step Size:")
+                       col.itemR(softbody, "minstep")
+                       col.itemR(softbody, "maxstep")
+                       col.itemR(softbody, "auto_step", text="Auto-Step")
+                       
+                       col = split.column()
+                       col.itemR(softbody, "error_limit")
+
+                       col.itemL(text="Helpers:")
+                       col.itemR(softbody, "choke")
+                       col.itemR(softbody, "fuzzy")
+                       
+                       layout.itemL(text="Diagnostics:")
+                       layout.itemR(softbody, "diagnose")
+       
+bpy.types.register(PHYSICS_PT_softbody)
+bpy.types.register(PHYSICS_PT_softbody_goal)
+bpy.types.register(PHYSICS_PT_softbody_edge)
+bpy.types.register(PHYSICS_PT_softbody_collision)
+bpy.types.register(PHYSICS_PT_softbody_solver)
diff --git a/release/ui/space_view3d_toolbar.py b/release/ui/space_view3d_toolbar.py
new file mode 100644 (file)
index 0000000..a866b21
--- /dev/null
@@ -0,0 +1,254 @@
+
+import bpy
+
+# ********** default tools for objectmode ****************
+
+class View3DPanel(bpy.types.Panel):
+       __space_type__ = "VIEW_3D"
+       __region_type__ = "TOOLS"
+       __context__ = "objectmode"
+
+class VIEW3D_PT_tools_objectmode(View3DPanel):
+       __idname__ = "VIEW3D_PT_tools_objectmode"
+       __label__ = "Object Tools"
+
+       def draw(self, context):
+               layout = self.layout
+
+               layout.row().itemO("OBJECT_OT_duplicate_add")
+               layout.row().itemO("OBJECT_OT_delete")
+               layout.row().itemO("OBJECT_OT_mesh_add")
+               layout.row().itemO("OBJECT_OT_curve_add")
+               layout.row().itemO("OBJECT_OT_text_add")
+               layout.row().itemO("OBJECT_OT_surface_add")
+
+# ********** default tools for editmode_mesh ****************
+
+class View3DPanel(bpy.types.Panel):
+       __space_type__ = "VIEW_3D"
+       __region_type__ = "TOOLS"
+       __context__ = "editmode_mesh"
+
+class VIEW3D_PT_tools_editmode_mesh(View3DPanel):
+       __idname__ = "VIEW3D_PT_tools_editmode_mesh"
+       __label__ = "Mesh Tools"
+
+       def draw(self, context):
+               layout = self.layout
+
+               layout.row().itemO("MESH_OT_duplicate_add")
+               layout.row().itemO("MESH_OT_delete")
+               layout.row().itemO("MESH_OT_spin")
+               layout.row().itemO("MESH_OT_screw")
+               layout.row().itemO("MESH_OT_primitive_plane_add")
+               layout.row().itemO("MESH_OT_primitive_cube_add")
+               layout.row().itemO("MESH_OT_primitive_circle_add")
+               layout.row().itemO("MESH_OT_primitive_cylinder_add")
+
+# ********** default tools for editmode_curve ****************
+
+class View3DPanel(bpy.types.Panel):
+       __space_type__ = "VIEW_3D"
+       __region_type__ = "TOOLS"
+       __context__ = "editmode_curve"
+
+class VIEW3D_PT_tools_editmode_curve(View3DPanel):
+       __idname__ = "VIEW3D_PT_tools_editmode_curve"
+       __label__ = "Curve Tools"
+
+       def draw(self, context):
+               layout = self.layout
+
+               layout.row().itemO("CURVE_OT_duplicate")
+               layout.row().itemO("CURVE_OT_delete")
+               layout.row().itemO("OBJECT_OT_curve_add")
+               layout.row().itemO("CURVE_OT_subdivide")
+
+# ********** default tools for editmode_surface ****************
+
+class View3DPanel(bpy.types.Panel):
+       __space_type__ = "VIEW_3D"
+       __region_type__ = "TOOLS"
+       __context__ = "editmode_surface"
+
+class VIEW3D_PT_tools_editmode_surface(View3DPanel):
+       __idname__ = "VIEW3D_PT_tools_editmode_surface"
+       __label__ = "Surface Tools"
+
+       def draw(self, context):
+               layout = self.layout
+
+               layout.row().itemO("CURVE_OT_duplicate")
+               layout.row().itemO("CURVE_OT_delete")
+               layout.row().itemO("OBJECT_OT_surface_add")
+               layout.row().itemO("CURVE_OT_subdivide")
+
+# ********** default tools for editmode_text ****************
+
+class View3DPanel(bpy.types.Panel):
+       __space_type__ = "VIEW_3D"
+       __region_type__ = "TOOLS"
+       __context__ = "editmode_text"
+
+class VIEW3D_PT_tools_editmode_text(View3DPanel):
+       __idname__ = "VIEW3D_PT_tools_editmode_text"
+       __label__ = "Text Tools"
+
+       def draw(self, context):
+               layout = self.layout
+
+               layout.row().itemO("FONT_OT_text_copy")
+               layout.row().itemO("FONT_OT_text_paste")
+               layout.row().itemO("FONT_OT_case_set")
+               layout.row().itemO("FONT_OT_style_toggle")
+
+# ********** default tools for editmode_armature ****************
+
+class View3DPanel(bpy.types.Panel):
+       __space_type__ = "VIEW_3D"
+       __region_type__ = "TOOLS"
+       __context__ = "editmode_armature"
+
+class VIEW3D_PT_tools_editmode_armature(View3DPanel):
+       __idname__ = "VIEW3D_PT_tools_editmode_armature"
+       __label__ = "Armature Tools"
+
+       def draw(self, context):
+               layout = self.layout
+
+               layout.row().itemO("ARMATURE_OT_duplicate_selected")
+               layout.row().itemO("ARMATURE_OT_bone_primitive_add")
+               layout.row().itemO("ARMATURE_OT_delete")
+               layout.row().itemO("ARMATURE_OT_parent_clear")
+
+# ********** default tools for editmode_mball ****************
+
+class View3DPanel(bpy.types.Panel):
+       __space_type__ = "VIEW_3D"
+       __region_type__ = "TOOLS"
+       __context__ = "editmode_mball"
+
+class VIEW3D_PT_tools_editmode_mball(View3DPanel):
+       __idname__ = "VIEW3D_PT_tools_editmode_mball"
+       __label__ = "Meta Tools"
+
+       def draw(self, context):
+               layout = self.layout
+
+               row = layout.row()
+
+# ********** default tools for editmode_lattice ****************
+
+class View3DPanel(bpy.types.Panel):
+       __space_type__ = "VIEW_3D"
+       __region_type__ = "TOOLS"
+       __context__ = "editmode_lattice"
+
+class VIEW3D_PT_tools_editmode_lattice(View3DPanel):
+       __idname__ = "VIEW3D_PT_tools_editmode_lattice"
+       __label__ = "Lattice Tools"
+
+       def draw(self, context):
+               layout = self.layout
+
+               row = layout.row()
+
+# ********** default tools for posemode ****************
+
+class View3DPanel(bpy.types.Panel):
+       __space_type__ = "VIEW_3D"
+       __region_type__ = "TOOLS"
+       __context__ = "posemode"
+
+class VIEW3D_PT_tools_posemode(View3DPanel):
+       __idname__ = "VIEW3D_PT_tools_posemode"
+       __label__ = "Pose Tools"
+
+       def draw(self, context):
+               layout = self.layout
+
+               layout.row().itemO("POSE_OT_hide")
+               layout.row().itemO("POSE_OT_reveal")
+               layout.row().itemO("POSE_OT_rot_clear")
+               layout.row().itemO("POSE_OT_loc_clear")
+
+# ********** default tools for sculptmode ****************
+
+class View3DPanel(bpy.types.Panel):
+       __space_type__ = "VIEW_3D"
+       __region_type__ = "TOOLS"
+       __context__ = "sculptmode"
+
+class VIEW3D_PT_tools_sculptmode(View3DPanel):
+       __idname__ = "VIEW3D_PT_tools_sculptmode"
+       __label__ = "Sculpt Tools"
+
+       def draw(self, context):
+               layout = self.layout
+
+               layout.row().itemO("SCULPT_OT_radial_control")
+
+# ********** default tools for weightpaint ****************
+
+class View3DPanel(bpy.types.Panel):
+       __space_type__ = "VIEW_3D"
+       __region_type__ = "TOOLS"
+       __context__ = "weightpaint"
+
+class VIEW3D_PT_tools_weightpaint(View3DPanel):
+       __idname__ = "VIEW3D_PT_tools_weightpaint"
+       __label__ = "Weight Paint Tools"
+
+       def draw(self, context):
+               layout = self.layout
+
+               layout.row().itemO("PAINT_OT_weight_paint_radial_control")
+
+# ********** default tools for vertexpaint ****************
+
+class View3DPanel(bpy.types.Panel):
+       __space_type__ = "VIEW_3D"
+       __region_type__ = "TOOLS"
+       __context__ = "vertexpaint"
+
+class VIEW3D_PT_tools_vertexpaint(View3DPanel):
+       __idname__ = "VIEW3D_PT_tools_vertexpaint"
+       __label__ = "Vertex Paint Tools"
+
+       def draw(self, context):
+               layout = self.layout
+
+               layout.row().itemO("PAINT_OT_vertex_paint_radial_control")
+
+# ********** default tools for texturepaint ****************
+
+class View3DPanel(bpy.types.Panel):
+       __space_type__ = "VIEW_3D"
+       __region_type__ = "TOOLS"
+       __context__ = "texturepaint"
+
+class VIEW3D_PT_tools_texturepaint(View3DPanel):
+       __idname__ = "VIEW3D_PT_tools_texturepaint"
+       __label__ = "Texture Paint Tools"
+
+       def draw(self, context):
+               layout = self.layout
+
+               layout.row().itemO("PAINT_OT_texture_paint_radial_control")
+
+
+bpy.types.register(VIEW3D_PT_tools_objectmode)
+bpy.types.register(VIEW3D_PT_tools_editmode_mesh)
+bpy.types.register(VIEW3D_PT_tools_editmode_curve)
+bpy.types.register(VIEW3D_PT_tools_editmode_surface)
+bpy.types.register(VIEW3D_PT_tools_editmode_text)
+bpy.types.register(VIEW3D_PT_tools_editmode_armature)
+bpy.types.register(VIEW3D_PT_tools_editmode_mball)
+bpy.types.register(VIEW3D_PT_tools_editmode_lattice)
+bpy.types.register(VIEW3D_PT_tools_posemode)
+bpy.types.register(VIEW3D_PT_tools_sculptmode)
+bpy.types.register(VIEW3D_PT_tools_weightpaint)
+bpy.types.register(VIEW3D_PT_tools_vertexpaint)
+bpy.types.register(VIEW3D_PT_tools_texturepaint)
+
+
index 2ee31a17fa658a411da7c873c85ddc910233b42c..c373fde5693f7d6a9228a300b32f0ae20c8a46f3 100644 (file)
@@ -78,6 +78,11 @@ float BLF_height(char *str);
 float BLF_width_default(char *str);
 float BLF_height_default(char *str);
 
+/*
+ * set rotation for default font
+ */
+void BLF_default_rotation(float angle);
+
 /*
  * By default, rotation and clipping are disable and
  * have to be enable/disable using BLF_enable/disable.
index 9dad5a4bfa06fb9b567cf4b218c5d00e7d4f2de8..a7e599fabf9c0f813d56c36dee87b4db57513adf 100644 (file)
@@ -321,6 +321,19 @@ void BLF_draw_default(float x, float y, float z, char *str)
        }
 }
 
+void BLF_default_rotation(float angle)
+{
+       
+       if (global_font_default>=0) {
+               global_font[global_font_default]->angle= angle;
+               if(angle)
+                       global_font[global_font_default]->flags |= BLF_ROTATION;
+               else
+                       global_font[global_font_default]->flags &= ~BLF_ROTATION;
+       }
+}
+
+
 void BLF_draw(char *str)
 {
        FontBLF *font;
index fd065978800fe03ed404f28d3b1637b9978a0694..e21e83bf5cf3aa63311d0b9964019a48f479b954 100644 (file)
@@ -41,6 +41,8 @@ struct Particle;
 struct Group;
 struct RNG;
 
+struct PartDeflect *object_add_collision_fields(void);
+
 typedef struct pEffectorCache {
        struct pEffectorCache *next, *prev;
        Object *ob;
index 93358fcf7e89f189530acaf880a3cbdd8ec410ec..145ae48e7324697c4b11a8c4331ed8391d1fa988 100644 (file)
@@ -1,6 +1,5 @@
 /**
- * BKE_fluidsim.h
- * 
+ * $Id$
  *
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * ***** END GPL LICENSE BLOCK *****
  */
 
-#include "DNA_modifier_types.h"
-#include "DNA_object_fluidsim.h" // N_T
-#include "DNA_object_types.h"
+#ifndef BKE_FLUIDSIM_H
+#define BKE_FLUIDSIM_H
 
-#include "BKE_DerivedMesh.h"
+struct Object;
+struct Scene;
+struct FluidsimModifierData;
+struct DerivedMesh;
+struct MVert;
 
 /* old interface */
-FluidsimSettings *fluidsimSettingsNew(Object *srcob);
-
-void initElbeemMesh(Scene *scene, Object *ob, int *numVertices, float **vertices, int *numTriangles, int **triangles, int useGlobalCoords, int modifierIndex);
+struct FluidsimSettings *fluidsimSettingsNew(struct Object *srcob);
 
+void initElbeemMesh(struct Scene *scene, struct Object *ob,
+       int *numVertices, float **vertices,
+       int *numTriangles, int **triangles,
+       int useGlobalCoords, int modifierIndex);
 
 /* new fluid-modifier interface */
-void fluidsim_init(FluidsimModifierData *fluidmd);
-void fluidsim_free(FluidsimModifierData *fluidmd);
+void fluidsim_init(struct FluidsimModifierData *fluidmd);
+void fluidsim_free(struct FluidsimModifierData *fluidmd);
 
-DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, FluidsimModifierData *fluidmd, int framenr, int useRenderParams);
-void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, DerivedMesh *dm, char *filename);
-DerivedMesh *fluidsimModifier_do(FluidsimModifierData *fluidmd, Scene *scene, Object *ob, DerivedMesh *dm, int useRenderParams, int isFinalCalc);
+struct DerivedMesh *fluidsim_read_cache(struct Object *ob, struct DerivedMesh *orgdm,
+       struct FluidsimModifierData *fluidmd, int framenr, int useRenderParams);
+void fluidsim_read_vel_cache(struct FluidsimModifierData *fluidmd, struct DerivedMesh *dm,
+       char *filename);
+struct DerivedMesh *fluidsimModifier_do(struct FluidsimModifierData *fluidmd,
+       struct Scene *scene, struct Object *ob, struct DerivedMesh *dm,
+       int useRenderParams, int isFinalCalc);
 
-// get bounding box of mesh
-void fluid_get_bb(MVert *mvert, int totvert, float obmat[][4],
-                /*RET*/ float start[3], /*RET*/ float size[3] );
+/* bounding box & memory estimate */
+void fluid_get_bb(struct MVert *mvert, int totvert, float obmat[][4],
+                float start[3], float size[3]);
 
+void fluid_estimate_memory(struct Object *ob, struct FluidsimSettings *fss, char *value);
 
+#endif
 
index 4065cbb70075f18b45d3f6eedd12c52772053bc5..144ed3bc624ecaf67ccc90656aae0aee3da15736 100644 (file)
@@ -62,7 +62,7 @@ typedef enum {
         * used for particles modifier that doesn't actually modify the object
         * unless it's a mesh and can be exploded -> curve can also emit particles
         */
-       eModifierTypeType_DeformOrConstruct
+       eModifierTypeType_DeformOrConstruct,
 } ModifierTypeType;
 
 typedef enum {
@@ -87,6 +87,9 @@ typedef enum {
        /* For modifiers that support pointcache, so we can check to see if it has files we need to deal with
        */
        eModifierTypeFlag_UsesPointCache = (1<<6),
+
+       /* For physics modifiers, max one per type */
+       eModifierTypeFlag_Single = (1<<7)
 } ModifierTypeFlag;
 
 typedef void (*ObjectWalkFunc)(void *userData, struct Object *ob, struct Object **obpoin);
index 73f0195d1d87a16f5c2212d9cc1615c8cc87e990..aa24706077d5b6324b34b22c491b613b0a1b6546 100644 (file)
@@ -91,7 +91,8 @@ typedef struct ParticleTexture{
        float ivel;                                                     /* used in reset */
        float time, life, exist, size;          /* used in init */
        float pvel[3];                                          /* used in physics */
-       float length, clump, kink, rough;       /* used in path caching */
+       float length, clump, kink, effector;/* used in path caching */
+       float rough1, rough2, roughe;           /* used in path caching */
 } ParticleTexture;
 
 typedef struct BoidVecFunc{
@@ -270,7 +271,7 @@ void psys_update_world_cos(struct Object *ob, struct ParticleSystem *psys);
 int do_guide(struct Scene *scene, struct ParticleKey *state, int pa_num, float time, struct ListBase *lb);
 float psys_get_size(struct Object *ob, struct Material *ma, struct ParticleSystemModifierData *psmd, struct IpoCurve *icu_size, struct ParticleSystem *psys, struct ParticleSettings *part, struct ParticleData *pa, float *vg_size);
 float psys_get_timestep(struct ParticleSettings *part);
-float psys_get_child_time(struct ParticleSystem *psys, struct ChildParticle *cpa, float cfra);
+float psys_get_child_time(struct ParticleSystem *psys, struct ChildParticle *cpa, float cfra, float *birthtime, float *dietime);
 float psys_get_child_size(struct ParticleSystem *psys, struct ChildParticle *cpa, float cfra, float *pa_time);
 void psys_get_particle_on_path(struct Scene *scene, struct Object *ob, struct ParticleSystem *psys, int pa_num, struct ParticleKey *state, int vel);
 int psys_get_particle_state(struct Scene *scene, struct Object *ob, struct ParticleSystem *psys, int p, struct ParticleKey *state, int always);
index 3f1c45d28ecc932353c7e06f4da88785aadf617f..c5d423c13baf1488e5406a566121433ce288d150 100644 (file)
@@ -114,6 +114,7 @@ typedef struct PTCacheBaker {
        struct Scene *scene;
        int bake;
        int render;
+       int anim_init;
        int quick_step;
        struct PTCacheID *pid;
        int (*break_test)(void *data);
index 750f4fba7e64f2ef125b829d2b8f81437e763332..be625fb856aaeab843ec2531c29cbf2197456c91 100644 (file)
@@ -91,6 +91,9 @@ typedef struct SpaceType {
        /* region type definitions */
        ListBase        regiontypes;
        
+       /* tool shelf definitions */
+       ListBase toolshelf;
+       
        /* read and write... */
        
        /* default keymaps to add */
@@ -139,7 +142,7 @@ typedef struct ARegionType {
 
        /* menu type definitions */
        ListBase menutypes;
-
+       
        /* hardcoded constraints, smaller than these values region is not visible */
        int                     minsizex, minsizey;
        /* default keymaps to add */
index 1aceca454d2b23925a125227772c46dd55642928..6c1b8eb9000cb192e7954bec3aedf235a47b7bcf 100644 (file)
@@ -786,8 +786,9 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
        BLI_srandom(31415926 + psys->seed);
        
        lay= scene->lay;
-       if((part->draw_as == PART_DRAW_OB && part->dup_ob) ||
-               (part->draw_as == PART_DRAW_GR && part->dup_group && part->dup_group->gobject.first)) {
+       if((psys->renderdata || part->draw_as==PART_DRAW_REND) &&
+               ((part->ren_as == PART_DRAW_OB && part->dup_ob) ||
+               (part->ren_as == PART_DRAW_GR && part->dup_group && part->dup_group->gobject.first))) {
 
                /* if we have a hair particle system, use the path cache */
                if(part->type == PART_HAIR) {
@@ -804,7 +805,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
                psys->lattice = psys_get_lattice(scene, par, psys);
 
                /* gather list of objects or single object */
-               if(part->draw_as==PART_DRAW_GR) {
+               if(part->ren_as==PART_DRAW_GR) {
                        group_handle_recalc_and_update(scene, par, part->dup_group);
 
                        for(go=part->dup_group->gobject.first; go; go=go->next)
@@ -850,7 +851,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
                                size = psys_get_child_size(psys, cpa, ctime, 0);
                        }
 
-                       if(part->draw_as==PART_DRAW_GR) {
+                       if(part->ren_as==PART_DRAW_GR) {
                                /* for groups, pick the object based on settings */
                                if(part->draw&PART_DRAW_RAND_GR)
                                        b= BLI_rand() % totgroup;
@@ -894,7 +895,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
                                pamat[3][3]= 1.0f;
                        }
 
-                       if(part->draw_as==PART_DRAW_GR && psys->part->draw & PART_DRAW_WHOLE_GR) {
+                       if(part->ren_as==PART_DRAW_GR && psys->part->draw & PART_DRAW_WHOLE_GR) {
                                for(go= part->dup_group->gobject.first, b=0; go; go= go->next, b++) {
                                        Mat4MulMat4(tmat, oblist[b]->obmat, pamat);
                                        Mat4MulFloat3((float *)tmat, size*scale);
@@ -930,7 +931,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
                }
 
                /* restore objects since they were changed in where_is_object_time */
-               if(part->draw_as==PART_DRAW_GR) {
+               if(part->ren_as==PART_DRAW_GR) {
                        for(a=0; a<totgroup; a++)
                                *(oblist[a])= obcopylist[a];
                }
index fbad585d9b7409171d0ff1971f2d7da4939db64c..4a68d90a4ed8e093f9248ecacb4280ad73ba95db 100644 (file)
@@ -378,7 +378,7 @@ PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, Stru
 {
        PointerRNA ptr = CTX_data_pointer_get(C, member);
 
-       if(ptr.data && ptr.type == type)
+       if(ptr.data && RNA_struct_is_a(ptr.type, type))
                return ptr;
        
        return PointerRNA_NULL;
index a36b825293e2793398940139394a324cb22d74fa..de036e25d828f0e76ab7a5ff14e48562a2ca1887 100644 (file)
@@ -568,14 +568,14 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
                                dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA, "Particle Keyed Physics");
                        }
 
-                       if(part->draw_as == PART_DRAW_OB && part->dup_ob) {
+                       if(part->ren_as == PART_DRAW_OB && part->dup_ob) {
                                node2 = dag_get_node(dag, part->dup_ob);
                                dag_add_relation(dag, node, node2, DAG_RL_OB_OB, "Particle Object Visualisation");
                                if(part->dup_ob->type == OB_MBALL)
                                        dag_add_relation(dag, node, node2, DAG_RL_DATA_DATA, "Particle Object Visualisation");
                        }
 
-                       if(part->draw_as == PART_DRAW_GR && part->dup_group) {
+                       if(part->ren_as == PART_DRAW_GR && part->dup_group) {
                                for(go=part->dup_group->gobject.first; go; go=go->next) {
                                        node2 = dag_get_node(dag, go->ob);
                                        dag_add_relation(dag, node, node2, DAG_RL_OB_OB, "Particle Group Visualisation");
index eaa2d541638a87d4ee9c2b9e4b18444f0e5897b4..553fdfe530e3375afe0e8e964c5d1c7f16097c4e 100644 (file)
@@ -56,6 +56,8 @@
 #include "BLI_jitter.h"
 #include "BLI_rand.h"
 
+#include "PIL_time.h"
+
 #include "BKE_action.h"
 #include "BKE_anim.h"          /* needed for where_on_path */
 #include "BKE_armature.h"
 
 //XXX #include "BIF_screen.h"
 
+PartDeflect *object_add_collision_fields(void)
+{
+       PartDeflect *pd;
+
+       pd= MEM_callocN(sizeof(PartDeflect), "PartDeflect");
+
+       pd->pdef_sbdamp = 0.1f;
+       pd->pdef_sbift  = 0.2f;
+       pd->pdef_sboft  = 0.02f;
+       pd->seed = ((unsigned int)(ceil(PIL_check_seconds_timer()))+1) % 128;
+
+       return pd;
+}
+
 /* temporal struct, used for reading return of mesh_get_mapped_verts_nors() */
 
 typedef struct VeNoCo {
index 54008185f724046050901e57330c97e3b92185e0..2b4032af5037168093be04a5bc50dc45b955b5cc 100644 (file)
@@ -34,7 +34,9 @@
 
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
+#include "DNA_object_fluidsim.h"
 #include "DNA_object_force.h" // for pointcache 
+#include "DNA_object_types.h"
 #include "DNA_particle_types.h"
 #include "DNA_scene_types.h" // N_T
 
@@ -78,7 +80,7 @@ void fluidsim_init(FluidsimModifierData *fluidmd)
                if(!fss)
                        return;
                
-               fss->type = OB_FSBND_NOSLIP;
+               fss->type = OB_FLUIDSIM_ENABLE;
                fss->show_advancedoptions = 0;
 
                fss->resolutionxyz = 50;
@@ -112,7 +114,7 @@ void fluidsim_init(FluidsimModifierData *fluidmd)
                // no bounding box needed
                
                // todo - reuse default init from elbeem!
-               fss->typeFlags = 0;
+               fss->typeFlags = OB_FSBND_NOSLIP;
                fss->domainNovecgen = 0;
                fss->volumeInitType = 1; // volume
                fss->partSlipValue = 0.0;
@@ -657,5 +659,20 @@ void initElbeemMesh(struct Scene *scene, struct Object *ob,
        dm->release(dm);
 }
 
+void fluid_estimate_memory(Object *ob, FluidsimSettings *fss, char *value)
+{
+       Mesh *mesh;
+
+       value[0]= '\0';
+
+       if(ob->type == OB_MESH) {
+               /* use mesh bounding box and object scaling */
+               mesh= ob->data;
+
+               fluid_get_bb(mesh->mvert, mesh->totvert, ob->obmat, fss->bbStart, fss->bbSize);
+               elbeemEstimateMemreq(fss->resolutionxyz, fss->bbSize[0],fss->bbSize[1],fss->bbSize[2], fss->maxRefine, value);
+       }
+}
+
 #endif // DISABLE_ELBEEM
 
index 5cf52d093147466df98793812958ff4cee993151..67d63d527cbc606eea12eb8b84386a9fed65e0ab 100644 (file)
@@ -232,8 +232,8 @@ void free_lattice(Lattice *lt)
        if(lt->def) MEM_freeN(lt->def);
        if(lt->dvert) free_dverts(lt->dvert, lt->pntsu*lt->pntsv*lt->pntsw);
        if(lt->editlatt) {
-               if(lt->def) MEM_freeN(lt->def);
-               if(lt->dvert) free_dverts(lt->dvert, lt->pntsu*lt->pntsv*lt->pntsw);
+               if(lt->editlatt->def) MEM_freeN(lt->editlatt->def);
+               if(lt->editlatt->dvert) free_dverts(lt->editlatt->dvert, lt->pntsu*lt->pntsv*lt->pntsw);
                MEM_freeN(lt->editlatt);
        }
 }
@@ -817,59 +817,68 @@ void outside_lattice(Lattice *lt)
        int u, v, w;
        float fac1, du=0.0, dv=0.0, dw=0.0;
 
-       bp= lt->def;
+       if(lt->flag & LT_OUTSIDE) {
+               bp= lt->def;
 
-       if(lt->pntsu>1) du= 1.0f/((float)lt->pntsu-1);
-       if(lt->pntsv>1) dv= 1.0f/((float)lt->pntsv-1);
-       if(lt->pntsw>1) dw= 1.0f/((float)lt->pntsw-1);
-               
-       for(w=0; w<lt->pntsw; w++) {
-               
-               for(v=0; v<lt->pntsv; v++) {
-               
-                       for(u=0; u<lt->pntsu; u++, bp++) {
-                               if(u==0 || v==0 || w==0 || u==lt->pntsu-1 || v==lt->pntsv-1 || w==lt->pntsw-1);
-                               else {
-                               
-                                       bp->hide= 1;
-                                       bp->f1 &= ~SELECT;
-                                       
-                                       /* u extrema */
-                                       bp1= latt_bp(lt, 0, v, w);
-                                       bp2= latt_bp(lt, lt->pntsu-1, v, w);
-                                       
-                                       fac1= du*u;
-                                       bp->vec[0]= (1.0f-fac1)*bp1->vec[0] + fac1*bp2->vec[0];
-                                       bp->vec[1]= (1.0f-fac1)*bp1->vec[1] + fac1*bp2->vec[1];
-                                       bp->vec[2]= (1.0f-fac1)*bp1->vec[2] + fac1*bp2->vec[2];
-                                       
-                                       /* v extrema */
-                                       bp1= latt_bp(lt, u, 0, w);
-                                       bp2= latt_bp(lt, u, lt->pntsv-1, w);
-                                       
-                                       fac1= dv*v;
-                                       bp->vec[0]+= (1.0f-fac1)*bp1->vec[0] + fac1*bp2->vec[0];
-                                       bp->vec[1]+= (1.0f-fac1)*bp1->vec[1] + fac1*bp2->vec[1];
-                                       bp->vec[2]+= (1.0f-fac1)*bp1->vec[2] + fac1*bp2->vec[2];
-                                       
-                                       /* w extrema */
-                                       bp1= latt_bp(lt, u, v, 0);
-                                       bp2= latt_bp(lt, u, v, lt->pntsw-1);
-                                       
-                                       fac1= dw*w;
-                                       bp->vec[0]+= (1.0f-fac1)*bp1->vec[0] + fac1*bp2->vec[0];
-                                       bp->vec[1]+= (1.0f-fac1)*bp1->vec[1] + fac1*bp2->vec[1];
-                                       bp->vec[2]+= (1.0f-fac1)*bp1->vec[2] + fac1*bp2->vec[2];
-                                       
-                                       VecMulf(bp->vec, 0.3333333f);
+               if(lt->pntsu>1) du= 1.0f/((float)lt->pntsu-1);
+               if(lt->pntsv>1) dv= 1.0f/((float)lt->pntsv-1);
+               if(lt->pntsw>1) dw= 1.0f/((float)lt->pntsw-1);
+                       
+               for(w=0; w<lt->pntsw; w++) {
+                       
+                       for(v=0; v<lt->pntsv; v++) {
+                       
+                               for(u=0; u<lt->pntsu; u++, bp++) {
+                                       if(u==0 || v==0 || w==0 || u==lt->pntsu-1 || v==lt->pntsv-1 || w==lt->pntsw-1);
+                                       else {
                                        
+                                               bp->hide= 1;
+                                               bp->f1 &= ~SELECT;
+                                               
+                                               /* u extrema */
+                                               bp1= latt_bp(lt, 0, v, w);
+                                               bp2= latt_bp(lt, lt->pntsu-1, v, w);
+                                               
+                                               fac1= du*u;
+                                               bp->vec[0]= (1.0f-fac1)*bp1->vec[0] + fac1*bp2->vec[0];
+                                               bp->vec[1]= (1.0f-fac1)*bp1->vec[1] + fac1*bp2->vec[1];
+                                               bp->vec[2]= (1.0f-fac1)*bp1->vec[2] + fac1*bp2->vec[2];
+                                               
+                                               /* v extrema */
+                                               bp1= latt_bp(lt, u, 0, w);
+                                               bp2= latt_bp(lt, u, lt->pntsv-1, w);
+                                               
+                                               fac1= dv*v;
+                                               bp->vec[0]+= (1.0f-fac1)*bp1->vec[0] + fac1*bp2->vec[0];
+                                               bp->vec[1]+= (1.0f-fac1)*bp1->vec[1] + fac1*bp2->vec[1];
+                                               bp->vec[2]+= (1.0f-fac1)*bp1->vec[2] + fac1*bp2->vec[2];
+                                               
+                                               /* w extrema */
+                                               bp1= latt_bp(lt, u, v, 0);
+                                               bp2= latt_bp(lt, u, v, lt->pntsw-1);
+                                               
+                                               fac1= dw*w;
+                                               bp->vec[0]+= (1.0f-fac1)*bp1->vec[0] + fac1*bp2->vec[0];
+                                               bp->vec[1]+= (1.0f-fac1)*bp1->vec[1] + fac1*bp2->vec[1];
+                                               bp->vec[2]+= (1.0f-fac1)*bp1->vec[2] + fac1*bp2->vec[2];
+                                               
+                                               VecMulf(bp->vec, 0.3333333f);
+                                               
+                                       }
                                }
+                               
                        }
                        
                }
-               
        }
-       
+       else {
+               bp= lt->def;
+
+               for(w=0; w<lt->pntsw; w++)
+                       for(v=0; v<lt->pntsv; v++)
+                               for(u=0; u<lt->pntsu; u++, bp++)
+                                       bp->hide= 0;
+       }
 }
 
 float (*lattice_getVertexCos(struct Object *ob, int *numVerts_r))[3]
index 80a9f173d6ac119b23c9d0918fc9e670f5d41e90..046dfcc9f87d847077556b6953396674be73197d 100644 (file)
@@ -63,6 +63,7 @@
 #include "DNA_meshdata_types.h"
 #include "DNA_modifier_types.h"
 #include "DNA_object_types.h"
+#include "DNA_object_fluidsim.h"
 #include "DNA_object_force.h"
 #include "DNA_particle_types.h"
 #include "DNA_scene_types.h"
@@ -6389,6 +6390,7 @@ static void particleSystemModifier_deformVerts(
                  }
 
                  if(psys){
+                         psmd->flag &= ~eParticleSystemFlag_psys_updated;
                          particle_system_update(md->scene, ob, psys);
                          psmd->flag |= eParticleSystemFlag_psys_updated;
                          psmd->flag &= ~eParticleSystemFlag_DM_changed;
@@ -6420,6 +6422,8 @@ static void particleInstanceModifier_initData(ModifierData *md)
        pimd->flag = eParticleInstanceFlag_Parents|eParticleInstanceFlag_Unborn|
                        eParticleInstanceFlag_Alive|eParticleInstanceFlag_Dead;
        pimd->psys = 1;
+       pimd->position = 1.0f;
+       pimd->axis = 2;
 
 }
 static void particleInstanceModifier_copyData(ModifierData *md, ModifierData *target)
@@ -6430,6 +6434,8 @@ static void particleInstanceModifier_copyData(ModifierData *md, ModifierData *ta
        tpimd->ob = pimd->ob;
        tpimd->psys = pimd->psys;
        tpimd->flag = pimd->flag;
+       tpimd->position = pimd->position;
+       tpimd->random_position = pimd->random_position;
 }
 
 static int particleInstanceModifier_dependsOnTime(ModifierData *md) 
@@ -6469,8 +6475,9 @@ static DerivedMesh * particleInstanceModifier_applyModifier(
        MFace *mface, *orig_mface;
        MVert *mvert, *orig_mvert;
        int i,totvert, totpart=0, totface, maxvert, maxface, first_particle=0;
-       short track=ob->trackflag%3, trackneg;
+       short track=ob->trackflag%3, trackneg, axis = pimd->axis;
        float max_co=0.0, min_co=0.0, temp_co[3], cross[3];
+       float *size=NULL;
 
        trackneg=((ob->trackflag>2)?1:0);
 
@@ -6497,6 +6504,25 @@ static DerivedMesh * particleInstanceModifier_applyModifier(
        if(totpart==0)
                return derivedData;
 
+       if(pimd->flag & eParticleInstanceFlag_UseSize) {
+               int p;
+               float *si;
+               si = size = MEM_callocN(totpart * sizeof(float), "particle size array");
+
+               if(pimd->flag & eParticleInstanceFlag_Parents) {
+                       for(p=0, pa= psys->particles; p<psys->totpart; p++, pa++, si++)
+                               *si = pa->size;
+               }
+
+               if(pimd->flag & eParticleInstanceFlag_Children) {
+                       ChildParticle *cpa = psys->child;
+
+                       for(p=0; p<psys->totchild; p++, cpa++, si++) {
+                               *si = psys_get_child_size(psys, cpa, 0.0f, NULL);
+                       }
+               }
+       }
+
        pars=psys->particles;
 
        totvert=dm->getNumVerts(dm);
@@ -6507,7 +6533,7 @@ static DerivedMesh * particleInstanceModifier_applyModifier(
 
        psys->lattice=psys_get_lattice(md->scene, ob, psys);
 
-       if(psys->flag & (PSYS_HAIR_DONE|PSYS_KEYED)){
+       if(psys->flag & (PSYS_HAIR_DONE|PSYS_KEYED) || psys->pointcache->flag & PTCACHE_BAKED){
 
                float min_r[3], max_r[3];
                INIT_MINMAX(min_r, max_r);
@@ -6532,40 +6558,59 @@ static DerivedMesh * particleInstanceModifier_applyModifier(
 
                /*change orientation based on object trackflag*/
                VECCOPY(temp_co,mv->co);
-               mv->co[0]=temp_co[track];
-               mv->co[1]=temp_co[(track+1)%3];
-               mv->co[2]=temp_co[(track+2)%3];
-
-               if(psys->flag & (PSYS_HAIR_DONE|PSYS_KEYED) && pimd->flag & eParticleInstanceFlag_Path){
-                       state.time=(mv->co[0]-min_co)/(max_co-min_co);
-                       if(trackneg)
-                               state.time=1.0f-state.time;
-                       psys_get_particle_on_path(md->scene, pimd->ob, psys,first_particle + i/totvert, &state,1);
+               mv->co[axis]=temp_co[track];
+               mv->co[(axis+1)%3]=temp_co[(track+1)%3];
+               mv->co[(axis+2)%3]=temp_co[(track+2)%3];
+
+               if((psys->flag & (PSYS_HAIR_DONE|PSYS_KEYED) || psys->pointcache->flag & PTCACHE_BAKED) && pimd->flag & eParticleInstanceFlag_Path){
+                       float ran = 0.0f;
+                       if(pimd->random_position != 0.0f) {
+                               /* just use some static collection of random numbers */
+                               /* TODO: use something else that's unique to each instanced object */
+                               pa = psys->particles + (i/totvert)%totpart;
+                               ran = pimd->random_position * 0.5 * (1.0f + pa->r_ave[0]);
+                       }
+
+                       if(pimd->flag & eParticleInstanceFlag_KeepShape) {
+                               state.time = pimd->position * (1.0f - ran);
+                       }
+                       else {
+                               state.time=(mv->co[axis]-min_co)/(max_co-min_co) * pimd->position * (1.0f - ran);
+
+                               if(trackneg)
+                                       state.time=1.0f-state.time;
+                               
+                               mv->co[axis] = 0.0;
+                       }
 
-                       mv->co[0] = 0.0;
+                       psys_get_particle_on_path(md->scene, pimd->ob, psys,first_particle + i/totvert, &state,1);
 
                        Normalize(state.vel);
                        
-                       if(state.vel[0] < -0.9999 || state.vel[0] > 0.9999) {
-                               state.rot[0] = 1.0;
+                       /* TODO: incremental rotations somehow */
+                       if(state.vel[axis] < -0.9999 || state.vel[axis] > 0.9999) {
+                               state.rot[0] = 1;
                                state.rot[1] = state.rot[2] = state.rot[3] = 0.0f;
                        }
                        else {
-                               /* a cross product of state.vel and a unit vector in x-direction */
-                               cross[0] = 0.0f;
-                               cross[1] = -state.vel[2];
-                               cross[2] = state.vel[1];
+                               float temp[3] = {0.0f,0.0f,0.0f};
+                               temp[axis] = 1.0f;
+
+                               Crossf(cross, temp, state.vel);
 
-                               /* state.vel[0] is the only component surviving from a dot product with a vector in x-direction*/
-                               VecRotToQuat(cross,saacos(state.vel[0]),state.rot);
+                               /* state.vel[axis] is the only component surviving from a dot product with the axis */
+                               VecRotToQuat(cross,saacos(state.vel[axis]),state.rot);
                        }
+
                }
                else{
                        state.time=-1.0;
-                       psys_get_particle_state(md->scene, pimd->ob, psys, i/totvert, &state,1);
+                       psys_get_particle_state(md->scene, pimd->ob, psys, first_particle + i/totvert, &state,1);
                }       
 
                QuatMulVecf(state.rot,mv->co);
+               if(pimd->flag & eParticleInstanceFlag_UseSize)
+                       VecMulf(mv->co, size[i/totvert]);
                VECADD(mv->co,mv->co,state.co);
        }
 
@@ -6618,6 +6663,9 @@ static DerivedMesh * particleInstanceModifier_applyModifier(
                psys->lattice= NULL;
        }
 
+       if(size)
+               MEM_freeN(size);
+
        return result;
 }
 static DerivedMesh *particleInstanceModifier_applyModifierEM(
@@ -7256,10 +7304,10 @@ static DerivedMesh * explodeModifier_explodeMesh(ExplodeModifierData *emd,
 
        timestep= psys_get_timestep(part);
 
-       if(part->flag & PART_GLOB_TIME)
+       //if(part->flag & PART_GLOB_TIME)
                cfra=bsystem_time(scene, 0,(float)scene->r.cfra,0.0);
-       else
-               cfra=bsystem_time(scene, ob,(float)scene->r.cfra,0.0);
+       //else
+       //      cfra=bsystem_time(scene, ob,(float)scene->r.cfra,0.0);
 
        /* hash table for vertice <-> particle relations */
        vertpahash= BLI_edgehash_new();
@@ -8387,7 +8435,8 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type)
                mti = INIT_TYPE(Softbody);
                mti->type = eModifierTypeType_OnlyDeform;
                mti->flags = eModifierTypeFlag_AcceptsCVs
-                               | eModifierTypeFlag_RequiresOriginalData;
+                               | eModifierTypeFlag_RequiresOriginalData
+                               | eModifierTypeFlag_Single;
                mti->deformVerts = softbodyModifier_deformVerts;
                mti->dependsOnTime = softbodyModifier_dependsOnTime;
        
@@ -8395,7 +8444,8 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type)
                mti->type = eModifierTypeType_Nonconstructive;
                mti->initData = clothModifier_initData;
                mti->flags = eModifierTypeFlag_AcceptsMesh
-                               | eModifierTypeFlag_UsesPointCache;
+                               | eModifierTypeFlag_UsesPointCache
+                               | eModifierTypeFlag_Single;
                mti->dependsOnTime = clothModifier_dependsOnTime;
                mti->freeData = clothModifier_freeData; 
                mti->requiredDataMask = clothModifier_requiredDataMask;
@@ -8406,7 +8456,8 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type)
                mti = INIT_TYPE(Collision);
                mti->type = eModifierTypeType_OnlyDeform;
                mti->initData = collisionModifier_initData;
-               mti->flags = eModifierTypeFlag_AcceptsMesh;
+               mti->flags = eModifierTypeFlag_AcceptsMesh
+                               | eModifierTypeFlag_Single;
                mti->dependsOnTime = collisionModifier_dependsOnTime;
                mti->freeData = collisionModifier_freeData; 
                mti->deformVerts = collisionModifier_deformVerts;
@@ -8489,7 +8540,8 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type)
                
                mti = INIT_TYPE(Fluidsim);
                mti->type = eModifierTypeType_Nonconstructive
-                               | eModifierTypeFlag_RequiresOriginalData;
+                               | eModifierTypeFlag_RequiresOriginalData
+                               | eModifierTypeFlag_Single;
                mti->flags = eModifierTypeFlag_AcceptsMesh;
                mti->initData = fluidsimModifier_initData;
                mti->freeData = fluidsimModifier_freeData;
index 5bf9335d211590cd363201e027f3d6958b77368a..6ab8d72aa6d1ab08c5c055ffcc494f9f9e54937a 100644 (file)
 static void key_from_object(Object *ob, ParticleKey *key);
 static void get_cpa_texture(DerivedMesh *dm, Material *ma, int face_index,
                                float *fuv, float *orco, ParticleTexture *ptex, int event);
+static void get_child_modifier_parameters(ParticleSettings *part, ParticleThreadContext *ctx,
+                               ChildParticle *cpa, short cpa_from, int cpa_num, float *cpa_fuv, float *orco, ParticleTexture *ptex);
+static void do_child_modifiers(Scene *scene, Object *ob, ParticleSystem *psys, ParticleSettings *part,
+                               ParticleTexture *ptex, ParticleKey *par, float *par_rot, ChildParticle *cpa, float *orco, ParticleKey *state, float t);
 
 /* few helpers for countall etc. */
 int count_particles(ParticleSystem *psys){
@@ -452,7 +456,7 @@ void psys_free(Object *ob, ParticleSystem * psys)
                for(tpsys=ob->particlesystem.first; tpsys; tpsys=tpsys->next){
                        if(tpsys->part)
                        {
-                               if(ELEM(tpsys->part->draw_as,PART_DRAW_OB,PART_DRAW_GR))
+                               if(ELEM(tpsys->part->ren_as,PART_DRAW_OB,PART_DRAW_GR))
                                {
                                        nr++;
                                        break;
@@ -491,6 +495,7 @@ typedef struct ParticleRenderData {
        ChildParticle *child;
        ParticleCacheKey **pathcache;
        ParticleCacheKey **childcache;
+       ListBase pathcachebufs, childcachebufs;
        int totchild, totcached, totchildcache;
        DerivedMesh *dm;
        int totdmvert, totdmedge, totdmface;
@@ -577,8 +582,12 @@ void psys_render_set(Object *ob, ParticleSystem *psys, float viewmat[][4], float
        data->child= psys->child;
        data->totchild= psys->totchild;
        data->pathcache= psys->pathcache;
+       data->pathcachebufs.first = psys->pathcachebufs.first;
+       data->pathcachebufs.last = psys->pathcachebufs.last;
        data->totcached= psys->totcached;
        data->childcache= psys->childcache;
+       data->childcachebufs.first = psys->childcachebufs.first;
+       data->childcachebufs.last = psys->childcachebufs.last;
        data->totchildcache= psys->totchildcache;
 
        if(psmd->dm)
@@ -591,6 +600,8 @@ void psys_render_set(Object *ob, ParticleSystem *psys, float viewmat[][4], float
        psys->pathcache= NULL;
        psys->childcache= NULL;
        psys->totchild= psys->totcached= psys->totchildcache= 0;
+       psys->pathcachebufs.first = psys->pathcachebufs.last = NULL;
+       psys->childcachebufs.first = psys->childcachebufs.last = NULL;
 
        Mat4CpyMat4(data->winmat, winmat);
        Mat4MulMat4(data->viewmat, ob->obmat, viewmat);
@@ -631,8 +642,12 @@ void psys_render_restore(Object *ob, ParticleSystem *psys)
        psys->child= data->child;
        psys->totchild= data->totchild;
        psys->pathcache= data->pathcache;
+       psys->pathcachebufs.first = data->pathcachebufs.first;
+       psys->pathcachebufs.last = data->pathcachebufs.last;
        psys->totcached= data->totcached;
        psys->childcache= data->childcache;
+       psys->childcachebufs.first = data->childcachebufs.first;
+       psys->childcachebufs.last = data->childcachebufs.last;
        psys->totchildcache= data->totchildcache;
 
        psmd->dm= data->dm;
@@ -663,7 +678,7 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot)
        int *origindex, *facetotvert;
        int a, b, totorigface, totface, newtot, skipped;
 
-       if(part->draw_as!=PART_DRAW_PATH || !(part->draw & PART_DRAW_REN_STRAND))
+       if(part->ren_as!=PART_DRAW_PATH || !(part->draw & PART_DRAW_REN_STRAND))
                return tot;
        if(!ctx->psys->renderdata)
                return tot;
@@ -1992,11 +2007,9 @@ void psys_thread_create_path(ParticleThread *thread, struct ChildParticle *cpa,
        ParticleData *pa=NULL;
        ParticleTexture ptex;
        float *cpa_fuv=0, *par_rot=0;
-       float co[3], orco[3], ornor[3], t, rough_t, cpa_1st[3], dvec[3];
+       float co[3], orco[3], ornor[3], t, cpa_1st[3], dvec[3];
        float branch_begin, branch_end, branch_prob, branchfac, rough_rand;
-       float pa_rough1, pa_rough2, pa_roughe;
-       float length, pa_length, pa_clump, pa_kink, pa_effector;
-       float max_length = 1.0f, cur_length = 0.0f;
+       float length, max_length = 1.0f, cur_length = 0.0f;
        float eff_length, eff_vec[3];
        int k, cpa_num, guided = 0;
        short cpa_from;
@@ -2059,9 +2072,11 @@ void psys_thread_create_path(ParticleThread *thread, struct ChildParticle *cpa,
 
                psys_particle_on_emitter(ctx->psmd,cpa_from,cpa_num,DMCACHE_ISCHILD,cpa->fuv,foffset,co,ornor,0,0,orco,0);
 
-               /* we need to save the actual root position of the child for positioning it accurately to the surface of the emitter */
-               VECCOPY(cpa_1st,co);
-               Mat4MulVecfl(ob->obmat,cpa_1st);
+               if(part->path_start==0.0f) {
+                       /* we need to save the actual root position of the child for positioning it accurately to the surface of the emitter */
+                       VECCOPY(cpa_1st,co);
+                       Mat4MulVecfl(ob->obmat,cpa_1st);
+               }
 
                pa=0;
        }
@@ -2098,43 +2113,13 @@ void psys_thread_create_path(ParticleThread *thread, struct ChildParticle *cpa,
 #endif // XXX old animation system
 
        /* get different child parameters from textures & vgroups */
-       ptex.length=part->length*(1.0f - part->randlength*cpa->rand[0]);
-       ptex.clump=1.0;
-       ptex.kink=1.0;
-       ptex.rough= 1.0;
-       ptex.exist= 1.0;
-
-       get_cpa_texture(ctx->dm,ctx->ma,cpa_num,cpa_fuv,orco,&ptex,
-               MAP_PA_DENS|MAP_PA_LENGTH|MAP_PA_CLUMP|MAP_PA_KINK|MAP_PA_ROUGH);
-       
-       pa_length=ptex.length;
-       pa_clump=ptex.clump;
-       pa_kink=ptex.kink;
-       pa_rough1=ptex.rough;
-       pa_rough2=ptex.rough;
-       pa_roughe=ptex.rough;
-       pa_effector= 1.0f;
+       get_child_modifier_parameters(part, ctx, cpa, cpa_from, cpa_num, cpa_fuv, orco, &ptex);
 
        if(ptex.exist < cpa->rand[1]) {
                keys->steps = -1;
                return;
        }
 
-       if(ctx->vg_length)
-               pa_length*=psys_interpolate_value_from_verts(ctx->dm,cpa_from,cpa_num,cpa_fuv,ctx->vg_length);
-       if(ctx->vg_clump)
-               pa_clump*=psys_interpolate_value_from_verts(ctx->dm,cpa_from,cpa_num,cpa_fuv,ctx->vg_clump);
-       if(ctx->vg_kink)
-               pa_kink*=psys_interpolate_value_from_verts(ctx->dm,cpa_from,cpa_num,cpa_fuv,ctx->vg_kink);
-       if(ctx->vg_rough1)
-               pa_rough1*=psys_interpolate_value_from_verts(ctx->dm,cpa_from,cpa_num,cpa_fuv,ctx->vg_rough1);
-       if(ctx->vg_rough2)
-               pa_rough2*=psys_interpolate_value_from_verts(ctx->dm,cpa_from,cpa_num,cpa_fuv,ctx->vg_rough2);
-       if(ctx->vg_roughe)
-               pa_roughe*=psys_interpolate_value_from_verts(ctx->dm,cpa_from,cpa_num,cpa_fuv,ctx->vg_roughe);
-       if(ctx->vg_effector)
-               pa_effector*=psys_interpolate_value_from_verts(ctx->dm,cpa_from,cpa_num,cpa_fuv,ctx->vg_effector);
-
        /* create the child path */
        for(k=0,state=keys; k<=ctx->steps; k++,state++){
                if(ctx->between){
@@ -2158,12 +2143,14 @@ void psys_thread_create_path(ParticleThread *thread, struct ChildParticle *cpa,
                                key[w]++;
                                w++;
                        }
-                       if(k==0){
-                               /* calculate the offset between actual child root position and first position interpolated from parents */
-                               VECSUB(cpa_1st,cpa_1st,state->co);
+                       if(part->path_start==0.0f) {
+                               if(k==0){
+                                       /* calculate the offset between actual child root position and first position interpolated from parents */
+                                       VECSUB(cpa_1st,cpa_1st,state->co);
+                               }
+                               /* apply offset for correct positioning */
+                               VECADD(state->co,state->co,cpa_1st);
                        }
-                       /* apply offset for correct positioning */
-                       VECADD(state->co,state->co,cpa_1st);
                }
                else{
                        /* offset the child from the parent position */
@@ -2177,7 +2164,7 @@ void psys_thread_create_path(ParticleThread *thread, struct ChildParticle *cpa,
        if(part->flag & PART_CHILD_EFFECT) {
                for(k=0,state=keys; k<=ctx->steps; k++,state++) {
                        if(k) {
-                               do_path_effectors(ctx->scene, ob, psys, cpa->pa[0], state, k, ctx->steps, keys->co, pa_effector, 0.0f, ctx->cfra, &eff_length, eff_vec);
+                               do_path_effectors(ctx->scene, ob, psys, cpa->pa[0], state, k, ctx->steps, keys->co, ptex.effector, 0.0f, ctx->cfra, &eff_length, eff_vec);
                        }
                        else {
                                VecSubf(eff_vec,(state+1)->co,state->co);
@@ -2203,67 +2190,50 @@ void psys_thread_create_path(ParticleThread *thread, struct ChildParticle *cpa,
                }
 
                /* apply different deformations to the child path */
-               if(part->flag & PART_CHILD_EFFECT)
-                       /* state is safe to cast, since only co and vel are used */
-                       guided = do_guide(ctx->scene, (ParticleKey*)state, cpa->parent, t, &(psys->effectors));
-
-               if(guided==0){
-                       if(part->kink)
-                               do_prekink((ParticleKey*)state, (ParticleKey*)par, par_rot, t,
-                               part->kink_freq * pa_kink, part->kink_shape, part->kink_amp, part->kink, part->kink_axis, ob->obmat);
-                                       
-                       do_clump((ParticleKey*)state, (ParticleKey*)par, t, part->clumpfac, part->clumppow, pa_clump);
-               }
-
-               if(part->flag & PART_BRANCHING && ctx->between == 0 && part->flag & PART_ANIM_BRANCHING)
-                       rough_t = t * rough_rand;
-               else
-                       rough_t = t;
+               do_child_modifiers(ctx->scene, ob, psys, part, &ptex, (ParticleKey *)par, par_rot, cpa, orco, (ParticleKey *)state, t);
 
-               if(part->rough1 != 0.0 && pa_rough1 != 0.0)
-                       do_rough(orco, rough_t, pa_rough1*part->rough1, part->rough1_size, 0.0, (ParticleKey*)state);
-
-               if(part->rough2 != 0.0 && pa_rough2 != 0.0)
-                       do_rough(cpa->rand, rough_t, pa_rough2*part->rough2, part->rough2_size, part->rough2_thres, (ParticleKey*)state);
-
-               if(part->rough_end != 0.0 && pa_roughe != 0.0)
-                       do_rough_end(cpa->rand, rough_t, pa_roughe*part->rough_end, part->rough_end_shape, (ParticleKey*)state, (ParticleKey*)par);
-
-               if(part->flag & PART_BRANCHING && ctx->between==0){
-                       if(branch_prob > part->branch_thres){
-                               branchfac=0.0f;
-                       }
-                       else{
-                               if(part->flag & PART_SYMM_BRANCHING){
-                                       if(t < branch_begin || t > branch_end)
-                                               branchfac=0.0f;
-                                       else{
-                                               if((t-branch_begin)/(branch_end-branch_begin)<0.5)
-                                                       branchfac=2.0f*(t-branch_begin)/(branch_end-branch_begin);
-                                               else
-                                                       branchfac=2.0f*(branch_end-t)/(branch_end-branch_begin);
+               /* TODO: better branching */
+               //if(part->flag & PART_BRANCHING && ctx->between == 0 && part->flag & PART_ANIM_BRANCHING)
+               //      rough_t = t * rough_rand;
+               //else
+               //      rough_t = t;
 
-                                               CLAMP(branchfac,0.0f,1.0f);
-                                       }
-                               }
-                               else{
-                                       if(t < branch_begin){
-                                               branchfac=0.0f;
-                                       }
-                                       else{
-                                               branchfac=(t-branch_begin)/((1.0f-branch_begin)*0.5f);
-                                               CLAMP(branchfac,0.0f,1.0f);
-                                       }
-                               }
-                       }
+               /* TODO: better branching */
+               //if(part->flag & PART_BRANCHING && ctx->between==0){
+               //      if(branch_prob > part->branch_thres){
+               //              branchfac=0.0f;
+               //      }
+               //      else{
+               //              if(part->flag & PART_SYMM_BRANCHING){
+               //                      if(t < branch_begin || t > branch_end)
+               //                              branchfac=0.0f;
+               //                      else{
+               //                              if((t-branch_begin)/(branch_end-branch_begin)<0.5)
+               //                                      branchfac=2.0f*(t-branch_begin)/(branch_end-branch_begin);
+               //                              else
+               //                                      branchfac=2.0f*(branch_end-t)/(branch_end-branch_begin);
+
+               //                              CLAMP(branchfac,0.0f,1.0f);
+               //                      }
+               //              }
+               //              else{
+               //                      if(t < branch_begin){
+               //                              branchfac=0.0f;
+               //                      }
+               //                      else{
+               //                              branchfac=(t-branch_begin)/((1.0f-branch_begin)*0.5f);
+               //                              CLAMP(branchfac,0.0f,1.0f);
+               //                      }
+               //              }
+               //      }
 
-                       if(i<psys->totpart)
-                               VecLerpf(state->co, (pcache[i] + k)->co, state->co, branchfac);
-                       else
-                               /* this is not threadsafe, but should only happen for
-                                * branching particles particles, which are not threaded */
-                               VecLerpf(state->co, (cache[i - psys->totpart] + k)->co, state->co, branchfac);
-               }
+               //      if(i<psys->totpart)
+               //              VecLerpf(state->co, (pcache[i] + k)->co, state->co, branchfac);
+               //      else
+               //              /* this is not threadsafe, but should only happen for
+               //               * branching particles particles, which are not threaded */
+               //              VecLerpf(state->co, (cache[i - psys->totpart] + k)->co, state->co, branchfac);
+               //}
 
                /* we have to correct velocity because of kink & clump */
                if(k>1){
@@ -2287,9 +2257,9 @@ void psys_thread_create_path(ParticleThread *thread, struct ChildParticle *cpa,
                else{
                        /* initialize length calculation */
                        if(part->flag&PART_ABS_LENGTH)
-                               max_length= part->abslength*pa_length;
+                               max_length= part->abslength*ptex.length;
                        else
-                               max_length= pa_length;
+                               max_length= ptex.length;
 
                        cur_length= 0.0f;
                }
@@ -2383,7 +2353,36 @@ void psys_cache_child_paths(Scene *scene, Object *ob, ParticleSystem *psys, floa
 
        psys_threads_free(pthreads);
 }
+static void get_pointcache_keys_for_time(ParticleSystem *psys, int index, float t, ParticleKey *key1, ParticleKey *key2)
+{
+       PointCache *cache = psys->pointcache;
+       static PTCacheMem *pm = NULL;
+
+       if(cache->flag & PTCACHE_DISK_CACHE) {
+               /* TODO */
+       }
+       else {
+               if(index < 0) { /* initialize */
+                       pm = cache->mem_cache.first;
+                       if(pm)
+                               pm = pm->next;
+               }
+               else {
+                       if(pm) {
+                               while(pm && pm->next && (float)pm->frame < t)
+                                       pm = pm->next;
 
+                               copy_particle_key(key2, ((ParticleKey *)pm->data) + index, 1);
+                               copy_particle_key(key1, ((ParticleKey *)(pm->prev)->data) + index, 1);
+                       }
+                       else if(cache->mem_cache.first) {
+                               pm = cache->mem_cache.first;
+                               copy_particle_key(key2, ((ParticleKey *)pm->data) + index, 1);
+                               copy_particle_key(key1, ((ParticleKey *)pm->data) + index, 1);
+                       }
+               }
+       }
+}
 /* Calculates paths ready for drawing/rendering.                                                                       */
 /* -Usefull for making use of opengl vertex arrays for super fast strand drawing.      */
 /* -Makes child strands possible and creates them too into the cache.                          */
@@ -2409,7 +2408,7 @@ void psys_cache_paths(Scene *scene, Object *ob, ParticleSystem *psys, float cfra
        
        float birthtime = 0.0, dietime = 0.0;
        float t, time = 0.0, keytime = 0.0, dfra = 1.0, frs_sec = scene->r.frs_sec;
-       float col[3] = {0.5f, 0.5f, 0.5f};
+       float col[4] = {0.5f, 0.5f, 0.5f, 1.0f};
        float prev_tangent[3], hairmat[4][4];
        int k,i;
        int steps = (int)pow(2.0, (double)psys->part->draw_step);
@@ -2419,12 +2418,17 @@ void psys_cache_paths(Scene *scene, Object *ob, ParticleSystem *psys, float cfra
        float length, vec[3];
        float *vg_effector= NULL, effector=0.0f;
        float *vg_length= NULL, pa_length=1.0f, max_length=1.0f, cur_length=0.0f;
-       float len, dvec[3];
+       int keyed, baked;
 
        /* we don't have anything valid to create paths from so let's quit here */
-       if((psys->flag & PSYS_HAIR_DONE)==0 && (psys->flag & PSYS_KEYED)==0)
+       if((psys->flag & PSYS_HAIR_DONE)==0 && (psys->flag & PSYS_KEYED)==0 && (psys->pointcache->flag & PTCACHE_BAKED)==0)
                return;
 
+       BLI_srandom(psys->seed);
+
+       keyed = psys->flag & PSYS_KEYED;
+       baked = psys->pointcache->flag & PTCACHE_BAKED;
+
        if(psys->renderdata) {
                steps = (int)pow(2.0, (double)psys->part->ren_step);
        }
@@ -2488,7 +2492,8 @@ void psys_cache_paths(Scene *scene, Object *ob, ParticleSystem *psys, float cfra
                else memset(cache[i], 0, sizeof(*cache[i])*(steps+1));
 
                if(!edit && !psys->totchild) {
-                       pa_length = part->length * (1.0f - part->randlength*pa->r_ave[0]);
+                       //pa_length = part->length * (1.0f - part->randlength*pa->r_ave[0]);
+                       pa_length = 1.0f - part->randlength * 0.5 * (1.0f + pa->r_ave[0]);
                        if(vg_length)
                                pa_length *= psys_particle_value_from_verts(psmd->dm,part->from,pa,vg_length);
                }
@@ -2499,13 +2504,19 @@ void psys_cache_paths(Scene *scene, Object *ob, ParticleSystem *psys, float cfra
                        ekey = edit->keys[i];
 
                /*--get the first data points--*/
-               if(psys->flag & PSYS_KEYED) {
+               if(keyed) {
                        kkey[0] = pa->keys;
                        kkey[1] = kkey[0] + 1;
 
                        birthtime = kkey[0]->time;
                        dietime = kkey[0][pa->totkey-1].time;
                }
+               else if(baked) {
+                       get_pointcache_keys_for_time(psys, -1, 0.0f, NULL, NULL);
+                       
+                       birthtime = pa->time;
+                       dietime = pa->dietime;
+               }
                else {
                        hkey[0] = pa->hair;
                        hkey[1] = hkey[0] + 1;
@@ -2516,6 +2527,25 @@ void psys_cache_paths(Scene *scene, Object *ob, ParticleSystem *psys, float cfra
                        psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, pa, hairmat);
                }
 
+               if(!edit) {
+                       if(part->draw & PART_ABS_PATH_TIME) {
+                               birthtime = MAX2(birthtime, part->path_start);
+                               dietime = MIN2(dietime, part->path_end);
+                       }
+                       else {
+                               float tb = birthtime;
+                               birthtime = tb + part->path_start * (dietime - tb);
+                               dietime = tb + part->path_end * (dietime - tb);
+                       }
+
+                       if(birthtime >= dietime) {
+                               cache[i]->steps = -1;
+                               continue;
+                       }
+
+                       dietime = birthtime + pa_length * (dietime - birthtime);
+               }
+
                if(soft){
                        bp[0] = soft->bpoint + pa->bpi;
                        bp[1] = bp[0] + 1;
@@ -2527,13 +2557,16 @@ void psys_cache_paths(Scene *scene, Object *ob, ParticleSystem *psys, float cfra
 
                        t = birthtime + time * (dietime - birthtime);
 
-                       if(psys->flag & PSYS_KEYED) {
+                       if(keyed) {
                                while(kkey[1]->time < t) {
                                        kkey[1]++;
                                }
 
                                kkey[0] = kkey[1] - 1;                          
                        }
+                       else if(baked) {
+                               get_pointcache_keys_for_time(psys, i, t, keys+1, keys+2);
+                       }
                        else {
                                while(hkey[1]->time < t) {
                                        hkey[1]++;
@@ -2548,17 +2581,19 @@ void psys_cache_paths(Scene *scene, Object *ob, ParticleSystem *psys, float cfra
                                bp_to_particle(keys + 1, bp[0], hkey[0]);
                                bp_to_particle(keys + 2, bp[1], hkey[1]);
                        }
-                       else if(psys->flag & PSYS_KEYED) {
+                       else if(keyed) {
                                memcpy(keys + 1, kkey[0], sizeof(ParticleKey));
                                memcpy(keys + 2, kkey[1], sizeof(ParticleKey));
                        }
+                       else if(baked)
+                               ; /* keys already set */
                        else {
                                hair_to_particle(keys + 1, hkey[0]);
                                hair_to_particle(keys + 2, hkey[1]);
                        }
 
 
-                       if((psys->flag & PSYS_KEYED)==0) {
+                       if(!keyed && !baked) {
                                if(soft) {
                                        if(hkey[0] != pa->hair)
                                                bp_to_particle(keys, bp[0] - 1, hkey[0] - 1);
@@ -2591,18 +2626,18 @@ void psys_cache_paths(Scene *scene, Object *ob, ParticleSystem *psys, float cfra
                        keytime = (t - keys[1].time) / dfra;
 
                        /* convert velocity to timestep size */
-                       if(psys->flag & PSYS_KEYED){
+                       if(keyed || baked){
                                VecMulf(keys[1].vel, dfra / frs_sec);
                                VecMulf(keys[2].vel, dfra / frs_sec);
                        }
 
                        /* now we should have in chronologiacl order k1<=k2<=t<=k3<=k4 with keytime between [0,1]->[k2,k3] (k1 & k4 used for cardinal & bspline interpolation)*/
-                       psys_interpolate_particle((psys->flag & PSYS_KEYED) ? -1 /* signal for cubic interpolation */
+                       psys_interpolate_particle((keyed || baked) ? -1 /* signal for cubic interpolation */
                                : ((psys->part->flag & PART_HAIR_BSPLINE) ? KEY_BSPLINE : KEY_CARDINAL)
                                ,keys, keytime, &result, 0);
 
                        /* the velocity needs to be converted back from cubic interpolation */
-                       if(psys->flag & PSYS_KEYED){
+                       if(keyed || baked){
                                VecMulf(result.vel, frs_sec / dfra);
                        }
                        else if(soft==NULL) { /* softbody and keyed are allready in global space */
@@ -2717,28 +2752,6 @@ void psys_cache_paths(Scene *scene, Object *ob, ParticleSystem *psys, float cfra
                                }
 
                        }
-
-                       if(!edit && !psys->totchild) {
-                               /* check if path needs to be cut before actual end of data points */
-                               if(k){
-                                       VECSUB(dvec,ca->co,(ca-1)->co);
-                                       if(part->flag&PART_ABS_LENGTH)
-                                               len=VecLength(dvec);
-                                       else
-                                               len=1.0f/(float)steps;
-
-                                       k=check_path_length(k,cache[i],ca,max_length,&cur_length,len,dvec);
-                               }
-                               else{
-                                       /* initialize length calculation */
-                                       if(part->flag&PART_ABS_LENGTH)
-                                               max_length= part->abslength*pa_length;
-                                       else
-                                               max_length= pa_length;
-
-                                       cur_length= 0.0f;
-                               }
-                       }
                }
        }
 
@@ -2990,7 +3003,8 @@ static void default_particle_settings(ParticleSettings *part)
 
        part->type= PART_EMITTER;
        part->distr= PART_DISTR_JIT;
-       part->draw_as=PART_DRAW_DOT;
+       part->draw_as = PART_DRAW_REND;
+       part->ren_as = PART_DRAW_HALO;
        part->bb_uv_split=1;
        part->bb_align=PART_BB_VIEW;
        part->bb_split_offset=PART_BB_OFF_LINEAR;
@@ -3046,6 +3060,8 @@ static void default_particle_settings(ParticleSettings *part)
        part->rough_end_shape=1.0;
 
        part->draw_line[0]=0.5;
+       part->path_start = 0.0f;
+       part->path_end = 1.0f;
 
        part->banking=1.0;
        part->max_bank=1.0;
@@ -3282,7 +3298,7 @@ static void get_cpa_texture(DerivedMesh *dm, Material *ma, int face_index, float
                        if((event & mtex->pmapto) & MAP_PA_KINK)
                                ptex->kink= texture_value_blend(def,ptex->kink,value,var,blend,neg & MAP_PA_KINK);
                        if((event & mtex->pmapto) & MAP_PA_ROUGH)
-                               ptex->rough= texture_value_blend(def,ptex->rough,value,var,blend,neg & MAP_PA_ROUGH);
+                               ptex->rough1= ptex->rough2= ptex->roughe= texture_value_blend(def,ptex->rough1,value,var,blend,neg & MAP_PA_ROUGH);
                        if((event & mtex->pmapto) & MAP_PA_DENS)
                                ptex->exist= texture_value_blend(def,ptex->exist,value,var,blend,neg & MAP_PA_DENS);
                }
@@ -3291,7 +3307,11 @@ static void get_cpa_texture(DerivedMesh *dm, Material *ma, int face_index, float
        if(event & MAP_PA_LENGTH) { CLAMP(ptex->length,0.0,1.0); }
        if(event & MAP_PA_CLUMP) { CLAMP(ptex->clump,0.0,1.0); }
        if(event & MAP_PA_KINK) { CLAMP(ptex->kink,0.0,1.0); }
-       if(event & MAP_PA_ROUGH) { CLAMP(ptex->rough,0.0,1.0); }
+       if(event & MAP_PA_ROUGH) {
+               CLAMP(ptex->rough1,0.0,1.0);
+               CLAMP(ptex->rough2,0.0,1.0);
+               CLAMP(ptex->roughe,0.0,1.0);
+       }
        if(event & MAP_PA_DENS) { CLAMP(ptex->exist,0.0,1.0); }
 }
 void psys_get_texture(Object *ob, Material *ma, ParticleSystemModifierData *psmd, ParticleSystem *psys, ParticleData *pa, ParticleTexture *ptex, int event)
@@ -3392,12 +3412,12 @@ float psys_get_size(Object *ob, Material *ma, ParticleSystemModifierData *psmd,
 
        return size*part->size;
 }
-float psys_get_child_time(ParticleSystem *psys, ChildParticle *cpa, float cfra)
+float psys_get_child_time(ParticleSystem *psys, ChildParticle *cpa, float cfra, float *birthtime, float *dietime)
 {
        ParticleSettings *part = psys->part;
+       float time, life;
 
        if(part->childtype==PART_CHILD_FACES){
-               float time;
                int w=0;
                time=0.0;
                while(w<4 && cpa->pa[w]>=0){
@@ -3405,12 +3425,21 @@ float psys_get_child_time(ParticleSystem *psys, ChildParticle *cpa, float cfra)
                        w++;
                }
 
-               return (cfra-time)/(part->lifetime*(1.0f-part->randlife*cpa->rand[1]));
+               life = part->lifetime*(1.0f-part->randlife*cpa->rand[1]);
        }
        else{
                ParticleData *pa = psys->particles + cpa->parent;
-               return (cfra-pa->time)/pa->lifetime;
+
+               time = pa->time;
+               life = pa->lifetime;
        }
+
+       if(birthtime)
+               *birthtime = time;
+       if(dietime)
+               *dietime = time+life;
+
+       return (cfra-time)/life;
 }
 float psys_get_child_size(ParticleSystem *psys, ChildParticle *cpa, float cfra, float *pa_time)
 {
@@ -3427,7 +3456,7 @@ float psys_get_child_size(ParticleSystem *psys, ChildParticle *cpa, float cfra,
                        if(pa_time)
                                time=*pa_time;
                        else
-                               time=psys_get_child_time(psys,cpa,cfra);
+                               time=psys_get_child_time(psys,cpa,cfra,NULL,NULL);
 
                        /* correction for lifetime */
                        calc_ipo(part->ipo, 100*time);
@@ -3449,6 +3478,64 @@ float psys_get_child_size(ParticleSystem *psys, ChildParticle *cpa, float cfra,
 
        return size;
 }
+static void get_child_modifier_parameters(ParticleSettings *part, ParticleThreadContext *ctx, ChildParticle *cpa, short cpa_from, int cpa_num, float *cpa_fuv, float *orco, ParticleTexture *ptex)
+{
+       ptex->length=part->length*(1.0f - part->randlength*cpa->rand[0]);
+       ptex->clump=1.0;
+       ptex->kink=1.0;
+       ptex->rough1= 1.0;
+       ptex->rough2= 1.0;
+       ptex->roughe= 1.0;
+       ptex->exist= 1.0;
+       ptex->effector= 1.0;
+
+       get_cpa_texture(ctx->dm,ctx->ma,cpa_num,cpa_fuv,orco,ptex,
+               MAP_PA_DENS|MAP_PA_LENGTH|MAP_PA_CLUMP|MAP_PA_KINK|MAP_PA_ROUGH);
+
+
+       if(ptex->exist < cpa->rand[1])
+               return;
+
+       if(ctx->vg_length)
+               ptex->length*=psys_interpolate_value_from_verts(ctx->dm,cpa_from,cpa_num,cpa_fuv,ctx->vg_length);
+       if(ctx->vg_clump)
+               ptex->clump*=psys_interpolate_value_from_verts(ctx->dm,cpa_from,cpa_num,cpa_fuv,ctx->vg_clump);
+       if(ctx->vg_kink)
+               ptex->kink*=psys_interpolate_value_from_verts(ctx->dm,cpa_from,cpa_num,cpa_fuv,ctx->vg_kink);
+       if(ctx->vg_rough1)
+               ptex->rough1*=psys_interpolate_value_from_verts(ctx->dm,cpa_from,cpa_num,cpa_fuv,ctx->vg_rough1);
+       if(ctx->vg_rough2)
+               ptex->rough2*=psys_interpolate_value_from_verts(ctx->dm,cpa_from,cpa_num,cpa_fuv,ctx->vg_rough2);
+       if(ctx->vg_roughe)
+               ptex->roughe*=psys_interpolate_value_from_verts(ctx->dm,cpa_from,cpa_num,cpa_fuv,ctx->vg_roughe);
+       if(ctx->vg_effector)
+               ptex->effector*=psys_interpolate_value_from_verts(ctx->dm,cpa_from,cpa_num,cpa_fuv,ctx->vg_effector);
+}
+static void do_child_modifiers(Scene *scene, Object *ob, ParticleSystem *psys, ParticleSettings *part, ParticleTexture *ptex, ParticleKey *par, float *par_rot, ChildParticle *cpa, float *orco, ParticleKey *state, float t)
+{
+       int guided = 0;
+
+       if(part->flag & PART_CHILD_EFFECT)
+               /* state is safe to cast, since only co and vel are used */
+               guided = do_guide(scene, (ParticleKey*)state, cpa->parent, t, &(psys->effectors));
+
+       if(guided==0){
+               if(part->kink)
+                       do_prekink(state, par, par_rot, t, part->kink_freq * ptex->kink, part->kink_shape,
+                       part->kink_amp, part->kink, part->kink_axis, ob->obmat);
+                               
+               do_clump(state, par, t, part->clumpfac, part->clumppow, ptex->clump);
+       }
+
+       if(part->rough1 != 0.0 && ptex->rough1 != 0.0)
+               do_rough(orco, t, ptex->rough1*part->rough1, part->rough1_size, 0.0, state);
+
+       if(part->rough2 != 0.0 && ptex->rough2 != 0.0)
+               do_rough(cpa->rand, t, ptex->rough2*part->rough2, part->rough2_size, part->rough2_thres, state);
+
+       if(part->rough_end != 0.0 && ptex->roughe != 0.0)
+               do_rough_end(cpa->rand, t, ptex->roughe*part->rough_end, part->rough_end_shape, state, par);
+}
 /* get's hair (or keyed) particles state at the "path time" specified in state->time */
 void psys_get_particle_on_path(Scene *scene, Object *ob, ParticleSystem *psys, int p, ParticleKey *state, int vel)
 {
@@ -3460,7 +3547,8 @@ void psys_get_particle_on_path(Scene *scene, Object *ob, ParticleSystem *psys, i
        ParticleTexture ptex;
        ParticleKey *kkey[2] = {NULL, NULL};
        HairKey *hkey[2] = {NULL, NULL};
-       ParticleKey *par=0, keys[4];
+       ParticleKey *par=0, keys[4], tstate;
+       ParticleThreadContext ctx; /* fake thread context for child modifiers */
 
        float t, real_t, dfra, keytime, frs_sec = scene->r.frs_sec;
        float co[3], orco[3];
@@ -3471,6 +3559,9 @@ void psys_get_particle_on_path(Scene *scene, Object *ob, ParticleSystem *psys, i
        int totchild = psys->totchild;
        short between = 0, edit = 0;
 
+       int keyed = psys->flag & PSYS_KEYED;
+       int cached = !keyed && part->type != PART_HAIR;
+
        float *cpa_fuv; int cpa_num; short cpa_from;
 
        //if(psys_in_edit_mode(scene, psys)){
@@ -3479,12 +3570,6 @@ void psys_get_particle_on_path(Scene *scene, Object *ob, ParticleSystem *psys, i
        //      edit=1;
        //}
 
-       /* user want's cubic interpolation but only without sb it possible */
-       //if(interpolation==PART_INTER_CUBIC && baked && psys->softflag==OB_SB_ENABLE)
-       //      interpolation=PART_INTER_BSPLINE;
-       //else if(baked==0) /* it doesn't make sense to use other types for keyed */
-       //      interpolation=PART_INTER_CUBIC;
-
        t=state->time;
        CLAMP(t, 0.0, 1.0);
 
@@ -3497,20 +3582,29 @@ void psys_get_particle_on_path(Scene *scene, Object *ob, ParticleSystem *psys, i
                        return;
                }
                
-               if(psys->flag & PSYS_KEYED) {
+               if(keyed) {
                        kkey[0] = pa->keys;
                        kkey[1] = kkey[0] + 1;
 
-                       real_t = kkey[0]->time + t * (kkey[0][pa->totkey-1].time - kkey[0]->time);
+                       if(state->time < 0.0f)
+                               real_t = -state->time;
+                       else
+                               real_t = kkey[0]->time + t * (kkey[0][pa->totkey-1].time - kkey[0]->time);
+               }
+               else if(cached) {
+                       get_pointcache_keys_for_time(psys, -1, 0.0f, NULL, NULL);
                }
                else {
                        hkey[0] = pa->hair;
                        hkey[1] = pa->hair + 1;
 
-                       real_t = hkey[0]->time + (hkey[0][pa->totkey-1].time - hkey[0]->time) * t;
+                       if(state->time < 0.0f)
+                               real_t = -state->time;
+                       else
+                               real_t = hkey[0]->time + t * (hkey[0][pa->totkey-1].time - hkey[0]->time);
                }
 
-               if(psys->flag & PSYS_KEYED) {
+               if(keyed) {
                        while(kkey[1]->time < real_t) {
                                kkey[1]++;
                        }
@@ -3519,6 +3613,14 @@ void psys_get_particle_on_path(Scene *scene, Object *ob, ParticleSystem *psys, i
                        memcpy(keys + 1, kkey[0], sizeof(ParticleKey));
                        memcpy(keys + 2, kkey[1], sizeof(ParticleKey));
                }
+               else if(cached) {
+                       if(state->time < 0.0f) /* flag for time in frames */
+                               real_t = -state->time;
+                       else
+                               real_t = pa->time + t * (pa->dietime - pa->time);
+
+                       get_pointcache_keys_for_time(psys, p, real_t, keys+1, keys+2);
+               }
                else {
                        while(hkey[1]->time < real_t)
                                hkey[1]++;
@@ -3529,63 +3631,35 @@ void psys_get_particle_on_path(Scene *scene, Object *ob, ParticleSystem *psys, i
                        hair_to_particle(keys + 2, hkey[1]);
                }
 
-               if((psys->flag & PSYS_KEYED)==0) {
-               //if(soft){
-               //      if(key[0] != sbel.keys)
-               //              DB_copy_key(&k1,key[0]-1);
-               //      else
-               //              DB_copy_key(&k1,&k2);
-               //}
-               //else{
+               if(!keyed && !cached) {
                        if(hkey[0] != pa->hair)
                                hair_to_particle(keys, hkey[0] - 1);
                        else
                                hair_to_particle(keys, hkey[0]);
-               //}
 
-               //if(soft){
-               //      if(key[1] != sbel.keys + sbel.totkey-1)
-               //              DB_copy_key(&k4,key[1]+1);
-               //      else
-               //              DB_copy_key(&k4,&k3);
-               //}
-               //else {
                        if(hkey[1] != pa->hair + pa->totkey - 1)
                                hair_to_particle(keys + 3, hkey[1] + 1);
                        else
                                hair_to_particle(keys + 3, hkey[1]);
                }
-               //}
-
-               //psys_get_particle_on_path(scene, bsys,p,t,bkey,ckey[0]);
-
-               //if(part->rotfrom==PART_ROT_KEYS)
-               //      QuatInterpol(state->rot,k2.rot,k3.rot,keytime);
-               //else{
-               //      /* TODO: different rotations */
-               //      float nvel[3];
-               //      VECCOPY(nvel,state->vel);
-               //      VecMulf(nvel,-1.0f);
-               //      vectoquat(nvel, OB_POSX, OB_POSZ, state->rot);
-               //}
 
                dfra = keys[2].time - keys[1].time;
 
                keytime = (real_t - keys[1].time) / dfra;
 
                /* convert velocity to timestep size */
-               if(psys->flag & PSYS_KEYED){
+               if(keyed || cached){
                        VecMulf(keys[1].vel, dfra / frs_sec);
                        VecMulf(keys[2].vel, dfra / frs_sec);
                        QuatInterpol(state->rot,keys[1].rot,keys[2].rot,keytime);
                }
 
-               psys_interpolate_particle((psys->flag & PSYS_KEYED) ? -1 /* signal for cubic interpolation */
+               psys_interpolate_particle((keyed || cached) ? -1 /* signal for cubic interpolation */
                        : ((psys->part->flag & PART_HAIR_BSPLINE) ? KEY_BSPLINE : KEY_CARDINAL)
                        ,keys, keytime, state, 1);
 
                /* the velocity needs to be converted back from cubic interpolation */
-               if(psys->flag & PSYS_KEYED){
+               if(keyed || cached){
                        VecMulf(state->vel, frs_sec / dfra);
                }
                else {
@@ -3606,8 +3680,11 @@ void psys_get_particle_on_path(Scene *scene, Object *ob, ParticleSystem *psys, i
        }
        else if(totchild){
                //Mat4Invert(imat,ob->obmat);
-               
+
                cpa=psys->child+p-totpart;
+
+               if(state->time < 0.0f)
+                       t = psys_get_child_time(psys, cpa, -state->time, NULL, NULL);
                
                if(totchild && part->from!=PART_FROM_PARTICLE && part->childtype==PART_CHILD_FACES){
                        totparent=(int)(totchild*part->parents*0.3);
@@ -3624,7 +3701,7 @@ void psys_get_particle_on_path(Scene *scene, Object *ob, ParticleSystem *psys, i
 
                        /* get parent states */
                        while(w<4 && cpa->pa[w]>=0){
-                               keys[w].time = t;
+                               keys[w].time = state->time;
                                psys_get_particle_on_path(scene, ob, psys, cpa->pa[w], keys+w, 1);
                                w++;
                        }
@@ -3650,7 +3727,7 @@ void psys_get_particle_on_path(Scene *scene, Object *ob, ParticleSystem *psys, i
                else{
                        /* get the parent state */
 
-                       keys->time = t;
+                       keys->time = state->time;
                        psys_get_particle_on_path(scene, ob, psys, cpa->parent, keys,1);
 
                        /* get the original coordinates (orco) for texture usage */
@@ -3672,15 +3749,11 @@ void psys_get_particle_on_path(Scene *scene, Object *ob, ParticleSystem *psys, i
 #endif // XXX old animation system
                
                /* get different child parameters from textures & vgroups */
-               ptex.clump=1.0;
-               ptex.kink=1.0;
-               
-               get_cpa_texture(psmd->dm,ma,cpa_num,cpa_fuv,orco,&ptex,MAP_PA_CLUMP|MAP_PA_KINK);
-               
-               pa_clump=ptex.clump;
-               pa_kink=ptex.kink;
-
-               /* TODO: vertex groups */
+               memset(&ctx, 0, sizeof(ParticleThreadContext));
+               ctx.dm = psmd->dm;
+               ctx.ma = ma;
+               /* TODO: assign vertex groups */
+               get_child_modifier_parameters(part, &ctx, cpa, cpa_from, cpa_num, cpa_fuv, orco, &ptex);
 
                if(between){
                        int w=0;
@@ -3708,46 +3781,34 @@ void psys_get_particle_on_path(Scene *scene, Object *ob, ParticleSystem *psys, i
                }
 
                par = keys;
-               //if(totparent){
-               //      if(p-totpart>=totparent){
-               //              key.time=t;
-               //              psys_get_particle_on_path(ob,psys,totpart+cpa->parent,&key,1);
-               //              bti->convert_dynamic_key(bsys,&key,par,cpar);
-               //      }
-               //      else
-               //              par=0;
-               //}
-               //else
-               //      DB_get_key_on_path(bsys,cpa->parent,t,par,cpar);
-
-               /* apply different deformations to the child path */
-               if(part->kink)
-                       do_prekink(state, par, par->rot, t, part->kink_freq * pa_kink, part->kink_shape,
-                       part->kink_amp, part->kink, part->kink_axis, ob->obmat);
-               
-               do_clump(state, par, t, part->clumpfac, part->clumppow, 1.0f);
-
-               if(part->rough1 != 0.0)
-                       do_rough(orco, t, part->rough1, part->rough1_size, 0.0, state);
 
-               if(part->rough2 != 0.0)
-                       do_rough(cpa->rand, t, part->rough2, part->rough2_size, part->rough2_thres, state);
+               if(vel)
+                       copy_particle_key(&tstate, state, 1);
 
-               if(part->rough_end != 0.0)
-                       do_rough_end(cpa->rand, t, part->rough_end, part->rough_end_shape, state, par); 
+               /* apply different deformations to the child path */
+               do_child_modifiers(scene, ob, psys, part, &ptex, par, par->rot, cpa, orco, state, t);
+
+               /* try to estimate correct velocity */
+               if(vel){
+                       ParticleKey tstate;
+                       float length = VecLength(state->vel);
+
+                       if(t>=0.001f){
+                               tstate.time=t-0.001f;
+                               psys_get_particle_on_path(scene,ob,psys,p,&tstate,0);
+                               VECSUB(state->vel,state->co,tstate.co);
+                               Normalize(state->vel);
+                       }
+                       else{
+                               float length = VecLength(state->vel);
+                               tstate.time=t+0.001f;
+                               psys_get_particle_on_path(scene, ob,psys,p,&tstate,0);
+                               VECSUB(state->vel,tstate.co,state->co);
+                               Normalize(state->vel);
+                       }
 
-               //if(vel){
-               //      if(t>=0.001f){
-               //              tstate.time=t-0.001f;
-               //              psys_get_particle_on_path(scene,ob,psys,p,&tstate,0);
-               //              VECSUB(state->vel,state->co,tstate.co);
-               //      }
-               //      else{
-               //              tstate.time=t+0.001f;
-               //              psys_get_particle_on_path(scene, ob,psys,p,&tstate,0);
-               //              VECSUB(state->vel,tstate.co,state->co);
-               //      }
-               //}
+                       VecMulf(state->vel, length);
+               }
        }
 }
 /* gets particle's state at a time, returns 1 if particle exists and can be seen and 0 if not */
@@ -3774,7 +3835,7 @@ int psys_get_particle_state(struct Scene *scene, Object *ob, ParticleSystem *psy
                pa=psys->particles+p;
 
        if(between){
-               state->time = psys_get_child_time(psys,&psys->child[p-totpart],cfra);
+               state->time = psys_get_child_time(psys,&psys->child[p-totpart],cfra,NULL,NULL);
 
                if(always==0)
                        if((state->time<0.0 && (part->flag & PART_UNBORN)==0)
index 591b6ca9be535cb9d931b3e6d36e4354b9a995c6..92b919f6b0e739829eda4069b7ef5addceb23b12 100644 (file)
@@ -4254,7 +4254,7 @@ static void psys_update_path_cache(Scene *scene, Object *ob, ParticleSystemModif
                }
        }
 
-       if((part->type==PART_HAIR || psys->flag&PSYS_KEYED) && ( psys_in_edit_mode(scene, psys) || (part->type==PART_HAIR 
+       if((part->type==PART_HAIR || psys->flag&PSYS_KEYED || psys->pointcache->flag & PTCACHE_BAKED) && ( psys_in_edit_mode(scene, psys) || (part->type==PART_HAIR 
                || (part->ren_as == PART_DRAW_PATH && (part->draw_as == PART_DRAW_REND || psys->renderdata))))){
 
                psys_cache_paths(scene, ob, psys, cfra, 0);
@@ -4371,8 +4371,10 @@ static void cached_step(Scene *scene, Object *ob, ParticleSystemModifierData *ps
                dietime = birthtime + (1 + pa->loop) * (pa->dietime - pa->time);
 
                /* update alive status and push events */
-               if(pa->time > cfra)
+               if(pa->time > cfra) {
                        pa->alive = PARS_UNBORN;
+                       reset_particle(scene, pa, psys, psmd, ob, 0.0f, cfra, NULL, NULL, NULL);
+               }
                else if(dietime <= cfra){
                        if(dietime > psys->cfra){
                                state.time = dietime;
@@ -4406,6 +4408,8 @@ static void cached_step(Scene *scene, Object *ob, ParticleSystemModifierData *ps
                distribute_particles(scene, ob, psys, PART_FROM_CHILD);
        }
 
+       psys_update_path_cache(scene, ob,psmd,psys,cfra);
+
        if(vg_size)
                MEM_freeN(vg_size);
 }
@@ -4433,10 +4437,17 @@ void psys_changed_type(ParticleSystem *psys)
 
                if(ELEM3(part->draw_as, PART_DRAW_NOT, PART_DRAW_REND, PART_DRAW_PATH)==0)
                        part->draw_as = PART_DRAW_REND;
+
+               CLAMP(part->path_start, 0.0f, 100.0f);
+               CLAMP(part->path_end, 0.0f, 100.0f);
        }
-       else
+       else {
                free_hair(psys, 1);
 
+               CLAMP(part->path_start, part->sta, part->end + part->lifetime);
+               CLAMP(part->path_end, part->sta, part->end + part->lifetime);
+       }
+
        psys->softflag= 0;
 
        psys_reset(psys, PSYS_RESET_ALL);
@@ -4629,9 +4640,8 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle
                totpart = psys->part->totpart;
        totchild = get_psys_tot_child(scene, psys);
 
-       if(oldtotpart != totpart || (psys->part->childtype && oldtotchild != totchild)) {
+       if(oldtotpart != totpart || oldtotchild != totchild) {
                only_children_changed = (oldtotpart == totpart);
-               realloc_particles(ob, psys, totpart);
                alloc = 1;
                distr= 1;
                init= 1;
@@ -4647,11 +4657,12 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle
                        if(alloc) {
                                realloc_particles(ob, psys, totpart);
 
-                               if(usecache)
+                               if(usecache && !only_children_changed)
                                        BKE_ptcache_id_clear(&pid, PTCACHE_CLEAR_ALL, 0);
                        }
 
-                       distribute_particles(scene, ob, psys, part->from);
+                       if(!only_children_changed)
+                               distribute_particles(scene, ob, psys, part->from);
 
                        if((psys->part->type == PART_HAIR) && !(psys->flag & PSYS_HAIR_DONE))
                        /* don't generate children while growing hair - waste of time */
@@ -4660,7 +4671,7 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle
                                distribute_particles(scene, ob, psys, PART_FROM_CHILD);
                }
 
-               if(only_children_changed==0) {
+               if(!only_children_changed) {
                        free_keyed_keys(psys);
 
                        initialize_all_particles(ob, psys, psmd);
@@ -4680,19 +4691,10 @@ static void system_step(Scene *scene, Object *ob, ParticleSystem *psys, Particle
                int result = get_particles_from_cache(scene, ob, psys, (float)framenr, &old_framenr);
 
                if(result == PTCACHE_READ_EXACT || result == PTCACHE_READ_INTERPOLATED) {
-                       //if(part->phystype==PART_PHYS_KEYED && psys->flag&PSYS_FIRST_KEYED) {
-                       //      psys_count_keyed_targets(ob,psys);
-                       //      set_keyed_keys(scene, ob, psys);
-                       //}
-
                        cached_step(scene, ob, psmd, psys, cfra);
                        psys->cfra=cfra;
                        psys->recalc = 0;
 
-                       //if(part->phystype==PART_PHYS_KEYED && psys->flag&PSYS_FIRST_KEYED) {
-                       //      psys_update_path_cache(scene, ob, psmd, psys, framenr);
-                       //}
-
                        cache->simframe= framenr;
                        cache->flag |= PTCACHE_SIMULATION_VALID;
 
index 64473d071517350885f1a5155be2175b818c181d..2fbd0278e0e2cef7b192444ec480a969eb327f6e 100644 (file)
@@ -1154,6 +1154,7 @@ void BKE_ptcache_quick_cache_all(Scene *scene)
        baker.progressbar=NULL;
        baker.progresscontext=NULL;
        baker.render=0;
+       baker.anim_init = 0;
        baker.scene=scene;
 
        if(count_quick_cache(scene, &baker.quick_step))
@@ -1171,7 +1172,7 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker)
        float frameleno = scene->r.framelen;
        int cfrao = CFRA;
        int startframe = MAXFRAME;
-       int endframe = CFRA;
+       int endframe = baker->anim_init ? scene->r.sfra : CFRA;
        int bake = baker->bake;
        int render = baker->render;
        int step = baker->quick_step;
@@ -1209,8 +1210,13 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker)
                for(pid=pidlist.first; pid; pid=pid->next) {
                        cache = pid->cache;
                        if((cache->flag & PTCACHE_BAKED)==0) {
-                               if(pid->type==PTCACHE_TYPE_PARTICLES)
+                               if(pid->type==PTCACHE_TYPE_PARTICLES) {
+                                       /* skip hair particles */
+                                       if(((ParticleSystem*)pid->data)->part->type == PART_HAIR)
+                                               continue;
+
                                        psys_get_pointcache_start_end(scene, pid->data, &cache->startframe, &cache->endframe);
+                               }
 
                                if((cache->flag & PTCACHE_REDO_NEEDED || (cache->flag & PTCACHE_SIMULATION_VALID)==0)
                                        && ((cache->flag & PTCACHE_QUICK_CACHE)==0 || render || bake))
@@ -1265,6 +1271,10 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker)
                BKE_ptcache_ids_from_object(&pidlist, base->object);
 
                for(pid=pidlist.first; pid; pid=pid->next) {
+                       /* skip hair particles */
+                       if(pid->type==PTCACHE_TYPE_PARTICLES && ((ParticleSystem*)pid->data)->part->type == PART_HAIR)
+                               continue;
+               
                        cache = pid->cache;
 
                        if(step > 1)
@@ -1282,7 +1292,9 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker)
 
        scene->r.framelen = frameleno;
        CFRA = cfrao;
-       scene_update_for_newframe(scene, scene->lay);
+
+       if(bake) /* already on cfra unless baking */
+               scene_update_for_newframe(scene, scene->lay);
 
        /* TODO: call redraw all windows somehow */
 }
index e25e4be90c8a999d5e1bd36151b6046b8e36cf31..4b6eddf60d0cd660b7f31793cbb9911111f40f92 100644 (file)
@@ -78,6 +78,8 @@ static void spacetype_free(SpaceType *st)
        }
        
        BLI_freelistN(&st->regiontypes);
+       BLI_freelistN(&st->toolshelf);
+
 }
 
 void BKE_spacetypes_free(void)
index c89f515f319859992464e9a6adb6c85bdc61f80f..93de096e7b453ade95f273bbe8fd63320d5de2c5 100644 (file)
@@ -9059,6 +9059,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                        part->draw_as = PART_DRAW_REND;
                                }
                        }
+                       part->path_end = 1.0f;
                }
                /* set old pointcaches to have disk cache flag */
                for(ob = main->object.first; ob; ob= ob->id.next) {
index 914fdaa4bc6f2043d43c1aa10b965e2161bf5e34..b7a868ad537dfb13a6252df9e23539e61c754942 100644 (file)
@@ -64,6 +64,10 @@ IF(WITH_FFMPEG)
   ADD_DEFINITIONS(-DWITH_FFMPEG)
 ENDIF(WITH_FFMPEG)
 
+IF(NOT WITH_ELBEEM)
+  ADD_DEFINITIONS(-DDISABLE_ELBEEM)
+ENDIF(NOT WITH_ELBEEM)
+
 IF(WITH_PYTHON)
   SET(INC ${INC} ${PYTHON_INC})
 ELSE(WITH_PYTHON)
index c176f20c26b274e35362bd848fcbca38c6be4550..128c6b078e75d74a1b357d3b1d2e93396e46bf2e 100644 (file)
@@ -165,7 +165,7 @@ void ANIM_draw_cfra (const bContext *C, View2D *v2d, short flag)
        glLineWidth(2.0);
        
        glBegin(GL_LINE_STRIP);
-               vec[1]= v2d->cur.ymin;
+               vec[1]= v2d->cur.ymin-500.0f;   /* XXX arbitrary... want it go to bottom */
                glVertex2fv(vec);
                
                vec[1]= v2d->cur.ymax;
index 2abec6b831ca12380e506ce8c8150dbfed52ad91..d6543b41f473567cf439e2e050af465799ad7a75 100644 (file)
@@ -976,7 +976,7 @@ static void MARKER_OT_delete(wmOperatorType *ot)
 /* ************************** registration **********************************/
 
 /* called in screen_ops.c:ED_operatortypes_screen() */
-void ED_marker_operatortypes(void)
+void ED_operatortypes_marker(void)
 {
        WM_operatortype_append(MARKER_OT_add);
        WM_operatortype_append(MARKER_OT_move);
index 586f16f42aab0e21377ad48e33e046f718363e14..2859ec897bf5eef8338c476b721974d0a6933c5b 100644 (file)
@@ -46,6 +46,8 @@ void fluidsimSettingsFree(struct FluidsimSettings* sb);
 /* duplicate internal data */
 struct FluidsimSettings* fluidsimSettingsCopy(struct FluidsimSettings* sb);
 
+/* memory estimate */
+void fluidsimEstimateMemory(struct Object *ob, struct FluidsimSettings *fs, char *value);
 
 #endif /* ED_FLUIDSIM_H */
 
index 048bbbd746371a8f6162114dcda4050b4961195f..4b7a295420629734737307f476fe7a3b23fc16fe 100644 (file)
@@ -54,7 +54,7 @@ void ED_markers_make_cfra_list(ListBase *markers, ListBase *lb, short sel);
 /* Operators ------------------------------ */
 
 /* called in screen_ops.c:ED_operatortypes_screen() */
-void ED_marker_operatortypes(void); 
+void ED_operatortypes_marker(void); 
 /* called in screen_ops.c:ED_keymap_screen() */
 void ED_marker_keymap(struct wmWindowManager *wm);
 
index e4e4b1d048699376ba1efcfdd605fe472b6fcc71..9dcdc30a691d5c8b52c341f63cbc08c21177b9b5 100644 (file)
@@ -103,7 +103,8 @@ void key_to_curve(struct KeyBlock *kb, struct Curve  *cu, struct ListBase *nurb)
 void curve_to_key(struct Curve *cu, struct KeyBlock *kb, struct ListBase *nurb);
 
 /* object_modifier.c */
-int ED_object_modifier_delete(struct ReportList *reports, struct Object *ob, struct ModifierData *md);
+int ED_object_modifier_add(struct ReportList *reports, struct Scene *scene, struct Object *ob, int type);
+int ED_object_modifier_remove(struct ReportList *reports, struct Scene *scene, struct Object *ob, struct ModifierData *md);
 int ED_object_modifier_move_down(struct ReportList *reports, struct Object *ob, struct ModifierData *md);
 int ED_object_modifier_move_up(struct ReportList *reports, struct Object *ob, struct ModifierData *md);
 int ED_object_modifier_convert(struct ReportList *reports, struct Scene *scene, struct Object *ob, struct ModifierData *md);
similarity index 97%
rename from source/blender/editors/include/ED_pointcache.h
rename to source/blender/editors/include/ED_physics.h
index dc50e274fa9a112c4ae4294be2bcd2b858fa6439..b04bfb992dc4488fa3b0c9c9ce18a57a58a9ad48 100644 (file)
@@ -31,7 +31,9 @@
 #define ED_PHYSICS_H
 
 /* operators */
+
 void ED_operatortypes_pointcache(void);
+void ED_operatortypes_fluid(void);
 //void ED_keymap_pointcache(struct wmWindowManager *wm);
 
 #endif /* ED_PHYSICS_H */
index ef682c871bcc41e6ba7dde0a6c5a5dccfa33a93f..4bb1dd65f853d55229f7be0d2fb86ed44f058d9c 100644 (file)
@@ -127,6 +127,7 @@ int         ED_operator_editcurve(struct bContext *C);
 int            ED_operator_editsurf(struct bContext *C);
 int            ED_operator_editsurfcurve(struct bContext *C);
 int            ED_operator_editfont(struct bContext *C);
+int            ED_operator_editlattice(struct bContext *C);
 int            ED_operator_uvedit(struct bContext *C);
 int            ED_operator_uvmap(struct bContext *C);
 int            ED_operator_posemode(struct bContext *C);
index cc8b936b04f2d15626dc8a4bc84f79f13142c67c..cf284e7b111d42db3556b09fbdcd66630d65d92b 100644 (file)
@@ -51,10 +51,12 @@ struct rcti;
 struct rctf;
 struct uiStyle;
 struct uiFontStyle;
+struct uiWidgetColors;
 struct ColorBand;
 struct CurveMapping;
 struct Image;
 struct ImageUser;
+struct uiWidgetColors;
 
 typedef struct uiBut uiBut;
 typedef struct uiBlock uiBlock;
@@ -214,6 +216,11 @@ void uiRoundRect(float minx, float miny, float maxx, float maxy, float rad);
 void uiDrawMenuBox(float minx, float miny, float maxx, float maxy, short flag, short direction);
 void uiDrawBoxShadow(unsigned char alpha, float minx, float miny, float maxx, float maxy);
 
+/* state for scrolldrawing */
+#define UI_SCROLL_PRESSED      1
+#define UI_SCROLL_ARROWS       2
+void uiWidgetScrollDraw(struct uiWidgetColors *wcol, struct rcti *rect, struct rcti *slider, int state);
+
 /* Menu Callbacks */
 
 typedef void (*uiMenuCreateFunc)(struct bContext *C, struct uiLayout *layout, void *arg1);
@@ -635,6 +642,7 @@ void uiItemFullO(uiLayout *layout, char *name, int icon, char *idname, struct ID
 void uiItemR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, int expand, int slider, int toggle);
 void uiItemFullR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, int value, int expand, int slider, int toggle);
 void uiItemEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, int value);
+void uiItemEnumR_string(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, char *value);
 void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, char *propname);
 void uiItemPointerR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, struct PointerRNA *searchptr, char *searchpropname);
 
index 4813b6957952e8de7214205e50f91b1734b61c57..537c1b42b972868a65b5b6c8b009bee4b9ef84a7 100644 (file)
@@ -97,12 +97,12 @@ enum {
 
 /* ------ Defines for Scrollers ----- */
 
-/* scroller thickness */
-#define V2D_SCROLL_HEIGHT      16
-#define V2D_SCROLL_WIDTH       16
+/* scroller area */
+#define V2D_SCROLL_HEIGHT      17
+#define V2D_SCROLL_WIDTH       17
 
-/* half the size (in pixels) of scroller 'handles' */
-#define V2D_SCROLLER_HANDLE_SIZE       5
+/* scroller 'handles' hotspot radius for mouse */
+#define V2D_SCROLLER_HANDLE_SIZE       12
 
 /* ------ Define for UI_view2d_sync ----- */
 
index f9816235b88e993cd866ba0086dc018c37f64d61..59726c6d5fd26b7cccf8e949508c693f7e22ba60 100644 (file)
@@ -615,14 +615,13 @@ void uiItemEnumO_string(uiLayout *layout, char *name, int icon, char *opname, ch
        /* for getting the enum */
        PropertyRNA *prop;
        const EnumPropertyItem *item;
-       int totitem;
        int value;
 
        WM_operator_properties_create(&ptr, opname);
        
        /* enum lookup */
        if((prop= RNA_struct_find_property(&ptr, propname))) {
-               RNA_property_enum_items(&ptr, prop, &item, &totitem);
+               RNA_property_enum_items(&ptr, prop, &item, NULL);
                if(RNA_enum_value_from_id(item, value_str, &value)==0) {
                        printf("uiItemEnumO_string: %s.%s, enum %s not found.\n", RNA_struct_identifier(ptr.type), propname, value_str);
                        return;
@@ -695,14 +694,17 @@ static void ui_item_rna_size(uiLayout *layout, char *name, int icon, PropertyRNA
        PropertySubType subtype;
        int len, w, h;
 
-       w= ui_text_icon_width(layout, name, icon);
-       h= UI_UNIT_Y;
-
        /* arbitrary extended width by type */
        type= RNA_property_type(prop);
        subtype= RNA_property_subtype(prop);
        len= RNA_property_array_length(prop);
 
+       if(ELEM(type, PROP_STRING, PROP_POINTER) && strcmp(name, "") == 0)
+               name= "non-empty";
+
+       w= ui_text_icon_width(layout, name, icon);
+       h= UI_UNIT_Y;
+
        /* increase height for arrays */
        if(index == RNA_NO_INDEX && len > 0) {
                if(strcmp(name, "") == 0 && icon == 0)
@@ -827,15 +829,48 @@ void uiItemEnumR(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr,
 
        prop= RNA_struct_find_property(ptr, propname);
 
-       if(!prop) {
+       if(!prop || RNA_property_type(prop) != PROP_ENUM) {
                ui_item_disabled(layout, propname);
-               printf("uiItemEnumR: property not found: %s\n", propname);
+               printf("uiItemEnumR: enum property not found: %s\n", propname);
                return;
        }
 
        uiItemFullR(layout, name, icon, ptr, prop, RNA_ENUM_VALUE, value, 0, 0, 0);
 }
 
+void uiItemEnumR_string(uiLayout *layout, char *name, int icon, struct PointerRNA *ptr, char *propname, char *value)
+{
+       PropertyRNA *prop;
+       const EnumPropertyItem *item;
+       int ivalue, a;
+
+       if(!ptr->data || !propname)
+               return;
+
+       prop= RNA_struct_find_property(ptr, propname);
+
+       if(!prop || RNA_property_type(prop) != PROP_ENUM) {
+               ui_item_disabled(layout, propname);
+               printf("uiItemEnumR: enum property not found: %s\n", propname);
+               return;
+       }
+
+       RNA_property_enum_items(ptr, prop, &item, NULL);
+
+       if(!RNA_enum_value_from_id(item, value, &ivalue)) {
+               ui_item_disabled(layout, propname);
+               printf("uiItemEnumR: enum property value not found: %s\n", value);
+               return;
+       }
+
+       for(a=0; item[a].identifier; a++) {
+               if(item[a].value == ivalue) {
+                       uiItemFullR(layout, (char*)item[a].name, item[a].icon, ptr, prop, RNA_ENUM_VALUE, ivalue, 0, 0, 0);
+                       break;
+               }
+       }
+}
+
 void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, char *propname)
 {
        PropertyRNA *prop;
index a20884a61a39a6906d28573c46d5a3eab810b490..319e69a40e48b9a27f6fdca6c244365f97e2f980 100644 (file)
@@ -106,7 +106,7 @@ static int panel_aligned(ScrArea *sa, ARegion *ar)
        }
        else if(sa->spacetype==SPACE_FILE && ar->regiontype == RGN_TYPE_CHANNELS)
                return BUT_VERTICAL;
-       else if(ELEM(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS))
+       else if(ELEM3(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS))
                return BUT_VERTICAL;
        
        return 0;
index 8f1d57b28ed3cbcf0ca4ab2c880890970ebfa173..1ce352444e68996cb7ce380f247e0a2e3abbc3f5 100644 (file)
@@ -320,134 +320,6 @@ void uiTemplateID(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname
 
 #include "ED_object.h"
 
-static void modifiers_del(bContext *C, void *ob_v, void *md_v)
-{
-       Scene *scene= CTX_data_scene(C);
-       Object *ob= ob_v;
-       ReportList reports;
-
-       BKE_reports_init(&reports, RPT_STORE);
-
-       if(ED_object_modifier_delete(&reports, ob_v, md_v)) {
-               WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
-               DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
-
-               ED_undo_push(C, "Delete modifier");
-       }
-       else
-               uiPupMenuReports(C, &reports);
-
-       BKE_reports_clear(&reports);
-}
-
-static void modifiers_activate(bContext *C, void *ob_v, void *md_v)
-{
-       Scene *scene= CTX_data_scene(C);
-       Object *ob= ob_v;
-
-       WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
-       DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
-}
-
-static void modifiers_moveUp(bContext *C, void *ob_v, void *md_v)
-{
-       Scene *scene= CTX_data_scene(C);
-       Object *ob= ob_v;
-       ReportList reports;
-
-       BKE_reports_init(&reports, RPT_STORE);
-
-       if(ED_object_modifier_move_up(&reports, ob_v, md_v)) {
-               WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
-               DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
-
-               ED_undo_push(C, "Move modifier");
-       }
-       else
-               uiPupMenuReports(C, &reports);
-
-       BKE_reports_clear(&reports);
-}
-
-static void modifiers_moveDown(bContext *C, void *ob_v, void *md_v)
-{
-       Scene *scene= CTX_data_scene(C);
-       Object *ob= ob_v;
-       ReportList reports;
-
-       BKE_reports_init(&reports, RPT_STORE);
-
-       if(ED_object_modifier_move_down(&reports, ob_v, md_v)) {
-               WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
-               DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
-
-               ED_undo_push(C, "Move modifier");
-       }
-       else
-               uiPupMenuReports(C, &reports);
-
-       BKE_reports_clear(&reports);
-}
-
-static void modifiers_convertParticles(bContext *C, void *obv, void *mdv)
-{
-       Scene *scene= CTX_data_scene(C);
-       Object *ob= obv;
-       ReportList reports;
-
-       BKE_reports_init(&reports, RPT_STORE);
-
-       if(ED_object_modifier_convert(&reports, scene, obv, mdv)) {
-               WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
-               DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
-
-               ED_undo_push(C, "Convert particles to mesh object(s).");
-       }
-       else
-               uiPupMenuReports(C, &reports);
-
-       BKE_reports_clear(&reports);
-}
-
-static void modifiers_applyModifier(bContext *C, void *obv, void *mdv)
-{
-       Scene *scene= CTX_data_scene(C);
-       Object *ob= obv;
-       ReportList reports;
-
-       BKE_reports_init(&reports, RPT_STORE);
-
-       if(ED_object_modifier_apply(&reports, scene, obv, mdv)) {
-               WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
-               DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
-
-               ED_undo_push(C, "Apply modifier");
-       }
-       else
-               uiPupMenuReports(C, &reports);
-
-       BKE_reports_clear(&reports);
-}
-
-static void modifiers_copyModifier(bContext *C, void *ob_v, void *md_v)
-{
-       Scene *scene= CTX_data_scene(C);
-       Object *ob= ob_v;
-       ReportList reports;
-
-       BKE_reports_init(&reports, RPT_STORE);
-
-       if(ED_object_modifier_copy(&reports, ob_v, md_v)) {
-               WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
-               DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
-               ED_undo_push(C, "Copy modifier");
-       }
-       else
-               uiPupMenuReports(C, &reports);
-
-       BKE_reports_clear(&reports);
-}
-
 static void modifiers_setOnCage(bContext *C, void *ob_v, void *md_v)
 {
        Scene *scene= CTX_data_scene(C);
@@ -490,15 +362,7 @@ static void modifiers_convertToReal(bContext *C, void *ob_v, void *md_v)
 
 static int modifier_can_delete(ModifierData *md)
 {
-       // deletion over the deflection panel
        // fluid particle modifier can't be deleted here
-
-       if(md->type==eModifierType_Fluidsim)
-               return 0;
-       if(md->type==eModifierType_Collision)
-               return 0;
-       if(md->type==eModifierType_Surface)
-               return 0;
        if(md->type == eModifierType_ParticleSystem)
                if(((ParticleSystemModifierData *)md)->psys->part->type == PART_FLUID)
                        return 0;
@@ -512,12 +376,12 @@ static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, i
        PointerRNA ptr;
        uiBut *but;
        uiBlock *block;
-       uiLayout *column, *row, *subrow, *result= NULL;
-       int isVirtual = md->mode&eModifierMode_Virtual;
+       uiLayout *column, *row, *result= NULL;
+       int isVirtual = md->mode & eModifierMode_Virtual;
        // XXX short color = md->error?TH_REDALERT:TH_BUT_NEUTRAL;
-       short width = 295, buttonWidth = width-120-10;
        char str[128];
 
+       /* create RNA pointer */
        RNA_pointer_create(&ob->id, &RNA_Modifier, md, &ptr);
 
        column= uiLayoutColumn(layout, 1);
@@ -528,57 +392,57 @@ static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, i
                /* roundbox 4 free variables: corner-rounding, nop, roundbox type, shade */
 
        row= uiLayoutRow(uiLayoutBox(column), 0);
-       block= uiLayoutGetBlock(row);
+       uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_EXPAND);
 
-       subrow= uiLayoutRow(row, 0);
-       uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_LEFT);
+       block= uiLayoutGetBlock(row);
 
        //uiDefBut(block, ROUNDBOX, 0, "", x-10, y-4, width, 25, NULL, 7.0, 0.0, 
-       //               (!isVirtual && (md->mode&eModifierMode_Expanded))?3:15, 20, ""); 
+       //               (!isVirtual && (md->mode & eModifierMode_Expanded))?3:15, 20, ""); 
        /* XXX uiBlockSetCol(block, TH_AUTO); */
        
        /* open/close icon */
-       if (!isVirtual) {
+       if(!isVirtual) {
                uiBlockSetEmboss(block, UI_EMBOSSN);
                uiDefIconButBitI(block, ICONTOG, eModifierMode_Expanded, 0, ICON_TRIA_RIGHT, 0, 0, UI_UNIT_X, UI_UNIT_Y, &md->mode, 0.0, 0.0, 0.0, 0.0, "Collapse/Expand Modifier");
        }
        
        /* modifier-type icon */
-       uiDefIconBut(block, BUT, 0, RNA_struct_ui_icon(ptr.type), 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, "Current Modifier Type");
+       uiItemL(row, "", RNA_struct_ui_icon(ptr.type));
        
        uiBlockSetEmboss(block, UI_EMBOSS);
        
-       if (isVirtual) {
+       if(isVirtual) {
+               /* virtual modifier */
                sprintf(str, "%s parent deform", md->name);
                uiDefBut(block, LABEL, 0, str, 0, 0, 185, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, "Modifier name"); 
 
                but = uiDefBut(block, BUT, 0, "Make Real", 0, 0, 80, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Convert virtual modifier to a real modifier");
                uiButSetFunc(but, modifiers_convertToReal, ob, md);
-       } else {
+       }
+       else {
+               /* real modifier */
                uiBlockBeginAlign(block);
-               uiDefBut(block, TEX, 0, "", 0, 0, buttonWidth-40, UI_UNIT_Y, md->name, 0.0, sizeof(md->name)-1, 0.0, 0.0, "Modifier name"); 
+               uiItemR(row, "", 0, &ptr, "name", 0, 0, 0);
 
                /* Softbody not allowed in this situation, enforce! */
-               if (((md->type!=eModifierType_Softbody && md->type!=eModifierType_Collision) || !(ob->pd && ob->pd->deflect)) && (md->type!=eModifierType_Surface)) {
-                       uiDefIconButBitI(block, TOG, eModifierMode_Render, 0, ICON_SCENE, 0, 0, 19, UI_UNIT_Y,&md->mode, 0, 0, 1, 0, "Enable modifier during rendering");
-                       but= uiDefIconButBitI(block, TOG, eModifierMode_Realtime, 0, ICON_VIEW3D, 0, 0, 19, UI_UNIT_Y,&md->mode, 0, 0, 1, 0, "Enable modifier during interactive display");
-                       uiButSetFunc(but, modifiers_activate, ob, md);
-                       if (mti->flags&eModifierTypeFlag_SupportsEditmode) {
-                               but= uiDefIconButBitI(block, TOG, eModifierMode_Editmode, 0, ICON_EDITMODE_HLT, 0, 0, 19, UI_UNIT_Y,&md->mode, 0, 0, 1, 0, "Enable modifier during Editmode (only if enabled for display)");
-                               uiButSetFunc(but, modifiers_activate, ob, md);
-                       }
+               if(((md->type!=eModifierType_Softbody && md->type!=eModifierType_Collision) || !(ob->pd && ob->pd->deflect)) && (md->type!=eModifierType_Surface)) {
+                       uiItemR(row, "", ICON_SCENE, &ptr, "render", 0, 0, 0);
+                       uiItemR(row, "", ICON_VIEW3D, &ptr, "realtime", 0, 0, 0);
+
+                       if(mti->flags & eModifierTypeFlag_SupportsEditmode)
+                               uiItemR(row, "", ICON_VIEW3D, &ptr, "editmode", 0, 0, 0);
                }
                uiBlockEndAlign(block);
 
                /* XXX uiBlockSetEmboss(block, UI_EMBOSSR); */
 
-               if (ob->type==OB_MESH && modifier_couldBeCage(md) && index<=lastCageIndex) {
+               if(ob->type==OB_MESH && modifier_couldBeCage(md) && index<=lastCageIndex) {
                        int icon; //, color;
 
-                       if (index==cageIndex) {
+                       if(index==cageIndex) {
                                // XXX color = TH_BUT_SETTING;
                                icon = VICON_EDITMODE_HLT;
-                       } else if (index<cageIndex) {
+                       } else if(index<cageIndex) {
                                // XXX color = TH_BUT_NEUTRAL;
                                icon = VICON_EDITMODE_DEHLT;
                        } else {
@@ -592,67 +456,55 @@ static uiLayout *draw_modifier(uiLayout *layout, Object *ob, ModifierData *md, i
                }
        }
 
-       subrow= uiLayoutRow(row, 0);
-       uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_RIGHT);
-
+       /* up/down/delete */
        if(!isVirtual) {
                /* XXX uiBlockSetCol(block, TH_BUT_ACTION); */
-
-               but = uiDefIconBut(block, BUT, 0, VICON_MOVE_UP, 0, 0, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Move modifier up in stack");
-               uiButSetFunc(but, modifiers_moveUp, ob, md);
-
-               but = uiDefIconBut(block, BUT, 0, VICON_MOVE_DOWN, 0, 0, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Move modifier down in stack");
-               uiButSetFunc(but, modifiers_moveDown, ob, md);
+               uiItemO(row, "", VICON_MOVE_UP, "OBJECT_OT_modifier_move_up");
+               uiItemO(row, "", VICON_MOVE_DOWN, "OBJECT_OT_modifier_move_down");
                
                uiBlockSetEmboss(block, UI_EMBOSSN);
-               
-               if(modifier_can_delete(md)) {
-                       but = uiDefIconBut(block, BUT, 0, VICON_X, 0, 0, 16, 16, NULL, 0.0, 0.0, 0.0, 0.0, "Delete modifier");
-                       uiButSetFunc(but, modifiers_del, ob, md);
-               }
+
+               if(modifier_can_delete(md))
+                       uiItemO(row, "", VICON_X, "OBJECT_OT_modifier_remove");
+
                /* XXX uiBlockSetCol(block, TH_AUTO); */
        }
 
        uiBlockSetEmboss(block, UI_EMBOSS);
 
-       if(!isVirtual && (md->mode&eModifierMode_Expanded)) {
+       if(!isVirtual && (md->mode & eModifierMode_Expanded)) {
+               /* apply/convert/copy */
                uiLayout *box;
 
                box= uiLayoutBox(column);
                row= uiLayoutRow(box, 1);
 
-               if (!isVirtual && (md->type!=eModifierType_Collision) && (md->type!=eModifierType_Surface)) {
-                       uiBlockSetButLock(block, object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE); /* only here obdata, the rest of modifiers is ob level */
+               if(!isVirtual && (md->type!=eModifierType_Collision) && (md->type!=eModifierType_Surface)) {
+                       /* only here obdata, the rest of modifiers is ob level */
+                       uiBlockSetButLock(block, object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
 
-                                               if (md->type==eModifierType_ParticleSystem) {
+                       if(md->type==eModifierType_ParticleSystem) {
                        ParticleSystem *psys= ((ParticleSystemModifierData *)md)->psys;
 
-                       if(!(G.f & G_PARTICLEEDIT)) {
-                                       if(ELEM3(psys->part->draw_as, PART_DRAW_PATH, PART_DRAW_GR, PART_DRAW_OB) && psys->pathcache) {
-                                               but = uiDefBut(block, BUT, 0, "Convert",        0,0,60,19, 0, 0, 0, 0, 0, "Convert the current particles to a mesh object");
-                                               uiButSetFunc(but, modifiers_convertParticles, ob, md);
-                                       }
-                               }
-                       }
-                       else{
-                               but = uiDefBut(block, BUT, 0, "Apply",  0,0,60,19, 0, 0, 0, 0, 0, "Apply the current modifier and remove from the stack");
-                               uiButSetFunc(but, modifiers_applyModifier, ob, md);
+                       if(!(G.f & G_PARTICLEEDIT))
+                                       if(ELEM3(psys->part->ren_as, PART_DRAW_PATH, PART_DRAW_GR, PART_DRAW_OB) && psys->pathcache)
+                                               uiItemO(row, "Convert", 0, "OBJECT_OT_modifier_convert");
                        }
+                       else
+                               uiItemO(row, "Apply", 0, "OBJECT_OT_modifier_apply");
                        
                        uiBlockClearButLock(block);
                        uiBlockSetButLock(block, ob && ob->id.lib, ERROR_LIBDATA_MESSAGE);
 
-                       if (md->type!=eModifierType_Fluidsim && md->type!=eModifierType_Softbody && md->type!=eModifierType_ParticleSystem && (md->type!=eModifierType_Cloth)) {
-                               but = uiDefBut(block, BUT, 0, "Copy",   0,0,60,19, 0, 0, 0, 0, 0, "Duplicate the current modifier at the same position in the stack");
-                               uiButSetFunc(but, modifiers_copyModifier, ob, md);
-                       }
+                       if(!ELEM4(md->type, eModifierType_Fluidsim, eModifierType_Softbody, eModifierType_ParticleSystem, eModifierType_Cloth))
+                               uiItemO(row, "Copy", 0, "OBJECT_OT_modifier_copy");
                }
 
                result= uiLayoutColumn(box, 0);
                block= uiLayoutFreeBlock(box);
        }
 
-       if (md->error) {
+       if(md->error) {
                row = uiLayoutRow(uiLayoutBox(column), 0);
 
                /* XXX uiBlockSetCol(block, color); */
@@ -694,7 +546,7 @@ uiLayout *uiTemplateModifier(uiLayout *layout, PointerRNA *ptr)
        for(i=0; vmd; i++, vmd=vmd->next) {
                if(md == vmd)
                        return draw_modifier(layout, ob, md, i, cageIndex, lastCageIndex);
-               else if(vmd->mode&eModifierMode_Virtual)
+               else if(vmd->mode & eModifierMode_Virtual)
                        i--;
        }
 
index ed2d00cb00d6c08baf847080c6f6d203dc7090a3..2cd7c1d61cd0c22cd59f46f2fd719e1ed35aefe9 100644 (file)
@@ -293,13 +293,15 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, fl
        float maxyi= maxy - 1.0f;
        float facxi= 1.0f/(maxxi-minxi); /* for uv */
        float facyi= 1.0f/(maxyi-minyi);
-       int a, tot= 0;
+       int a, tot= 0, minsize;
        
-       if(2.0f*rad > rect->ymax-rect->ymin)
-               rad= 0.5f*(rect->ymax-rect->ymin);
+       minsize= MIN2(rect->xmax-rect->xmin, rect->ymax-rect->ymin);
+       
+       if(2.0f*rad > minsize)
+               rad= 0.5f*minsize;
 
-       if(2.0f*(radi+1.0f) > rect->ymax-rect->ymin)
-               radi= 0.5f*(rect->ymax-rect->ymin) - 1.0f;
+       if(2.0f*(radi+1.0f) > minsize)
+               radi= 0.5f*minsize - 1.0f;
        
        /* mult */
        for(a=0; a<9; a++) {
@@ -433,22 +435,33 @@ static void round_box_edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, flo
 /* based on button rect, return scaled array of triangles */
 static void widget_num_tria(uiWidgetTrias *tria, rcti *rect, float triasize, char where)
 {
-       float centx, centy, size;
-       int a;
+       float centx, centy, sizex, sizey, minsize;
+       int a, i1=0, i2=1;
+       
+       minsize= MIN2(rect->xmax-rect->xmin, rect->ymax-rect->ymin);
        
        /* center position and size */
-       centx= (float)rect->xmin + 0.5f*(rect->ymax-rect->ymin);
-       centy= (float)rect->ymin + 0.5f*(rect->ymax-rect->ymin);
-       size= -0.5f*triasize*(rect->ymax-rect->ymin);
+       centx= (float)rect->xmin + 0.5f*minsize;
+       centy= (float)rect->ymin + 0.5f*minsize;
+       sizex= sizey= -0.5f*triasize*minsize;
 
        if(where=='r') {
-               centx= (float)rect->xmax - 0.5f*(rect->ymax-rect->ymin);
-               size= -size;
+               centx= (float)rect->xmax - 0.5f*minsize;
+               sizex= -sizex;
+       }       
+       else if(where=='t') {
+               centy= (float)rect->ymax - 0.5f*minsize;
+               sizey= -sizey;
+               i2=0; i1= 1;
+       }       
+       else if(where=='b') {
+               sizex= -sizex;
+               i2=0; i1= 1;
        }       
        
        for(a=0; a<19; a++) {
-               tria->vec[a][0]= size*num_tria_vert[a][0] + centx;
-               tria->vec[a][1]= size*num_tria_vert[a][1] + centy;
+               tria->vec[a][0]= sizex*num_tria_vert[a][i1] + centx;
+               tria->vec[a][1]= sizey*num_tria_vert[a][i2] + centy;
        }
        
        tria->tot= 19;
@@ -525,7 +538,7 @@ static void shadecolors4(char *coltop, char *coldown, char *color, short shadeto
        coldown[0]= CLAMPIS(color[0]+shadedown, 0, 255);
        coldown[1]= CLAMPIS(color[1]+shadedown, 0, 255);
        coldown[2]= CLAMPIS(color[2]+shadedown, 0, 255);
-       coldown[3]= color[3];
+       coldown[3]= color[3];   
 }
 
 static void round_box_shade_col4(char *col1, char *col2, float fac)
@@ -1104,16 +1117,16 @@ static struct uiWidgetColors wcol_toggle= {
 };
 
 static struct uiWidgetColors wcol_scroll= {
-       {25, 25, 25, 255},
+       {50, 50, 50, 180},
+       {80, 80, 80, 180},
+       {100, 100, 100, 180},
        {180, 180, 180, 255},
-       {153, 153, 153, 255},
-       {90, 90, 90, 255},
        
        {0, 0, 0, 255},
        {255, 255, 255, 255},
        
        1,
-       0, -20
+       10, -20
 };
 
 /* free wcol struct to play with */
@@ -1204,6 +1217,10 @@ static void widget_state_label(uiWidgetType *wt, int state)
        
 }
 
+static void widget_state_nothing(uiWidgetType *wt, int state)
+{
+       wt->wcol= *(wt->wcol_theme);
+}      
 
 /* special case, button that calls pulldown */
 static void widget_state_pulldown(uiWidgetType *wt, int state)
@@ -1570,7 +1587,7 @@ static void widget_numbut(uiWidgetColors *wcol, rcti *rect, int state, int round
        
        /* decoration */
        if(!(state & UI_TEXTINPUT)) {
-               widget_num_tria(&wtb.tria1, rect, 0.6f, 0);
+               widget_num_tria(&wtb.tria1, rect, 0.6f, 'l');
                widget_num_tria(&wtb.tria2, rect, 0.6f, 'r');
        }       
        widgetbase_draw(&wtb, wcol);
@@ -1632,44 +1649,79 @@ void ui_draw_link_bezier(rcti *rect)
        }
 }
 
-static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
+/* function in use for buttons and for view2d sliders */
+void uiWidgetScrollDraw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int state)
 {
        uiWidgetBase wtb;
-       rcti rect1;
-       double value;
-       char inner[3];
-       float fac, size, rad;
+       float rad;
        int horizontal;
 
+       widget_init(&wtb);
+
        /* determine horizontal/vertical */
        horizontal= (rect->xmax - rect->xmin > rect->ymax - rect->ymin);
-
+       
        if(horizontal)
                rad= 0.5f*(rect->ymax - rect->ymin);
        else
                rad= 0.5f*(rect->xmax - rect->xmin);
-
-       widget_init(&wtb);
+       
        wtb.shadedir= (horizontal)? 1: 0;
-
+       
        /* draw back part, colors swapped and shading inverted */
-       VECCOPY(inner, wcol->inner);
-       VECCOPY(wcol->inner, wcol->item);
        if(horizontal)
                SWAP(short, wcol->shadetop, wcol->shadedown);
-       if(state & UI_SELECT)
-               SWAP(short, wcol->shadetop, wcol->shadedown);
        
-       round_box_edges(&wtb, roundboxalign, rect, rad); /* XXX vertical gradient is wrong */
+       round_box_edges(&wtb, 15, rect, rad); 
        widgetbase_draw(&wtb, wcol);
-
-       VECCOPY(wcol->inner, inner);
-       if(horizontal)
-               SWAP(short, wcol->shadetop, wcol->shadedown);
-       if(state & UI_SELECT)
-               SWAP(short, wcol->shadetop, wcol->shadedown);
        
-       /* front part */
+       /* slider */
+       if(slider->xmax-slider->xmin<2 || slider->ymax-slider->ymin<2);
+       else {
+               
+               SWAP(short, wcol->shadetop, wcol->shadedown);
+               
+               QUATCOPY(wcol->inner, wcol->item);
+               
+               if(wcol->shadetop>wcol->shadedown)
+                       wcol->shadetop+= 20;    /* XXX violates themes... */
+               else wcol->shadedown+= 20;
+               
+               if(state & UI_SCROLL_PRESSED)
+                       SWAP(short, wcol->shadetop, wcol->shadedown);
+
+               /* draw */
+               wtb.emboss= 0; /* only emboss once */
+               
+               round_box_edges(&wtb, 15, slider, rad); 
+               
+               if(state & UI_SCROLL_ARROWS) {
+                       if(wcol->item[0] > 48) wcol->item[0]-= 48;
+                       if(wcol->item[1] > 48) wcol->item[1]-= 48;
+                       if(wcol->item[2] > 48) wcol->item[2]-= 48;
+                       wcol->item[3]= 255;
+                       
+                       if(horizontal) {
+                               widget_num_tria(&wtb.tria1, slider, 0.6f, 'l');
+                               widget_num_tria(&wtb.tria2, slider, 0.6f, 'r');
+                       }
+                       else {
+                               widget_num_tria(&wtb.tria1, slider, 0.6f, 'b');
+                               widget_num_tria(&wtb.tria2, slider, 0.6f, 't');
+                       }
+               }
+               widgetbase_draw(&wtb, wcol);
+       }       
+}
+
+static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
+{
+       rcti rect1;
+       double value;
+       float fac, size;
+       int horizontal;
+
+       /* calculate slider part */
        value= ui_get_but_val(but);
 
        size= (but->softmax + but->a1 - but->softmin);
@@ -1678,6 +1730,9 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
        /* position */
        rect1= *rect;
 
+       /* determine horizontal/vertical */
+       horizontal= (rect->xmax - rect->xmin > rect->ymax - rect->ymin);
+       
        if(horizontal) {
                fac= (rect->xmax - rect->xmin)/(size);
                rect1.xmin= rect1.xmin + ceil(fac*(value - but->softmin));
@@ -1689,17 +1744,12 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
                rect1.ymin= rect1.ymax - ceil(fac*(but->a1 - but->softmin));
        }
 
-       /* draw */
-       wtb.emboss= 0; /* only emboss once */
-
-       if(!horizontal)
-               SWAP(short, wcol->shadetop, wcol->shadedown);
-
-       round_box_edges(&wtb, roundboxalign, &rect1, rad); /* XXX vertical gradient is wrong */
-       widgetbase_draw(&wtb, wcol);
+       if(state & UI_SELECT)
+               state= UI_SCROLL_PRESSED;
+       else
+               state= 0;
+       uiWidgetScrollDraw(wcol, rect, &rect1, state);
 
-       if(!horizontal)
-               SWAP(short, wcol->shadetop, wcol->shadedown);
 }
 
 static void widget_link(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
@@ -2101,6 +2151,7 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
 
                case UI_WTYPE_SCROLL:
                        wt.wcol_theme= &btheme->tui.wcol_scroll;
+                       wt.state= widget_state_nothing;
                        wt.custom= widget_scroll;
                        break;
        }
index aa5aa65d300b6cb0aa4dba37df37f335a18be0df..11714df0491b5d6f3960631d51e3be7459ee6460 100644 (file)
@@ -34,6 +34,7 @@
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_space_types.h"
+#include "DNA_userdef_types.h"
 #include "DNA_view2d_types.h"
 
 #include "BLI_blenlib.h"
@@ -901,7 +902,14 @@ void UI_view2d_view_orthoSpecial(const bContext *C, View2D *v2d, short xaxis)
 /* Restore view matrices after drawing */
 void UI_view2d_view_restore(const bContext *C)
 {
-       ED_region_pixelspace(CTX_wm_region(C));
+       ARegion *ar= CTX_wm_region(C);
+       int width= ar->winrct.xmax-ar->winrct.xmin+1;
+       int height= ar->winrct.ymax-ar->winrct.ymin+1;
+       
+       wmOrtho2(0.0f, (float)width, 0.0f, (float)height);
+       wmLoadIdentity();
+       
+       //      ED_region_pixelspace(CTX_wm_region(C));
 }
 
 /* *********************************************************************** */
@@ -1198,12 +1206,15 @@ void UI_view2d_grid_free(View2DGrid *grid)
  * WARNING: the start of this struct must not change, as view2d_ops.c uses this too. 
  *                For now, we don't need to have a separate (internal) header for structs like this...
  */
-struct View2DScrollers {       
+struct View2DScrollers {
                /* focus bubbles */
        int vert_min, vert_max; /* vertical scrollbar */
        int hor_min, hor_max;   /* horizontal scrollbar */
        
-               /* scales */
+       rcti hor, vert;                 /* exact size of slider backdrop */
+       int horfull, vertfull;  /* set if sliders are full, we don't draw them */
+       
+       /* scales */
        View2DGrid *grid;               /* grid for coordinate drawing */
        short xunits, xclamp;   /* units and clamping options for x-axis */
        short yunits, yclamp;   /* units and clamping options for y-axis */
@@ -1214,14 +1225,33 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
 {
        View2DScrollers *scrollers;
        rcti vert, hor;
-       float fac, totsize, scrollsize;
+       float fac1, fac2, totsize, scrollsize;
        int scroll= view2d_scroll_mapped(v2d->scroll);
        
+       /* scrollers is allocated here... */
+       scrollers= MEM_callocN(sizeof(View2DScrollers), "View2DScrollers");
+       
        vert= v2d->vert;
        hor= v2d->hor;
        
-       /* scrollers is allocated here... */
-       scrollers= MEM_callocN(sizeof(View2DScrollers), "View2DScrollers");
+       /* slider rects smaller than region */
+       hor.xmin+=4;
+       hor.xmax-=4;
+       if (scroll & V2D_SCROLL_BOTTOM)
+               hor.ymin+=4;
+       else
+               hor.ymax-=4;
+       
+       if (scroll & V2D_SCROLL_LEFT)
+               vert.xmin+=4;
+       else
+               vert.xmax-=4;
+       vert.ymin+=4;
+       vert.ymax-=4;
+       
+       /* store in scrollers, used for drawing */
+       scrollers->vert= vert;
+       scrollers->hor= hor;
        
        /* scroller 'buttons':
         *      - These should always remain within the visible region of the scrollbar
@@ -1234,14 +1264,23 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
                totsize= v2d->tot.xmax - v2d->tot.xmin;
                scrollsize= (float)(hor.xmax - hor.xmin);
                
-               fac= (v2d->cur.xmin - v2d->tot.xmin) / totsize;
-               scrollers->hor_min= (int)(hor.xmin + (fac * scrollsize));
+               fac1= (v2d->cur.xmin - v2d->tot.xmin) / totsize;
+               if(fac1<=0.0f)
+                       scrollers->hor_min= hor.xmin;
+               else
+                       scrollers->hor_min= (int)(hor.xmin + (fac1 * scrollsize));
                
-               fac= (v2d->cur.xmax - v2d->tot.xmin) / totsize;
-               scrollers->hor_max= (int)(hor.xmin + (fac * scrollsize));
+               fac2= (v2d->cur.xmax - v2d->tot.xmin) / totsize;
+               if(fac2>=1.0f)
+                       scrollers->hor_max= hor.xmax;
+               else
+                       scrollers->hor_max= (int)(hor.xmin + (fac2 * scrollsize));
                
                if (scrollers->hor_min > scrollers->hor_max) 
                        scrollers->hor_min= scrollers->hor_max;
+               
+               if(fac1 <= 0.0f && fac2 >= 1.0f) 
+                       scrollers->horfull= 1;
        }
        
        /* vertical scrollers */
@@ -1250,14 +1289,23 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
                totsize= v2d->tot.ymax - v2d->tot.ymin;
                scrollsize= (float)(vert.ymax - vert.ymin);
                
-               fac= (v2d->cur.ymin- v2d->tot.ymin) / totsize;
-               scrollers->vert_min= (int)(vert.ymin + (fac * scrollsize));
+               fac1= (v2d->cur.ymin- v2d->tot.ymin) / totsize;
+               if(fac1<=0.0f)
+                       scrollers->vert_min= vert.ymin;
+               else
+                       scrollers->vert_min= (int)(vert.ymin + (fac1 * scrollsize));
                
-               fac= (v2d->cur.ymax - v2d->tot.ymin) / totsize;
-               scrollers->vert_max= (int)(vert.ymin + (fac * scrollsize));
+               fac2= (v2d->cur.ymax - v2d->tot.ymin) / totsize;
+               if(fac2>=1.0f)
+                       scrollers->vert_max= vert.ymax;
+               else
+                       scrollers->vert_max= (int)(vert.ymin + (fac2 * scrollsize));
                
                if (scrollers->vert_min > scrollers->vert_max) 
                        scrollers->vert_min= scrollers->vert_max;
+               
+               if(fac1 <= 0.0f && fac2 >= 1.0f) 
+                       scrollers->vertfull= 1;
        }
        
        /* grid markings on scrollbars */
@@ -1287,7 +1335,7 @@ static void scroll_printstr(View2DScrollers *scrollers, Scene *scene, float x, f
                 * rotation values (hence 'degrees') are divided by 10 to 
                 * be able to show the curves at the same time
                 */
-               if ELEM(unit, V2D_UNIT_DEGREES, V2D_UNIT_TIME) {
+               if (ELEM(unit, V2D_UNIT_DEGREES, V2D_UNIT_TIME)) {
                        power += 1;
                        val *= 10;
                }
@@ -1393,81 +1441,31 @@ static void scroll_printstr(View2DScrollers *scrollers, Scene *scene, float x, f
 void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *vs)
 {
        Scene *scene= CTX_data_scene(C);
-       const short darker= -50, dark= -10, light= 20, lighter= 50;
-       rcti vert, hor, corner;
+       rcti vert, hor;
        int scroll= view2d_scroll_mapped(v2d->scroll);
        
        /* make copies of rects for less typing */
-       vert= v2d->vert;
-       hor= v2d->hor;
+       vert= vs->vert;
+       hor= vs->hor;
        
        /* horizontal scrollbar */
        if (scroll & V2D_SCROLL_HORIZONTAL) {
-               /* scroller backdrop */
-               UI_ThemeColorShade(TH_SHADE1, light);
-               glRecti(hor.xmin,  hor.ymin,  hor.xmax,  hor.ymax);
-               
-               /* scroller 'button' 
-                *      - if view is zoomable in x, draw handles too 
-                *      - handles are drawn darker
-                *      - no slider when view is > total for non-zoomable views
-                *        (otherwise, zoomable ones tend to flicker)
-                */
-               if ( (v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL) ||
-                        ((v2d->tot.xmax - v2d->tot.xmin) > (v2d->cur.xmax - v2d->cur.xmin)) ) 
-               { 
-                       if (v2d->keepzoom & V2D_LOCKZOOM_X) {
-                               /* draw base bar as rounded shape */
-                               UI_ThemeColorShade(TH_SHADE1, dark);
-                               uiSetRoundBox(15);
-                               
-                               /* check that box is large enough for round drawing */
-                               if ((vs->hor_max - vs->hor_min) < (V2D_SCROLLCAP_RAD * 2)) {
-                                       /* Rounded box still gets drawn at the minimum size limit
-                                        * This doesn't represent extreme scaling well, but looks nicer...
-                                        */
-                                       float mid= 0.5f * (vs->hor_max + vs->hor_min);
-                                       
-                                       gl_round_box_shade(GL_POLYGON, 
-                                               mid-V2D_SCROLLCAP_RAD, (float)hor.ymin+2, 
-                                               mid+V2D_SCROLLCAP_RAD, (float)hor.ymax-2, 
-                                               V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE);
-                               }
-                               else {
-                                       /* draw rounded box as per normal */
-                                       gl_round_box_shade(GL_POLYGON, 
-                                               (float)vs->hor_min, (float)hor.ymin+2, 
-                                               (float)vs->hor_max, (float)hor.ymax-2, 
-                                               V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE);
-                               }
-                       }
-                       else {
-                               /* base bar drawn as shaded rect */
-                               UI_ThemeColorShade(TH_SHADE1, dark);
-                               uiSetRoundBox(0);
-                               gl_round_box_shade(GL_POLYGON, 
-                                       (float)vs->hor_min, (float)hor.ymin+2, 
-                                       (float)vs->hor_max, (float)hor.ymax-2, 
-                                       V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE);
-                               
-                               /* 'minimum' handle */
-                               uiSetRoundBox(9);
-                               UI_ThemeColorShade(TH_SHADE1, darker);
-                               
-                               gl_round_box_shade(GL_POLYGON, 
-                                       (float)vs->hor_min-V2D_SCROLLER_HANDLE_SIZE, (float)hor.ymin+2, 
-                                       (float)vs->hor_min+V2D_SCROLLER_HANDLE_SIZE, (float)hor.ymax-2, 
-                                       V2D_SCROLLCAP_RAD, V2D_SCROLLCAP_SHADE, -V2D_SCROLLCAP_SHADE);
-                               
-                               /* maximum handle */
-                               uiSetRoundBox(6);
-                               UI_ThemeColorShade(TH_SHADE1, darker);
-                               
-                               gl_round_box_shade(GL_POLYGON, 
-                                       (float)vs->hor_max-V2D_SCROLLER_HANDLE_SIZE, (float)hor.ymin+2, 
-                                       (float)vs->hor_max+V2D_SCROLLER_HANDLE_SIZE, (float)hor.ymax-2, 
-                                       V2D_SCROLLCAP_RAD, V2D_SCROLLCAP_SHADE, -V2D_SCROLLCAP_SHADE);
-                       }
+               
+               if(vs->horfull==0) {
+                       bTheme *btheme= U.themes.first;
+                       uiWidgetColors wcol= btheme->tui.wcol_scroll;
+                       rcti slider;
+                       int state;
+                       
+                       slider.xmin= vs->hor_min;
+                       slider.xmax= vs->hor_max;
+                       slider.ymin= hor.ymin;
+                       slider.ymax= hor.ymax;
+                       
+                       state= (v2d->scroll_ui & V2D_SCROLL_H_ACTIVE)?UI_SCROLL_PRESSED:0;
+                       if (!(v2d->keepzoom & V2D_LOCKZOOM_X))
+                               state |= UI_SCROLL_ARROWS;
+                       uiWidgetScrollDraw(&wcol, &hor, &slider, state);
                }
                
                /* scale indicators */
@@ -1502,19 +1500,26 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
                        
                        /* draw numbers in the appropriate range */
                        if (dfac > 0.0f) {
-                               for (; fac < hor.xmax; fac+=dfac, val+=grid->dx) {
+                               float h= 2.0f+(float)(hor.ymin);
+                               
+                               for (; fac < hor.xmax-10; fac+=dfac, val+=grid->dx) {
+                                       
+                                       /* make prints look nicer for scrollers */
+                                       if(fac < hor.xmin+10)
+                                               continue;
+                                       
                                        switch (vs->xunits) {                                                   
                                                case V2D_UNIT_FRAMES:           /* frames (as whole numbers)*/
-                                                       scroll_printstr(vs, scene, fac, 3.0f+(float)(hor.ymin), val, grid->powerx, V2D_UNIT_FRAMES, 'h');
+                                                       scroll_printstr(vs, scene, fac, h, val, grid->powerx, V2D_UNIT_FRAMES, 'h');
                                                        break;
                                                        
                                                case V2D_UNIT_FRAMESCALE:       /* frames (not always as whole numbers) */
-                                                       scroll_printstr(vs, scene, fac, 3.0f+(float)(hor.ymin), val, grid->powerx, V2D_UNIT_FRAMESCALE, 'h');
+                                                       scroll_printstr(vs, scene, fac, h, val, grid->powerx, V2D_UNIT_FRAMESCALE, 'h');
                                                        break;
                                                
                                                case V2D_UNIT_SECONDS:          /* seconds */
                                                        fac2= val/(float)FPS;
-                                                       scroll_printstr(vs, scene, fac, 3.0f+(float)(hor.ymin), fac2, grid->powerx, V2D_UNIT_SECONDS, 'h');
+                                                       scroll_printstr(vs, scene, fac, h, fac2, grid->powerx, V2D_UNIT_SECONDS, 'h');
                                                        break;
                                                        
                                                case V2D_UNIT_SECONDSSEQ:       /* seconds with special calculations (only used for sequencer only) */
@@ -1525,96 +1530,41 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
                                                        time= (float)floor(fac2);
                                                        fac2= fac2-time;
                                                        
-                                                       scroll_printstr(vs, scene, fac, 3.0f+(float)(hor.ymin), time+(float)FPS*fac2/100.0f, grid->powerx, V2D_UNIT_SECONDSSEQ, 'h');
+                                                       scroll_printstr(vs, scene, fac, h, time+(float)FPS*fac2/100.0f, grid->powerx, V2D_UNIT_SECONDSSEQ, 'h');
                                                }
                                                        break;
                                                        
                                                case V2D_UNIT_DEGREES:          /* Graph Editor for rotation Drivers */
                                                        /* HACK: although we're drawing horizontal, we make this draw as 'vertical', just to get degree signs */
-                                                       scroll_printstr(vs, scene, fac, 3.0f+(float)(hor.ymin), val, grid->powerx, V2D_UNIT_DEGREES, 'v');
+                                                       scroll_printstr(vs, scene, fac, h, val, grid->powerx, V2D_UNIT_DEGREES, 'v');
                                                        break;
                                        }
                                }
                        }
                }
-               
-               /* decoration outer bevel line */
-               UI_ThemeColorShade(TH_SHADE1, lighter);
-               if (scroll & (V2D_SCROLL_BOTTOM|V2D_SCROLL_BOTTOM_O))
-                       sdrawline(hor.xmin, hor.ymax, hor.xmax, hor.ymax);
-               else if (scroll & V2D_SCROLL_TOP)
-                       sdrawline(hor.xmin, hor.ymin, hor.xmax, hor.ymin);
        }
        
        /* vertical scrollbar */
        if (scroll & V2D_SCROLL_VERTICAL) {
-               /* scroller backdrop  */
-               UI_ThemeColorShade(TH_SHADE1, light);
-               glRecti(vert.xmin,  vert.ymin,  vert.xmax,  vert.ymax);
-               
-               /* scroller 'button' 
-                *      - if view is zoomable in y, draw handles too 
-                *      - handles are drawn darker
-                *      - no slider when view is > total for non-zoomable views
-                *        (otherwise, zoomable ones tend to flicker)
-                */
-               if ( (v2d->scroll & V2D_SCROLL_SCALE_VERTICAL) ||
-                        ((v2d->tot.ymax - v2d->tot.ymin) > (v2d->cur.ymax - v2d->cur.ymin)) ) 
-               { 
-                       if (v2d->keepzoom & V2D_LOCKZOOM_Y) {
-                               /* draw base bar as rounded shape */
-                               UI_ThemeColorShade(TH_SHADE1, dark);
-                               uiSetRoundBox(15);
-                               
-                               /* check that box is large enough for round drawing */
-                               if ((vs->vert_max - vs->vert_min) < (V2D_SCROLLCAP_RAD * 2)) {
-                                       /* Rounded box still gets drawn at the minimum size limit
-                                        * This doesn't represent extreme scaling well, but looks nicer...
-                                        */
-                                       float mid= 0.5f * (vs->vert_max + vs->vert_min);
-                                       
-                                       gl_round_box_vertical_shade(GL_POLYGON, 
-                                               (float)vert.xmin+2, mid-V2D_SCROLLCAP_RAD, 
-                                               (float)vert.xmax-2, mid+V2D_SCROLLCAP_RAD, 
-                                               V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE);
-                               }
-                               else {
-                                       /* draw rounded box as per normal */
-                                       gl_round_box_vertical_shade(GL_POLYGON, 
-                                               (float)vert.xmin+2, (float)vs->vert_min, 
-                                               (float)vert.xmax-2, (float)vs->vert_max, 
-                                               V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE);
-                               }
-                       }
-                       else {
-                               /* base bar drawn as shaded rect */
-                               UI_ThemeColorShade(TH_SHADE1, dark);
-                               uiSetRoundBox(0);
-                               gl_round_box_vertical_shade(GL_POLYGON, 
-                                       (float)vert.xmin+2, (float)vs->vert_min, 
-                                       (float)vert.xmax-2, (float)vs->vert_max,
-                                       V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE);
-                               
-                               /* 'minimum' handle */
-                               UI_ThemeColorShade(TH_SHADE1, darker);
-                               uiSetRoundBox(12);
-                               
-                               gl_round_box_vertical_shade(GL_POLYGON, 
-                                       (float)vert.xmin+2, (float)vs->vert_min-V2D_SCROLLER_HANDLE_SIZE, 
-                                       (float)vert.xmax-2, (float)vs->vert_min+V2D_SCROLLER_HANDLE_SIZE, 
-                                       V2D_SCROLLCAP_RAD, V2D_SCROLLCAP_SHADE, -V2D_SCROLLCAP_SHADE);
-                               
-                               /* maximum handle */
-                               UI_ThemeColorShade(TH_SHADE1, darker);
-                               uiSetRoundBox(3);
-                               
-                               gl_round_box_vertical_shade(GL_POLYGON, 
-                                       (float)vert.xmin+2, (float)vs->vert_max-V2D_SCROLLER_HANDLE_SIZE, 
-                                       (float)vert.xmax-2, (float)vs->vert_max+V2D_SCROLLER_HANDLE_SIZE, 
-                                       V2D_SCROLLCAP_RAD, V2D_SCROLLCAP_SHADE, -V2D_SCROLLCAP_SHADE);
-                       }
+               
+               if(vs->vertfull==0) {
+                       bTheme *btheme= U.themes.first;
+                       uiWidgetColors wcol= btheme->tui.wcol_scroll;
+                       rcti slider;
+                       int state;
+                       
+                       slider.xmin= vert.xmin;
+                       slider.xmax= vert.xmax;
+                       slider.ymin= vs->vert_min;
+                       slider.ymax= vs->vert_max;
+                       
+                       state= (v2d->scroll_ui & V2D_SCROLL_V_ACTIVE)?UI_SCROLL_PRESSED:0;
+                       if (!(v2d->keepzoom & V2D_LOCKZOOM_Y))
+                               state |= UI_SCROLL_ARROWS;
+                       uiWidgetScrollDraw(&wcol, &vert, &slider, state);
                }
                
+               
                /* scale indiators */
                // XXX will need to update the font drawing when the new stuff comes in
                if ((scroll & V2D_SCROLL_SCALE_VERTICAL) && (vs->grid)) {
@@ -1644,42 +1594,23 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
                                
                        /* draw vertical steps */
                        if (dfac > 0.0f) {
-                               for (; fac < vert.ymax; fac+= dfac, val += grid->dy) {
-                                       scroll_printstr(vs, scene, (float)(vert.xmax)-14.0f, fac, val, grid->powery, vs->yunits, 'v');
+                               
+                               BLF_default_rotation(90.0f);
+                               
+                               for (; fac < vert.ymax-10; fac+= dfac, val += grid->dy) {
+                                       
+                                       /* make prints look nicer for scrollers */
+                                       if(fac < vert.ymin+10)
+                                               continue;
+                                       
+                                       scroll_printstr(vs, scene, (float)(vert.xmax)-2.0f, fac, val, grid->powery, vs->yunits, 'v');
                                }
+                               
+                               BLF_default_rotation(0.0f);
                        }
                }       
-               
-               /* decoration outer bevel line */
-               UI_ThemeColorShade(TH_SHADE1, lighter);
-               if (scroll & V2D_SCROLL_RIGHT)
-                       sdrawline(vert.xmin, vert.ymin, vert.xmin, vert.ymax);
-               else if (scroll & V2D_SCROLL_LEFT)
-                       sdrawline(vert.xmax, vert.ymin, vert.xmax, vert.ymax);
        }
        
-       /* draw a 'sunken square' to cover up any overlapping corners resulting from intersection of overflowing scroller data */
-       if ((scroll & V2D_SCROLL_VERTICAL) && (scroll & V2D_SCROLL_HORIZONTAL)) {
-               /* set bounds (these should be right) */
-               corner.xmin= vert.xmin;
-               corner.xmax= vert.xmax;
-               corner.ymin= hor.ymin;
-               corner.ymax= hor.ymax;
-               
-               /* firstly, draw using background color to cover up any overlapping junk */
-               UI_ThemeColor(TH_SHADE1);
-               glRecti(corner.xmin, corner.ymin, corner.xmax, corner.ymax);
-               
-               /* now, draw suggestive highlighting... */
-                       /* first, dark lines on top to suggest scrollers overlap box */
-               UI_ThemeColorShade(TH_SHADE1, darker);
-               sdrawline(corner.xmin, corner.ymin, corner.xmin, corner.ymax);
-               sdrawline(corner.xmin, corner.ymax, corner.xmax, corner.ymax);
-                       /* now, light lines on bottom to show box is sunken in */
-               UI_ThemeColorShade(TH_SHADE1, lighter);
-               sdrawline(corner.xmax, corner.ymin, corner.xmax, corner.ymax);
-               sdrawline(corner.xmin, corner.ymin, corner.xmax, corner.ymin);
-       }
 }
 
 /* free temporary memory used for drawing scrollers */
index bd1c734b870ae6ecc311dfd9e210d9232b8d4d46..101d89da618180636cd1c9e4812d0156e6f5b7a5 100644 (file)
@@ -1010,15 +1010,7 @@ static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_
        
        
        if (in_view == 0) {
-               /* handles are only activated if the mouse is within the relative quater lengths of the scroller */
-               int qLen = (sc_max + sc_min) / 4;
-               
-               if (mouse >= (sc_max - qLen))
-                       return SCROLLHANDLE_MAX;
-               else if (mouse <= qLen)
-                       return SCROLLHANDLE_MIN;
-               else
-                       return SCROLLHANDLE_BAR;
+               return SCROLLHANDLE_BAR;
        }
        
        /* check if mouse is in or past either handle */
@@ -1095,15 +1087,23 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event,
                        vsm->zone= mouse_in_scroller_handle(y, v2d->vert.ymin, v2d->vert.ymax, scrollers->vert_min, scrollers->vert_max); 
                }
        }
+       
        UI_view2d_scrollers_free(scrollers);
+       ED_region_tag_redraw(ar);
 }
 
 /* cleanup temp customdata  */
 static void scroller_activate_exit(bContext *C, wmOperator *op)
 {
        if (op->customdata) {
+               v2dScrollerMove *vsm= op->customdata;
+
+               vsm->v2d->scroll_ui &= ~(V2D_SCROLL_H_ACTIVE|V2D_SCROLL_V_ACTIVE);
+               
                MEM_freeN(op->customdata);
-               op->customdata= NULL;                           
+               op->customdata= NULL;           
+               
+               ED_region_tag_redraw(CTX_wm_region(C));
        }
 } 
 
@@ -1120,14 +1120,14 @@ static void scroller_activate_apply(bContext *C, wmOperator *op)
        /* type of movement */
        switch (vsm->zone) {
                case SCROLLHANDLE_MIN:
+               case SCROLLHANDLE_MAX:
+                       
                        /* only expand view on axis if zoom is allowed */
                        if ((vsm->scroller == 'h') && !(v2d->keepzoom & V2D_LOCKZOOM_X))
                                v2d->cur.xmin -= temp;
                        if ((vsm->scroller == 'v') && !(v2d->keepzoom & V2D_LOCKZOOM_Y))
                                v2d->cur.ymin -= temp;
-                       break;
                
-               case SCROLLHANDLE_MAX:
                        /* only expand view on axis if zoom is allowed */
                        if ((vsm->scroller == 'h') && !(v2d->keepzoom & V2D_LOCKZOOM_X))
                                v2d->cur.xmax += temp;
@@ -1240,6 +1240,11 @@ static int scroller_activate_invoke(bContext *C, wmOperator *op, wmEvent *event)
                        }                       
                }
                
+               if(vsm->scroller=='h')
+                       v2d->scroll_ui |= V2D_SCROLL_H_ACTIVE;
+               else
+                       v2d->scroll_ui |= V2D_SCROLL_V_ACTIVE;
+               
                /* still ok, so can add */
                WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
                return OPERATOR_RUNNING_MODAL;
index 1c31c7c765356a134dd9f92cf4a089b37eeec5be..f38c03fb284873025266ef789afe997a3a11d195 100644 (file)
 
 #include "object_intern.h"
 
-/* XXX */
-static void BIF_undo_push() {}
-/* XXX */
-
 #if 0 // XXX old animation system
 static void default_key_ipo(Scene *scene, Key *key)
 {
@@ -117,7 +113,7 @@ static void default_key_ipo(Scene *scene, Key *key)
 #endif // XXX old animation system
        
 
-/* **************************************** */
+/************************* Mesh ************************/
 
 void mesh_to_key(Mesh *me, KeyBlock *kb)
 {
@@ -213,7 +209,7 @@ void insert_meshkey(Scene *scene, Mesh *me, short rel)
        mesh_to_key(me, kb);
 }
 
-/* ******************** */
+/************************* Lattice ************************/
 
 void latt_to_key(Lattice *lt, KeyBlock *kb)
 {
@@ -271,7 +267,7 @@ void insert_lattkey(Scene *scene, Lattice *lt, short rel)
        latt_to_key(lt, kb);
 }
 
-/* ******************************** */
+/************************* Curve ************************/
 
 void curve_to_key(Curve *cu, KeyBlock *kb, ListBase *nurb)
 {
@@ -383,7 +379,7 @@ void insert_curvekey(Scene *scene, Curve *cu, short rel)
        if(cu->key==NULL) {
                cu->key= add_key( (ID *)cu);
 
-               if (rel)
+               if(rel)
                        cu->key->type = KEY_RELATIVE;
 //             else
 //                     default_key_ipo(scene, cu->key);        // XXX old animation system
@@ -396,17 +392,34 @@ void insert_curvekey(Scene *scene, Curve *cu, short rel)
        else curve_to_key(cu, kb, &cu->nurb);
 }
 
+/*********************** add shape key ***********************/
+
+void ED_object_shape_key_add(bContext *C, Scene *scene, Object *ob)
+{
+       Key *key;
+
+       if(ob->type==OB_MESH) insert_meshkey(scene, ob->data, 1);
+       else if ELEM(ob->type, OB_CURVE, OB_SURF) insert_curvekey(scene, ob->data, 1);
+       else if(ob->type==OB_LATTICE) insert_lattkey(scene, ob->data, 1);
 
-/* ******************** */
+       key= ob_get_key(ob);
+       ob->shapenr= BLI_countlist(&key->block);
 
-void delete_key(Scene *scene, Object *ob)
+       WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
+}
+
+/*********************** remove shape key ***********************/
+
+int ED_object_shape_key_remove(bContext *C, Scene *scene, Object *ob)
 {
+       Main *bmain= CTX_data_main(C);
        KeyBlock *kb, *rkb;
        Key *key;
        //IpoCurve *icu;
-       
+
        key= ob_get_key(ob);
-       if(key==NULL) return;
+       if(key==NULL)
+               return 0;
        
        kb= BLI_findlink(&key->block, ob->shapenr-1);
 
@@ -417,15 +430,15 @@ void delete_key(Scene *scene, Object *ob)
 
                BLI_remlink(&key->block, kb);
                key->totkey--;
-               if(key->refkey== kb) key->refkey= key->block.first;
+               if(key->refkey== kb)
+                       key->refkey= key->block.first;
                        
                if(kb->data) MEM_freeN(kb->data);
                MEM_freeN(kb);
                
-               for(kb= key->block.first; kb; kb= kb->next) {
+               for(kb= key->block.first; kb; kb= kb->next)
                        if(kb->adrcode>=ob->shapenr)
                                kb->adrcode--;
-               }
                
 #if 0 // XXX old animation system
                if(key->ipo) {
@@ -451,12 +464,13 @@ void delete_key(Scene *scene, Object *ob)
                else if(GS(key->from->name)==ID_CU) ((Curve *)key->from)->key= NULL;
                else if(GS(key->from->name)==ID_LT) ((Lattice *)key->from)->key= NULL;
 
-               free_libblock_us(&(G.main->key), key);
+               free_libblock_us(&(bmain->key), key);
        }
        
        DAG_object_flush_update(scene, OBACT, OB_RECALC_DATA);
-       
-       BIF_undo_push("Delete Shapekey");
+       WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
+
+       return 1;
 }
 
 /********************** shape key operators *********************/
@@ -465,19 +479,11 @@ static int shape_key_add_exec(bContext *C, wmOperator *op)
 {
        Scene *scene= CTX_data_scene(C);
        Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
-       Key *key;
 
        if(!ob)
                return OPERATOR_CANCELLED;
 
-       if(ob->type==OB_MESH) insert_meshkey(scene, ob->data, 1);
-       else if ELEM(ob->type, OB_CURVE, OB_SURF) insert_curvekey(scene, ob->data, 1);
-       else if(ob->type==OB_LATTICE) insert_lattkey(scene, ob->data, 1);
-
-       key= ob_get_key(ob);
-       ob->shapenr= BLI_countlist(&key->block);
-
-       WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
+       ED_object_shape_key_add(C, scene, ob);
        
        return OPERATOR_FINISHED;
 }
@@ -499,67 +505,13 @@ static int shape_key_remove_exec(bContext *C, wmOperator *op)
 {
        Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
        Scene *scene= CTX_data_scene(C);
-       Main *bmain= CTX_data_main(C);
-       KeyBlock *kb, *rkb;
-       Key *key;
-       //IpoCurve *icu;
 
        if(!ob)
                return OPERATOR_CANCELLED;
        
-       key= ob_get_key(ob);
-       if(key==NULL)
+       if(!ED_object_shape_key_remove(C, scene, ob))
                return OPERATOR_CANCELLED;
        
-       kb= BLI_findlink(&key->block, ob->shapenr-1);
-
-       if(kb) {
-               for(rkb= key->block.first; rkb; rkb= rkb->next)
-                       if(rkb->relative == ob->shapenr-1)
-                               rkb->relative= 0;
-
-               BLI_remlink(&key->block, kb);
-               key->totkey--;
-               if(key->refkey== kb)
-                       key->refkey= key->block.first;
-                       
-               if(kb->data) MEM_freeN(kb->data);
-               MEM_freeN(kb);
-               
-               for(kb= key->block.first; kb; kb= kb->next)
-                       if(kb->adrcode>=ob->shapenr)
-                               kb->adrcode--;
-               
-#if 0 // XXX old animation system
-               if(key->ipo) {
-                       
-                       for(icu= key->ipo->curve.first; icu; icu= icu->next) {
-                               if(icu->adrcode==ob->shapenr-1) {
-                                       BLI_remlink(&key->ipo->curve, icu);
-                                       free_ipo_curve(icu);
-                                       break;
-                               }
-                       }
-                       for(icu= key->ipo->curve.first; icu; icu= icu->next) 
-                               if(icu->adrcode>=ob->shapenr)
-                                       icu->adrcode--;
-               }
-#endif // XXX old animation system             
-               
-               if(ob->shapenr>1) ob->shapenr--;
-       }
-       
-       if(key->totkey==0) {
-               if(GS(key->from->name)==ID_ME) ((Mesh *)key->from)->key= NULL;
-               else if(GS(key->from->name)==ID_CU) ((Curve *)key->from)->key= NULL;
-               else if(GS(key->from->name)==ID_LT) ((Lattice *)key->from)->key= NULL;
-
-               free_libblock_us(&(bmain->key), key);
-       }
-       
-       DAG_object_flush_update(scene, OBACT, OB_RECALC_DATA);
-       WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
-       
        return OPERATOR_FINISHED;
 }
 
index 523f38dd43246c0ae5a1f98d5920cb1932ffa182..3e30efd635aa063fc3cc1f3713f20a9034331fde 100644 (file)
@@ -52,6 +52,7 @@
 #include "BKE_utildefines.h"
 
 #include "ED_object.h"
+#include "ED_screen.h"
 #include "ED_view3d.h"
 #include "ED_util.h"
 
 
 #include "object_intern.h"
 
-/* ***************************** */
-
-static int okee() {return 0;}
+/********************** Load/Make/Free ********************/
 
 void free_editLatt(Object *ob)
 {
        Lattice *lt= ob->data;
        
        if(lt->editlatt) {
-               if(lt->editlatt->def) MEM_freeN(lt->editlatt->def);
+               if(lt->editlatt->def)
+                       MEM_freeN(lt->editlatt->def);
                if(lt->editlatt->dvert) 
                        free_dverts(lt->editlatt->dvert, lt->editlatt->pntsu*lt->editlatt->pntsv*lt->editlatt->pntsw);
                
@@ -78,27 +78,6 @@ void free_editLatt(Object *ob)
        }
 }
 
-
-static void setflagsLatt(Object *obedit, int flag)
-{
-       Lattice *lt= obedit->data;
-       BPoint *bp;
-       int a;
-       
-       bp= lt->editlatt->def;
-       
-       a= lt->editlatt->pntsu*lt->editlatt->pntsv*lt->editlatt->pntsw;
-       
-       while(a--) {
-               if(bp->hide==0) {
-                       bp->f1= flag;
-               }
-               bp++;
-       }
-}
-
-
-
 void make_editLatt(Object *obedit)
 {
        Lattice *lt= obedit->data;
@@ -108,10 +87,9 @@ void make_editLatt(Object *obedit)
        
        lt= obedit->data;
 
-       actkey = ob_get_keyblock(obedit);
-       if(actkey) {
+       actkey= ob_get_keyblock(obedit);
+       if(actkey)
                key_to_latt(actkey, lt);
-       }
 
        lt->editlatt= MEM_dupallocN(lt);
        lt->editlatt->def= MEM_dupallocN(lt->def);
@@ -121,11 +99,8 @@ void make_editLatt(Object *obedit)
                lt->editlatt->dvert = MEM_mallocN (sizeof (MDeformVert)*tot, "Lattice MDeformVert");
                copy_dverts(lt->editlatt->dvert, lt->dvert, tot);
        }
-       
-       //BIF_undo_push("Original");
 }
 
-
 void load_editLatt(Object *obedit)
 {
        Lattice *lt;
@@ -136,7 +111,8 @@ void load_editLatt(Object *obedit)
        
        lt= obedit->data;
        
-       actkey = ob_get_keyblock(obedit);
+       actkey= ob_get_keyblock(obedit);
+
        if(actkey) {
                /* active key: vertices */
                tot= lt->editlatt->pntsu*lt->editlatt->pntsv*lt->editlatt->pntsw;
@@ -154,7 +130,6 @@ void load_editLatt(Object *obedit)
                }
        }
        else {
-
                MEM_freeN(lt->def);
        
                lt->def= MEM_dupallocN(lt->editlatt->def);
@@ -181,55 +156,135 @@ void load_editLatt(Object *obedit)
                lt->dvert = MEM_mallocN (sizeof (MDeformVert)*tot, "Lattice MDeformVert");
                copy_dverts(lt->dvert, lt->editlatt->dvert, tot);
        }
-       
 }
 
-void remake_editLatt(Object *obedit)
+/************************** Operators *************************/
+
+static void setflagsLatt(Object *obedit, int flag)
 {
-       if(okee("Reload original data")==0) return;
+       Lattice *lt= obedit->data;
+       BPoint *bp;
+       int a;
        
-       make_editLatt(obedit);
-
-       //BIF_undo_push("Reload original");
+       bp= lt->editlatt->def;
+       
+       a= lt->editlatt->pntsu*lt->editlatt->pntsv*lt->editlatt->pntsw;
+       
+       while(a--) {
+               if(bp->hide==0) {
+                       bp->f1= flag;
+               }
+               bp++;
+       }
 }
 
-
-void deselectall_Latt(Object *obedit)
+int de_select_all_exec(bContext *C, wmOperator *op)
 {
+       Object *obedit= CTX_data_edit_object(C);
        Lattice *lt= obedit->data;
        BPoint *bp;
-       int a;
+       int a, deselect= 0;
        
        bp= lt->editlatt->def;
-       
        a= lt->editlatt->pntsu*lt->editlatt->pntsv*lt->editlatt->pntsw;
        
        while(a--) {
                if(bp->hide==0) {
                        if(bp->f1) {
-                               setflagsLatt(obedit, 0);
-                               //BIF_undo_push("(De)select all");
-                               return;
+                               deselect= 1;
+                               break;
                        }
                }
                bp++;
        }
-       setflagsLatt(obedit, 1);
-       //BIF_undo_push("(De)select all");
+
+       if(deselect)
+               setflagsLatt(obedit, 0);
+       else
+               setflagsLatt(obedit, 1);
+       
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+
+       return OPERATOR_FINISHED;
 }
 
+void LATTICE_OT_select_all_toggle(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Select or Deselect All";
+       ot->idname= "LATTICE_OT_select_all_toggle";
+       
+       /* api callbacks */
+       ot->exec= de_select_all_exec;
+       ot->poll= ED_operator_editlattice;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+int make_regular_poll(bContext *C)
+{
+       Object *ob;
+
+       if(ED_operator_editlattice(C)) return 1;
+
+       ob= CTX_data_active_object(C);
+       return (ob && ob->type==OB_LATTICE);
+}
+
+int make_regular_exec(bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+       Object *ob= CTX_data_edit_object(C);
+       Lattice *lt;
+       
+       if(ob) {
+               lt= ob->data;
+               resizelattice(lt->editlatt, lt->pntsu, lt->pntsv, lt->pntsw, NULL);
+       }
+       else {
+               ob= CTX_data_active_object(C);
+               lt= ob->data;
+               resizelattice(lt, lt->pntsu, lt->pntsv, lt->pntsw, NULL);
+       }
+       
+       DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_DATA, ob);
+
+       return OPERATOR_FINISHED;
+}
+
+void LATTICE_OT_make_regular(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Make Regular";
+       ot->idname= "LATTICE_OT_make_regular";
+       
+       /* api callbacks */
+       ot->exec= make_regular_exec;
+       ot->poll= make_regular_poll;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/****************************** Mouse Selection *************************/
+
 static void findnearestLattvert__doClosest(void *userData, BPoint *bp, int x, int y)
 {
        struct { BPoint *bp; short dist, select, mval[2]; } *data = userData;
        float temp = abs(data->mval[0]-x) + abs(data->mval[1]-y);
        
-       if ((bp->f1 & SELECT)==data->select) temp += 5;
-       if (temp<data->dist) {
+       if((bp->f1 & SELECT)==data->select)
+               temp += 5;
+
+       if(temp<data->dist) {
                data->dist = temp;
 
                data->bp = bp;
        }
 }
+
 static BPoint *findnearestLattvert(ViewContext *vc, short mval[2], int sel)
 {
                /* sel==1: selected gets a disadvantage */
@@ -247,34 +302,27 @@ static BPoint *findnearestLattvert(ViewContext *vc, short mval[2], int sel)
        return data.bp;
 }
 
-
 void mouse_lattice(bContext *C, short mval[2], int extend)
 {
        ViewContext vc;
-       BPoint *bp=0;
+       BPoint *bp= NULL;
 
        view3d_set_viewcontext(C, &vc);
-       
        bp= findnearestLattvert(&vc, mval, 1);
 
        if(bp) {
                if(extend==0) {
-               
                        setflagsLatt(vc.obedit, 0);
                        bp->f1 |= SELECT;
-
                }
-               else {
+               else
                        bp->f1 ^= SELECT; /* swap */
-               }
 
                WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, vc.obedit);
-               //BIF_undo_push("Select");
        }
 }
 
-
-/* **************** undo for lattice object ************** */
+/******************************** Undo *************************/
 
 typedef struct UndoLattice {
        BPoint *def;
@@ -324,20 +372,18 @@ static int validate_undoLatt(void *data, void *edata)
 static void *get_editlatt(bContext *C)
 {
        Object *obedit= CTX_data_edit_object(C);
+
        if(obedit && obedit->type==OB_LATTICE) {
                Lattice *lt= obedit->data;
                return lt->editlatt;
        }
+
        return NULL;
 }
 
-
 /* and this is all the undo system needs to know */
 void undo_push_lattice(bContext *C, char *name)
 {
        undo_editmode_push(C, name, get_editlatt, free_undoLatt, undoLatt_to_editLatt, editLatt_to_undoLatt, validate_undoLatt);
 }
 
-
-
-/***/
index c436ccdb328473c6a1f328d9b6ca80dd0b2b220d..c28200612ead37086cbaa6ded24700b6784bb434 100644 (file)
@@ -3208,7 +3208,11 @@ void ED_object_exit_editmode(bContext *C, int flag)
                }
                load_editMesh(scene, obedit);
                
-               if(freedata) free_editMesh(me->edit_mesh);
+               if(freedata) {
+                       free_editMesh(me->edit_mesh);
+                       MEM_freeN(me->edit_mesh);
+                       me->edit_mesh= NULL;
+               }
                
                if(G.f & G_WEIGHTPAINT)
                        mesh_octree_table(obedit, NULL, NULL, 'e');
index a52acdd4e1e89780f1ef23e819b097a6dca2ece2..f7bdf5da92401007cbcd168311a739b3f8bccc93 100644 (file)
@@ -78,6 +78,9 @@ void make_editLatt(Object *obedit);
 void load_editLatt(Object *obedit);
 void remake_editLatt(Object *obedit);
 
+void LATTICE_OT_select_all_toggle(struct wmOperatorType *ot);
+void LATTICE_OT_make_regular(struct wmOperatorType *ot);
+
 /* editgroup.c */
 void GROUP_OT_group_create(struct wmOperatorType *ot);
 void GROUP_OT_objects_remove(struct wmOperatorType *ot);
@@ -86,6 +89,12 @@ void GROUP_OT_objects_remove_active(struct wmOperatorType *ot);
 
 /* object_modifier.c */
 void OBJECT_OT_modifier_add(struct wmOperatorType *ot);
+void OBJECT_OT_modifier_remove(struct wmOperatorType *ot);
+void OBJECT_OT_modifier_move_up(struct wmOperatorType *ot);
+void OBJECT_OT_modifier_move_down(struct wmOperatorType *ot);
+void OBJECT_OT_modifier_apply(struct wmOperatorType *ot);
+void OBJECT_OT_modifier_convert(struct wmOperatorType *ot);
+void OBJECT_OT_modifier_copy(struct wmOperatorType *ot);
 void OBJECT_OT_multires_subdivide(struct wmOperatorType *ot);
 void OBJECT_OT_modifier_mdef_bind(struct wmOperatorType *ot);
 
index 4bcfcc4d5ab46dfcfe613ffab16ded77892e1787..eb723dcca6c13450c1beab3b62b224a99b76b5b8 100644 (file)
@@ -25,6 +25,7 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 
+#include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -35,6 +36,7 @@
 #include "DNA_meshdata_types.h"
 #include "DNA_modifier_types.h"
 #include "DNA_object_types.h"
+#include "DNA_object_force.h"
 #include "DNA_scene_types.h"
 
 #include "BLI_listbase.h"
@@ -44,6 +46,7 @@
 #include "BKE_depsgraph.h"
 #include "BKE_displist.h"
 #include "BKE_DerivedMesh.h"
+#include "BKE_effect.h"
 #include "BKE_global.h"
 #include "BKE_lattice.h"
 #include "BKE_mesh.h"
@@ -52,6 +55,7 @@
 #include "BKE_report.h"
 #include "BKE_object.h"
 #include "BKE_particle.h"
+#include "BKE_softbody.h"
 #include "BKE_utildefines.h"
 
 #include "RNA_access.h"
 
 /******************************** API ****************************/
 
-int ED_object_modifier_delete(ReportList *reports, Object *ob, ModifierData *md)
+int ED_object_modifier_add(ReportList *reports, Scene *scene, Object *ob, int type)
+{
+       ModifierData *md;
+       ModifierTypeInfo *mti = modifierType_getInfo(type);
+
+       if(mti->flags&eModifierTypeFlag_Single) {
+               if(modifiers_findByType(ob, type)) {
+                       BKE_report(reports, RPT_WARNING, "Only one modifier of this type allowed.");
+                       return 0;
+               }
+       }
+
+       if(mti->flags&eModifierTypeFlag_RequiresOriginalData) {
+               md = ob->modifiers.first;
+
+               while(md && modifierType_getInfo(md->type)->type==eModifierTypeType_OnlyDeform)
+                       md = md->next;
+
+               BLI_insertlinkbefore(&ob->modifiers, md, modifier_new(type));
+       }
+       else
+               BLI_addtail(&ob->modifiers, modifier_new(type));
+       
+       /* special cases */
+       if(type == eModifierType_Softbody) {
+               if(!ob->soft) {
+                       ob->soft= sbNew(scene);
+                       ob->softflag |= OB_SB_GOAL|OB_SB_EDGES;
+               }
+       }
+       else if(type == eModifierType_Collision) {
+               if(!ob->pd)
+                       ob->pd= object_add_collision_fields();
+
+               ob->pd->deflect= 1;
+        DAG_scene_sort(scene);
+       }
+       else if(type == eModifierType_Surface)
+        DAG_scene_sort(scene);
+
+       DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+
+       return 1;
+}
+
+int ED_object_modifier_remove(ReportList *reports, Scene *scene, Object *ob, ModifierData *md)
 {
        ModifierData *obmd;
 
        /* It seems on rapid delete it is possible to
         * get called twice on same modifier, so make
         * sure it is in list. */
-       for (obmd=ob->modifiers.first; obmd; obmd=obmd->next)
-               if (obmd==md)
+       for(obmd=ob->modifiers.first; obmd; obmd=obmd->next)
+               if(obmd==md)
                        break;
        
-       if (!obmd)
+       if(!obmd)
                return 0;
 
+       /* special cases */
        if(md->type == eModifierType_ParticleSystem) {
                ParticleSystemModifierData *psmd=(ParticleSystemModifierData*)md;
 
                BLI_remlink(&ob->particlesystem, psmd->psys);
                psys_free(ob, psmd->psys);
        }
+       else if(md->type == eModifierType_Softbody) {
+               if(ob->soft) {
+                       sbFree(ob->soft);
+                       ob->soft= NULL;
+                       ob->softflag= 0;
+               }
+       }
+       else if(md->type == eModifierType_Collision) {
+               if(ob->pd)
+                       ob->pd->deflect= 0;
 
-       BLI_remlink(&ob->modifiers, md);
+        DAG_scene_sort(scene);
+       }
+       else if(md->type == eModifierType_Surface) {
+               if(ob->pd)
+                       ob->pd->flag &= ~PFIELD_SURFACE;
 
+        DAG_scene_sort(scene);
+       }
+
+       BLI_remlink(&ob->modifiers, md);
        modifier_free(md);
 
+       DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+
        return 1;
 }
 
@@ -103,9 +173,10 @@ int ED_object_modifier_move_up(ReportList *reports, Object *ob, ModifierData *md
                if(mti->type!=eModifierTypeType_OnlyDeform) {
                        ModifierTypeInfo *nmti = modifierType_getInfo(md->prev->type);
 
-                       if(nmti->flags&eModifierTypeFlag_RequiresOriginalData)
+                       if(nmti->flags&eModifierTypeFlag_RequiresOriginalData) {
                                BKE_report(reports, RPT_WARNING, "Cannot move above a modifier requiring original data.");
                                return 0;
+                       }
                }
 
                BLI_remlink(&ob->modifiers, md);
@@ -155,11 +226,11 @@ int ED_object_modifier_convert(ReportList *reports, Scene *scene, Object *ob, Mo
        psys=((ParticleSystemModifierData *)md)->psys;
        part= psys->part;
 
-       if(part->draw_as == PART_DRAW_GR || part->draw_as == PART_DRAW_OB) {
+       if(part->ren_as == PART_DRAW_GR || part->ren_as == PART_DRAW_OB) {
                ; // XXX make_object_duplilist_real(NULL);
        }
        else {
-               if(part->draw_as != PART_DRAW_PATH || psys->pathcache == 0)
+               if(part->ren_as != PART_DRAW_PATH || psys->pathcache == 0)
                        return 0;
 
                totpart= psys->totcached;
@@ -260,6 +331,10 @@ int ED_object_modifier_apply(ReportList *reports, Scene *scene, Object *ob, Modi
                }
        
                mesh_pmv_off(ob, me);
+
+               /* Multires: ensure that recent sculpting is applied */
+               if(md->type == eModifierType_Multires)
+                       multires_force_update(ob);
        
                dm = mesh_create_derived_for_modifier(scene, ob, md);
                if (!dm) {
@@ -329,22 +404,11 @@ static int modifier_add_exec(bContext *C, wmOperator *op)
 {
        Scene *scene= CTX_data_scene(C);
     Object *ob = CTX_data_active_object(C);
-       ModifierData *md;
        int type= RNA_enum_get(op->ptr, "type");
-       ModifierTypeInfo *mti = modifierType_getInfo(type);
-
-       if(mti->flags&eModifierTypeFlag_RequiresOriginalData) {
-               md = ob->modifiers.first;
 
-               while(md && modifierType_getInfo(md->type)->type==eModifierTypeType_OnlyDeform)
-                       md = md->next;
+       if(!ED_object_modifier_add(op->reports, scene, ob, type))
+               return OPERATOR_CANCELLED;
 
-               BLI_insertlinkbefore(&ob->modifiers, md, modifier_new(type));
-       }
-       else
-               BLI_addtail(&ob->modifiers, modifier_new(type));
-
-       DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
        WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
        
        return OPERATOR_FINISHED;
@@ -370,13 +434,198 @@ void OBJECT_OT_modifier_add(wmOperatorType *ot)
        RNA_def_enum(ot->srna, "type", modifier_type_items, 0, "Type", "");
 }
 
+/************************ remove modifier operator *********************/
+
+static int modifier_remove_exec(bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+       PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_Modifier);
+       Object *ob= ptr.id.data;
+       ModifierData *md= ptr.data;
+
+       if(!ob || !md || !ED_object_modifier_remove(op->reports, scene, ob, md))
+               return OPERATOR_CANCELLED;
+
+       WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
+       
+       return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_modifier_remove(wmOperatorType *ot)
+{
+       ot->name= "Remove Modifier";
+       ot->description= "Remove a modifier from the active object.";
+       ot->idname= "OBJECT_OT_modifier_remove";
+       ot->poll= ED_operator_object_active;
+
+       ot->exec= modifier_remove_exec;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/************************ move up modifier operator *********************/
+
+static int modifier_move_up_exec(bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+       PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_Modifier);
+       Object *ob= ptr.id.data;
+       ModifierData *md= ptr.data;
+
+       if(!ob || !md || !ED_object_modifier_move_up(op->reports, ob, md))
+               return OPERATOR_CANCELLED;
+
+       DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+       WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
+       
+       return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_modifier_move_up(wmOperatorType *ot)
+{
+       ot->name= "Move Up Modifier";
+       ot->description= "Move modifier up in the stack.";
+       ot->idname= "OBJECT_OT_modifier_move_up";
+       ot->poll= ED_operator_object_active;
+
+       ot->exec= modifier_move_up_exec;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/************************ move down modifier operator *********************/
+
+static int modifier_move_down_exec(bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+       PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_Modifier);
+       Object *ob= ptr.id.data;
+       ModifierData *md= ptr.data;
+
+       if(!ob || !md || !ED_object_modifier_move_down(op->reports, ob, md))
+               return OPERATOR_CANCELLED;
+
+       DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+       WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
+       
+       return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_modifier_move_down(wmOperatorType *ot)
+{
+       ot->name= "Move Down Modifier";
+       ot->description= "Move modifier down in the stack.";
+       ot->idname= "OBJECT_OT_modifier_move_down";
+       ot->poll= ED_operator_object_active;
+
+       ot->exec= modifier_move_down_exec;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/************************ apply modifier operator *********************/
+
+static int modifier_apply_exec(bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+       PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_Modifier);
+       Object *ob= ptr.id.data;
+       ModifierData *md= ptr.data;
+
+       if(!ob || !md || !ED_object_modifier_apply(op->reports, scene, ob, md))
+               return OPERATOR_CANCELLED;
+
+       DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+       WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
+       
+       return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_modifier_apply(wmOperatorType *ot)
+{
+       ot->name= "Apply Modifier";
+       ot->description= "Apply modifier and remove from the stack.";
+       ot->idname= "OBJECT_OT_modifier_apply";
+       ot->poll= ED_operator_object_active;
+
+       ot->exec= modifier_apply_exec;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/************************ convert modifier operator *********************/
+
+static int modifier_convert_exec(bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+       PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_Modifier);
+       Object *ob= ptr.id.data;
+       ModifierData *md= ptr.data;
+
+       if(!ob || !md || !ED_object_modifier_convert(op->reports, scene, ob, md))
+               return OPERATOR_CANCELLED;
+
+       DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+       WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
+       
+       return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_modifier_convert(wmOperatorType *ot)
+{
+       ot->name= "Convert Modifier";
+       ot->description= "Convert particles to a mesh object.";
+       ot->idname= "OBJECT_OT_modifier_convert";
+       ot->poll= ED_operator_object_active;
+
+       ot->exec= modifier_convert_exec;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/************************ copy modifier operator *********************/
+
+static int modifier_copy_exec(bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+       PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_Modifier);
+       Object *ob= ptr.id.data;
+       ModifierData *md= ptr.data;
+
+       if(!ob || !md || !ED_object_modifier_copy(op->reports, ob, md))
+               return OPERATOR_CANCELLED;
+
+       DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+       WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);