Add multimesh format max for proper error checking
This commit is contained in:
parent
f2aa99a8e2
commit
041fa57a88
5 changed files with 14 additions and 8 deletions
|
@ -3051,7 +3051,7 @@ void RasterizerStorageGLES2::multimesh_instance_set_color(RID p_multimesh, int p
|
|||
ERR_FAIL_COND(!multimesh);
|
||||
ERR_FAIL_INDEX(p_index, multimesh->size);
|
||||
ERR_FAIL_COND(multimesh->color_format == VS::MULTIMESH_COLOR_NONE);
|
||||
ERR_FAIL_INDEX(multimesh->color_format, VS::MULTIMESH_COLOR_FLOAT);
|
||||
ERR_FAIL_INDEX(multimesh->color_format, VS::MULTIMESH_COLOR_MAX);
|
||||
|
||||
int stride = multimesh->color_floats + multimesh->xform_floats + multimesh->custom_data_floats;
|
||||
float *dataptr = &multimesh->data.write[stride * p_index + multimesh->xform_floats];
|
||||
|
@ -3084,7 +3084,7 @@ void RasterizerStorageGLES2::multimesh_instance_set_custom_data(RID p_multimesh,
|
|||
ERR_FAIL_COND(!multimesh);
|
||||
ERR_FAIL_INDEX(p_index, multimesh->size);
|
||||
ERR_FAIL_COND(multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_NONE);
|
||||
ERR_FAIL_INDEX(multimesh->custom_data_format, VS::MULTIMESH_CUSTOM_DATA_FLOAT);
|
||||
ERR_FAIL_INDEX(multimesh->custom_data_format, VS::MULTIMESH_CUSTOM_DATA_MAX);
|
||||
|
||||
int stride = multimesh->color_floats + multimesh->xform_floats + multimesh->custom_data_floats;
|
||||
float *dataptr = &multimesh->data.write[stride * p_index + multimesh->xform_floats + multimesh->color_floats];
|
||||
|
@ -3172,7 +3172,7 @@ Color RasterizerStorageGLES2::multimesh_instance_get_color(RID p_multimesh, int
|
|||
ERR_FAIL_COND_V(!multimesh, Color());
|
||||
ERR_FAIL_INDEX_V(p_index, multimesh->size, Color());
|
||||
ERR_FAIL_COND_V(multimesh->color_format == VS::MULTIMESH_COLOR_NONE, Color());
|
||||
ERR_FAIL_INDEX_V(multimesh->color_format, VS::MULTIMESH_COLOR_FLOAT, Color());
|
||||
ERR_FAIL_INDEX_V(multimesh->color_format, VS::MULTIMESH_COLOR_MAX, Color());
|
||||
|
||||
int stride = multimesh->color_floats + multimesh->xform_floats + multimesh->custom_data_floats;
|
||||
float *dataptr = &multimesh->data.write[stride * p_index + multimesh->xform_floats];
|
||||
|
@ -3205,7 +3205,7 @@ Color RasterizerStorageGLES2::multimesh_instance_get_custom_data(RID p_multimesh
|
|||
ERR_FAIL_COND_V(!multimesh, Color());
|
||||
ERR_FAIL_INDEX_V(p_index, multimesh->size, Color());
|
||||
ERR_FAIL_COND_V(multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_NONE, Color());
|
||||
ERR_FAIL_INDEX_V(multimesh->custom_data_format, VS::MULTIMESH_CUSTOM_DATA_FLOAT, Color());
|
||||
ERR_FAIL_INDEX_V(multimesh->custom_data_format, VS::MULTIMESH_CUSTOM_DATA_MAX, Color());
|
||||
|
||||
int stride = multimesh->color_floats + multimesh->xform_floats + multimesh->custom_data_floats;
|
||||
float *dataptr = &multimesh->data.write[stride * p_index + multimesh->xform_floats + multimesh->color_floats];
|
||||
|
|
|
@ -1012,6 +1012,7 @@ void RasterizerCanvasGLES3::_canvas_item_render_commands(Item *p_item, Item *cur
|
|||
|
||||
switch (multi_mesh->color_format) {
|
||||
|
||||
case VS::MULTIMESH_COLOR_MAX:
|
||||
case VS::MULTIMESH_COLOR_NONE: {
|
||||
glDisableVertexAttribArray(11);
|
||||
glVertexAttrib4f(11, 1, 1, 1, 1);
|
||||
|
@ -1033,6 +1034,7 @@ void RasterizerCanvasGLES3::_canvas_item_render_commands(Item *p_item, Item *cur
|
|||
|
||||
switch (multi_mesh->custom_data_format) {
|
||||
|
||||
case VS::MULTIMESH_CUSTOM_DATA_MAX:
|
||||
case VS::MULTIMESH_CUSTOM_DATA_NONE: {
|
||||
glDisableVertexAttribArray(12);
|
||||
glVertexAttrib4f(12, 1, 1, 1, 1);
|
||||
|
|
|
@ -1416,6 +1416,7 @@ void RasterizerSceneGLES3::_setup_geometry(RenderList::Element *e, const Transfo
|
|||
|
||||
switch (multi_mesh->color_format) {
|
||||
|
||||
case VS::MULTIMESH_COLOR_MAX:
|
||||
case VS::MULTIMESH_COLOR_NONE: {
|
||||
glDisableVertexAttribArray(11);
|
||||
glVertexAttrib4f(11, 1, 1, 1, 1);
|
||||
|
@ -1437,6 +1438,7 @@ void RasterizerSceneGLES3::_setup_geometry(RenderList::Element *e, const Transfo
|
|||
|
||||
switch (multi_mesh->custom_data_format) {
|
||||
|
||||
case VS::MULTIMESH_CUSTOM_DATA_MAX:
|
||||
case VS::MULTIMESH_CUSTOM_DATA_NONE: {
|
||||
glDisableVertexAttribArray(12);
|
||||
glVertexAttrib4f(12, 1, 1, 1, 1);
|
||||
|
|
|
@ -4679,7 +4679,7 @@ void RasterizerStorageGLES3::multimesh_instance_set_color(RID p_multimesh, int p
|
|||
ERR_FAIL_COND(!multimesh);
|
||||
ERR_FAIL_INDEX(p_index, multimesh->size);
|
||||
ERR_FAIL_COND(multimesh->color_format == VS::MULTIMESH_COLOR_NONE);
|
||||
ERR_FAIL_INDEX(multimesh->color_format, VS::MULTIMESH_COLOR_FLOAT);
|
||||
ERR_FAIL_INDEX(multimesh->color_format, VS::MULTIMESH_COLOR_MAX);
|
||||
|
||||
int stride = multimesh->color_floats + multimesh->xform_floats + multimesh->custom_data_floats;
|
||||
float *dataptr = &multimesh->data.write[stride * p_index + multimesh->xform_floats];
|
||||
|
@ -4713,7 +4713,7 @@ void RasterizerStorageGLES3::multimesh_instance_set_custom_data(RID p_multimesh,
|
|||
ERR_FAIL_COND(!multimesh);
|
||||
ERR_FAIL_INDEX(p_index, multimesh->size);
|
||||
ERR_FAIL_COND(multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_NONE);
|
||||
ERR_FAIL_INDEX(multimesh->custom_data_format, VS::MULTIMESH_CUSTOM_DATA_FLOAT);
|
||||
ERR_FAIL_INDEX(multimesh->custom_data_format, VS::MULTIMESH_CUSTOM_DATA_MAX);
|
||||
|
||||
int stride = multimesh->color_floats + multimesh->xform_floats + multimesh->custom_data_floats;
|
||||
float *dataptr = &multimesh->data.write[stride * p_index + multimesh->xform_floats + multimesh->color_floats];
|
||||
|
@ -4802,7 +4802,7 @@ Color RasterizerStorageGLES3::multimesh_instance_get_color(RID p_multimesh, int
|
|||
ERR_FAIL_COND_V(!multimesh, Color());
|
||||
ERR_FAIL_INDEX_V(p_index, multimesh->size, Color());
|
||||
ERR_FAIL_COND_V(multimesh->color_format == VS::MULTIMESH_COLOR_NONE, Color());
|
||||
ERR_FAIL_INDEX_V(multimesh->color_format, VS::MULTIMESH_COLOR_FLOAT, Color());
|
||||
ERR_FAIL_INDEX_V(multimesh->color_format, VS::MULTIMESH_COLOR_MAX, Color());
|
||||
|
||||
int stride = multimesh->color_floats + multimesh->xform_floats + multimesh->custom_data_floats;
|
||||
float *dataptr = &multimesh->data.write[stride * p_index + multimesh->xform_floats];
|
||||
|
@ -4836,7 +4836,7 @@ Color RasterizerStorageGLES3::multimesh_instance_get_custom_data(RID p_multimesh
|
|||
ERR_FAIL_COND_V(!multimesh, Color());
|
||||
ERR_FAIL_INDEX_V(p_index, multimesh->size, Color());
|
||||
ERR_FAIL_COND_V(multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_NONE, Color());
|
||||
ERR_FAIL_INDEX_V(multimesh->custom_data_format, VS::MULTIMESH_CUSTOM_DATA_FLOAT, Color());
|
||||
ERR_FAIL_INDEX_V(multimesh->custom_data_format, VS::MULTIMESH_CUSTOM_DATA_MAX, Color());
|
||||
|
||||
int stride = multimesh->color_floats + multimesh->xform_floats + multimesh->custom_data_floats;
|
||||
float *dataptr = &multimesh->data.write[stride * p_index + multimesh->xform_floats + multimesh->color_floats];
|
||||
|
|
|
@ -335,12 +335,14 @@ public:
|
|||
MULTIMESH_COLOR_NONE,
|
||||
MULTIMESH_COLOR_8BIT,
|
||||
MULTIMESH_COLOR_FLOAT,
|
||||
MULTIMESH_COLOR_MAX,
|
||||
};
|
||||
|
||||
enum MultimeshCustomDataFormat {
|
||||
MULTIMESH_CUSTOM_DATA_NONE,
|
||||
MULTIMESH_CUSTOM_DATA_8BIT,
|
||||
MULTIMESH_CUSTOM_DATA_FLOAT,
|
||||
MULTIMESH_CUSTOM_DATA_MAX,
|
||||
};
|
||||
|
||||
virtual void multimesh_allocate(RID p_multimesh, int p_instances, MultimeshTransformFormat p_transform_format, MultimeshColorFormat p_color_format, MultimeshCustomDataFormat p_data_format = MULTIMESH_CUSTOM_DATA_NONE) = 0;
|
||||
|
|
Loading…
Reference in a new issue