Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/gpu/intern/gpu_draw.c')
-rw-r--r--source/blender/gpu/intern/gpu_draw.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index 49faaef23e1..c8d5d92b66b 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -56,6 +56,7 @@
#include "DNA_scene_types.h"
#include "DNA_smoke_types.h"
#include "DNA_view3d_types.h"
+#include "DNA_particle_types.h"
#include "MEM_guardedalloc.h"
@@ -1871,6 +1872,35 @@ void GPU_begin_object_materials(
GPU_object_material_unbind();
}
+static int GPU_get_particle_info(GPUParticleInfo *pi)
+{
+ DupliObject *dob = GMS.dob;
+ if (dob->particle_system) {
+ int ind;
+ if (dob->persistent_id[0] < dob->particle_system->totpart)
+ ind = dob->persistent_id[0];
+ else {
+ ind = dob->particle_system->child[dob->persistent_id[0] - dob->particle_system->totpart].parent;
+ }
+ if (ind >= 0) {
+ ParticleData *p = &dob->particle_system->particles[ind];
+
+ pi->scalprops[0] = ind;
+ pi->scalprops[1] = GMS.gscene->r.cfra - p->time;
+ pi->scalprops[2] = p->lifetime;
+ pi->scalprops[3] = p->size;
+
+ copy_v3_v3(pi->location, p->state.co);
+ copy_v3_v3(pi->velocity, p->state.vel);
+ copy_v3_v3(pi->angular_velocity, p->state.ave);
+ return 1;
+ }
+ else return 0;
+ }
+ else
+ return 0;
+}
+
int GPU_object_material_bind(int nr, void *attribs)
{
GPUVertexAttribs *gattribs = attribs;
@@ -1929,18 +1959,22 @@ int GPU_object_material_bind(int nr, void *attribs)
if (gattribs && GMS.gmatbuf[nr]) {
/* bind glsl material and get attributes */
Material *mat = GMS.gmatbuf[nr];
+ GPUParticleInfo partile_info;
float auto_bump_scale;
GPUMaterial *gpumat = GPU_material_from_blender(GMS.gscene, mat, GMS.is_opensubdiv);
GPU_material_vertex_attributes(gpumat, gattribs);
+ if (GMS.dob)
+ GPU_get_particle_info(&partile_info);
+
GPU_material_bind(
gpumat, GMS.gob->lay, GMS.glay, 1.0, !(GMS.gob->mode & OB_MODE_TEXTURE_PAINT),
GMS.gviewmat, GMS.gviewinv, GMS.gviewcamtexcofac, GMS.gscenelock);
auto_bump_scale = GMS.gob->derivedFinal != NULL ? GMS.gob->derivedFinal->auto_bump_scale : 1.0f;
- GPU_material_bind_uniforms(gpumat, GMS.gob->obmat, GMS.gviewmat, GMS.gob->col, auto_bump_scale);
+ GPU_material_bind_uniforms(gpumat, GMS.gob->obmat, GMS.gviewmat, GMS.gob->col, auto_bump_scale, &partile_info);
GMS.gboundmat = mat;
/* for glsl use alpha blend mode, unless it's set to solid and