1
$\begingroup$

I notice that when you create a bmesh from an object using

bm = bmesh.new()
bm.from_mesh(obj.data)

the scale of the object is ignored, in the sense that you get the same bmesh regardless of whether you do

obj.scale = (100, 100, 100)

or not.

Is this a bug or a feature?

I feel this is a bug since if you are doing ray casting, you should build the BVH tree with the scaled object for correct behaviors, but right now, if you just create your BVH tree from the mesh data, you are ignoring the object scale.

$\endgroup$
2
$\begingroup$

This is NOT a bug.

The bmesh module provides access to blender's mesh data structures.

The bmesh is created from the mesh using its local coordinates. What object or objects it is linked to, and their object transformations, is immaterial. The mesh may also be linked to no objects.

For example. Python console code. The cube mesh linked to cube object in default scene

>>> C.object.data
bpy.data.meshes['Cube']

there is no difference between creating a from mesh bmesh passing C.object.data or bpy.data.meshes["Cube"] as the mesh argument.

To transform the bmesh to global coordinates, based on its linked object obj

bm = bmesh.new()
bm.from_mesh(obj.data)
bmesh.ops.transform(bm, matrix=obj.matrix_world, verts=bm.verts)

If you require the deformation modifiers assigned to object applied to the bmesh, use bm.from_object(...). However this will also not apply any object transformations (loc, rot, scale) to the coordinate data of the bmesh either, and will need to be done separately as shown above as well.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.