17 #ifndef __BLENDER_UTIL_H__
18 #define __BLENDER_UTIL_H__
57 bool subsurf_mod_show_render =
false;
58 bool subsurf_mod_show_viewport =
false;
61 BL::Modifier subsurf_mod =
object.modifiers[
object.modifiers.length() - 1];
63 subsurf_mod_show_render = subsurf_mod.show_render();
64 subsurf_mod_show_viewport = subsurf_mod.show_viewport();
66 subsurf_mod.show_render(
false);
67 subsurf_mod.show_viewport(
false);
72 if (
object.
type() == BL::Object::type_MESH) {
79 if (
mesh.is_editmode() ||
92 BL::Modifier subsurf_mod =
object.modifiers[
object.modifiers.length() - 1];
94 subsurf_mod.show_render(subsurf_mod_show_render);
95 subsurf_mod.show_viewport(subsurf_mod_show_viewport);
100 if (
mesh.use_auto_smooth()) {
101 mesh.split_faces(
false);
104 mesh.calc_loop_triangles();
116 object.to_mesh_clear();
128 for (
int i = 0; i <
size; i++) {
131 ramp.evaluate((
float)i / (
float)(
size - 1), color);
132 ramp_color[i] =
make_float3(color[0], color[1], color[2]);
133 ramp_alpha[i] = color[3];
139 *min_x =
min(*min_x,
curve.points[0].location()[0]);
140 *max_x =
max(*max_x,
curve.points[
curve.points.length() - 1].location()[0]);
149 const int num_curves = rgb_curve ? 4 : 3;
152 for (
int i = 0; i < num_curves; ++i) {
163 for (
int i = 0; i <
size; i++) {
174 float min_x = 0.0f, max_x = 1.0f;
189 const float range_x = max_x - min_x;
201 for (
int i = 0; i <
size; i++) {
202 const float t = min_x + (
float)i / (
float)(
size - 1) * range_x;
204 cumap.evaluate(mapG, cumap.evaluate(mapI,
t)),
205 cumap.evaluate(mapB, cumap.evaluate(mapI,
t)));
209 for (
int i = 0; i <
size; i++) {
210 float t = min_x + (
float)i / (
float)(
size - 1) * range_x;
212 cumap.evaluate(mapR,
t), cumap.evaluate(mapG,
t), cumap.evaluate(mapB,
t));
219 return self.is_modified(
scene, (preview) ? (1 << 0) : (1 << 1)) ? true :
false;
224 return self.is_deform_modified(
scene, (preview) ? (1 << 0) : (1 << 1)) ? true :
false;
229 return b_render.resolution_x() * b_render.resolution_percentage() / 100;
234 return b_render.resolution_y() * b_render.resolution_percentage() / 100;
247 string filepath_str = string(filepath);
248 if (load_tiled && ima.source() == BL::Image::source_TILED) {
257 return iuser.frame_current();
272 b_rr.stamp_data_add_field(name.c_str(), value.c_str());
283 memcpy((
void *)&projection, &
array,
sizeof(
float) * 16);
389 int default_value = -1)
392 if (num_values != -1 && value >= num_values) {
393 assert(default_value != -1);
394 value = default_value;
402 const char *identifier =
"";
407 return string(identifier);
440 if (path.size() >= 2 && path[0] ==
'/' && path[1] ==
'/') {
443 if (b_id.library()) {
444 BL::ID b_library_id(b_id.library());
463 BL::Text::lines_iterator iter;
464 for (iter.begin(
ptr); iter; ++iter) {
465 content += iter->body() +
"\n";
491 const int max_steps = INT_MAX)
495 bool use_motion =
get_boolean(cobject,
"use_motion_blur");
504 if (b_parent.ptr.data != b_ob.ptr.data) {
506 use_motion &=
get_boolean(parent_cobject,
"use_motion_blur");
518 return min((2 << (
steps - 1)) + 1, max_steps);
525 bool use_deform_motion =
get_boolean(cobject,
"use_deform_motion");
532 if (use_deform_motion && b_parent.ptr.data != b_ob.ptr.data) {
534 use_deform_motion &=
get_boolean(parent_cobject,
"use_deform_motion");
536 return use_deform_motion;
541 for (BL::Modifier &b_mod : b_ob.modifiers) {
543 BL::FluidModifier b_mmd(b_mod);
545 if (b_mmd.fluid_type() == BL::FluidModifier::fluid_type_DOMAIN &&
546 b_mmd.domain_settings().domain_type() == BL::FluidDomainSettings::domain_type_LIQUID) {
547 return b_mmd.domain_settings();
557 for (BL::Modifier &b_mod : b_ob.modifiers) {
559 BL::FluidModifier b_mmd(b_mod);
561 if (b_mmd.fluid_type() == BL::FluidModifier::fluid_type_DOMAIN &&
562 b_mmd.domain_settings().domain_type() == BL::FluidDomainSettings::domain_type_GAS) {
563 return b_mmd.domain_settings();
577 if (cobj.
data && b_ob.modifiers.length() > 0 && experimental) {
578 BL::Modifier
mod = b_ob.modifiers[b_ob.modifiers.length() - 1];
579 bool enabled = preview ?
mod.show_viewport() :
mod.show_render();
581 if (
enabled &&
mod.type() == BL::Modifier::type_SUBSURF &&
583 BL::SubsurfModifier subsurf(
mod);
585 if (subsurf.subdivision_type() == BL::SubsurfModifier::subdivision_type_CATMULL_CLARK) {
626 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 type
_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 RGB to Bright Vector Camera Vector Combine Material Light Line Style Layer Add Ambient Diffuse Glossy Refraction Transparent Toon Principled Hair Volume Principled Light Particle Volume Image Sky Noise Wave Voronoi Brick Texture Vector Combine Vertex Separate Vector White ColorRamp
struct RenderResult RenderResult
StructRNA RNA_FluidModifier
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 BL::FluidDomainSettings object_fluid_liquid_domain_find(BL::Object &b_ob)
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)
void python_thread_state_restore(void **python_thread_state)
static bool BKE_object_is_deform_modified(BL::Object &self, BL::Scene &scene, bool preview)
static void curvemapping_minmax(BL::CurveMapping &cumap, bool rgb_curve, float *min_x, float *max_x)
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 string get_enum_identifier(PointerRNA &ptr, const char *name)
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 int get_enum(PointerRNA &ptr, const char *name, int num_values=-1, int default_value=-1)
CCL_NAMESPACE_BEGIN typedef BL::ShaderNodeAttribute::attribute_type_enum BlenderAttributeType
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 int4 get_int4(const BL::Array< int, 4 > &array)
void BKE_image_user_file_path(void *iuser, void *ima, char *path)
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)
static BL::Mesh object_to_mesh(BL::BlendData &, BL::Object &object, BL::Depsgraph &, bool, Mesh::SubdivisionType subdivision_type)
void BKE_image_user_frame_calc(void *ima, void *iuser, int cfra)
static string image_user_file_path(BL::ImageUser &iuser, BL::Image &ima, int cfra, bool load_tiled)
static void set_int(PointerRNA &ptr, const char *name, int value)
static BL::FluidDomainSettings object_fluid_gas_domain_find(BL::Object &b_ob)
static void free_object_to_mesh(BL::BlendData &, BL::Object &object, BL::Mesh &mesh)
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 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)
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)
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)
const Depsgraph * depsgraph
#define CCL_NAMESPACE_END
#define make_int4(x, y, z, w)
#define make_float2(x, y)
#define make_float4(x, y, z, w)
#define make_int3(x, y, z)
#define make_float3(x, y, z)
@ PATH_RAY_VOLUME_SCATTER
void(* MEM_freeN)(void *vmemh)
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)
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)
char * RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, int fixedlen)
@ SUBDIVISION_CATMULL_CLARK
ccl_device_inline int mod(int x, int m)
string path_dirname(const string &path)
string path_join(const string &dir, const string &file)
ccl_device_inline Transform projection_to_transform(const ProjectionTransform &a)
ccl_device_inline ProjectionTransform projection_transpose(const ProjectionTransform &a)
void string_replace(string &haystack, const string &needle, const string &other)