Removed particle operators API and point cache operators.

This commit is contained in:
Lukas Tönne
2016-04-12 11:47:08 +02:00
parent 5a783144e2
commit 82ec9c87a7
19 changed files with 22 additions and 2007 deletions

View File

@@ -1,74 +0,0 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2007 by Janne Karhu.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file ED_particle.h
* \ingroup editors
*/
#ifndef __ED_PARTICLE_H__
#define __ED_PARTICLE_H__
struct bContext;
struct Object;
struct ParticleEditSettings;
struct rcti;
struct PTCacheEdit;
struct Scene;
/* particle edit mode */
void PE_free_ptcache_edit(struct PTCacheEdit *edit);
int PE_start_edit(struct PTCacheEdit *edit);
/* access */
struct PTCacheEdit *PE_get_current(struct Scene *scene, struct Object *ob);
struct PTCacheEdit *PE_create_current(struct Scene *scene, struct Object *ob);
void PE_current_changed(struct Scene *scene, struct Object *ob);
int PE_minmax(struct Scene *scene, float min[3], float max[3]);
struct ParticleEditSettings *PE_settings(struct Scene *scene);
/* update calls */
void PE_hide_keys_time(struct Scene *scene, struct PTCacheEdit *edit, float cfra);
void PE_update_object(struct Scene *scene, struct Object *ob, int useflag);
/* selection tools */
int PE_mouse_particles(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle);
int PE_border_select(struct bContext *C, struct rcti *rect, bool select, bool extend);
int PE_circle_select(struct bContext *C, int selecting, const int mval[2], float rad);
int PE_lasso_select(struct bContext *C, const int mcords[][2], const short moves, bool extend, bool select);
void PE_deselect_all_visible(struct PTCacheEdit *edit);
/* undo */
void PE_undo_push(struct Scene *scene, const char *str);
void PE_undo_step(struct Scene *scene, int step);
void PE_undo(struct Scene *scene);
void PE_redo(struct Scene *scene);
bool PE_undo_is_valid(struct Scene *scene);
void PE_undo_number(struct Scene *scene, int nr);
const char *PE_undo_get_name(struct Scene *scene, int nr, bool *r_active);
#endif /* __ED_PARTICLE_H__ */

View File

@@ -39,11 +39,6 @@ struct wmKeyConfig;
struct Scene;
struct Object;
/* particle_edit.c */
int PE_poll(struct bContext *C);
int PE_hair_poll(struct bContext *C);
int PE_poll_view3d(struct bContext *C);
/* rigidbody_object.c */
bool ED_rigidbody_object_add(struct Scene *scene, struct Object *ob, int type, struct ReportList *reports);
void ED_rigidbody_object_remove(struct Scene *scene, struct Object *ob);

View File

@@ -40,7 +40,6 @@ set(SRC
dynamicpaint_ops.c
physics_fluid.c
physics_ops.c
physics_pointcache.c
rigidbody_constraint.c
rigidbody_object.c
rigidbody_world.c

View File

@@ -45,15 +45,6 @@ void DPAINT_OT_surface_slot_remove(struct wmOperatorType *ot);
void DPAINT_OT_type_toggle(struct wmOperatorType *ot);
void DPAINT_OT_output_toggle(struct wmOperatorType *ot);
/* physics_pointcache.c */
void PTCACHE_OT_bake_all(struct wmOperatorType *ot);
void PTCACHE_OT_free_bake_all(struct wmOperatorType *ot);
void PTCACHE_OT_bake(struct wmOperatorType *ot);
void PTCACHE_OT_free_bake(struct wmOperatorType *ot);
void PTCACHE_OT_bake_from_cache(struct wmOperatorType *ot);
void PTCACHE_OT_add(struct wmOperatorType *ot);
void PTCACHE_OT_remove(struct wmOperatorType *ot);
/* rigidbody_object.c */
void RIGIDBODY_OT_object_add(struct wmOperatorType *ot);
void RIGIDBODY_OT_object_remove(struct wmOperatorType *ot);

View File

@@ -68,19 +68,6 @@ static void operatortypes_fluid(void)
WM_operatortype_append(FLUID_OT_bake);
}
/**************************** point cache **********************************/
static void operatortypes_pointcache(void)
{
WM_operatortype_append(PTCACHE_OT_bake_all);
WM_operatortype_append(PTCACHE_OT_free_bake_all);
WM_operatortype_append(PTCACHE_OT_bake);
WM_operatortype_append(PTCACHE_OT_free_bake);
WM_operatortype_append(PTCACHE_OT_bake_from_cache);
WM_operatortype_append(PTCACHE_OT_add);
WM_operatortype_append(PTCACHE_OT_remove);
}
/********************************* dynamic paint ***********************************/
static void operatortypes_dynamicpaint(void)
@@ -92,29 +79,17 @@ static void operatortypes_dynamicpaint(void)
WM_operatortype_append(DPAINT_OT_output_toggle);
}
//static void keymap_pointcache(wmWindowManager *wm)
//{
// wmKeyMap *keymap = WM_keymap_find(wm, "Pointcache", 0, 0);
//
// WM_keymap_add_item(keymap, "PHYSICS_OT_bake_all", AKEY, KM_PRESS, 0, 0);
// WM_keymap_add_item(keymap, "PHYSICS_OT_free_all", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
// WM_keymap_add_item(keymap, "PHYSICS_OT_bake_particle_system", PADMINUS, KM_PRESS, KM_CTRL, 0);
// WM_keymap_add_item(keymap, "PHYSICS_OT_free_particle_system", LKEY, KM_PRESS, 0, 0);
//}
/****************************** general ************************************/
void ED_operatortypes_physics(void)
{
operatortypes_rigidbody();
operatortypes_fluid();
operatortypes_pointcache();
operatortypes_dynamicpaint();
}
void ED_keymap_physics(wmKeyConfig *UNUSED(keyconf))
{
//keymap_pointcache(keyconf);
}

View File

@@ -1,469 +0,0 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2007 by Janne Karhu.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file blender/editors/physics/physics_pointcache.c
* \ingroup edphys
*/
#include <stdlib.h>
#include <string.h>
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
#include "DNA_scene_types.h"
#include "BKE_context.h"
#include "BKE_screen.h"
#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_particle.h"
#include "BKE_pointcache.h"
#include "ED_particle.h"
#include "WM_api.h"
#include "WM_types.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "physics_intern.h"
static int ptcache_bake_all_poll(bContext *C)
{
return CTX_data_scene(C) != NULL;
}
static int ptcache_poll(bContext *C)
{
PointerRNA ptr= CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache);
return (ptr.data && ptr.id.data);
}
typedef struct PointCacheJob {
void *owner;
short *stop, *do_update;
float *progress;
PTCacheBaker *baker;
} PointCacheJob;
static void ptcache_job_free(void *customdata)
{
PointCacheJob *job = customdata;
MEM_freeN(job->baker);
MEM_freeN(job);
}
static int ptcache_job_break(void *customdata)
{
PointCacheJob *job = customdata;
if (G.is_break) {
return 1;
}
if (job->stop && *(job->stop)) {
return 1;
}
return 0;
}
static void ptcache_job_update(void *customdata, float progress, int *cancel)
{
PointCacheJob *job = customdata;
if (ptcache_job_break(job)) {
*cancel = 1;
}
*(job->do_update) = true;
*(job->progress) = progress;
}
static void ptcache_job_startjob(void *customdata, short *stop, short *do_update, float *progress)
{
PointCacheJob *job = customdata;
job->stop = stop;
job->do_update = do_update;
job->progress = progress;
G.is_break = false;
/* XXX annoying hack: needed to prevent data corruption when changing
* scene frame in separate threads
*/
G.is_rendering = true;
BKE_spacedata_draw_locks(true);
BKE_ptcache_bake(job->baker);
*do_update = true;
*stop = 0;
}
static void ptcache_job_endjob(void *customdata)
{
PointCacheJob *job = customdata;
Scene *scene = job->baker->scene;
G.is_rendering = false;
BKE_spacedata_draw_locks(false);
WM_set_locked_interface(G.main->wm.first, false);
WM_main_add_notifier(NC_SCENE | ND_FRAME, scene);
WM_main_add_notifier(NC_OBJECT | ND_POINTCACHE, job->baker->pid.ob);
}
static void ptcache_free_bake(PointCache *cache)
{
if (cache->edit) {
if (!cache->edit->edited || 1) {// XXX okee("Lose changes done in particle mode?")) {
PE_free_ptcache_edit(cache->edit);
cache->edit = NULL;
cache->flag &= ~PTCACHE_BAKED;
}
}
else {
cache->flag &= ~PTCACHE_BAKED;
}
}
static PTCacheBaker *ptcache_baker_create(bContext *C, wmOperator *op, bool all)
{
PTCacheBaker *baker = MEM_callocN(sizeof(PTCacheBaker), "PTCacheBaker");
baker->main = CTX_data_main(C);
baker->scene = CTX_data_scene(C);
baker->bake = RNA_boolean_get(op->ptr, "bake");
baker->render = 0;
baker->anim_init = 0;
baker->quick_step = 1;
if (!all) {
PointerRNA ptr = CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache);
Object *ob = ptr.id.data;
PointCache *cache = ptr.data;
ListBase pidlist;
BKE_ptcache_ids_from_object(&pidlist, ob, baker->scene, MAX_DUPLI_RECUR);
for (PTCacheID *pid = pidlist.first; pid; pid = pid->next) {
if (pid->cache == cache) {
baker->pid = *pid;
break;
}
}
BLI_freelistN(&pidlist);
}
return baker;
}
static int ptcache_bake_exec(bContext *C, wmOperator *op)
{
bool all = STREQ(op->type->idname, "PTCACHE_OT_bake_all");
PTCacheBaker *baker = ptcache_baker_create(C, op, all);
BKE_ptcache_bake(baker);
MEM_freeN(baker);
return OPERATOR_FINISHED;
}
static int ptcache_bake_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
bool all = STREQ(op->type->idname, "PTCACHE_OT_bake_all");
PointCacheJob *job = MEM_mallocN(sizeof(PointCacheJob), "PointCacheJob");
job->baker = ptcache_baker_create(C, op, all);
job->baker->bake_job = job;
job->baker->update_progress = ptcache_job_update;
wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), CTX_data_scene(C),
"Point Cache", WM_JOB_PROGRESS, WM_JOB_TYPE_POINTCACHE);
WM_jobs_customdata_set(wm_job, job, ptcache_job_free);
WM_jobs_timer(wm_job, 0.1, NC_OBJECT | ND_POINTCACHE, NC_OBJECT | ND_POINTCACHE);
WM_jobs_callbacks(wm_job, ptcache_job_startjob, NULL, NULL, ptcache_job_endjob);
WM_set_locked_interface(CTX_wm_manager(C), true);
WM_jobs_start(CTX_wm_manager(C), wm_job);
WM_event_add_modal_handler(C, op);
/* we must run modal until the bake job is done, otherwise the undo push
* happens before the job ends, which can lead to race conditions between
* the baking and file writing code */
return OPERATOR_RUNNING_MODAL;
}
static int ptcache_bake_modal(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
Scene *scene = (Scene *) op->customdata;
/* no running blender, remove handler and pass through */
if (0 == WM_jobs_test(CTX_wm_manager(C), scene, WM_JOB_TYPE_POINTCACHE)) {
return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
}
return OPERATOR_PASS_THROUGH;
}
static void ptcache_bake_cancel(bContext *C, wmOperator *op)
{
wmWindowManager *wm = CTX_wm_manager(C);
Scene *scene = (Scene *) op->customdata;
/* kill on cancel, because job is using op->reports */
WM_jobs_kill_type(wm, scene, WM_JOB_TYPE_POINTCACHE);
}
static int ptcache_free_bake_all_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene= CTX_data_scene(C);
Base *base;
PTCacheID *pid;
ListBase pidlist;
for (base=scene->base.first; base; base= base->next) {
BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR);
for (pid=pidlist.first; pid; pid=pid->next) {
ptcache_free_bake(pid->cache);
}
BLI_freelistN(&pidlist);
WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, base->object);
}
WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
return OPERATOR_FINISHED;
}
void PTCACHE_OT_bake_all(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Bake All Physics";
ot->description = "Bake all physics";
ot->idname = "PTCACHE_OT_bake_all";
/* api callbacks */
ot->exec = ptcache_bake_exec;
ot->invoke = ptcache_bake_invoke;
ot->modal = ptcache_bake_modal;
ot->cancel = ptcache_bake_cancel;
ot->poll = ptcache_bake_all_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
RNA_def_boolean(ot->srna, "bake", 1, "Bake", "");
}
void PTCACHE_OT_free_bake_all(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Free All Physics Bakes";
ot->idname = "PTCACHE_OT_free_bake_all";
ot->description = "Free all baked caches of all objects in the current scene";
/* api callbacks */
ot->exec = ptcache_free_bake_all_exec;
ot->poll = ptcache_bake_all_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
static int ptcache_free_bake_exec(bContext *C, wmOperator *UNUSED(op))
{
PointerRNA ptr= CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache);
PointCache *cache= ptr.data;
Object *ob= ptr.id.data;
ptcache_free_bake(cache);
WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob);
return OPERATOR_FINISHED;
}
static int ptcache_bake_from_cache_exec(bContext *C, wmOperator *UNUSED(op))
{
PointerRNA ptr= CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache);
PointCache *cache= ptr.data;
Object *ob= ptr.id.data;
cache->flag |= PTCACHE_BAKED;
WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob);
return OPERATOR_FINISHED;
}
void PTCACHE_OT_bake(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Bake Physics";
ot->description = "Bake physics";
ot->idname = "PTCACHE_OT_bake";
/* api callbacks */
ot->exec = ptcache_bake_exec;
ot->invoke = ptcache_bake_invoke;
ot->modal = ptcache_bake_modal;
ot->cancel = ptcache_bake_cancel;
ot->poll = ptcache_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
RNA_def_boolean(ot->srna, "bake", 0, "Bake", "");
}
void PTCACHE_OT_free_bake(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Free Physics Bake";
ot->description = "Free physics bake";
ot->idname = "PTCACHE_OT_free_bake";
/* api callbacks */
ot->exec = ptcache_free_bake_exec;
ot->poll = ptcache_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
void PTCACHE_OT_bake_from_cache(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Bake From Cache";
ot->description = "Bake from cache";
ot->idname = "PTCACHE_OT_bake_from_cache";
/* api callbacks */
ot->exec = ptcache_bake_from_cache_exec;
ot->poll = ptcache_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
static int ptcache_add_new_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
PointerRNA ptr= CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache);
Object *ob= ptr.id.data;
PointCache *cache= ptr.data;
PTCacheID *pid;
ListBase pidlist;
BKE_ptcache_ids_from_object(&pidlist, ob, scene, MAX_DUPLI_RECUR);
for (pid=pidlist.first; pid; pid=pid->next) {
if (pid->cache == cache) {
PointCache *cache_new = BKE_ptcache_add(pid->ptcaches);
cache_new->step = pid->default_step;
*(pid->cache_ptr) = cache_new;
break;
}
}
BLI_freelistN(&pidlist);
WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob);
return OPERATOR_FINISHED;
}
static int ptcache_remove_exec(bContext *C, wmOperator *UNUSED(op))
{
PointerRNA ptr= CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache);
Scene *scene= CTX_data_scene(C);
Object *ob= ptr.id.data;
PointCache *cache= ptr.data;
PTCacheID *pid;
ListBase pidlist;
BKE_ptcache_ids_from_object(&pidlist, ob, scene, MAX_DUPLI_RECUR);
for (pid=pidlist.first; pid; pid=pid->next) {
if (pid->cache == cache) {
if (pid->ptcaches->first == pid->ptcaches->last)
continue; /* don't delete last cache */
BLI_remlink(pid->ptcaches, pid->cache);
BKE_ptcache_free(pid->cache);
*(pid->cache_ptr) = pid->ptcaches->first;
break;
}
}
BLI_freelistN(&pidlist);
WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob);
return OPERATOR_FINISHED;
}
void PTCACHE_OT_add(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Add New Cache";
ot->description = "Add new cache";
ot->idname = "PTCACHE_OT_add";
/* api callbacks */
ot->exec = ptcache_add_new_exec;
ot->poll = ptcache_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
void PTCACHE_OT_remove(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Delete Current Cache";
ot->description = "Delete current cache";
ot->idname = "PTCACHE_OT_remove";
/* api callbacks */
ot->exec = ptcache_remove_exec;
ot->poll = ptcache_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}

View File

@@ -963,38 +963,6 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
set_pointer_type(path, result, &RNA_PoseBone);
return 1;
}
else if (CTX_data_equals(member, "particle_system")) {
set_pointer_type(path, result, &RNA_ParticleSystem);
return 1;
}
else if (CTX_data_equals(member, "particle_system_editable")) {
if (PE_poll((bContext *)C))
set_pointer_type(path, result, &RNA_ParticleSystem);
else
CTX_data_pointer_set(result, NULL, &RNA_ParticleSystem, NULL);
return 1;
}
else if (CTX_data_equals(member, "particle_settings")) {
/* only available when pinned */
PointerRNA *ptr = get_pointer_type(path, &RNA_ParticleSettings);
if (ptr && ptr->data) {
CTX_data_pointer_set(result, ptr->id.data, &RNA_ParticleSettings, ptr->data);
return 1;
}
else {
/* get settings from active particle system instead */
ptr = get_pointer_type(path, &RNA_ParticleSystem);
if (ptr && ptr->data) {
ParticleSettings *part = ((ParticleSystem *)ptr->data)->part;
CTX_data_pointer_set(result, ptr->id.data, &RNA_ParticleSettings, part);
return 1;
}
}
set_pointer_type(path, result, &RNA_ParticleSettings);
return 1;
}
else if (CTX_data_equals(member, "cloth")) {
PointerRNA *ptr = get_pointer_type(path, &RNA_Object);

View File

@@ -92,7 +92,6 @@
#include "GPU_shader.h"
#include "ED_mesh.h"
#include "ED_particle.h"
#include "ED_screen.h"
#include "ED_sculpt.h"
#include "ED_types.h"
@@ -4769,215 +4768,6 @@ static bool drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *ba
}
/* *********** drawing for particles ************* */
static void draw_particle_arrays(int draw_as, int totpoint, int ob_dt, int select)
{
/* draw created data arrays */
switch (draw_as) {
case PART_DRAW_AXIS:
case PART_DRAW_CROSS:
glDrawArrays(GL_LINES, 0, 6 * totpoint);
break;
case PART_DRAW_LINE:
glDrawArrays(GL_LINES, 0, 2 * totpoint);
break;
case PART_DRAW_BB:
if (ob_dt <= OB_WIRE || select)
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
else
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glDrawArrays(GL_QUADS, 0, 4 * totpoint);
break;
default:
glDrawArrays(GL_POINTS, 0, totpoint);
break;
}
}
static void draw_particle(ParticleKey *state, int draw_as, short draw, float pixsize,
float imat[4][4], const float draw_line[2], ParticleBillboardData *bb, ParticleDrawData *pdd)
{
float vec[3], vec2[3];
float *vd = NULL;
float *cd = NULL;
float ma_col[3] = {0.0f, 0.0f, 0.0f};
/* null only for PART_DRAW_CIRC */
if (pdd) {
vd = pdd->vd;
cd = pdd->cd;
if (pdd->ma_col) {
copy_v3_v3(ma_col, pdd->ma_col);
}
}
switch (draw_as) {
case PART_DRAW_DOT:
{
if (vd) {
copy_v3_v3(vd, state->co); pdd->vd += 3;
}
if (cd) {
copy_v3_v3(cd, pdd->ma_col);
pdd->cd += 3;
}
break;
}
case PART_DRAW_CROSS:
case PART_DRAW_AXIS:
{
vec[0] = 2.0f * pixsize;
vec[1] = vec[2] = 0.0;
mul_qt_v3(state->rot, vec);
if (draw_as == PART_DRAW_AXIS) {
if (cd) {
cd[1] = cd[2] = cd[4] = cd[5] = 0.0;
cd[0] = cd[3] = 1.0;
cd[6] = cd[8] = cd[9] = cd[11] = 0.0;
cd[7] = cd[10] = 1.0;
cd[13] = cd[12] = cd[15] = cd[16] = 0.0;
cd[14] = cd[17] = 1.0;
pdd->cd += 18;
}
copy_v3_v3(vec2, state->co);
}
else {
if (cd) {
cd[0] = cd[3] = cd[6] = cd[9] = cd[12] = cd[15] = ma_col[0];
cd[1] = cd[4] = cd[7] = cd[10] = cd[13] = cd[16] = ma_col[1];
cd[2] = cd[5] = cd[8] = cd[11] = cd[14] = cd[17] = ma_col[2];
pdd->cd += 18;
}
sub_v3_v3v3(vec2, state->co, vec);
}
add_v3_v3(vec, state->co);
copy_v3_v3(pdd->vd, vec); pdd->vd += 3;
copy_v3_v3(pdd->vd, vec2); pdd->vd += 3;
vec[1] = 2.0f * pixsize;
vec[0] = vec[2] = 0.0;
mul_qt_v3(state->rot, vec);
if (draw_as == PART_DRAW_AXIS) {
copy_v3_v3(vec2, state->co);
}
else {
sub_v3_v3v3(vec2, state->co, vec);
}
add_v3_v3(vec, state->co);
copy_v3_v3(pdd->vd, vec); pdd->vd += 3;
copy_v3_v3(pdd->vd, vec2); pdd->vd += 3;
vec[2] = 2.0f * pixsize;
vec[0] = vec[1] = 0.0f;
mul_qt_v3(state->rot, vec);
if (draw_as == PART_DRAW_AXIS) {
copy_v3_v3(vec2, state->co);
}
else {
sub_v3_v3v3(vec2, state->co, vec);
}
add_v3_v3(vec, state->co);
copy_v3_v3(pdd->vd, vec); pdd->vd += 3;
copy_v3_v3(pdd->vd, vec2); pdd->vd += 3;
break;
}
case PART_DRAW_LINE:
{
copy_v3_v3(vec, state->vel);
normalize_v3(vec);
if (draw & PART_DRAW_VEL_LENGTH)
mul_v3_fl(vec, len_v3(state->vel));
madd_v3_v3v3fl(pdd->vd, state->co, vec, -draw_line[0]); pdd->vd += 3;
madd_v3_v3v3fl(pdd->vd, state->co, vec, draw_line[1]); pdd->vd += 3;
if (cd) {
cd[0] = cd[3] = ma_col[0];
cd[1] = cd[4] = ma_col[1];
cd[2] = cd[5] = ma_col[2];
pdd->cd += 6;
}
break;
}
case PART_DRAW_CIRC:
{
drawcircball(GL_LINE_LOOP, state->co, pixsize, imat);
break;
}
case PART_DRAW_BB:
{
float xvec[3], yvec[3], zvec[3], bb_center[3];
if (cd) {
cd[0] = cd[3] = cd[6] = cd[9] = ma_col[0];
cd[1] = cd[4] = cd[7] = cd[10] = ma_col[1];
cd[2] = cd[5] = cd[8] = cd[11] = ma_col[2];
pdd->cd += 12;
}
copy_v3_v3(bb->vec, state->co);
copy_v3_v3(bb->vel, state->vel);
psys_make_billboard(bb, xvec, yvec, zvec, bb_center);
add_v3_v3v3(pdd->vd, bb_center, xvec);
add_v3_v3(pdd->vd, yvec); pdd->vd += 3;
sub_v3_v3v3(pdd->vd, bb_center, xvec);
add_v3_v3(pdd->vd, yvec); pdd->vd += 3;
sub_v3_v3v3(pdd->vd, bb_center, xvec);
sub_v3_v3v3(pdd->vd, pdd->vd, yvec); pdd->vd += 3;
add_v3_v3v3(pdd->vd, bb_center, xvec);
sub_v3_v3v3(pdd->vd, pdd->vd, yvec); pdd->vd += 3;
copy_v3_v3(pdd->nd, zvec); pdd->nd += 3;
copy_v3_v3(pdd->nd, zvec); pdd->nd += 3;
copy_v3_v3(pdd->nd, zvec); pdd->nd += 3;
copy_v3_v3(pdd->nd, zvec); pdd->nd += 3;
break;
}
}
}
static void draw_particle_data(ParticleSystem *psys, RegionView3D *rv3d,
ParticleKey *state, int draw_as,
float imat[4][4], ParticleBillboardData *bb, ParticleDrawData *pdd,
const float ct, const float pa_size, const float r_tilt, const float pixsize_scale)
{
ParticleSettings *part = psys->part;
float pixsize;
if (psys->parent)
mul_m4_v3(psys->parent->obmat, state->co);
/* create actual particle data */
if (draw_as == PART_DRAW_BB) {
bb->offset[0] = part->bb_offset[0];
bb->offset[1] = part->bb_offset[1];
bb->size[0] = part->bb_size[0] * pa_size;
if (part->bb_align == PART_BB_VEL) {
float pa_vel = len_v3(state->vel);
float head = part->bb_vel_head * pa_vel;
float tail = part->bb_vel_tail * pa_vel;
bb->size[1] = part->bb_size[1] * pa_size + head + tail;
/* use offset to adjust the particle center. this is relative to size, so need to divide! */
if (bb->size[1] > 0.0f)
bb->offset[1] += (head - tail) / bb->size[1];
}
else {
bb->size[1] = part->bb_size[1] * pa_size;
}
bb->tilt = part->bb_tilt * (1.0f - part->bb_rand_tilt * r_tilt);
bb->time = ct;
}
pixsize = ED_view3d_pixel_size(rv3d, state->co) * pixsize_scale;
draw_particle(state, draw_as, part->draw, pixsize, imat, part->draw_line, bb, pdd);
}
/* unified drawing of all new particle systems draw types except dupli ob & group
* mostly tries to use vertex arrays for speed
*
@@ -4993,891 +4783,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
Base *base, ParticleSystem *psys,
const char ob_dt, const short dflag)
{
Object *ob = base->object;
ParticleEditSettings *pset = PE_settings(scene);
ParticleSettings *part = psys->part;
ParticleData *pars = psys->particles;
ParticleData *pa;
ParticleKey state, *states = NULL;
ParticleBillboardData bb;
ParticleSimulationData sim = {NULL};
ParticleDrawData *pdd = psys->pdd;
Material *ma;
float vel[3], imat[4][4];
float timestep, pixsize_scale = 1.0f, pa_size, r_tilt, r_length;
float pa_time, pa_birthtime, pa_dietime, pa_health, intensity;
float cfra;
float ma_col[3] = {0.0f, 0.0f, 0.0f};
int a, totpart, totpoint = 0, totve = 0, drawn, draw_as, totchild = 0;
bool select = (ob->flag & SELECT) != 0, create_cdata = false, need_v = false;
GLint polygonmode[2];
char numstr[32];
unsigned char tcol[4] = {0, 0, 0, 255};
/* 1. */
if (part == NULL || !psys_check_enabled(ob, psys))
return;
if (pars == NULL) return;
/* don't draw normal paths in edit mode */
if (psys_in_edit_mode(scene, psys) && (pset->flag & PE_DRAW_PART) == 0)
return;
if (part->draw_as == PART_DRAW_REND)
draw_as = part->ren_as;
else
draw_as = part->draw_as;
if (draw_as == PART_DRAW_NOT)
return;
/* prepare curvemapping tables */
if ((psys->part->child_flag & PART_CHILD_USE_CLUMP_CURVE) && psys->part->clumpcurve)
curvemapping_changed_all(psys->part->clumpcurve);
if ((psys->part->child_flag & PART_CHILD_USE_ROUGH_CURVE) && psys->part->roughcurve)
curvemapping_changed_all(psys->part->roughcurve);
/* 2. */
sim.scene = scene;
sim.ob = ob;
sim.psys = psys;
sim.psmd = psys_get_modifier(ob, psys);
if (part->phystype == PART_PHYS_KEYED) {
if (psys->flag & PSYS_KEYED) {
psys_count_keyed_targets(&sim);
if (psys->totkeyed == 0)
return;
}
}
if (select) {
select = false;
if (psys_get_current(ob) == psys)
select = true;
}
psys->flag |= PSYS_DRAWING;
if (part->type == PART_HAIR && !psys->childcache)
totchild = 0;
else
totchild = psys->totchild * part->disp / 100;
ma = give_current_material(ob, part->omat);
if (v3d->zbuf) glDepthMask(1);
if ((ma) && (part->draw_col == PART_DRAW_COL_MAT)) {
rgb_float_to_uchar(tcol, &(ma->r));
copy_v3_v3(ma_col, &ma->r);
}
if ((dflag & DRAW_CONSTCOLOR) == 0) {
glColor3ubv(tcol);
}
timestep = psys_get_timestep(&sim);
if ((base->flag & OB_FROMDUPLI) && (ob->flag & OB_FROMGROUP)) {
float mat[4][4];
mul_m4_m4m4(mat, ob->obmat, psys->imat);
glMultMatrixf(mat);
}
/* needed for text display */
invert_m4_m4(ob->imat, ob->obmat);
totpart = psys->totpart;
cfra = BKE_scene_frame_get(scene);
if (draw_as == PART_DRAW_PATH && psys->pathcache == NULL && psys->childcache == NULL)
draw_as = PART_DRAW_DOT;
/* 3. */
glLineWidth(1.0f);
switch (draw_as) {
case PART_DRAW_DOT:
if (part->draw_size)
glPointSize(part->draw_size);
else
glPointSize(2.0); /* default dot size */
break;
case PART_DRAW_CIRC:
/* calculate view aligned matrix: */
copy_m4_m4(imat, rv3d->viewinv);
normalize_v3(imat[0]);
normalize_v3(imat[1]);
/* fall-through */
case PART_DRAW_CROSS:
case PART_DRAW_AXIS:
/* lets calculate the scale: */
if (part->draw_size == 0.0)
pixsize_scale = 2.0f;
else
pixsize_scale = part->draw_size;
if (draw_as == PART_DRAW_AXIS)
create_cdata = 1;
break;
case PART_DRAW_OB:
if (part->dup_ob == NULL)
draw_as = PART_DRAW_DOT;
else
draw_as = 0;
break;
case PART_DRAW_GR:
if (part->dup_group == NULL)
draw_as = PART_DRAW_DOT;
else
draw_as = 0;
break;
case PART_DRAW_BB:
if (v3d->camera == NULL && part->bb_ob == NULL) {
printf("Billboards need an active camera or a target object!\n");
draw_as = part->draw_as = PART_DRAW_DOT;
if (part->draw_size)
glPointSize(part->draw_size);
else
glPointSize(2.0); /* default dot size */
}
else if (part->bb_ob)
bb.ob = part->bb_ob;
else
bb.ob = v3d->camera;
bb.align = part->bb_align;
bb.anim = part->bb_anim;
bb.lock = part->draw & PART_DRAW_BB_LOCK;
break;
case PART_DRAW_PATH:
break;
case PART_DRAW_LINE:
need_v = 1;
break;
}
if (part->draw & PART_DRAW_SIZE && part->draw_as != PART_DRAW_CIRC) {
copy_m4_m4(imat, rv3d->viewinv);
normalize_v3(imat[0]);
normalize_v3(imat[1]);
}
if (ELEM(draw_as, PART_DRAW_DOT, PART_DRAW_CROSS, PART_DRAW_LINE) &&
(part->draw_col > PART_DRAW_COL_MAT))
{
create_cdata = 1;
}
if (!create_cdata && pdd && pdd->cdata) {
MEM_freeN(pdd->cdata);
pdd->cdata = pdd->cd = NULL;
}
/* 4. */
if (draw_as && ELEM(draw_as, PART_DRAW_PATH, PART_DRAW_CIRC) == 0) {
int tot_vec_size = (totpart + totchild) * 3 * sizeof(float);
int create_ndata = 0;
if (!pdd)
pdd = psys->pdd = MEM_callocN(sizeof(ParticleDrawData), "ParticleDrawData");
if (part->draw_as == PART_DRAW_REND && part->trail_count > 1) {
tot_vec_size *= part->trail_count;
psys_make_temp_pointcache(ob, psys);
}
switch (draw_as) {
case PART_DRAW_AXIS:
case PART_DRAW_CROSS:
tot_vec_size *= 6;
if (draw_as != PART_DRAW_CROSS)
create_cdata = 1;
break;
case PART_DRAW_LINE:
tot_vec_size *= 2;
break;
case PART_DRAW_BB:
tot_vec_size *= 4;
create_ndata = 1;
break;
}
if (pdd->tot_vec_size != tot_vec_size)
psys_free_pdd(psys);
if (!pdd->vdata)
pdd->vdata = MEM_callocN(tot_vec_size, "particle_vdata");
if (create_cdata && !pdd->cdata)
pdd->cdata = MEM_callocN(tot_vec_size, "particle_cdata");
if (create_ndata && !pdd->ndata)
pdd->ndata = MEM_callocN(tot_vec_size, "particle_ndata");
if (part->draw & PART_DRAW_VEL && draw_as != PART_DRAW_LINE) {
if (!pdd->vedata)
pdd->vedata = MEM_callocN(2 * (totpart + totchild) * 3 * sizeof(float), "particle_vedata");
need_v = 1;
}
else if (pdd->vedata) {
/* velocity data not needed, so free it */
MEM_freeN(pdd->vedata);
pdd->vedata = NULL;
}
pdd->vd = pdd->vdata;
pdd->ved = pdd->vedata;
pdd->cd = pdd->cdata;
pdd->nd = pdd->ndata;
pdd->tot_vec_size = tot_vec_size;
}
else if (psys->pdd) {
psys_free_pdd(psys);
MEM_freeN(psys->pdd);
pdd = psys->pdd = NULL;
}
if (pdd) {
pdd->ma_col = ma_col;
}
psys->lattice_deform_data = psys_create_lattice_deform_data(&sim);
/* circles don't use drawdata, so have to add a special case here */
if ((pdd || draw_as == PART_DRAW_CIRC) && draw_as != PART_DRAW_PATH) {
/* 5. */
if (pdd && (pdd->flag & PARTICLE_DRAW_DATA_UPDATED) &&
(pdd->vedata || part->draw & (PART_DRAW_SIZE | PART_DRAW_NUM | PART_DRAW_HEALTH)) == 0)
{
totpoint = pdd->totpoint; /* draw data is up to date */
}
else {
for (a = 0, pa = pars; a < totpart + totchild; a++, pa++) {
/* setup per particle individual stuff */
if (a < totpart) {
if (totchild && (part->draw & PART_DRAW_PARENT) == 0) continue;
if (pa->flag & PARS_NO_DISP || pa->flag & PARS_UNEXIST) continue;
pa_time = (cfra - pa->time) / pa->lifetime;
pa_birthtime = pa->time;
pa_dietime = pa->dietime;
pa_size = pa->size;
if (part->phystype == PART_PHYS_BOIDS)
pa_health = pa->boid->data.health;
else
pa_health = -1.0;
r_tilt = 2.0f * (psys_frand(psys, a + 21) - 0.5f);
r_length = psys_frand(psys, a + 22);
if (part->draw_col > PART_DRAW_COL_MAT) {
switch (part->draw_col) {
case PART_DRAW_COL_VEL:
intensity = len_v3(pa->state.vel) / part->color_vec_max;
break;
case PART_DRAW_COL_ACC:
intensity = len_v3v3(pa->state.vel, pa->prev_state.vel) / ((pa->state.time - pa->prev_state.time) * part->color_vec_max);
break;
default:
intensity = 1.0f; /* should never happen */
BLI_assert(0);
break;
}
CLAMP(intensity, 0.0f, 1.0f);
weight_to_rgb(ma_col, intensity);
}
}
else {
ChildParticle *cpa = &psys->child[a - totpart];
pa_time = psys_get_child_time(psys, cpa, cfra, &pa_birthtime, &pa_dietime);
pa_size = psys_get_child_size(psys, cpa, cfra, NULL);
pa_health = -1.0;
r_tilt = 2.0f * (psys_frand(psys, a + 21) - 0.5f);
r_length = psys_frand(psys, a + 22);
}
drawn = 0;
if (part->draw_as == PART_DRAW_REND && part->trail_count > 1) {
float length = part->path_end * (1.0f - part->randlength * r_length);
int trail_count = part->trail_count * (1.0f - part->randlength * r_length);
float ct = ((part->draw & PART_ABS_PATH_TIME) ? cfra : pa_time) - length;
float dt = length / (trail_count ? (float)trail_count : 1.0f);
int i = 0;
ct += dt;
for (i = 0; i < trail_count; i++, ct += dt) {
if (part->draw & PART_ABS_PATH_TIME) {
if (ct < pa_birthtime || ct > pa_dietime)
continue;
}
else if (ct < 0.0f || ct > 1.0f)
continue;
state.time = (part->draw & PART_ABS_PATH_TIME) ? -ct : -(pa_birthtime + ct * (pa_dietime - pa_birthtime));
psys_get_particle_on_path(&sim, a, &state, need_v);
draw_particle_data(psys, rv3d,
&state, draw_as, imat, &bb, psys->pdd,
ct, pa_size, r_tilt, pixsize_scale);
totpoint++;
drawn = 1;
}
}
else {
state.time = cfra;
if (psys_get_particle_state(&sim, a, &state, 0)) {
draw_particle_data(psys, rv3d,
&state, draw_as, imat, &bb, psys->pdd,
pa_time, pa_size, r_tilt, pixsize_scale);
totpoint++;
drawn = 1;
}
}
if (drawn) {
/* additional things to draw for each particle
* (velocity, size and number) */
if ((part->draw & PART_DRAW_VEL) && pdd && pdd->vedata) {
copy_v3_v3(pdd->ved, state.co);
pdd->ved += 3;
mul_v3_v3fl(vel, state.vel, timestep);
add_v3_v3v3(pdd->ved, state.co, vel);
pdd->ved += 3;
totve++;
}
if (part->draw & PART_DRAW_SIZE) {
setlinestyle(3);
drawcircball(GL_LINE_LOOP, state.co, pa_size, imat);
setlinestyle(0);
}
if ((part->draw & PART_DRAW_NUM || part->draw & PART_DRAW_HEALTH) &&
(v3d->flag2 & V3D_RENDER_OVERRIDE) == 0)
{
size_t numstr_len;
float vec_txt[3];
char *val_pos = numstr;
numstr[0] = '\0';
if (part->draw & PART_DRAW_NUM) {
if (a < totpart && (part->draw & PART_DRAW_HEALTH) && (part->phystype == PART_PHYS_BOIDS)) {
numstr_len = BLI_snprintf_rlen(val_pos, sizeof(numstr), "%d:%.2f", a, pa_health);
}
else {
numstr_len = BLI_snprintf_rlen(val_pos, sizeof(numstr), "%d", a);
}
}
else {
if (a < totpart && (part->draw & PART_DRAW_HEALTH) && (part->phystype == PART_PHYS_BOIDS)) {
numstr_len = BLI_snprintf_rlen(val_pos, sizeof(numstr), "%.2f", pa_health);
}
}
if (numstr[0]) {
/* in path drawing state.co is the end point
* use worldspace because object matrix is already applied */
mul_v3_m4v3(vec_txt, ob->imat, state.co);
view3d_cached_text_draw_add(vec_txt, numstr, numstr_len,
10, V3D_CACHE_TEXT_WORLDSPACE | V3D_CACHE_TEXT_ASCII, tcol);
}
}
}
}
}
}
/* 6. */
glGetIntegerv(GL_POLYGON_MODE, polygonmode);
glEnableClientState(GL_VERTEX_ARRAY);
if (draw_as == PART_DRAW_PATH) {
ParticleCacheKey **cache, *path;
float *cdata2 = NULL;
/* setup gl flags */
if (1) { //ob_dt > OB_WIRE) {
glEnableClientState(GL_NORMAL_ARRAY);
if ((dflag & DRAW_CONSTCOLOR) == 0) {
if (part->draw_col == PART_DRAW_COL_MAT)
glEnableClientState(GL_COLOR_ARRAY);
}
// XXX test
GPU_basic_shader_colors(NULL, NULL, 0.0f, 1.0f);
GPU_basic_shader_bind(GPU_SHADER_LIGHTING | GPU_SHADER_USE_COLOR);
}
if (totchild && (part->draw & PART_DRAW_PARENT) == 0)
totpart = 0;
else if (psys->pathcache == NULL)
totpart = 0;
/* draw actual/parent particles */
cache = psys->pathcache;
for (a = 0, pa = psys->particles; a < totpart; a++, pa++) {
path = cache[a];
if (path->segments > 0) {
glVertexPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->co);
if (1) { //ob_dt > OB_WIRE) {
glNormalPointer(GL_FLOAT, sizeof(ParticleCacheKey), path->vel);
if ((dflag & DRAW_CONSTCOLOR) == 0) {
if (part->draw_col == PART_DRAW_COL_MAT) {
glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->col);
}
}
}
glDrawArrays(GL_LINE_STRIP, 0, path->segments + 1);
}
}
if (part->type == PART_HAIR) {
if (part->draw & PART_DRAW_GUIDE_HAIRS) {
DerivedMesh *hair_dm = psys->hair_out_dm;
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
for (a = 0, pa = psys->particles; a < totpart; a++, pa++) {
if (pa->totkey > 1) {
HairKey *hkey = pa->hair;
glVertexPointer(3, GL_FLOAT, sizeof(HairKey), hkey->world_co);
#if 0 /* XXX use proper theme color here */
UI_ThemeColor(TH_NORMAL);
#else
glColor3f(0.58f, 0.67f, 1.0f);
#endif
glDrawArrays(GL_LINE_STRIP, 0, pa->totkey);
}
}
if (hair_dm) {
MVert *mvert = hair_dm->getVertArray(hair_dm);
int i;
glColor3f(0.9f, 0.4f, 0.4f);
glBegin(GL_LINES);
for (a = 0, pa = psys->particles; a < totpart; a++, pa++) {
for (i = 1; i < pa->totkey; ++i) {
float v1[3], v2[3];
copy_v3_v3(v1, mvert[pa->hair_index + i - 1].co);
copy_v3_v3(v2, mvert[pa->hair_index + i].co);
mul_m4_v3(ob->obmat, v1);
mul_m4_v3(ob->obmat, v2);
glVertex3fv(v1);
glVertex3fv(v2);
}
}
glEnd();
}
glEnableClientState(GL_NORMAL_ARRAY);
if ((dflag & DRAW_CONSTCOLOR) == 0)
if (part->draw_col == PART_DRAW_COL_MAT)
glEnableClientState(GL_COLOR_ARRAY);
}
if (part->draw & PART_DRAW_HAIR_GRID) {
ClothModifierData *clmd = psys->clmd;
if (clmd) {
float *gmin = clmd->hair_grid_min;
float *gmax = clmd->hair_grid_max;
int *res = clmd->hair_grid_res;
int i;
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
if (select)
UI_ThemeColor(TH_ACTIVE);
else
UI_ThemeColor(TH_WIRE);
glBegin(GL_LINES);
glVertex3f(gmin[0], gmin[1], gmin[2]); glVertex3f(gmax[0], gmin[1], gmin[2]);
glVertex3f(gmax[0], gmin[1], gmin[2]); glVertex3f(gmax[0], gmax[1], gmin[2]);
glVertex3f(gmax[0], gmax[1], gmin[2]); glVertex3f(gmin[0], gmax[1], gmin[2]);
glVertex3f(gmin[0], gmax[1], gmin[2]); glVertex3f(gmin[0], gmin[1], gmin[2]);
glVertex3f(gmin[0], gmin[1], gmax[2]); glVertex3f(gmax[0], gmin[1], gmax[2]);
glVertex3f(gmax[0], gmin[1], gmax[2]); glVertex3f(gmax[0], gmax[1], gmax[2]);
glVertex3f(gmax[0], gmax[1], gmax[2]); glVertex3f(gmin[0], gmax[1], gmax[2]);
glVertex3f(gmin[0], gmax[1], gmax[2]); glVertex3f(gmin[0], gmin[1], gmax[2]);
glVertex3f(gmin[0], gmin[1], gmin[2]); glVertex3f(gmin[0], gmin[1], gmax[2]);
glVertex3f(gmax[0], gmin[1], gmin[2]); glVertex3f(gmax[0], gmin[1], gmax[2]);
glVertex3f(gmin[0], gmax[1], gmin[2]); glVertex3f(gmin[0], gmax[1], gmax[2]);
glVertex3f(gmax[0], gmax[1], gmin[2]); glVertex3f(gmax[0], gmax[1], gmax[2]);
glEnd();
if (select)
UI_ThemeColorShadeAlpha(TH_ACTIVE, 0, -100);
else
UI_ThemeColorShadeAlpha(TH_WIRE, 0, -100);
glEnable(GL_BLEND);
glBegin(GL_LINES);
for (i = 1; i < res[0] - 1; ++i) {
float f = interpf(gmax[0], gmin[0], (float)i / (float)(res[0] - 1));
glVertex3f(f, gmin[1], gmin[2]); glVertex3f(f, gmax[1], gmin[2]);
glVertex3f(f, gmax[1], gmin[2]); glVertex3f(f, gmax[1], gmax[2]);
glVertex3f(f, gmax[1], gmax[2]); glVertex3f(f, gmin[1], gmax[2]);
glVertex3f(f, gmin[1], gmax[2]); glVertex3f(f, gmin[1], gmin[2]);
}
for (i = 1; i < res[1] - 1; ++i) {
float f = interpf(gmax[1], gmin[1], (float)i / (float)(res[1] - 1));
glVertex3f(gmin[0], f, gmin[2]); glVertex3f(gmax[0], f, gmin[2]);
glVertex3f(gmax[0], f, gmin[2]); glVertex3f(gmax[0], f, gmax[2]);
glVertex3f(gmax[0], f, gmax[2]); glVertex3f(gmin[0], f, gmax[2]);
glVertex3f(gmin[0], f, gmax[2]); glVertex3f(gmin[0], f, gmin[2]);
}
for (i = 1; i < res[2] - 1; ++i) {
float f = interpf(gmax[2], gmin[2], (float)i / (float)(res[2] - 1));
glVertex3f(gmin[0], gmin[1], f); glVertex3f(gmax[0], gmin[1], f);
glVertex3f(gmax[0], gmin[1], f); glVertex3f(gmax[0], gmax[1], f);
glVertex3f(gmax[0], gmax[1], f); glVertex3f(gmin[0], gmax[1], f);
glVertex3f(gmin[0], gmax[1], f); glVertex3f(gmin[0], gmin[1], f);
}
glEnd();
glDisable(GL_BLEND);
glEnableClientState(GL_NORMAL_ARRAY);
if ((dflag & DRAW_CONSTCOLOR) == 0)
if (part->draw_col == PART_DRAW_COL_MAT)
glEnableClientState(GL_COLOR_ARRAY);
}
}
}
/* draw child particles */
cache = psys->childcache;
for (a = 0; a < totchild; a++) {
path = cache[a];
glVertexPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->co);
if (1) { //ob_dt > OB_WIRE) {
glNormalPointer(GL_FLOAT, sizeof(ParticleCacheKey), path->vel);
if ((dflag & DRAW_CONSTCOLOR) == 0) {
if (part->draw_col == PART_DRAW_COL_MAT) {
glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->col);
}
}
}
glDrawArrays(GL_LINE_STRIP, 0, path->segments + 1);
}
/* restore & clean up */
if (1) { //ob_dt > OB_WIRE) {
if (part->draw_col == PART_DRAW_COL_MAT)
glDisableClientState(GL_COLOR_ARRAY);
GPU_basic_shader_bind(GPU_SHADER_USE_COLOR);
}
if (cdata2) {
MEM_freeN(cdata2);
cdata2 = NULL;
}
if ((part->draw & PART_DRAW_NUM) && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
cache = psys->pathcache;
for (a = 0, pa = psys->particles; a < totpart; a++, pa++) {
float vec_txt[3];
size_t numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%i", a);
/* use worldspace because object matrix is already applied */
mul_v3_m4v3(vec_txt, ob->imat, cache[a]->co);
view3d_cached_text_draw_add(vec_txt, numstr, numstr_len,
10, V3D_CACHE_TEXT_WORLDSPACE | V3D_CACHE_TEXT_ASCII, tcol);
}
}
}
else if (pdd && ELEM(draw_as, 0, PART_DRAW_CIRC) == 0) {
glDisableClientState(GL_COLOR_ARRAY);
/* enable point data array */
if (pdd->vdata) {
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, pdd->vdata);
}
else
glDisableClientState(GL_VERTEX_ARRAY);
if ((dflag & DRAW_CONSTCOLOR) == 0) {
if (select) {
UI_ThemeColor(TH_ACTIVE);
if (part->draw_size)
glPointSize(part->draw_size + 2);
else
glPointSize(4.0);
glLineWidth(3.0);
draw_particle_arrays(draw_as, totpoint, ob_dt, 1);
}
/* restore from select */
glColor3fv(ma_col);
}
glPointSize(part->draw_size ? part->draw_size : 2.0);
glLineWidth(1.0);
/* enable other data arrays */
/* billboards are drawn this way */
if (pdd->ndata && ob_dt > OB_WIRE) {
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_FLOAT, 0, pdd->ndata);
GPU_basic_shader_colors(NULL, NULL, 0.0f, 1.0f);
GPU_basic_shader_bind(GPU_SHADER_LIGHTING | GPU_SHADER_USE_COLOR);
}
if ((dflag & DRAW_CONSTCOLOR) == 0) {
if (pdd->cdata) {
glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(3, GL_FLOAT, 0, pdd->cdata);
}
}
draw_particle_arrays(draw_as, totpoint, ob_dt, 0);
pdd->flag |= PARTICLE_DRAW_DATA_UPDATED;
pdd->totpoint = totpoint;
}
if (pdd && pdd->vedata) {
if ((dflag & DRAW_CONSTCOLOR) == 0) {
glDisableClientState(GL_COLOR_ARRAY);
cpack(0xC0C0C0);
}
glVertexPointer(3, GL_FLOAT, 0, pdd->vedata);
glDrawArrays(GL_LINES, 0, 2 * totve);
}
glPolygonMode(GL_FRONT, polygonmode[0]);
glPolygonMode(GL_BACK, polygonmode[1]);
/* 7. */
GPU_basic_shader_bind(GPU_SHADER_USE_COLOR);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
if (states)
MEM_freeN(states);
psys->flag &= ~PSYS_DRAWING;
/* draw data can't be saved for billboards as they must update to target changes */
if (draw_as == PART_DRAW_BB) {
psys_free_pdd(psys);
pdd->flag &= ~PARTICLE_DRAW_DATA_UPDATED;
}
if (psys->lattice_deform_data) {
end_latt_deform(psys->lattice_deform_data);
psys->lattice_deform_data = NULL;
}
if (pdd) {
/* drop references to stack memory */
pdd->ma_col = NULL;
}
if ((base->flag & OB_FROMDUPLI) && (ob->flag & OB_FROMGROUP)) {
glLoadMatrixf(rv3d->viewmat);
}
}
static void draw_update_ptcache_edit(Scene *scene, Object *ob, PTCacheEdit *edit)
{
if (edit->psys && edit->psys->flag & PSYS_HAIR_UPDATED)
PE_update_object(scene, ob, 0);
/* create path and child path cache if it doesn't exist already */
if (edit->pathcache == NULL)
psys_cache_edit_paths(scene, ob, edit, CFRA);
}
static void draw_ptcache_edit(Scene *scene, View3D *v3d, PTCacheEdit *edit)
{
ParticleCacheKey **cache, *path, *pkey;
PTCacheEditPoint *point;
PTCacheEditKey *key;
ParticleEditSettings *pset = PE_settings(scene);
int i, k, totpoint = edit->totpoint, timed = (pset->flag & PE_FADE_TIME) ? pset->fade_frames : 0;
int totkeys = 1;
float sel_col[3];
float nosel_col[3];
float *pathcol = NULL, *pcol;
if (edit->pathcache == NULL)
return;
PE_hide_keys_time(scene, edit, CFRA);
/* opengl setup */
if ((v3d->flag & V3D_ZBUF_SELECT) == 0)
glDisable(GL_DEPTH_TEST);
/* get selection theme colors */
UI_GetThemeColor3fv(TH_VERTEX_SELECT, sel_col);
UI_GetThemeColor3fv(TH_VERTEX, nosel_col);
/* draw paths */
totkeys = (*edit->pathcache)->segments + 1;
glEnable(GL_BLEND);
pathcol = MEM_callocN(totkeys * 4 * sizeof(float), "particle path color data");
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glShadeModel(GL_SMOOTH);
if (pset->brushtype == PE_BRUSH_WEIGHT)
glLineWidth(2.0f);
cache = edit->pathcache;
for (i = 0, point = edit->points; i < totpoint; i++, point++) {
path = cache[i];
glVertexPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->co);
if (point->flag & PEP_HIDE) {
for (k = 0, pcol = pathcol; k < totkeys; k++, pcol += 4) {
copy_v3_v3(pcol, path->col);
pcol[3] = 0.25f;
}
glColorPointer(4, GL_FLOAT, 4 * sizeof(float), pathcol);
}
else if (timed) {
for (k = 0, pcol = pathcol, pkey = path; k < totkeys; k++, pkey++, pcol += 4) {
copy_v3_v3(pcol, pkey->col);
pcol[3] = 1.0f - fabsf((float)(CFRA) -pkey->time) / (float)pset->fade_frames;
}
glColorPointer(4, GL_FLOAT, 4 * sizeof(float), pathcol);
}
else
glColorPointer(3, GL_FLOAT, sizeof(ParticleCacheKey), path->col);
glDrawArrays(GL_LINE_STRIP, 0, path->segments + 1);
}
if (pathcol) { MEM_freeN(pathcol); pathcol = pcol = NULL; }
/* draw edit vertices */
if (pset->selectmode != SCE_SELECT_PATH) {
glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE));
if (pset->selectmode == SCE_SELECT_POINT) {
float *pd = NULL, *pdata = NULL;
float *cd = NULL, *cdata = NULL;
int totkeys_visible = 0;
for (i = 0, point = edit->points; i < totpoint; i++, point++)
if (!(point->flag & PEP_HIDE))
totkeys_visible += point->totkey;
if (totkeys_visible) {
if (edit->points && !(edit->points->keys->flag & PEK_USE_WCO))
pd = pdata = MEM_callocN(totkeys_visible * 3 * sizeof(float), "particle edit point data");
cd = cdata = MEM_callocN(totkeys_visible * (timed ? 4 : 3) * sizeof(float), "particle edit color data");
}
for (i = 0, point = edit->points; i < totpoint; i++, point++) {
if (point->flag & PEP_HIDE)
continue;
for (k = 0, key = point->keys; k < point->totkey; k++, key++) {
if (pd) {
copy_v3_v3(pd, key->co);
pd += 3;
}
if (key->flag & PEK_SELECT) {
copy_v3_v3(cd, sel_col);
}
else {
copy_v3_v3(cd, nosel_col);
}
if (timed)
*(cd + 3) = 1.0f - fabsf((float)CFRA - *key->time) / (float)pset->fade_frames;
cd += (timed ? 4 : 3);
}
}
cd = cdata;
pd = pdata;
for (i = 0, point = edit->points; i < totpoint; i++, point++) {
if (point->flag & PEP_HIDE || point->totkey == 0)
continue;
if (point->keys->flag & PEK_USE_WCO)
glVertexPointer(3, GL_FLOAT, sizeof(PTCacheEditKey), point->keys->world_co);
else
glVertexPointer(3, GL_FLOAT, 3 * sizeof(float), pd);
glColorPointer((timed ? 4 : 3), GL_FLOAT, (timed ? 4 : 3) * sizeof(float), cd);
glDrawArrays(GL_POINTS, 0, point->totkey);
pd += pd ? 3 * point->totkey : 0;
cd += (timed ? 4 : 3) * point->totkey;
}
if (pdata) { MEM_freeN(pdata); pd = pdata = NULL; }
if (cdata) { MEM_freeN(cdata); cd = cdata = NULL; }
}
else if (pset->selectmode == SCE_SELECT_END) {
glBegin(GL_POINTS);
for (i = 0, point = edit->points; i < totpoint; i++, point++) {
if ((point->flag & PEP_HIDE) == 0 && point->totkey) {
key = point->keys + point->totkey - 1;
glColor3fv((key->flag & PEK_SELECT) ? sel_col : nosel_col);
/* has to be like this.. otherwise selection won't work, have try glArrayElement later..*/
glVertex3fv((key->flag & PEK_USE_WCO) ? key->world_co : key->co);
}
}
glEnd();
}
}
glDisable(GL_BLEND);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
glShadeModel(GL_FLAT);
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
UNUSED_VARS(scene, v3d, rv3d, base, psys, ob_dt, dflag);
}
static void ob_draw_RE_motion(float com[3], float rotscale[3][3], float itw, float ith, float drw_size)
@@ -7813,9 +6719,9 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
for (psys = ob->particlesystem.first; psys; psys = psys->next) {
/* run this so that possible child particles get cached */
if (ob->mode & OB_MODE_PARTICLE_EDIT && is_obact) {
PTCacheEdit *edit = PE_create_current(scene, ob);
if (edit && edit->psys == psys)
draw_update_ptcache_edit(scene, ob, edit);
// PTCacheEdit *edit = PE_create_current(scene, ob);
// if (edit && edit->psys == psys)
// draw_update_ptcache_edit(scene, ob, edit);
}
draw_new_particle_system(scene, v3d, rv3d, base, psys, dt, dflag);
@@ -7835,13 +6741,13 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
{
if (ob->mode & OB_MODE_PARTICLE_EDIT && is_obact) {
PTCacheEdit *edit = PE_create_current(scene, ob);
if (edit) {
glLoadMatrixf(rv3d->viewmat);
draw_update_ptcache_edit(scene, ob, edit);
draw_ptcache_edit(scene, v3d, edit);
glMultMatrixf(ob->obmat);
}
// PTCacheEdit *edit = PE_create_current(scene, ob);
// if (edit) {
// glLoadMatrixf(rv3d->viewmat);
// draw_update_ptcache_edit(scene, ob, edit);
// draw_ptcache_edit(scene, v3d, edit);
// glMultMatrixf(ob->obmat);
// }
}
}

View File

@@ -69,7 +69,6 @@
#include "RNA_define.h"
#include "ED_armature.h"
#include "ED_particle.h"
#include "ED_keyframing.h"
#include "ED_screen.h"
#include "ED_transform.h"
@@ -3041,9 +3040,6 @@ static int viewselected_exec(bContext *C, wmOperator *op)
else if (BKE_paint_select_face_test(ob)) {
ok = paintface_minmax(ob, min, max);
}
else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT)) {
ok = PE_minmax(scene, min, max);
}
else if (ob && (ob->mode & (OB_MODE_SCULPT | OB_MODE_TEXTURE_PAINT))) {
BKE_paint_stroke_get_average(scene, ob, min);
copy_v3_v3(max, min);

View File

@@ -85,7 +85,6 @@
#include "ED_armature.h"
#include "ED_curve.h"
#include "ED_particle.h"
#include "ED_mesh.h"
#include "ED_object.h"
#include "ED_screen.h"
@@ -833,8 +832,6 @@ static void view3d_lasso_select(bContext *C, ViewContext *vc,
else if (ob && (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))) {
/* pass */
}
else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT))
PE_lasso_select(C, mcords, moves, extend, select);
else {
do_lasso_select_objects(vc, mcords, moves, extend, select);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, vc->scene);
@@ -2165,9 +2162,6 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op)
else if (vc.obact && BKE_paint_select_vert_test(vc.obact)) {
ret = do_paintvert_box_select(&vc, &rect, select, extend);
}
else if (vc.obact && vc.obact->mode & OB_MODE_PARTICLE_EDIT) {
ret = PE_border_select(C, &rect, select, extend);
}
else { /* object mode with none active */
ret = do_object_pose_box_select(C, &vc, &rect, select, extend);
}
@@ -2298,8 +2292,6 @@ static int view3d_select_exec(bContext *C, wmOperator *op)
retval = ED_curve_editfont_select_pick(C, location, extend, deselect, toggle);
}
else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT)
return PE_mouse_particles(C, location, extend, deselect, toggle);
else if (obact && BKE_paint_select_face_test(obact))
retval = paintface_mouse_select(C, obact, location, extend, deselect, toggle);
else if (BKE_paint_select_vert_test(obact))
@@ -2837,8 +2829,6 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op)
}
else if (obact->mode & OB_MODE_POSE)
pose_circle_select(&vc, select, mval, (float)radius);
else
return PE_circle_select(C, select, mval, (float)radius);
}
else if (obact && obact->mode & OB_MODE_SCULPT) {
return OPERATOR_CANCELLED;

View File

@@ -607,7 +607,6 @@ void flushTransIntFrameActionData(TransInfo *t);
void flushTransGraphData(TransInfo *t);
void remake_graph_transdata(TransInfo *t, struct ListBase *anim_data);
void flushTransUVs(TransInfo *t);
void flushTransParticles(TransInfo *t);
bool clipUVTransform(TransInfo *t, float vec[2], const bool resize);
void clipUVData(TransInfo *t);
void flushTransNodes(TransInfo *t);

View File

@@ -96,7 +96,6 @@
#include "ED_anim_api.h"
#include "ED_armature.h"
#include "ED_particle.h"
#include "ED_image.h"
#include "ED_keyframing.h"
#include "ED_keyframes_edit.h"
@@ -1793,174 +1792,6 @@ static void createTransLatticeVerts(TransInfo *t)
}
}
/* ******************* particle edit **************** */
static void createTransParticleVerts(bContext *C, TransInfo *t)
{
TransData *td = NULL;
TransDataExtension *tx;
Base *base = CTX_data_active_base(C);
Object *ob = CTX_data_active_object(C);
ParticleEditSettings *pset = PE_settings(t->scene);
PTCacheEdit *edit = PE_get_current(t->scene, ob);
ParticleSystem *psys = NULL;
ParticleSystemModifierData *psmd = NULL;
PTCacheEditPoint *point;
PTCacheEditKey *key;
float mat[4][4];
int i, k, transformparticle;
int count = 0, hasselected = 0;
const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
if (edit == NULL || t->settings->particle.selectmode == SCE_SELECT_PATH) return;
psys = edit->psys;
if (psys)
psmd = psys_get_modifier(ob, psys);
base->flag |= BA_HAS_RECALC_DATA;
for (i = 0, point = edit->points; i < edit->totpoint; i++, point++) {
point->flag &= ~PEP_TRANSFORM;
transformparticle = 0;
if ((point->flag & PEP_HIDE) == 0) {
for (k = 0, key = point->keys; k < point->totkey; k++, key++) {
if ((key->flag & PEK_HIDE) == 0) {
if (key->flag & PEK_SELECT) {
hasselected = 1;
transformparticle = 1;
}
else if (is_prop_edit)
transformparticle = 1;
}
}
}
if (transformparticle) {
count += point->totkey;
point->flag |= PEP_TRANSFORM;
}
}
/* note: in prop mode we need at least 1 selected */
if (hasselected == 0) return;
t->total = count;
td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(Particle Mode)");
if (t->mode == TFM_BAKE_TIME)
tx = t->ext = MEM_callocN(t->total * sizeof(TransDataExtension), "Particle_TransExtension");
else
tx = t->ext = NULL;
unit_m4(mat);
invert_m4_m4(ob->imat, ob->obmat);
for (i = 0, point = edit->points; i < edit->totpoint; i++, point++) {
TransData *head, *tail;
head = tail = td;
if (!(point->flag & PEP_TRANSFORM)) continue;
if (psys && !(psys->flag & PSYS_GLOBAL_HAIR))
psys_mat_hair_to_global(ob, psmd->dm_final, psys->part->from, psys->particles + i, mat);
for (k = 0, key = point->keys; k < point->totkey; k++, key++) {
if (key->flag & PEK_USE_WCO) {
copy_v3_v3(key->world_co, key->co);
mul_m4_v3(mat, key->world_co);
td->loc = key->world_co;
}
else
td->loc = key->co;
copy_v3_v3(td->iloc, td->loc);
copy_v3_v3(td->center, td->loc);
if (key->flag & PEK_SELECT)
td->flag |= TD_SELECTED;
else if (!is_prop_edit)
td->flag |= TD_SKIP;
unit_m3(td->mtx);
unit_m3(td->smtx);
/* don't allow moving roots */
if (k == 0 && pset->flag & PE_LOCK_FIRST && (!psys || !(psys->flag & PSYS_GLOBAL_HAIR)))
td->protectflag |= OB_LOCK_LOC;
td->ob = ob;
td->ext = tx;
if (t->mode == TFM_BAKE_TIME) {
td->val = key->time;
td->ival = *(key->time);
/* abuse size and quat for min/max values */
td->flag |= TD_NO_EXT;
if (k == 0) tx->size = NULL;
else tx->size = (key - 1)->time;
if (k == point->totkey - 1) tx->quat = NULL;
else tx->quat = (key + 1)->time;
}
td++;
if (tx)
tx++;
tail++;
}
if (is_prop_edit && head != tail)
calc_distanceCurveVerts(head, tail - 1);
}
}
void flushTransParticles(TransInfo *t)
{
Scene *scene = t->scene;
Object *ob = OBACT;
PTCacheEdit *edit = PE_get_current(scene, ob);
ParticleSystem *psys = edit->psys;
ParticleSystemModifierData *psmd = NULL;
PTCacheEditPoint *point;
PTCacheEditKey *key;
TransData *td;
float mat[4][4], imat[4][4], co[3];
int i, k;
const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
if (psys)
psmd = psys_get_modifier(ob, psys);
/* we do transform in world space, so flush world space position
* back to particle local space (only for hair particles) */
td = t->data;
for (i = 0, point = edit->points; i < edit->totpoint; i++, point++, td++) {
if (!(point->flag & PEP_TRANSFORM)) continue;
if (psys && !(psys->flag & PSYS_GLOBAL_HAIR)) {
psys_mat_hair_to_global(ob, psmd->dm_final, psys->part->from, psys->particles + i, mat);
invert_m4_m4(imat, mat);
for (k = 0, key = point->keys; k < point->totkey; k++, key++) {
copy_v3_v3(co, key->world_co);
mul_m4_v3(imat, co);
/* optimization for proportional edit */
if (!is_prop_edit || !compare_v3v3(key->co, co, 0.0001f)) {
copy_v3_v3(key->co, co);
point->flag |= PEP_EDIT_RECALC;
}
}
}
else
point->flag |= PEP_EDIT_RECALC;
}
PE_update_object(scene, OBACT, 1);
}
/* ********************* mesh ****************** */
static bool bmesh_test_dist_add(BMVert *v, BMVert *v_other,
@@ -6289,13 +6120,6 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
else if (t->options & CTX_PAINT_CURVE) {
/* pass */
}
else if ((t->scene->basact) &&
(ob = t->scene->basact->object) &&
(ob->mode & OB_MODE_PARTICLE_EDIT) &&
PE_get_current(t->scene, ob))
{
/* do nothing */
}
else { /* Objects */
int i;
@@ -8004,16 +7828,6 @@ void createTransData(bContext *C, TransInfo *t)
}
}
else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT) && PE_start_edit(PE_get_current(scene, ob))) {
createTransParticleVerts(C, t);
t->flag |= T_POINTS;
if (t->data && t->flag & T_PROP_EDIT) {
sort_trans_data(t); // makes selected become first in array
set_prop_dist(t, 1);
sort_trans_data_dist(t);
}
}
else if (ob && (ob->mode & OB_MODE_ALL_PAINT)) {
if ((t->options & CTX_PAINT_CURVE) && !ELEM(t->mode, TFM_SHEAR, TFM_SHRINKFATTEN)) {
t->flag |= T_POINTS | T_2D_EDIT;

View File

@@ -91,7 +91,6 @@
#include "ED_markers.h"
#include "ED_mesh.h"
#include "ED_object.h"
#include "ED_particle.h"
#include "ED_screen_types.h"
#include "ED_space_api.h"
#include "ED_uvedit.h"
@@ -896,12 +895,6 @@ static void recalcData_objects(TransInfo *t)
else
BKE_pose_where_is(t->scene, ob);
}
else if (base && (base->object->mode & OB_MODE_PARTICLE_EDIT) && PE_get_current(t->scene, base->object)) {
if (t->state != TRANS_CANCEL) {
applyProject(t);
}
flushTransParticles(t);
}
else {
int i;

View File

@@ -66,7 +66,6 @@
#include "ED_armature.h"
#include "ED_curve.h"
#include "ED_particle.h"
#include "ED_view3d.h"
#include "UI_resources.h"
@@ -533,30 +532,6 @@ static int calc_manipulator_stats(const bContext *C)
else if (ob && (ob->mode & OB_MODE_ALL_PAINT)) {
/* pass */
}
else if (ob && ob->mode & OB_MODE_PARTICLE_EDIT) {
PTCacheEdit *edit = PE_get_current(scene, ob);
PTCacheEditPoint *point;
PTCacheEditKey *ek;
int k;
if (edit) {
point = edit->points;
for (a = 0; a < edit->totpoint; a++, point++) {
if (point->flag & PEP_HIDE) continue;
for (k = 0, ek = point->keys; k < point->totkey; k++, ek++) {
if (ek->flag & PEK_SELECT) {
calc_tw_center(scene, (ek->flag & PEK_USE_WCO) ? ek->world_co : ek->co);
totsel++;
}
}
}
/* selection center */
if (totsel)
mul_v3_fl(scene->twcent, 1.0f / (float)totsel); // centroid!
}
}
else {
/* we need the one selected object, if its not active */

View File

@@ -72,7 +72,6 @@ set(SRC
../include/ED_object.h
../include/ED_outliner.h
../include/ED_paint.h
../include/ED_particle.h
../include/ED_physics.h
../include/ED_render.h
../include/ED_screen.h

View File

@@ -49,7 +49,6 @@
#include "BKE_screen.h"
#include "ED_armature.h"
#include "ED_particle.h"
#include "ED_curve.h"
#include "ED_gpencil.h"
#include "ED_mball.h"
@@ -98,11 +97,6 @@ void ED_undo_push(bContext *C, const char *str)
else if (obedit->type == OB_ARMATURE)
undo_push_armature(C, str);
}
else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT) {
if (U.undosteps == 0) return;
PE_undo_push(CTX_data_scene(C), str);
}
else if (obact && obact->mode & OB_MODE_SCULPT) {
/* do nothing for now */
}
@@ -178,12 +172,6 @@ static int ed_undo_step(bContext *C, int step, const char *undoname)
else if (obact && obact->mode & OB_MODE_SCULPT) {
ED_undo_paint_step(C, UNDO_PAINT_MESH, step, undoname);
}
else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT) {
if (step == 1)
PE_undo(scene);
else
PE_redo(scene);
}
else if (U.uiflag & USER_GLOBALUNDO) {
// note python defines not valid here anymore.
//#ifdef WITH_PYTHON
@@ -273,9 +261,6 @@ bool ED_undo_is_valid(const bContext *C, const char *undoname)
if (ED_undo_paint_is_valid(UNDO_PAINT_MESH, undoname))
return 1;
}
else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT) {
return PE_undo_is_valid(CTX_data_scene(C));
}
if (U.uiflag & USER_GLOBALUNDO) {
return BKE_undo_is_valid(undoname);
@@ -435,8 +420,7 @@ void ED_undo_operator_repeat_cb_evt(bContext *C, void *arg_op, int UNUSED(arg_ev
enum {
UNDOSYSTEM_GLOBAL = 1,
UNDOSYSTEM_EDITMODE = 2,
UNDOSYSTEM_PARTICLE = 3,
UNDOSYSTEM_IMAPAINT = 4
UNDOSYSTEM_IMAPAINT = 3
};
static int get_undo_system(bContext *C)
@@ -462,9 +446,7 @@ static int get_undo_system(bContext *C)
}
else {
if (obact) {
if (obact->mode & OB_MODE_PARTICLE_EDIT)
return UNDOSYSTEM_PARTICLE;
else if (obact->mode & OB_MODE_TEXTURE_PAINT) {
if (obact->mode & OB_MODE_TEXTURE_PAINT) {
if (!ED_undo_paint_empty(UNDO_PAINT_IMAGE))
return UNDOSYSTEM_IMAPAINT;
}
@@ -486,10 +468,7 @@ static EnumPropertyItem *rna_undo_itemf(bContext *C, int undosys, int *totitem)
while (true) {
const char *name = NULL;
if (undosys == UNDOSYSTEM_PARTICLE) {
name = PE_undo_get_name(CTX_data_scene(C), i, &active);
}
else if (undosys == UNDOSYSTEM_EDITMODE) {
if (undosys == UNDOSYSTEM_EDITMODE) {
name = undo_editmode_get_name(C, i, &active);
}
else if (undosys == UNDOSYSTEM_IMAPAINT) {
@@ -566,10 +545,7 @@ static int undo_history_exec(bContext *C, wmOperator *op)
int undosys = get_undo_system(C);
int item = RNA_int_get(op->ptr, "item");
if (undosys == UNDOSYSTEM_PARTICLE) {
PE_undo_number(CTX_data_scene(C), item);
}
else if (undosys == UNDOSYSTEM_EDITMODE) {
if (undosys == UNDOSYSTEM_EDITMODE) {
undo_editmode_number(C, item + 1);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, NULL);
}

View File

@@ -193,7 +193,6 @@ EnumPropertyItem rna_enum_object_axis_items[] = {
#include "BKE_deform.h"
#include "ED_object.h"
#include "ED_particle.h"
#include "ED_curve.h"
#include "ED_lattice.h"
@@ -750,9 +749,10 @@ static void rna_Object_active_particle_system_index_set(PointerRNA *ptr, int val
static void rna_Object_particle_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
{
Object *ob = (Object *)ptr->id.data;
UNUSED_VARS(scene, ptr);
// Object *ob = (Object *)ptr->id.data;
PE_current_changed(scene, ob);
// PE_current_changed(scene, ob);
}
/* rotation - axis-angle */

View File

@@ -98,8 +98,6 @@ EnumPropertyItem rna_enum_symmetrize_direction_items[] = {
#include "GPU_buffers.h"
#include "ED_particle.h"
static EnumPropertyItem particle_edit_disconnected_hair_brush_items[] = {
{PE_BRUSH_NONE, "NONE", 0, "None", "Don't use any brush"},
{PE_BRUSH_COMB, "COMB", 0, "Comb", "Comb hairs"},
@@ -136,13 +134,7 @@ static PointerRNA rna_ParticleBrush_curve_get(PointerRNA *ptr)
static void rna_ParticleEdit_redo(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
{
Object *ob = (scene->basact) ? scene->basact->object : NULL;
PTCacheEdit *edit = PE_get_current(scene, ob);
if (!edit)
return;
psys_free_path_cache(edit->psys, edit);
UNUSED_VARS(scene);
}
static void rna_ParticleEdit_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
@@ -193,22 +185,13 @@ static EnumPropertyItem *rna_ParticleEdit_tool_itemf(bContext *C, PointerRNA *UN
return particle_edit_cache_brush_items;
}
static int rna_ParticleEdit_editable_get(PointerRNA *ptr)
static int rna_ParticleEdit_editable_get(PointerRNA *UNUSED(ptr))
{
ParticleEditSettings *pset = (ParticleEditSettings *)ptr->data;
return (pset->object && pset->scene && PE_get_current(pset->scene, pset->object));
return false;
}
static int rna_ParticleEdit_hair_get(PointerRNA *ptr)
{
ParticleEditSettings *pset = (ParticleEditSettings *)ptr->data;
if (pset->scene) {
PTCacheEdit *edit = PE_get_current(pset->scene, pset->object);
return (edit && edit->psys);
}
UNUSED_VARS(ptr);
return 0;
}

View File

@@ -161,7 +161,6 @@ struct wmWindowManager;
#include "../blender/editors/include/ED_mesh.h"
#include "../blender/editors/include/ED_node.h"
#include "../blender/editors/include/ED_object.h"
#include "../blender/editors/include/ED_particle.h"
#include "../blender/editors/include/ED_render.h"
#include "../blender/editors/include/ED_screen.h"
#include "../blender/editors/include/ED_space_api.h"