diff options
-rw-r--r-- | intern/cycles/render/mesh_displace.cpp | 26 | ||||
-rw-r--r-- | intern/cycles/render/svm.cpp | 91 |
2 files changed, 66 insertions, 51 deletions
diff --git a/intern/cycles/render/mesh_displace.cpp b/intern/cycles/render/mesh_displace.cpp index f20bc73a542..159705cbb6a 100644 --- a/intern/cycles/render/mesh_displace.cpp +++ b/intern/cycles/render/mesh_displace.cpp @@ -79,18 +79,20 @@ bool MeshManager::displace(Device *device, DeviceScene *dscene, Scene *scene, Me int object = ~object_index; int prim = mesh->tri_offset + i; float u, v; - - if(j == 0) { - u = 1.0f; - v = 0.0f; - } - else if(j == 1) { - u = 0.0f; - v = 1.0f; - } - else { - u = 0.0f; - v = 0.0f; + + switch (j) { + case 0: + u = 1.0f; + v = 0.0f; + break; + case 1: + u = 0.0f; + v = 1.0f; + break; + default: + u = 0.0f; + v = 0.0f; + break; } /* back */ diff --git a/intern/cycles/render/svm.cpp b/intern/cycles/render/svm.cpp index ea2fe4991db..f61f9ca0fe3 100644 --- a/intern/cycles/render/svm.cpp +++ b/intern/cycles/render/svm.cpp @@ -124,23 +124,28 @@ SVMCompiler::SVMCompiler(ShaderManager *shader_manager_, ImageManager *image_man int SVMCompiler::stack_size(ShaderSocketType type) { - if(type == SHADER_SOCKET_FLOAT) - return 1; - else if(type == SHADER_SOCKET_INT) - return 1; - else if(type == SHADER_SOCKET_COLOR) - return 3; - else if(type == SHADER_SOCKET_VECTOR) - return 3; - else if(type == SHADER_SOCKET_NORMAL) - return 3; - else if(type == SHADER_SOCKET_POINT) - return 3; - else if(type == SHADER_SOCKET_CLOSURE) - return 0; - - assert(0); - return 0; + int size = 0; + + switch (type) { + case SHADER_SOCKET_FLOAT: + case SHADER_SOCKET_INT: + size = 1; + break; + case SHADER_SOCKET_COLOR: + case SHADER_SOCKET_VECTOR: + case SHADER_SOCKET_NORMAL: + case SHADER_SOCKET_POINT: + size = 3; + break; + case SHADER_SOCKET_CLOSURE: + size = 0; + break; + default: + assert(0); + break; + } + + return size; } int SVMCompiler::stack_find_offset(ShaderSocketType type) @@ -581,14 +586,20 @@ void SVMCompiler::compile_type(Shader *shader, ShaderGraph *graph, ShaderType ty ShaderNode *node = graph->output(); ShaderInput *clin = NULL; - if(type == SHADER_TYPE_SURFACE) - clin = node->input("Surface"); - else if(type == SHADER_TYPE_VOLUME) - clin = node->input("Volume"); - else if(type == SHADER_TYPE_DISPLACEMENT) - clin = node->input("Displacement"); - else - assert(0); + switch (type) { + case SHADER_TYPE_SURFACE: + clin = node->input("Surface"); + break; + case SHADER_TYPE_VOLUME: + clin = node->input("Volume"); + break; + case SHADER_TYPE_DISPLACEMENT: + clin = node->input("Displacement"); + break; + default: + assert(0); + break; + } /* clear all compiler state */ memset(&active_stack, 0, sizeof(active_stack)); @@ -604,20 +615,22 @@ void SVMCompiler::compile_type(Shader *shader, ShaderGraph *graph, ShaderType ty if(shader->used) { if(clin->link) { bool generate = false; - if(type == SHADER_TYPE_SURFACE) { - /* generate surface shader */ - generate = true; - shader->has_surface = true; - } - else if(type == SHADER_TYPE_VOLUME) { - /* generate volume shader */ - generate = true; - shader->has_volume = true; - } - else if(type == SHADER_TYPE_DISPLACEMENT) { - /* generate displacement shader */ - generate = true; - shader->has_displacement = true; + + switch (type) { + case SHADER_TYPE_SURFACE: /* generate surface shader */ + generate = true; + shader->has_surface = true; + break; + case SHADER_TYPE_VOLUME: /* generate volume shader */ + generate = true; + shader->has_volume = true; + break; + case SHADER_TYPE_DISPLACEMENT: /* generate displacement shader */ + generate = true; + shader->has_displacement = true; + break; + default: + break; } if(generate) { |