Blender Git Commit Log

Git Commits -> Revision 74027ea

Revision 74027ea by Tamito Kajiyama (master)
August 2, 2009, 19:36 (GMT)
SWIG/directors dependency removal (cont'd)

Removed all castToSomething() methods from Interface0D's subclasses.
These methods are useless, because introspection-based automatic type
conversion takes place whenever it is applicable.

If you need to rewrite old style modules that rely on the cast methods,
apply the following rewriting rules:

- SVertex.castToSVertex()
- TVertex.castToViewVertex()
- TVertex.castToTVertex()
- NonTVertex.castToViewVertex()
- NonTVertex.castToNonTVertex()

These 5 methods return an object itself, so just removing a method
call will suffice. If you need to handle objects in a different way
depending on their types, then you can use Python's type checking
idioms such as "type(obj) is T" and "isinstance(obj, T)". Example:

[Original]
v = it.getObject()
# try to convert v into a TVertex object
vertex = v.castToTVertex()
if vertex != None:
... # do something on the TVertex object
# try to convert v into a NonTVertex object
vertex = v.castToNonTVertex()
if vertex != None:
... # do something on the NonTVertex object

[Rewritten]
vertex = it.getObject()
if type(vertex) is TVertex:
... # do something on the TVertex object
elif type(vertex) is NonTVertex:
... # do something on the NonTVertex object

- SVertex.castToViewVertex()
- SVertex.castToTVertex()
- SVertex.castToNonTVertex()

Use SVertex.viewvertex() instead. You don't need to care about
which cast method is appropriate. SVertex.viewvertex() does, if
necessary, introspection-based automatic type conversion for you.

- NonTVertex.castToSVertex()

Use NonTVertex.svertex() instead.

- CurvePoint.castToSVertex()

Let cp be a CurvePoint object, then this method can be expressed as
follows:

if cp.t2d() == 0.0:
return cp.A() # returns an SVertex
elif cp.t2d() == 1.0:
return cp.B() # returns an SVertex
return None

- CurvePoint.castToViewVertex()
- CurvePoint.castToTVertex()
- CurvePoint.castToNonVertex()

Similarly, these 3 methods can be expressed as follows:

if cp.t2d() == 0.0:
return cp.A().viewvertex()
elif cp.t2d() == 1.0:
return cp.B().viewvertex()
return None

Commit Details:

Full Hash: 74027eafcbdb4de4fea48d0fbc765553f9294078
SVN Revision: 22153
Parent Commit: 0ea01da
Lines Changed: +0, -33

2 Modified Paths:

/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_NonTVertex.cpp (+0, -21) (Diff)
/source/blender/freestyle/intern/python/Interface0D/ViewVertex/BPy_TVertex.cpp (+0, -12) (Diff)
By: Miika HämäläinenLast update: Nov-07-2014 14:18MiikaHweb | 2003-2021