Changeset View
Changeset View
Standalone View
Standalone View
src/app/cycles_xml.cpp
| Context not available. | |||||
| * RGBCurvesNode, VectorCurvesNode, RGBRampNode and ConvertNode (RGB -> BW). | * RGBCurvesNode, VectorCurvesNode, RGBRampNode and ConvertNode (RGB -> BW). | ||||
| */ | */ | ||||
| if(string_iequals(node.name(), "image_texture")) { | if (string_iequals(node.name(), "rgb_curves")) { | ||||
| RGBCurvesNode *rgbcurves = new RGBCurvesNode(); | |||||
| string curves_data_path; | |||||
| xml_read_string(&curves_data_path, node, "src"); | |||||
sergey: We should avoid having such a direct linkage, this is something `<include>` is intended to do. | |||||
| curves_data_path = path_join(state.base, curves_data_path); | |||||
| pugi::xml_document doc; | |||||
| pugi::xml_node data_node; | |||||
| if (doc.load_file(curves_data_path.c_str())) | |||||
| data_node = doc.child("cycles").child("curves_data"); | |||||
| int curve_table_size = 0; | |||||
| xml_read_int(&curve_table_size, data_node, "size"); | |||||
| if (curve_table_size != RAMP_TABLE_SIZE) | |||||
sergeyUnsubmitted Not Done Inline ActionsCode style: should be no space between keyword and brace. sergey: Code style: should be no space between keyword and brace. | |||||
| fprintf(stderr, "Error table size \"%d\".\n", curve_table_size); | |||||
sergeyUnsubmitted Not Done Inline ActionsYou're reporting error here, but still keep reading the node. Straight way to either write pass the array boundaries or to have uninitialized values. sergey: You're reporting error here, but still keep reading the node. Straight way to either write pass… | |||||
| vector<vector<int> > curves(3, vector<int>()); | |||||
sergeyUnsubmitted Not Done Inline ActionsWhy's that int and why not to use array of vectors instead? sergey: Why's that `int` and why not to use array of vectors instead? | |||||
| xml_read_int_array(curves[0], data_node, "rcurve"); | |||||
| xml_read_int_array(curves[1], data_node, "gcurve"); | |||||
| xml_read_int_array(curves[2], data_node, "bcurve"); | |||||
| for (int i = 0; i < curve_table_size; i++) | |||||
sergeyUnsubmitted Not Done Inline ActionsPlease always use parenthesis. sergey: Please always use parenthesis. | |||||
| for (int j = 0; j < 3; j++) | |||||
sergeyUnsubmitted Not Done Inline ActionsCode style. sergey: Code style. | |||||
| { | |||||
| float t = (float)i / (float)(curve_table_size - 1) * curves[j][i]; | |||||
sergeyUnsubmitted Not Done Inline ActionsWhy is that? sergey: Why is that? | |||||
| rgbcurves->curves[i][j] = t; | |||||
| } | |||||
| snode = rgbcurves; | |||||
| } | |||||
| else if(string_iequals(node.name(), "image_texture")) { | |||||
| ImageTextureNode *img = new ImageTextureNode(); | ImageTextureNode *img = new ImageTextureNode(); | ||||
| xml_read_string(&img->filename, node, "src"); | xml_read_string(&img->filename, node, "src"); | ||||
| Context not available. | |||||
We should avoid having such a direct linkage, this is something <include> is intended to do. Benefits:
Surely some changes will need to be done in xml_read_include() or something like that.
Perhaps easiest way to go would be to: