4 #ifndef __BLENDER_UTIL_H__
5 #define __BLENDER_UTIL_H__
25 void *bmain,
void *iuser,
void *ima,
char *path,
bool resolve_udim,
bool resolve_multiview);
68 bool subsurf_mod_show_render =
false;
69 bool subsurf_mod_show_viewport =
false;
72 BL::Modifier subsurf_mod =
object.modifiers[
object.modifiers.length() - 1];
74 subsurf_mod_show_render = subsurf_mod.show_render();
75 subsurf_mod_show_viewport = subsurf_mod.show_viewport();
77 subsurf_mod.show_render(
false);
78 subsurf_mod.show_viewport(
false);
90 if (
mesh.is_editmode() ||
107 BL::Modifier subsurf_mod =
object.modifiers[
object.modifiers.length() - 1];
109 subsurf_mod.show_render(subsurf_mod_show_render);
110 subsurf_mod.show_viewport(subsurf_mod_show_viewport);
115 if (
mesh.use_auto_smooth()) {
116 mesh.split_faces(
false);
119 mesh.calc_loop_triangles();
135 object.to_mesh_clear();
147 for (
int i = 0; i <
size; i++) {
150 ramp.evaluate((
float)i / (
float)(
size - 1),
color);
152 ramp_alpha[i] =
color[3];
158 *min_x =
min(*min_x,
curve.points[0].location()[0]);
159 *max_x =
max(*max_x,
curve.points[
curve.points.length() - 1].location()[0]);
170 for (
int i = 0; i < num_curves; ++i) {
181 for (
int i = 0; i <
size; i++) {
191 float min = 0.0f,
max = 1.0f;
195 const float range =
max -
min;
203 for (
int i = 0; i <
size; i++) {
214 float min_x = 0.0f, max_x = 1.0f;
227 const int num_curves = rgb_curve ? 4 : 3;
230 const float range_x = max_x - min_x;
242 for (
int i = 0; i <
size; i++) {
243 const float t = min_x + (
float)i / (
float)(
size - 1) * range_x;
245 cumap.evaluate(mapG, cumap.evaluate(mapI,
t)),
246 cumap.evaluate(mapB, cumap.evaluate(mapI,
t)));
250 for (
int i = 0; i <
size; i++) {
251 float t = min_x + (
float)i / (
float)(
size - 1) * range_x;
253 cumap.evaluate(mapR,
t), cumap.evaluate(mapG,
t), cumap.evaluate(mapB,
t));
260 return self.is_modified(
scene, (
preview) ? (1 << 0) : (1 << 1)) ? true :
false;
265 if (!
self.is_real_object_data()) {
271 return self.real_object.is_deform_modified(
scene, (
preview) ? (1 << 0) : (1 << 1)) ? true :
277 return b_render.resolution_x() * b_render.resolution_percentage() / 100;
282 return b_render.resolution_y() * b_render.resolution_percentage() / 100;
295 return string(filepath);
301 return iuser.frame_current();
316 b_rr.stamp_data_add_field(name.c_str(), value.c_str());
327 memcpy((
void *)&projection, &
array,
sizeof(
float) * 16);
433 int default_value = -1)
437 assert(default_value != -1);
438 value = default_value;
446 const char *identifier =
"";
451 return string(identifier);
484 if (path.size() >= 2 && path[0] ==
'/' && path[1] ==
'/') {
487 if (b_id.library()) {
488 BL::ID b_library_id(b_id.library());
507 BL::Text::lines_iterator iter;
508 for (iter.begin(
ptr); iter; ++iter) {
509 content += iter->body() +
"\n";
535 const int max_steps = INT_MAX)
539 bool use_motion =
get_boolean(cobject,
"use_motion_blur");
548 if (b_parent.ptr.data != b_ob.ptr.data) {
550 use_motion &=
get_boolean(parent_cobject,
"use_motion_blur");
562 return min((2 << (
steps - 1)) + 1, max_steps);
569 bool use_deform_motion =
get_boolean(cobject,
"use_deform_motion");
576 if (use_deform_motion && b_parent.ptr.data != b_ob.ptr.data) {
578 use_deform_motion &=
get_boolean(parent_cobject,
"use_deform_motion");
580 return use_deform_motion;
585 for (BL::Modifier &b_mod : b_ob.modifiers) {
586 if (b_mod.is_a(&RNA_FluidModifier)) {
587 BL::FluidModifier b_mmd(b_mod);
589 if (b_mmd.fluid_type() == BL::FluidModifier::fluid_type_DOMAIN &&
590 b_mmd.domain_settings().domain_type() == BL::FluidDomainSettings::domain_type_GAS) {
591 return b_mmd.domain_settings();
600 bool *has_subdivision_modifier)
602 for (
int i = b_ob.modifiers.length() - 1; i >= 0; --i) {
603 BL::Modifier b_mod = b_ob.modifiers[i];
605 if (b_mod.type() == BL::Modifier::type_MESH_SEQUENCE_CACHE) {
606 BL::MeshSequenceCacheModifier mesh_cache = BL::MeshSequenceCacheModifier(b_mod);
611 if (b_mod.type() == BL::Modifier::type_PARTICLE_SYSTEM) {
615 if (b_mod.type() == BL::Modifier::type_SUBSURF) {
616 if (has_subdivision_modifier) {
617 *has_subdivision_modifier =
true;
634 if (cobj.
data && !b_ob.modifiers.empty() && experimental) {
635 BL::Modifier
mod = b_ob.modifiers[b_ob.modifiers.length() - 1];
638 if (
enabled &&
mod.type() == BL::Modifier::type_SUBSURF &&
640 BL::SubsurfModifier subsurf(
mod);
642 if (subsurf.subdivision_type() == BL::SubsurfModifier::subdivision_type_CATMULL_CLARK) {
691 const bool use_motion =
get_boolean(cobject,
"use_motion_blur");
716 edges_.insert(std::pair<int, int>(v0,
v1));
typedef float(TangentPoint)[2]
const char * dirname(char *path)
struct Depsgraph Depsgraph
struct CurveMapping CurveMapping
struct FluidDomainSettings FluidDomainSettings
struct ImageUser ImageUser
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble t
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble v1
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a color
struct RenderResult RenderResult
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
set< std::pair< int, int > > edges_
void insert(int v0, int v1)
bool exists(int v0, int v1)
void get_sorted_verts(int &v0, int &v1)
T * resize(size_t newsize)
#define CCL_NAMESPACE_END
static string image_user_file_path(BL::BlendData &data, BL::ImageUser &iuser, BL::Image &ima, int cfra)
static uint object_ray_visibility(BL::Object &b_ob)
static float4 get_float4(const BL::Array< float, 4 > &array)
float * BKE_image_get_float_pixels_for_frame(void *image, int frame, int tile)
static uint object_motion_steps(BL::Object &b_parent, BL::Object &b_ob, const int max_steps=INT_MAX)
static int render_resolution_x(BL::RenderSettings &b_render)
static float get_float(PointerRNA &ptr, const char *name)
static void curvemapping_float_to_array(BL::CurveMapping &cumap, array< float > &data, int size)
void python_thread_state_restore(void **python_thread_state)
static void set_boolean(PointerRNA &ptr, const char *name, bool value)
static bool get_boolean(PointerRNA &ptr, const char *name)
static void set_float3(PointerRNA &ptr, const char *name, float3 value)
static unsigned char * image_get_pixels_for_frame(BL::Image &image, int frame, int tile)
static bool BKE_object_is_modified(BL::Object &self, BL::Scene &scene, bool preview)
unsigned char * BKE_image_get_pixels_for_frame(void *image, int frame, int tile)
static int get_int(PointerRNA &ptr, const char *name)
static void free_object_to_mesh(BL::BlendData &, BObjectInfo &b_ob_info, BL::Mesh &mesh)
static string get_enum_identifier(PointerRNA &ptr, const char *name)
static BL::Mesh object_to_mesh(BL::BlendData &, BObjectInfo &b_ob_info, BL::Depsgraph &, bool, Mesh::SubdivisionType subdivision_type)
static string get_text_datablock_content(const PointerRNA &ptr)
static void colorramp_to_array(BL::ColorRamp &ramp, array< float3 > &ramp_color, array< float > &ramp_alpha, int size)
static void curvemapping_to_array(BL::CurveMapping &cumap, array< float > &data, int size)
static float3 get_float3(const BL::Array< float, 2 > &array)
static int render_resolution_y(BL::RenderSettings &b_render)
static bool object_need_motion_attribute(BObjectInfo &b_ob_info, Scene *scene)
static int get_enum(PointerRNA &ptr, const char *name, int num_values=-1, int default_value=-1)
void BKE_image_user_file_path_ex(void *bmain, void *iuser, void *ima, char *path, bool resolve_udim, bool resolve_multiview)
static void set_enum(PointerRNA &ptr, const char *name, int value)
static void render_add_metadata(BL::RenderResult &b_rr, string name, string value)
BlenderAttributeType blender_attribute_name_split_type(ustring name, string *r_real_name)
static void set_float4(PointerRNA &ptr, const char *name, float4 value)
static bool BKE_object_is_deform_modified(BObjectInfo &self, BL::Scene &scene, bool preview)
static int4 get_int4(const BL::Array< int, 4 > &array)
static void curvemapping_color_to_array(BL::CurveMapping &cumap, array< float3 > &data, int size, bool rgb_curve)
static string blender_absolute_path(BL::BlendData &b_data, BL::ID &b_id, const string &path)
static int3 get_int3(const BL::Array< int, 3 > &array)
static float2 get_float2(const BL::Array< float, 2 > &array)
static Mesh::SubdivisionType object_subdivision_type(BL::Object &b_ob, bool preview, bool experimental)
void BKE_image_user_frame_calc(void *ima, void *iuser, int cfra)
static void set_int(PointerRNA &ptr, const char *name, int value)
static BL::FluidDomainSettings object_fluid_gas_domain_find(BL::Object &b_ob)
void python_thread_state_save(void **python_thread_state)
static void curvemap_minmax_curve(BL::CurveMap &curve, float *min_x, float *max_x)
static string get_string(PointerRNA &ptr, const char *name)
static void set_float(PointerRNA &ptr, const char *name, float value)
static Transform get_transform(const BL::Array< float, 16 > &array)
static void curvemapping_minmax(BL::CurveMapping &cumap, int num_curves, float *min_x, float *max_x)
static BL::MeshSequenceCacheModifier object_mesh_cache_find(BL::Object &b_ob, bool *has_subdivision_modifier)
static bool object_use_deform_motion(BL::Object &b_parent, BL::Object &b_ob)
static void mesh_texture_space(BL::Mesh &b_mesh, float3 &loc, float3 &size)
static void set_string(PointerRNA &ptr, const char *name, const string &value)
BL::ShaderNodeAttribute::attribute_type_enum BlenderAttributeType
static int image_user_frame_number(BL::ImageUser &iuser, BL::Image &ima, int cfra)
static float * image_get_float_pixels_for_frame(BL::Image &image, int frame, int tile)
ccl_device_inline Transform projection_to_transform(const ProjectionTransform &a)
ccl_device_inline ProjectionTransform projection_transpose(const ProjectionTransform &a)
const Depsgraph * depsgraph
depth_tx normal_tx diffuse_light_tx specular_light_tx volume_light_tx environment_tx ambient_occlusion_tx aov_value_tx in_weight_img image(1, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D_ARRAY, "out_weight_img") .image(3
ccl_gpu_kernel_postfix ccl_global int ccl_global int int num_values
ccl_global const KernelWorkTile * tile
@ PATH_RAY_VOLUME_SCATTER
void(* MEM_freeN)(void *vmemh)
static const pxr::TfToken preview("preview", pxr::TfToken::Immortal)
SocketIndexByIdentifierMap * map
string path_dirname(const string &path)
string path_join(const string &dir, const string &file)
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
const PointerRNA PointerRNA_NULL
void RNA_int_set(PointerRNA *ptr, const char *name, int value)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
void RNA_enum_set_identifier(bContext *C, PointerRNA *ptr, const char *name, const char *id)
int RNA_int_get(PointerRNA *ptr, const char *name)
float RNA_float_get(PointerRNA *ptr, const char *name)
bool RNA_property_enum_identifier(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const int value, const char **identifier)
void RNA_float_set(PointerRNA *ptr, const char *name, float value)
char * RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, int fixedlen, int *r_len)
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
int RNA_enum_get(PointerRNA *ptr, const char *name)
bool is_real_object_data() const
@ SUBDIVISION_CATMULL_CLARK
MotionType need_motion() const
ccl_device_inline int mod(int x, int m)