Cycles: Fixes for recent refactor

- add_vertex() can be called from split_vertex() which does not guarantee
  to have properly pre-allocate arrays.

- Need to check whether Cycles is compiled with OSL in XML reader.
This commit is contained in:
Sergey Sharybin 2016-05-31 15:32:31 +02:00
parent 230cf2e46d
commit d5220d23f9
3 changed files with 9 additions and 1 deletions

@ -306,6 +306,7 @@ static void xml_read_shader_graph(XMLReadState& state, Shader *shader, pugi::xml
snode = env;
}
#ifdef WITH_OSL
else if(string_iequals(node.name(), "osl_shader")) {
if(manager->use_osl()) {
std::string filepath;
@ -329,6 +330,7 @@ static void xml_read_shader_graph(XMLReadState& state, Shader *shader, pugi::xml
fprintf(stderr, "OSL node without using --shadingsys osl.\n");
}
}
#endif
else if(string_iequals(node.name(), "sky_texture")) {
SkyTextureNode *sky = new SkyTextureNode();

@ -206,7 +206,7 @@ void Mesh::clear()
int Mesh::split_vertex(int vertex)
{
/* copy vertex location and vertex attributes */
add_vertex(verts[vertex]);
add_vertex_slow(verts[vertex]);
foreach(Attribute& attr, attributes.attributes) {
if(attr.element == ATTR_ELEMENT_VERTEX) {
@ -224,6 +224,11 @@ void Mesh::add_vertex(float3 P)
verts.push_back_reserved(P);
}
void Mesh::add_vertex_slow(float3 P)
{
verts.push_back_slow(P);
}
void Mesh::add_triangle(int v0, int v1, int v2, int shader_, bool smooth_, bool forms_quad_)
{
triangles.push_back_reserved(v0);

@ -156,6 +156,7 @@ public:
void reserve_curves(int numcurves, int numkeys);
void clear();
void add_vertex(float3 P);
void add_vertex_slow(float3 P);
void add_triangle(int v0, int v1, int v2, int shader, bool smooth, bool forms_quad = false);
void add_curve_key(float3 loc, float radius);
void add_curve(int first_key, int shader);