Blender Git Loki
Git Commits -> Revision 26b1406
Revision 26b1406 by Tamito Kajiyama (master) March 5, 2014, 12:56 (GMT) |
Freestyle: Fix for incorrect comparisons of Nature values with integer and boolean values. The problem is that comparisons involving the constants Nature.POINT (for vertices) and Nature.NO_FEATURE (for edges) were evaluated in a wrong way. It is recalled that the Nature class is a subclass of Python's built-in int type, and that these two constants are zero when evaluated as numbers. The issue was caused by the implementation of the constants in an incompatible way for comparison with Python int (and boolean) values. Specifically, the zero of Python int is represented by an empty array of digits, whereas the zero-valued Nature constants were represented by an array of size 1. Python int comparison operators first check the lengths of the arrays of two operands, and then start comparing the digits only when the array length is the same. For this reason, the two Nature constants were not properly compared with int values (and thus with boolean values). It is noted that the zero-valued Nature constants may result from bitwise operations on other Nature constants (e.g., Nature.SILHOUETTE & Nature.BORDER), so this issue must have affected many existing style modules. The problem was reported by Folkert de Vries (flokkievids) through personal communications. Thanks a lot! |
Commit Details:
Full Hash: 26b1406f6ee9beae3245fcc7e0fa5c8cfa867d98
Parent Commit: f5d2b46
Lines Changed: +14, -16
1 Modified Path:
/source/blender/freestyle/intern/python/BPy_Nature.cpp (+14, -16) (Diff)