Merge branch 'master' into blender2.8

This commit is contained in:
Brecht Van Lommel
2018-03-03 14:58:14 +01:00
5 changed files with 32 additions and 18 deletions

View File

@@ -204,7 +204,7 @@ static void xml_read_camera(XMLReadState& state, xml_node node)
cam->matrix = state.tfm; cam->matrix = state.tfm;
cam->need_update = true; cam->need_update = true;
cam->update(); cam->update(state.scene);
} }
/* Shader */ /* Shader */
@@ -515,7 +515,7 @@ static void xml_read_mesh(const XMLReadState& state, xml_node node)
xml_read_float(&sdparams.dicing_rate, node, "dicing_rate"); xml_read_float(&sdparams.dicing_rate, node, "dicing_rate");
sdparams.dicing_rate = std::max(0.1f, sdparams.dicing_rate); sdparams.dicing_rate = std::max(0.1f, sdparams.dicing_rate);
state.scene->camera->update(); state.scene->camera->update(state.scene);
sdparams.camera = state.scene->camera; sdparams.camera = state.scene->camera;
sdparams.objecttoworld = state.tfm; sdparams.objecttoworld = state.tfm;
} }

View File

@@ -30,7 +30,7 @@ if(NOT CYCLES_STANDALONE_REPOSITORY)
set(GLEW_INCLUDE_DIR "${GLEW_INCLUDE_PATH}") set(GLEW_INCLUDE_DIR "${GLEW_INCLUDE_PATH}")
endif() endif()
if(WITH_CYCLES_STANDALONE AND WITH_CYCLES_STANDALONE_GUI) if(WITH_CYCLES_STANDALONE)
set(CYCLES_APP_GLEW_LIBRARY ${BLENDER_GLEW_LIBRARIES}) set(CYCLES_APP_GLEW_LIBRARY ${BLENDER_GLEW_LIBRARIES})
endif() endif()

View File

@@ -561,8 +561,9 @@ void Mesh::clear(bool preserve_voxel_data)
subd_attributes.clear(); subd_attributes.clear();
attributes.clear(preserve_voxel_data); attributes.clear(preserve_voxel_data);
if(!preserve_voxel_data) {
used_shaders.clear(); used_shaders.clear();
if(!preserve_voxel_data) {
geometry_flags = GEOMETRY_NONE; geometry_flags = GEOMETRY_NONE;
} }

View File

@@ -393,9 +393,6 @@ void VolumeMeshBuilder::convert_quads_to_tris(const vector<QuadData> &quads,
/* ************************************************************************** */ /* ************************************************************************** */
/* For debugging: render the created mesh using the default diffuse shader. */
//#define RENDER_DIFFUSE
struct VoxelAttributeGrid { struct VoxelAttributeGrid {
float *data; float *data;
int channels; int channels;
@@ -443,6 +440,8 @@ void MeshManager::create_volume_mesh(Scene *scene,
return; return;
} }
/* Compute padding. */
Shader *volume_shader = NULL;
int pad_size = 0; int pad_size = 0;
foreach(Shader *shader, mesh->used_shaders) { foreach(Shader *shader, mesh->used_shaders) {
@@ -450,12 +449,20 @@ void MeshManager::create_volume_mesh(Scene *scene,
continue; continue;
} }
volume_shader = shader;
if(shader->volume_interpolation_method == VOLUME_INTERPOLATION_LINEAR) { if(shader->volume_interpolation_method == VOLUME_INTERPOLATION_LINEAR) {
pad_size = max(1, pad_size); pad_size = max(1, pad_size);
} }
else if(shader->volume_interpolation_method == VOLUME_INTERPOLATION_CUBIC) { else if(shader->volume_interpolation_method == VOLUME_INTERPOLATION_CUBIC) {
pad_size = max(2, pad_size); pad_size = max(2, pad_size);
} }
break;
}
if(!volume_shader) {
return;
} }
/* Compute start point and cell size from transform. */ /* Compute start point and cell size from transform. */
@@ -477,6 +484,7 @@ void MeshManager::create_volume_mesh(Scene *scene,
volume_params.cell_size = cell_size; volume_params.cell_size = cell_size;
volume_params.pad_size = pad_size; volume_params.pad_size = pad_size;
/* Build bounding mesh around non-empty volume cells. */
VolumeMeshBuilder builder(&volume_params); VolumeMeshBuilder builder(&volume_params);
const float isovalue = mesh->volume_isovalue; const float isovalue = mesh->volume_isovalue;
@@ -540,26 +548,22 @@ void MeshManager::create_volume_mesh(Scene *scene,
} }
} }
/* Create mesh. */
vector<float3> vertices; vector<float3> vertices;
vector<int> indices; vector<int> indices;
vector<float3> face_normals; vector<float3> face_normals;
builder.create_mesh(vertices, indices, face_normals); builder.create_mesh(vertices, indices, face_normals);
#ifdef RENDER_DIFFUSE
int shader = mesh->used_shaders[0]->id;
#else
int shader = mesh->shader[0];
#endif
mesh->clear(true); mesh->clear(true);
mesh->reserve_mesh(vertices.size(), indices.size()/3); mesh->reserve_mesh(vertices.size(), indices.size()/3);
mesh->used_shaders.push_back(volume_shader);
for(size_t i = 0; i < vertices.size(); ++i) { for(size_t i = 0; i < vertices.size(); ++i) {
mesh->add_vertex(vertices[i]); mesh->add_vertex(vertices[i]);
} }
for(size_t i = 0; i < indices.size(); i += 3) { for(size_t i = 0; i < indices.size(); i += 3) {
mesh->add_triangle(indices[i], indices[i + 1], indices[i + 2], shader, false); mesh->add_triangle(indices[i], indices[i + 1], indices[i + 2], 0, false);
} }
Attribute *attr_fN = mesh->attributes.add(ATTR_STD_FACE_NORMAL); Attribute *attr_fN = mesh->attributes.add(ATTR_STD_FACE_NORMAL);
@@ -569,6 +573,7 @@ void MeshManager::create_volume_mesh(Scene *scene,
fN[i] = face_normals[i]; fN[i] = face_normals[i];
} }
/* Print stats. */
VLOG(1) << "Memory usage volume mesh: " VLOG(1) << "Memory usage volume mesh: "
<< ((vertices.size() + face_normals.size())*sizeof(float3) + indices.size()*sizeof(int))/(1024.0*1024.0) << ((vertices.size() + face_normals.size())*sizeof(float3) + indices.size()*sizeof(int))/(1024.0*1024.0)
<< "Mb."; << "Mb.";

View File

@@ -3489,19 +3489,27 @@ void DM_draw_attrib_vertex_uniforms(const DMVertexAttribs *attribs)
{ {
int i; int i;
if (attribs->totorco) { if (attribs->totorco) {
if (attribs->orco.gl_info_index != -1) {
glUniform1i(attribs->orco.gl_info_index, 0); glUniform1i(attribs->orco.gl_info_index, 0);
} }
}
for (i = 0; i < attribs->tottface; i++) { for (i = 0; i < attribs->tottface; i++) {
if (attribs->tface[i].gl_info_index != -1) {
glUniform1i(attribs->tface[i].gl_info_index, 0); glUniform1i(attribs->tface[i].gl_info_index, 0);
} }
}
for (i = 0; i < attribs->totmcol; i++) { for (i = 0; i < attribs->totmcol; i++) {
if (attribs->mcol[i].gl_info_index != -1) {
glUniform1i(attribs->mcol[i].gl_info_index, GPU_ATTR_INFO_SRGB); glUniform1i(attribs->mcol[i].gl_info_index, GPU_ATTR_INFO_SRGB);
} }
}
for (i = 0; i < attribs->tottang; i++) { for (i = 0; i < attribs->tottang; i++) {
if (attribs->tang[i].gl_info_index != -1) {
glUniform1i(attribs->tang[i].gl_info_index, 0); glUniform1i(attribs->tang[i].gl_info_index, 0);
} }
} }
}
/* Set object's bounding box based on DerivedMesh min/max data */ /* Set object's bounding box based on DerivedMesh min/max data */
void DM_set_object_boundbox(Object *ob, DerivedMesh *dm) void DM_set_object_boundbox(Object *ob, DerivedMesh *dm)