Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlijenstina <lijenstina@gmail.com>2017-09-28 15:32:15 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-01-06 18:42:40 +0300
commit01be96c6920939afac7266cedeb61d62b5088852 (patch)
tree4c218eb755a44800fa96d0d5487d65d5fb7c8d4c
parentf09e66a3936396251310d56c4e76b51d6f560ae1 (diff)
Display Tools: Fix particles issues with Fast Navigation
Bump version to 1.6.4 Fix several issues related to drawing particles: - Particles not restored on exit - Needless modal looping through them - Hook the InitialParticles property properly Fix not restoring the viewport shading on exit Fix crash with changing Screens Some UI fixes Improve the tooltip for Fast Navigate
-rw-r--r--space_view3d_display_tools/__init__.py24
-rw-r--r--space_view3d_display_tools/fast_navigate.py123
2 files changed, 103 insertions, 44 deletions
diff --git a/space_view3d_display_tools/__init__.py b/space_view3d_display_tools/__init__.py
index 03df6a32..58699f98 100644
--- a/space_view3d_display_tools/__init__.py
+++ b/space_view3d_display_tools/__init__.py
@@ -25,7 +25,7 @@
bl_info = {
"name": "Display Tools",
"author": "Jordi Vall-llovera Medina, Jhon Wallace",
- "version": (1, 6, 3),
+ "version": (1, 6, 4),
"blender": (2, 7, 0),
"location": "Toolshelf",
"description": "Display tools for fast navigation/interaction with the viewport",
@@ -446,13 +446,20 @@ class DisplayToolsPanel(Panel):
layout.prop(display_tools, "OriginalMode")
layout.prop(display_tools, "FastMode")
layout.prop(display_tools, "EditActive", "Edit mode")
+
layout.prop(display_tools, "Delay")
- layout.prop(display_tools, "DelayTimeGlobal", "Delay time")
+ col = layout.column(align=True)
+ col.active = display_tools.Delay
+ col.prop(display_tools, "DelayTimeGlobal", "Delay time")
+
layout.prop(display_tools, "ShowParticles")
- layout.prop(display_tools, "ParticlesPercentageDisplay")
- layout.separator()
+ col = layout.column(align=True)
+ col.active = display_tools.ShowParticles
+ col.prop(display_tools, "InitialParticles")
+ col.prop(display_tools, "ParticlesPercentageDisplay")
col = layout.column(align=True)
+ col.label("Screen Active Area:")
col.prop(display_tools, "ScreenStart")
col.prop(display_tools, "ScreenEnd")
@@ -517,8 +524,8 @@ class display_tools_scene_props(PropertyGroup):
default=True
)
ParticlesPercentageDisplay = IntProperty(
- name="Display",
- description="Display only a percentage of particles",
+ name="Fast Display",
+ description="Display only a percentage of particles when active",
default=25,
min=0,
max=100,
@@ -527,8 +534,9 @@ class display_tools_scene_props(PropertyGroup):
subtype='FACTOR'
)
InitialParticles = IntProperty(
- name="Count for initial particle setting before entering fast navigate",
- description="Display a percentage value of particles",
+ name="Normal Display",
+ description="When idle, how much particles are displayed\n"
+ "Overrides the Particles settings",
default=100,
min=0,
max=100,
diff --git a/space_view3d_display_tools/fast_navigate.py b/space_view3d_display_tools/fast_navigate.py
index 5551bd32..269aec2c 100644
--- a/space_view3d_display_tools/fast_navigate.py
+++ b/space_view3d_display_tools/fast_navigate.py
@@ -1,7 +1,7 @@
# space_view_3d_display_tools.py Copyright (C) 2014, Jordi Vall-llovera
# Multiple display tools for fast navigate/interact with the viewport
-# ***** BEGIN GPL LICENSE BLOCK *****
+# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -17,7 +17,7 @@
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
-# ***** END GPL LICENCE BLOCK *****
+# ##### END GPL LICENCE BLOCK #####
"""
Additional links:
@@ -27,6 +27,7 @@ Additional links:
import bpy
from bpy.types import Operator
from bpy.props import BoolProperty
+from collections import defaultdict
# Fast Navigate toggle function
@@ -37,25 +38,21 @@ def trigger_fast_navigate(trigger):
# Control how to display particles during fast navigate
-def display_particles(mode):
+def display_particles(mode, dis_particles):
scene = bpy.context.scene.display_tools
- if mode is True:
- for particles in bpy.data.particles:
+ for particles in bpy.data.particles:
+ if scene.ShowParticles is False:
+ particles.draw_method = 'NONE'
+ else:
if particles.type == 'EMITTER':
particles.draw_method = 'DOT'
particles.draw_percentage = 100
else:
particles.draw_method = 'RENDER'
- particles.draw_percentage = 100
- else:
- for particles in bpy.data.particles:
- if particles.type == 'EMITTER':
- particles.draw_method = 'DOT'
- particles.draw_percentage = scene.ParticlesPercentageDisplay
- else:
- particles.draw_method = 'RENDER'
- particles.draw_percentage = scene.ParticlesPercentageDisplay
+ particles.draw_percentage = dis_particles
+
+ return dis_particles
# Fast Navigate operator
@@ -63,18 +60,27 @@ class FastNavigate(Operator):
bl_idname = "view3d.fast_navigate_operator"
bl_label = "Fast Navigate"
bl_description = ("Limit the objects drawing in the 3D view for faster navigation\n"
- "Runs in modal mode until Stop is pressed")
+ "Runs in modal mode until Stop is pressed or Esc, Return, Space")
trigger = BoolProperty(default=False)
mode = BoolProperty(default=False)
screen_width = [0, 0]
+ store_fail = False
+ store_init_particles = {}
+ store_viewport_shade = None
+ check_particles_draw = False
+ fast_particles_draw = 0
def modal(self, context, event):
context.area.tag_redraw()
scene = context.scene.display_tools
if scene.FastNavigateStop is True:
- self.cancel(context)
+ self.execute(context)
+ return {'FINISHED'}
+
+ if context.area.type != 'VIEW_3D':
+ self.execute(context)
return {'FINISHED'}
if scene.EditActive is True:
@@ -92,20 +98,69 @@ class FastNavigate(Operator):
self.fast_navigate_stuff(context, event)
return {'PASS_THROUGH'}
- def execute(self, context):
+ return {'RUNNING_MODAL'}
+
+ def invoke(self, context, event):
+ if context.area.type != 'VIEW_3D':
+ self.report({'WARNING'},
+ "Fast Navigate: View3D not found. Operation Cancelled")
+ return {'CANCELLED'}
+
+ self.store_init_particles = defaultdict(list)
+ self.store_fail = False
+
context.window_manager.modal_handler_add(self)
trigger_fast_navigate(self.trigger)
scene = context.scene.display_tools
scene.DelayTime = scene.DelayTimeGlobal
self.get_screen_size(context, scene)
+ self.start_settings_store(context, store=False)
+ self.check_particles_draw = True
+
return {'RUNNING_MODAL'}
+ def execute(self, context):
+ scene = context.scene.display_tools
+ scene.FastNavigateStop = True
+
+ self.start_settings_store(context, store=True)
+
+ mess, mess_txt = ('WARNING', "Fast Navigate: Some Settings could not be restored") if \
+ self.store_fail else ('INFO', "Exited the Fast Navigate mode")
+
+ self.report({mess}, mess_txt)
+
+ return {'FINISHED'}
+
@staticmethod
def calc_delay(scene):
if scene.Delay is True:
if scene.DelayTime < scene.DelayTimeGlobal:
scene.DelayTime += 1
+ def start_settings_store(self, context, store=False):
+ try:
+ view = context.space_data
+ shade = view.viewport_shade if view.type == 'VIEW_3D' else None
+ if store is False:
+ if not shade:
+ self.store_fail = True
+ else:
+ self.store_viewport_shade = shade
+ for particle in bpy.data.particles:
+ self.store_init_particles[particle.name] = \
+ [particle.draw_method, particle.draw_percentage]
+ else:
+ if not shade:
+ self.store_fail = True
+ else:
+ shade = self.store_viewport_shade or 'SOLID'
+ for particle in bpy.data.particles:
+ particle.draw_method = self.store_init_particles[particle.name][0]
+ particle.draw_percentage = self.store_init_particles[particle.name][1]
+ except:
+ self.store_fail = True
+
def get_screen_size(self, context, scene):
if context.area.type == 'VIEW_3D':
coord_x = context.area.x + scene.ScreenStart
@@ -117,16 +172,15 @@ class FastNavigate(Operator):
scene = context.scene.display_tools
view = context.space_data
+ if scene.FastNavigateStop is True:
+ return {'FINISHED'}
+
if context.area.type != 'VIEW_3D':
- self.cancel(context)
- return {'CANCELLED'}
+ scene.FastNavigateStop = True
+ return {'FINISHED'}
if event.type in {'ESC', 'RET', 'SPACE'}:
- self.cancel(context)
- return {'CANCELLED'}
-
- if scene.FastNavigateStop is True:
- self.cancel(context)
+ scene.FastNavigateStop = True
return {'CANCELLED'}
# limit the active area
@@ -182,19 +236,15 @@ class FastNavigate(Operator):
scene.DelayTime = scene.DelayTimeGlobal
self.mode = True
- if scene.ShowParticles is False:
- for particles in bpy.data.particles:
- if particles.type == 'EMITTER':
- particles.draw_method = 'NONE'
- else:
- particles.draw_method = 'NONE'
- else:
- display_particles(self.mode)
+ # update particles draw (only update call when the fast draw or the percentage are changed)
+ self.check_particles_draw = not self.mode
+ dis_particles = scene.InitialParticles if self.mode else scene.ParticlesPercentageDisplay
- def cancel(self, context):
- scene = context.scene.display_tools
- for particles in bpy.data.particles:
- particles.draw_percentage = scene.InitialParticles
+ if self.check_particles_draw is True:
+ self.fast_particles_draw = display_particles(self.mode, dis_particles)
+ else:
+ if self.fast_particles_draw != dis_particles:
+ self.fast_particles_draw = display_particles(self.mode, dis_particles)
# Fast Navigate Stop
@@ -211,6 +261,7 @@ class FastNavigateStop(Operator):
def execute(self, context):
fast_navigate_stop(context)
+
return {'FINISHED'}