Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(5324)

Issue 5502053: bTrace.py review

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 4 months ago by ideasman42
Modified:
12 years, 4 months ago
Reviewers:
trumanblending
CC:
crazycourier
Base URL:
https://svn.blender.org/svnroot/bf-extensions/contrib/py/scripts/addons/
Visibility:
Public.

Patch Set 1 #

Total comments: 19
Unified diffs Side-by-side diffs Delta from patch set Stats (+1 line, -0 lines) Patch
M btrace/bTrace.py View 1 chunk +1 line, -0 lines 19 comments Download

Messages

Total messages: 2
TrumanBlending
http://codereview.appspot.com/5502053/diff/1/btrace/bTrace.py File btrace/bTrace.py (right): http://codereview.appspot.com/5502053/diff/1/btrace/bTrace.py#newcode42 btrace/bTrace.py:42: from bpy.props import * Should explicitly import each property ...
12 years, 4 months ago (2012-01-04 03:14:59 UTC) #1
ideasman42
12 years, 4 months ago (2012-01-04 03:47:56 UTC) #2
agree with all trumanblending@gmail.com's comments, added some more.

Main error is with bpy.selection, others are more suggestions for better
practice.

http://codereview.appspot.com/5502053/diff/1/btrace/bTrace.py
File btrace/bTrace.py (right):

http://codereview.appspot.com/5502053/diff/1/btrace/bTrace.py#newcode45
btrace/bTrace.py:45: class TracerProperties(bpy.types.PropertyGroup):
TR prefix of all attributes seems redundant, since the PropertyGroup is already
a collection of of related attrbutes.

http://codereview.appspot.com/5502053/diff/1/btrace/bTrace.py#newcode730
btrace/bTrace.py:730: spline.bezier_points[bFrames].co =
ps.particles[e].location
better to get the point otherwise access each time becomes slow eg:

bp = spline.bezier_points[bFrames]
pt = ps.particles[e]
bp.co = pt.location
...

http://codereview.appspot.com/5502053/diff/1/btrace/bTrace.py#newcode758
btrace/bTrace.py:758: return (context.object and context.object.type in
['MESH','FONT','CURVE'])
Python3 optimizes for frozen set checking, eg:

context.object.type in {'MESH','FONT','CURVE'}

http://codereview.appspot.com/5502053/diff/1/btrace/bTrace.py#newcode814
btrace/bTrace.py:814: bpy.ops.object.mode_set()
would be better to give an argument to make it explicit what mode is set.

http://codereview.appspot.com/5502053/diff/1/btrace/bTrace.py#newcode824
btrace/bTrace.py:824: v.co[u] += TRobjectnoise*(random.random()*2-1)
On 2012/01/04 03:14:59, TrumanBlending wrote:
> Could use random.uniform() instead

yep, v.co += Vector(random.uniform()) would be better.

http://codereview.appspot.com/5502053/diff/1/btrace/bTrace.py#newcode1004
btrace/bTrace.py:1004: bpy.context.scene.frame_set(actual)
possible inefficiency - not essential but worth looking into.

changing the frame can be a slow operation depending on the scene, It looks like
this might not even be needed since keyframe_insert takes a frame argument.

http://codereview.appspot.com/5502053/diff/1/btrace/bTrace.py#newcode1058
btrace/bTrace.py:1058: bpy.selection=[]
On 2012/01/04 03:14:59, TrumanBlending wrote:
> Not sure about adding this to bpy, seems polluting.

this should be avoided, blender just doesnt store selection order - you can
however use the active object with the selected objects - where you can think of
the active object as 'Last Selected'

Other notes -
- if you define a list at the top of the script it will be persistent just as
bpy.selected is, so no need to add attributes to bpy.

- storing the objects themselves will crash on undo since the pointers are
re-allocated. This should store their names instead if it is to be used at all.

- notice bpy.context.selected_objects is being accessed a lot, this should be
stored once before the loop starts since it has to make a new list every time,
notice you have 'sel' defined before, why not re-use?.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b