Cleanup: style

This commit is contained in:
Campbell Barton 2018-07-19 16:06:37 +10:00
parent 34a45c54e0
commit 9df1e54079
Notes: blender-bot 2023-02-14 05:32:39 +01:00
Referenced by issue #56085, Crash when selecting bone in editmode using mouse
31 changed files with 136 additions and 126 deletions

View File

@ -170,7 +170,7 @@ def draw(layout, context, context_member, property_type, use_edit=True):
else:
row = box.row(align=True)
row.alignment = "RIGHT"
row.alignment = 'RIGHT'
row.label(text=key, translate=False)

View File

@ -2440,9 +2440,9 @@ class WM_OT_studiolight_install(Operator):
)
orientation: EnumProperty(
items=(
("MATCAP", "MatCap", ""),
("WORLD", "World", ""),
("CAMERA", "Camera", ""),
('MATCAP', "MatCap", ""),
('WORLD', "World", ""),
('CAMERA', "Camera", ""),
)
)

View File

@ -132,7 +132,7 @@ def point_cache_ui(self, context, cache, enabled, cachetype):
cache_info = cache.info
if cache_info:
col = layout.column()
col.alignment = "RIGHT"
col.alignment = 'RIGHT'
col.label(text=cache_info)
else:
if cachetype in {'SMOKE', 'DYNAMIC_PAINT'}:
@ -156,7 +156,7 @@ def point_cache_ui(self, context, cache, enabled, cachetype):
cache_info = cache.info
if cachetype != 'SMOKE' and cache_info: # avoid empty space.
col = layout.column(align=True)
col.alignment = "RIGHT"
col.alignment = 'RIGHT'
col.label(text=cache_info)
can_bake = True
@ -186,7 +186,7 @@ def point_cache_ui(self, context, cache, enabled, cachetype):
can_bake = False
col = layout.column(align=True)
col.alignment = "RIGHT"
col.alignment = 'RIGHT'
col.separator()

View File

@ -215,7 +215,7 @@ class SCENE_PT_keyframing_settings(SceneButtonsPanel, SceneKeyingSetsPanel, Pane
flow = layout.grid_flow(row_major=True, columns=0, even_columns=False, even_rows=False, align=True)
col = flow.column(align=True)
col.alignment = "RIGHT"
col.alignment = 'RIGHT'
col.label(text="General Override")
self.draw_keyframing_settings(context, col, ks, None)
@ -225,7 +225,7 @@ class SCENE_PT_keyframing_settings(SceneButtonsPanel, SceneKeyingSetsPanel, Pane
col.separator()
col = flow.column(align=True)
col.alignment = "RIGHT"
col.alignment = 'RIGHT'
col.label(text="Active Set Override")
self.draw_keyframing_settings(context, col, ks, ksp)
@ -272,7 +272,7 @@ class SCENE_PT_keying_set_paths(SceneButtonsPanel, SceneKeyingSetsPanel, Panel):
ksp = ks.paths.active
if ksp:
col = flow.column(align=True)
col.alignment = "RIGHT"
col.alignment = 'RIGHT'
col.template_any_ID(ksp, "id", "id_type", text="Target ID-Block")

View File

@ -23,8 +23,8 @@
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __BKE_SUBDIV_CONVERTER_H__
#define __BKE_SUBDIV_CONVERTER_H__
#ifndef __SUBDIV_CONVERTER_H__
#define __SUBDIV_CONVERTER_H__
#include "BKE_subdiv.h"
@ -54,4 +54,4 @@ void BKE_subdiv_converter_free(struct OpenSubdiv_Converter *converter);
int BKE_subdiv_converter_fvar_linear_from_settings(
const SubdivSettings *settings);
#endif /* __BKE_SUBDIV_CONVERTER_H__ */
#endif /* __SUBDIV_CONVERTER_H__ */

View File

@ -152,7 +152,7 @@ static void edges_of_ptex_get(
typedef struct VerticesForInterpolation {
/* This field points to a vertex data which is to be used for interpolation.
* The idea is to avoid unnecessary allocations for regular faces, where
* we can simply
* we can simply
*/
const CustomData *vertex_data;
/* Vertices data calculated for ptex corners. There are always 4 elements
@ -176,7 +176,7 @@ typedef struct VerticesForInterpolation {
static void vertex_interpolation_init(
const SubdivMeshContext *ctx,
VerticesForInterpolation *vertex_interpolation,
const MPoly *coarse_poly)
const MPoly *coarse_poly)
{
const Mesh *coarse_mesh = ctx->coarse_mesh;
const MLoop *coarse_mloop = coarse_mesh->mloop;
@ -234,7 +234,8 @@ static void vertex_interpolation_from_ptex(
{
if (coarse_poly->totloop == 4) {
/* Nothing to do, all indices and data is already assigned. */
} else {
}
else {
const CustomData *vertex_data = &ctx->coarse_mesh->vdata;
const Mesh *coarse_mesh = ctx->coarse_mesh;
const MLoop *coarse_mloop = coarse_mesh->mloop;
@ -287,7 +288,7 @@ static void vertex_interpolation_end(
typedef struct LoopsForInterpolation {
/* This field points to a loop data which is to be used for interpolation.
* The idea is to avoid unnecessary allocations for regular faces, where
* we can simply
* we can simply
*/
const CustomData *loop_data;
/* Loops data calculated for ptex corners. There are always 4 elements
@ -311,7 +312,7 @@ typedef struct LoopsForInterpolation {
static void loop_interpolation_init(
const SubdivMeshContext *ctx,
LoopsForInterpolation *loop_interpolation,
const MPoly *coarse_poly)
const MPoly *coarse_poly)
{
const Mesh *coarse_mesh = ctx->coarse_mesh;
if (coarse_poly->totloop == 4) {
@ -363,7 +364,8 @@ static void loop_interpolation_from_ptex(
{
if (coarse_poly->totloop == 4) {
/* Nothing to do, all indices and data is already assigned. */
} else {
}
else {
const CustomData *loop_data = &ctx->coarse_mesh->ldata;
const Mesh *coarse_mesh = ctx->coarse_mesh;
const MLoop *coarse_mloop = coarse_mesh->mloop;
@ -481,9 +483,10 @@ static void subdiv_evaluate_vertices(SubdivMeshContext *ctx,
vertex_interpolation_end(&vertex_interpolation);
}
static void subdiv_copy_edge_data(SubdivMeshContext *ctx,
MEdge *subdiv_edge,
const MEdge *coarse_edge)
static void subdiv_copy_edge_data(
SubdivMeshContext *ctx,
MEdge *subdiv_edge,
const MEdge *coarse_edge)
{
if (coarse_edge == NULL) {
subdiv_edge->crease = 0;
@ -586,11 +589,12 @@ static void subdiv_create_edges(SubdivMeshContext *ctx, int poly_index)
EdgesOfPtex edges_of_ptex;
edges_of_ptex_get(ctx, &edges_of_ptex, coarse_poly, i);
/* Create bottom row of edges (0-1, 1-2). */
subdiv_edge = subdiv_create_edges_row(ctx,
subdiv_edge,
edges_of_ptex.first_edge,
start_ptex_face_vertex_index,
resolution);
subdiv_edge = subdiv_create_edges_row(
ctx,
subdiv_edge,
edges_of_ptex.first_edge,
start_ptex_face_vertex_index,
resolution);
/* Create remaining edges. */
for (int row = 0; row < resolution - 1; row++) {
const int start_row_vertex_index =

View File

@ -92,7 +92,7 @@ BLI_INLINE uint64_t fmix64(uint64_t k)
uint32_t BLI_hash_mm3(const unsigned char *in, size_t len, uint32_t seed)
{
const uint8_t *data = (const uint8_t*)in;
const uint8_t *data = (const uint8_t *)in;
const int nblocks = len / 4;
uint32_t h1 = seed;
@ -102,23 +102,23 @@ uint32_t BLI_hash_mm3(const unsigned char *in, size_t len, uint32_t seed)
/* body */
const uint32_t *blocks = (const uint32_t *)(data + nblocks*4);
const uint32_t *blocks = (const uint32_t *)(data + nblocks * 4);
for (int i = -nblocks; i; i++) {
uint32_t k1 = getblock32(blocks,i);
uint32_t k1 = getblock32(blocks, i);
k1 *= c1;
k1 = ROTL32(k1,15);
k1 = ROTL32(k1, 15);
k1 *= c2;
h1 ^= k1;
h1 = ROTL32(h1,13);
h1 = h1*5+0xe6546b64;
h1 = ROTL32(h1, 13);
h1 = h1 * 5 + 0xe6546b64;
}
/* tail */
const uint8_t *tail = (const uint8_t*)(data + nblocks*4);
const uint8_t *tail = (const uint8_t *)(data + nblocks * 4);
uint32_t k1 = 0;
@ -132,10 +132,10 @@ uint32_t BLI_hash_mm3(const unsigned char *in, size_t len, uint32_t seed)
case 1:
k1 ^= tail[0];
k1 *= c1;
k1 = ROTL32(k1,15);
k1 = ROTL32(k1, 15);
k1 *= c2;
h1 ^= k1;
};
}
/* finalization */

View File

@ -62,7 +62,7 @@ void CryptomatteNode::convertToOperations(NodeConverter &converter, const Compos
bNode *node = this->getbNode();
NodeCryptomatte *cryptoMatteSettings = (NodeCryptomatte *)node->storage;
CryptomatteOperation *operation = new CryptomatteOperation(getNumberOfInputSockets()-1);
CryptomatteOperation *operation = new CryptomatteOperation(getNumberOfInputSockets() - 1);
if (cryptoMatteSettings) {
if (cryptoMatteSettings->matte_id) {
/* Split the string by commas, ignoring white space. */
@ -83,7 +83,7 @@ void CryptomatteNode::convertToOperations(NodeConverter &converter, const Compos
operation->addObjectIndex(atof(token.substr(1, token.length() - 2).c_str()));
}
else {
uint32_t hash = BLI_hash_mm3((const unsigned char*)token.c_str(), token.length(), 0);
uint32_t hash = BLI_hash_mm3((const unsigned char *)token.c_str(), token.length(), 0);
operation->addObjectIndex(hash_to_float(hash));
}
}
@ -93,14 +93,14 @@ void CryptomatteNode::convertToOperations(NodeConverter &converter, const Compos
converter.addOperation(operation);
for (int i = 0; i < getNumberOfInputSockets()-1; ++i) {
for (int i = 0; i < getNumberOfInputSockets() - 1; ++i) {
converter.mapInputSocket(this->getInputSocket(i + 1), operation->getInputSocket(i));
}
SeparateChannelOperation *separateOperation = new SeparateChannelOperation;
separateOperation->setChannel(3);
converter.addOperation(separateOperation);
SetAlphaOperation *operationAlpha = new SetAlphaOperation();
converter.addOperation(operationAlpha);
@ -117,5 +117,5 @@ void CryptomatteNode::convertToOperations(NodeConverter &converter, const Compos
converter.mapOutputSocket(outputSocketMatte, separateOperation->getOutputSocket(0));
converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket(0));
converter.mapOutputSocket(outputSocketPick, clearAlphaOperation->getOutputSocket(0));
}

View File

@ -63,7 +63,7 @@ void CryptomatteOperation::executePixel(float output[4],
output[1] = ((float) ((m3hash << 8)) / (float) UINT32_MAX);
output[2] = ((float) ((m3hash << 16)) / (float) UINT32_MAX);
}
for(size_t i = 0; i < m_objectIndex.size(); i++) {
for (size_t i = 0; i < m_objectIndex.size(); i++) {
if (m_objectIndex[i] == input[0]) {
output[3] += input[1];
}

View File

@ -269,9 +269,9 @@ void DEG_debug_print_eval_parent_typed(struct Depsgraph *depsgraph,
const void *parent_address);
void DEG_debug_print_eval_time(struct Depsgraph *depsgraph,
const char* function_name,
const char* object_name,
const void* object_address,
const char *function_name,
const char *object_name,
const void *object_address,
float time);
#ifdef __cplusplus

View File

@ -37,24 +37,29 @@
namespace DEG {
BuilderMap::BuilderMap() {
BuilderMap::BuilderMap()
{
set = BLI_gset_ptr_new("deg builder gset");
}
BuilderMap::~BuilderMap() {
BuilderMap::~BuilderMap()
{
BLI_gset_free(set, NULL);
}
bool BuilderMap::checkIsBuilt(ID *id) {
bool BuilderMap::checkIsBuilt(ID *id)
{
return BLI_gset_haskey(set, id);
}
void BuilderMap::tagBuild(ID *id) {
void BuilderMap::tagBuild(ID *id)
{
BLI_gset_insert(set, id);
}
bool BuilderMap::checkIsBuiltAndTag(ID *id) {
bool BuilderMap::checkIsBuiltAndTag(ID *id)
{
void **key_p;
if (!BLI_gset_ensure_p_ex(set, id, &key_p)) {
*key_p = id;

View File

@ -158,7 +158,7 @@ struct DepsgraphNodeBuilder {
const char *name = "",
int name_tag = -1);
void build_id(ID* id);
void build_id(ID *id);
void build_layer_collections(ListBase *lb);
void build_view_layer(Scene *scene,
ViewLayer *view_layer,

View File

@ -33,11 +33,11 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd)
if (wpd->shading.light == V3D_LIGHTING_MATCAP) {
wpd->studio_light = BKE_studiolight_find(
wpd->shading.matcap, STUDIOLIGHT_ORIENTATION_VIEWNORMAL);
wpd->shading.matcap, STUDIOLIGHT_ORIENTATION_VIEWNORMAL);
}
else {
wpd->studio_light = BKE_studiolight_find(
wpd->shading.studio_light, STUDIOLIGHT_ORIENTATION_CAMERA | STUDIOLIGHT_ORIENTATION_WORLD);
wpd->shading.studio_light, STUDIOLIGHT_ORIENTATION_CAMERA | STUDIOLIGHT_ORIENTATION_WORLD);
}
wpd->shadow_multiplier = 1.0 - wpd->shading.shadow_intensity;

View File

@ -19,7 +19,7 @@
*
*/
/** \file workbench_volumed.c
/** \file workbench_volume.c
* \ingroup draw_engine
*/

View File

@ -901,7 +901,7 @@ GPUBatch *DRW_cache_empty_capsule_cap_get(void)
float v[3] = {0.0f, 0.0f, 0.0f};
copy_v2_v2(v, p[(i) % NSEGMENTS]);
GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
copy_v2_v2(v, p[(i+1) % NSEGMENTS]);
copy_v2_v2(v, p[(i + 1) % NSEGMENTS]);
GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
}

View File

@ -828,7 +828,7 @@ static void shader_preview_free(void *customdata)
ShaderPreview *sp = customdata;
Main *pr_main = sp->pr_main;
if (sp->id_copy){
if (sp->id_copy) {
switch (GS(sp->id_copy->name)) {
case ID_MA:
BKE_material_free((Material *)sp->id_copy);

View File

@ -33,14 +33,14 @@
#define PROGRAM_NO_OPTI 0
#if defined(NDEBUG)
#define TRUST_NO_ONE 0
# define TRUST_NO_ONE 0
#else
/* strict error checking, enabled for debug builds during early development */
#define TRUST_NO_ONE 1
# define TRUST_NO_ONE 1
#endif
#if defined(WITH_OPENGL)
#include <GL/glew.h>
# include <GL/glew.h>
#endif
#include <stdbool.h>
@ -48,7 +48,7 @@
#include "BLI_sys_types.h"
#if TRUST_NO_ONE
#include <assert.h>
# include <assert.h>
#endif
/* GPU_INLINE */

View File

@ -35,7 +35,7 @@
#include <stdlib.h>
#if GPU_VERT_ATTR_MAX_LEN != 16
#error "attrib binding code assumes GPU_VERT_ATTR_MAX_LEN = 16"
# error "attrib binding code assumes GPU_VERT_ATTR_MAX_LEN = 16"
#endif
void AttribBinding_clear(GPUAttrBinding *binding)

View File

@ -35,9 +35,11 @@
#include "GPU_vertex_format.h"
#include "GPU_shader_interface.h"
void AttribBinding_clear(GPUAttrBinding*);
void AttribBinding_clear(GPUAttrBinding *binding);
void get_attrib_locations(const GPUVertFormat*, GPUAttrBinding*, const GPUShaderInterface*);
unsigned read_attrib_location(const GPUAttrBinding*, unsigned a_idx);
void get_attrib_locations(
const GPUVertFormat *format, GPUAttrBinding *binding, const GPUShaderInterface *shaderface);
unsigned read_attrib_location(
const GPUAttrBinding *binding, unsigned a_idx);
#endif /* __GPU_ATTR_BINDING_PRIVATE_H__ */

View File

@ -41,10 +41,10 @@ extern "C" {
#include "GPU_context.h"
#include "GPU_shader_interface.h"
void gpu_batch_remove_interface_ref(GPUBatch*, const GPUShaderInterface*);
void gpu_batch_remove_interface_ref(GPUBatch *batch, const GPUShaderInterface *interface);
void gpu_context_add_batch(GPUContext*, GPUBatch*);
void gpu_context_remove_batch(GPUContext*, GPUBatch*);
void gpu_context_add_batch(GPUContext *ctx, GPUBatch *batch);
void gpu_context_remove_batch(GPUContext *ctx, GPUBatch *batch);
#ifdef __cplusplus
}

View File

@ -37,7 +37,7 @@
#define ORPHAN_DEBUG 0
#if ORPHAN_DEBUG
#include <cstdio>
# include <cstdio>
#endif
static std::vector<GLuint> orphaned_buffer_ids;

View File

@ -701,17 +701,17 @@ void immVertex2iv(uint attrib_id, const int data[2])
/* --- generic uniform functions --- */
#if 0
#if TRUST_NO_ONE
#define GET_UNIFORM const GPUShaderInput* uniform = GPU_shaderinterface_uniform(imm.shader_interface, name); assert(uniform);
#else
#define GET_UNIFORM const GPUShaderInput* uniform = GPU_shaderinterface_uniform(imm.shader_interface, name);
#endif
# if TRUST_NO_ONE
# define GET_UNIFORM const GPUShaderInput* uniform = GPU_shaderinterface_uniform(imm.shader_interface, name); assert(uniform);
# else
# define GET_UNIFORM const GPUShaderInput* uniform = GPU_shaderinterface_uniform(imm.shader_interface, name);
# endif
#else
/* NOTE: It is possible to have uniform fully optimized out from the shader.
* In this case we can't assert failure or allow NULL-pointer dereference.
* TODO(sergey): How can we detect existing-but-optimized-out uniform but still
* catch typos in uniform names passed to immUniform*() functions? */
#define GET_UNIFORM const GPUShaderInput* uniform = GPU_shaderinterface_uniform(imm.shader_interface, name); if (uniform == NULL) return;
# define GET_UNIFORM const GPUShaderInput* uniform = GPU_shaderinterface_uniform(imm.shader_interface, name); if (uniform == NULL) return;
#endif
void immUniform1f(const char *name, float x)

View File

@ -18,7 +18,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
/** \file blender/gpu/intern/gpu_imm_util.c
/** \file blender/gpu/intern/gpu_immediate_util.c
* \ingroup gpu
*
* GPU immediate mode drawing utilities

View File

@ -39,7 +39,7 @@
#define DEBUG_SHADER_INTERFACE 0
#if DEBUG_SHADER_INTERFACE
#include <stdio.h>
# include <stdio.h>
#endif
static const char *BuiltinUniform_name(GPUUniformBuiltin u)

View File

@ -23,7 +23,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
/** \file blender/gpu/gpu_vertex_array_id.cpp
/** \file blender/gpu/intern/gpu_vertex_array_id.cpp
* \ingroup gpu
*
* Manage GL vertex array IDs in a thread-safe way
@ -58,7 +58,7 @@ static bool thread_is_main() {
struct GPUContext {
GLuint default_vao;
std::unordered_set<GPUBatch*> batches; /* Batches that have VAOs from this context */
std::unordered_set<GPUBatch *> batches; /* Batches that have VAOs from this context */
std::vector<GLuint> orphaned_vertarray_ids;
std::mutex orphans_mutex; /* todo: try spinlock instead */
#if TRUST_NO_ONE
@ -73,12 +73,12 @@ struct GPUContext {
#if defined(_MSC_VER) && (_MSC_VER == 1800)
#define thread_local __declspec(thread)
thread_local GPUContext* active_ctx = NULL;
thread_local GPUContext *active_ctx = NULL;
#else
static thread_local GPUContext* active_ctx = NULL;
static thread_local GPUContext *active_ctx = NULL;
#endif
static void clear_orphans(GPUContext* ctx)
static void clear_orphans(GPUContext *ctx)
{
ctx->orphans_mutex.lock();
if (!ctx->orphaned_vertarray_ids.empty()) {
@ -89,19 +89,19 @@ static void clear_orphans(GPUContext* ctx)
ctx->orphans_mutex.unlock();
}
GPUContext* GPU_context_create(void)
GPUContext *GPU_context_create(void)
{
#if TRUST_NO_ONE
/* assert(thread_is_main()); */
#endif
GPUContext* ctx = new GPUContext;
GPUContext *ctx = new GPUContext;
glGenVertexArrays(1, &ctx->default_vao);
GPU_context_active_set(ctx);
return ctx;
}
/* to be called after GPU_context_active_set(ctx_to_destroy) */
void GPU_context_discard(GPUContext* ctx)
void GPU_context_discard(GPUContext *ctx)
{
#if TRUST_NO_ONE
/* Make sure no other thread has locked it. */
@ -120,7 +120,7 @@ void GPU_context_discard(GPUContext* ctx)
}
/* ctx can be NULL */
void GPU_context_active_set(GPUContext* ctx)
void GPU_context_active_set(GPUContext *ctx)
{
#if TRUST_NO_ONE
if (active_ctx) {
@ -140,7 +140,7 @@ void GPU_context_active_set(GPUContext* ctx)
active_ctx = ctx;
}
GPUContext* GPU_context_active_get(void)
GPUContext *GPU_context_active_get(void)
{
return active_ctx;
}
@ -168,7 +168,7 @@ GLuint GPU_vao_alloc(void)
}
/* this can be called from multiple thread */
void GPU_vao_free(GLuint vao_id, GPUContext* ctx)
void GPU_vao_free(GLuint vao_id, GPUContext *ctx)
{
#if TRUST_NO_ONE
assert(ctx);
@ -183,12 +183,12 @@ void GPU_vao_free(GLuint vao_id, GPUContext* ctx)
}
}
void gpu_context_add_batch(GPUContext* ctx, GPUBatch* batch)
void gpu_context_add_batch(GPUContext *ctx, GPUBatch *batch)
{
ctx->batches.emplace(batch);
}
void gpu_context_remove_batch(GPUContext* ctx, GPUBatch* batch)
void gpu_context_remove_batch(GPUContext *ctx, GPUBatch *batch)
{
ctx->orphans_mutex.lock();
ctx->batches.erase(batch);

View File

@ -37,7 +37,7 @@
#define PACK_DEBUG 0
#if PACK_DEBUG
#include <stdio.h>
# include <stdio.h>
#endif
void GPU_vertformat_clear(GPUVertFormat *format)

View File

@ -32,8 +32,8 @@
#ifndef __GPU_VERTEX_FORMAT_PRIVATE_H__
#define __GPU_VERTEX_FORMAT_PRIVATE_H__
void VertexFormat_pack(GPUVertFormat*);
void VertexFormat_pack(GPUVertFormat *format);
uint padding(uint offset, uint alignment);
uint vertex_buffer_size(const GPUVertFormat*, uint vertex_len);
uint vertex_buffer_size(const GPUVertFormat *format, uint vertex_len);
#endif /* __GPU_VERTEX_FORMAT_PRIVATE_H__ */

View File

@ -6976,8 +6976,9 @@ static void def_cmp_cryptomatte(StructRNA *srna)
RNA_def_struct_sdna_from(srna, "NodeCryptomatte", "storage");
prop = RNA_def_property(srna, "matte_id", PROP_STRING, PROP_NONE);
RNA_def_property_string_funcs(prop, "rna_NodeCryptomatte_matte_get", "rna_NodeCryptomatte_matte_length",
"rna_NodeCryptomatte_matte_set");
RNA_def_property_string_funcs(
prop, "rna_NodeCryptomatte_matte_get", "rna_NodeCryptomatte_matte_length",
"rna_NodeCryptomatte_matte_set");
RNA_def_property_ui_text(prop, "Matte Objects", "List of object and material crypto IDs to include in matte");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");

View File

@ -39,10 +39,10 @@
static inline float hash_to_float(uint32_t hash)
{
uint32_t mantissa = hash & (( 1 << 23) - 1);
uint32_t mantissa = hash & ((1 << 23) - 1);
uint32_t exponent = (hash >> 23) & ((1 << 8) - 1);
exponent = MAX2(exponent, (uint32_t) 1);
exponent = MIN2(exponent, (uint32_t) 254);
exponent = MAX2(exponent, (uint32_t)1);
exponent = MIN2(exponent, (uint32_t)254);
exponent = exponent << 23;
uint32_t sign = (hash >> 31);
sign = sign << 31;
@ -54,7 +54,7 @@ static inline float hash_to_float(uint32_t hash)
return f;
}
static void cryptomatte_add(NodeCryptomatte* n, float f)
static void cryptomatte_add(NodeCryptomatte *n, float f)
{
/* Turn the number into a string. */
char number[32];
@ -72,16 +72,16 @@ static void cryptomatte_add(NodeCryptomatte* n, float f)
}
/* Find the next seprator. */
char* token_end = strchr(n->matte_id+start, ',');
if (token_end == NULL || token_end == n->matte_id+start) {
token_end = n->matte_id+end;
char *token_end = strchr(n->matte_id + start, ',');
if (token_end == NULL || token_end == n->matte_id + start) {
token_end = n->matte_id + end;
}
/* Be aware that token_len still contains any trailing white space. */
token_len = token_end - (n->matte_id + start);
/* If this has a leading bracket, assume a raw floating point number and look for the closing bracket. */
if (n->matte_id[start] == '<') {
if (strncmp(n->matte_id+start, number, strlen(number)) == 0) {
if (strncmp(n->matte_id + start, number, strlen(number)) == 0) {
/* This number is already there, so continue. */
return;
}
@ -89,16 +89,16 @@ static void cryptomatte_add(NodeCryptomatte* n, float f)
else {
/* Remove trailing white space */
size_t name_len = token_len;
while (n->matte_id[start+name_len] == ' ' && name_len > 0) {
while (n->matte_id[start + name_len] == ' ' && name_len > 0) {
name_len--;
}
/* Calculate the hash of the token and compare. */
uint32_t hash = BLI_hash_mm3((const unsigned char*)(n->matte_id+start), name_len, 0);
uint32_t hash = BLI_hash_mm3((const unsigned char *)(n->matte_id + start), name_len, 0);
if (f == hash_to_float(hash)) {
return;
}
}
start += token_len+1;
start += token_len + 1;
}
}
@ -107,12 +107,12 @@ static void cryptomatte_add(NodeCryptomatte* n, float f)
return;
}
if(n->matte_id) {
if (n->matte_id) {
BLI_dynstr_append(new_matte, n->matte_id);
MEM_freeN(n->matte_id);
}
if(BLI_dynstr_get_len(new_matte) > 0) {
if (BLI_dynstr_get_len(new_matte) > 0) {
BLI_dynstr_append(new_matte, ",");
}
BLI_dynstr_append(new_matte, number);
@ -120,7 +120,7 @@ static void cryptomatte_add(NodeCryptomatte* n, float f)
BLI_dynstr_free(new_matte);
}
static void cryptomatte_remove(NodeCryptomatte*n, float f)
static void cryptomatte_remove(NodeCryptomatte *n, float f)
{
if (n->matte_id == NULL || strlen(n->matte_id) == 0) {
/* Empty string, nothing to remove. */
@ -150,9 +150,9 @@ static void cryptomatte_remove(NodeCryptomatte*n, float f)
}
/* Find the next seprator. */
char* token_end = strchr(n->matte_id+start+1, ',');
if (token_end == NULL || token_end == n->matte_id+start) {
token_end = n->matte_id+end;
char *token_end = strchr(n->matte_id + start + 1, ',');
if (token_end == NULL || token_end == n->matte_id + start) {
token_end = n->matte_id + end;
}
/* Be aware that token_len still contains any trailing white space. */
token_len = token_end - (n->matte_id + start);
@ -162,7 +162,7 @@ static void cryptomatte_remove(NodeCryptomatte*n, float f)
}
/* If this has a leading bracket, assume a raw floating point number and look for the closing bracket. */
else if (n->matte_id[start] == '<') {
if (strncmp(n->matte_id+start, number, strlen(number)) == 0) {
if (strncmp(n->matte_id + start, number, strlen(number)) == 0) {
/* This number is already there, so skip it. */
skip = true;
}
@ -170,11 +170,11 @@ static void cryptomatte_remove(NodeCryptomatte*n, float f)
else {
/* Remove trailing white space */
size_t name_len = token_len;
while (n->matte_id[start+name_len] == ' ' && name_len > 0) {
while (n->matte_id[start + name_len] == ' ' && name_len > 0) {
name_len--;
}
/* Calculate the hash of the token and compare. */
uint32_t hash = BLI_hash_mm3((const unsigned char*)(n->matte_id+start), name_len, 0);
uint32_t hash = BLI_hash_mm3((const unsigned char *)(n->matte_id + start), name_len, 0);
if (f == hash_to_float(hash)) {
skip = true;
}
@ -186,26 +186,26 @@ static void cryptomatte_remove(NodeCryptomatte*n, float f)
else {
BLI_dynstr_append(new_matte, ", ");
}
BLI_dynstr_nappend(new_matte, n->matte_id+start, token_len);
BLI_dynstr_nappend(new_matte, n->matte_id + start, token_len);
}
start += token_len+1;
start += token_len + 1;
}
if(n->matte_id) {
if (n->matte_id) {
MEM_freeN(n->matte_id);
n->matte_id = NULL;
}
if(BLI_dynstr_get_len(new_matte) > 0) {
if (BLI_dynstr_get_len(new_matte) > 0) {
n->matte_id = BLI_dynstr_get_cstring(new_matte);
}
BLI_dynstr_free(new_matte);
}
static bNodeSocketTemplate outputs[] = {
{ SOCK_RGBA, 0, N_("Image")},
{ SOCK_FLOAT, 0, N_("Matte")},
{ SOCK_RGBA, 0, N_("Pick")},
{ -1, 0, "" }
{ SOCK_RGBA, 0, N_("Image")},
{ SOCK_FLOAT, 0, N_("Matte")},
{ SOCK_RGBA, 0, N_("Pick")},
{ -1, 0, "" }
};
void ntreeCompositCryptomatteSyncFromAdd(bNodeTree *UNUSED(ntree), bNode *node)
@ -235,7 +235,7 @@ bNodeSocket *ntreeCompositCryptomatteAddSocket(bNodeTree *ntree, bNode *node)
NodeCryptomatte *n = node->storage;
char sockname[32];
n->num_inputs++;
BLI_snprintf(sockname, sizeof(sockname), "Crypto %.2d", n->num_inputs-1);
BLI_snprintf(sockname, sizeof(sockname), "Crypto %.2d", n->num_inputs - 1);
bNodeSocket *sock = nodeAddStaticSocket(ntree, node, SOCK_IN, SOCK_RGBA, PROP_NONE, NULL, sockname);
return sock;
}

View File

@ -40,7 +40,7 @@ static bNodeSocketTemplate sh_node_bsdf_hair_principled_in[] = {
{ SOCK_FLOAT, 1, N_("Radial Roughness"), 0.3f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
{ SOCK_FLOAT, 1, N_("Coat"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
{ SOCK_FLOAT, 1, N_("IOR"), 1.55f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
{ SOCK_FLOAT, 1, N_("Offset"), 2.f*((float)M_PI)/180.f, 0.0f, 0.0f, 0.0f, -M_PI_2, M_PI_2, PROP_ANGLE},
{ SOCK_FLOAT, 1, N_("Offset"), 2.0f * ((float)M_PI) / 180.f, 0.0f, 0.0f, 0.0f, -M_PI_2, M_PI_2, PROP_ANGLE},
{ SOCK_FLOAT, 1, N_("Random Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
{ SOCK_FLOAT, 1, N_("Random Roughness"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
{ SOCK_FLOAT, 1, N_("Random"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},

View File

@ -32,8 +32,6 @@
#include "BLI_math.h"
#include "GPU_batch.h"
#include "MEM_guardedalloc.h"
#include "../generic/py_capi_utils.h"