Hi I’m digging into blender c code and I’ll post my questions here for anyone who is willing to help. I guess my questions were too basic for blender.chat to answer.
So my question is how do you call for blender operators?
here is a code example from : \blender\source\blender\bmesh\operators\bmo_symmetrize.c
so this part of code should initiate and execute mesh bisecting right?
my question is:
is “bisect_plane geom=%s plane_no=%v dist=%f clear_outer=%b use_snap_center=%b” is responsible for calling the code for bisecting?
what and where does it call? bmesh_bisect_plane.hORbmesh_bisect_plane.cor something else?
cause I don’t think it does. if yes how do you explane this line:
Though I have not participated in Blender source so far, only in terms of function calls. It was a good exercise for me to spend a few minutes and find the answer, now I know something as well too.
[1]
All the mesh operators are defined here https://github.com/blender/blender/blob/67f3941dd592d8a02d86450e303b6b7e50857c9c/source/blender/bmesh/intern/bmesh_opdefines.c
The definition of the operator is: bmo_bisect_edges_def which means that it initializes the operator as an object, along with all of the essential configuration.
The implementation of the operator is bmo_bisect_edges_exec and is the exact code how it works is found here. https://github.com/blender/blender/blob/2d1cce8331f3ecdfb8cb0c651e111ffac5dc7153/source/blender/bmesh/operators/bmo_subdivide.c
[2]
All operator definitions are placed in bmo_opdefines, which is the literal global array with all operators.
[3]
When the BMO_op_initf is called it wants to search bmo_opdefines and return the definition. https://github.com/blender/blender/blob/2d1cce8331f3ecdfb8cb0c651e111ffac5dc7153/source/blender/bmesh/intern/bmesh_operators.c
Other questions:
is “bisect_plane geom=%s plane_no=%v dist=%f clear_outer=%b use_snap_center=%b” is responsible for calling the code for bisecting?
This part is a formatted string and the rest after var args. Everything will be used as operator parameters. When the operator gets executed it will use the values to do it’s work.
The only way to understand how the code works is by searching. For example (in github) if you search for bmo_bisect_edges_def you will find a few files that this is either [declared] or [used].
Also another thing I forgot to mention is that operators are setup like having a design pattern (in this case see the command design pattern). Though C is not object oriented, the design principles can be replicated since the ideas universal. This is mostly a matter of convention and architecture.