2003-04-25 15:48:11 +00:00
|
|
|
/* displist.c
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* $Id$
|
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
|
* 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
|
2008-04-16 22:40:48 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
|
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
2002-11-25 10:13:52 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include <math.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
#include "IMB_imbuf_types.h"
|
|
|
|
|
|
|
|
|
|
#include "DNA_texture_types.h"
|
|
|
|
|
#include "DNA_meta_types.h"
|
|
|
|
|
#include "DNA_curve_types.h"
|
2004-09-19 17:44:20 +00:00
|
|
|
#include "DNA_effect_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "DNA_listBase.h"
|
|
|
|
|
#include "DNA_lamp_types.h"
|
|
|
|
|
#include "DNA_object_types.h"
|
2005-05-02 13:28:13 +00:00
|
|
|
#include "DNA_object_force.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "DNA_mesh_types.h"
|
2004-03-20 22:55:42 +00:00
|
|
|
#include "DNA_meshdata_types.h"
|
2005-08-14 12:17:34 +00:00
|
|
|
#include "DNA_modifier_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
#include "DNA_image_types.h"
|
|
|
|
|
#include "DNA_material_types.h"
|
|
|
|
|
#include "DNA_view3d_types.h"
|
|
|
|
|
#include "DNA_lattice_types.h"
|
2005-08-11 07:11:57 +00:00
|
|
|
#include "DNA_key_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
|
#include "BLI_arithb.h"
|
|
|
|
|
#include "BLI_editVert.h"
|
2005-09-03 17:22:29 +00:00
|
|
|
#include "BLI_edgehash.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
#include "BKE_bad_level_calls.h"
|
|
|
|
|
#include "BKE_utildefines.h"
|
|
|
|
|
#include "BKE_global.h"
|
|
|
|
|
#include "BKE_displist.h"
|
2004-09-14 19:03:11 +00:00
|
|
|
#include "BKE_deform.h"
|
2005-03-29 06:46:11 +00:00
|
|
|
#include "BKE_DerivedMesh.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BKE_object.h"
|
|
|
|
|
#include "BKE_world.h"
|
|
|
|
|
#include "BKE_mesh.h"
|
|
|
|
|
#include "BKE_effect.h"
|
|
|
|
|
#include "BKE_mball.h"
|
|
|
|
|
#include "BKE_material.h"
|
|
|
|
|
#include "BKE_curve.h"
|
2005-08-14 06:08:41 +00:00
|
|
|
#include "BKE_key.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BKE_anim.h"
|
|
|
|
|
#include "BKE_screen.h"
|
|
|
|
|
#include "BKE_texture.h"
|
|
|
|
|
#include "BKE_library.h"
|
|
|
|
|
#include "BKE_font.h"
|
|
|
|
|
#include "BKE_lattice.h"
|
|
|
|
|
#include "BKE_scene.h"
|
|
|
|
|
#include "BKE_subsurf.h"
|
2005-08-14 12:17:34 +00:00
|
|
|
#include "BKE_modifier.h"
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
#include "BKE_customdata.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2006-05-28 11:49:22 +00:00
|
|
|
#include "RE_pipeline.h"
|
|
|
|
|
#include "RE_shader_ext.h"
|
Phew, a lot of work, and no new features...
Main target was to make the inner rendering loop using no globals anymore.
This is essential for proper usage while raytracing, it caused a lot of
hacks in the raycode as well, which even didn't work correctly for all
situations (textures especially).
Done this by creating a new local struct RenderInput, which replaces usage
of the global struct Render R. The latter now only is used to denote
image size, viewmatrix, and the like.
Making the inner render loops using no globals caused 1000s of vars to
be changed... but the result definitely is much nicer code, which enables
making 'real' shaders in a next stage.
It also enabled me to remove the hacks from ray.c
Then i went to the task of removing redundant code. Especially the calculus
of texture coords took place (identical) in three locations.
Most obvious is the change in the unified render part, which is much less
code now; it uses the same rendering routines as normal render now.
(Note; not for halos yet!)
I also removed 6 files called 'shadowbuffer' something. This was experimen-
tal stuff from NaN days. And again saved a lot of double used code.
Finally I went over the blenkernel and blender/src calls to render stuff.
Here the same local data is used now, resulting in less dependency.
I also moved render-texture to the render module, this was still in Kernel.
(new file: texture.c)
So! After this commit I will check on the autofiles, to try to fix that.
MSVC people have to do it themselves.
This commit will need quite some testing help, but I'm around!
2003-12-21 21:52:51 +00:00
|
|
|
|
2008-08-17 17:08:00 +00:00
|
|
|
#include "BLO_sys_types.h" // for intptr_t support
|
|
|
|
|
|
Phew, a lot of work, and no new features...
Main target was to make the inner rendering loop using no globals anymore.
This is essential for proper usage while raytracing, it caused a lot of
hacks in the raycode as well, which even didn't work correctly for all
situations (textures especially).
Done this by creating a new local struct RenderInput, which replaces usage
of the global struct Render R. The latter now only is used to denote
image size, viewmatrix, and the like.
Making the inner render loops using no globals caused 1000s of vars to
be changed... but the result definitely is much nicer code, which enables
making 'real' shaders in a next stage.
It also enabled me to remove the hacks from ray.c
Then i went to the task of removing redundant code. Especially the calculus
of texture coords took place (identical) in three locations.
Most obvious is the change in the unified render part, which is much less
code now; it uses the same rendering routines as normal render now.
(Note; not for halos yet!)
I also removed 6 files called 'shadowbuffer' something. This was experimen-
tal stuff from NaN days. And again saved a lot of double used code.
Finally I went over the blenkernel and blender/src calls to render stuff.
Here the same local data is used now, resulting in less dependency.
I also moved render-texture to the render module, this was still in Kernel.
(new file: texture.c)
So! After this commit I will check on the autofiles, to try to fix that.
MSVC people have to do it themselves.
This commit will need quite some testing help, but I'm around!
2003-12-21 21:52:51 +00:00
|
|
|
|
2005-07-17 04:17:33 +00:00
|
|
|
static void boundbox_displist(Object *ob);
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
void free_disp_elem(DispList *dl)
|
|
|
|
|
{
|
|
|
|
|
if(dl) {
|
|
|
|
|
if(dl->verts) MEM_freeN(dl->verts);
|
|
|
|
|
if(dl->nors) MEM_freeN(dl->nors);
|
|
|
|
|
if(dl->index) MEM_freeN(dl->index);
|
|
|
|
|
if(dl->col1) MEM_freeN(dl->col1);
|
|
|
|
|
if(dl->col2) MEM_freeN(dl->col2);
|
2005-08-14 06:08:41 +00:00
|
|
|
if(dl->bevelSplitFlag) MEM_freeN(dl->bevelSplitFlag);
|
2002-10-12 11:37:38 +00:00
|
|
|
MEM_freeN(dl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void freedisplist(ListBase *lb)
|
|
|
|
|
{
|
|
|
|
|
DispList *dl;
|
|
|
|
|
|
|
|
|
|
dl= lb->first;
|
|
|
|
|
while(dl) {
|
|
|
|
|
BLI_remlink(lb, dl);
|
|
|
|
|
free_disp_elem(dl);
|
|
|
|
|
dl= lb->first;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DispList *find_displist_create(ListBase *lb, int type)
|
|
|
|
|
{
|
|
|
|
|
DispList *dl;
|
|
|
|
|
|
|
|
|
|
dl= lb->first;
|
|
|
|
|
while(dl) {
|
|
|
|
|
if(dl->type==type) return dl;
|
|
|
|
|
dl= dl->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dl= MEM_callocN(sizeof(DispList), "find_disp");
|
|
|
|
|
dl->type= type;
|
|
|
|
|
BLI_addtail(lb, dl);
|
|
|
|
|
|
|
|
|
|
return dl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DispList *find_displist(ListBase *lb, int type)
|
|
|
|
|
{
|
|
|
|
|
DispList *dl;
|
|
|
|
|
|
|
|
|
|
dl= lb->first;
|
|
|
|
|
while(dl) {
|
|
|
|
|
if(dl->type==type) return dl;
|
|
|
|
|
dl= dl->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2004-10-29 15:39:01 +00:00
|
|
|
int displist_has_faces(ListBase *lb)
|
|
|
|
|
{
|
|
|
|
|
DispList *dl;
|
2007-12-11 14:19:05 +00:00
|
|
|
for(dl= lb->first; dl; dl= dl->next) {
|
2005-11-27 18:54:23 +00:00
|
|
|
if ELEM3(dl->type, DL_INDEX3, DL_INDEX4, DL_SURF)
|
2004-10-29 15:39:01 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
void copy_displist(ListBase *lbn, ListBase *lb)
|
|
|
|
|
{
|
|
|
|
|
DispList *dln, *dl;
|
|
|
|
|
|
|
|
|
|
lbn->first= lbn->last= 0;
|
|
|
|
|
|
|
|
|
|
dl= lb->first;
|
|
|
|
|
while(dl) {
|
|
|
|
|
|
|
|
|
|
dln= MEM_dupallocN(dl);
|
|
|
|
|
BLI_addtail(lbn, dln);
|
|
|
|
|
dln->verts= MEM_dupallocN(dl->verts);
|
|
|
|
|
dln->nors= MEM_dupallocN(dl->nors);
|
|
|
|
|
dln->index= MEM_dupallocN(dl->index);
|
|
|
|
|
dln->col1= MEM_dupallocN(dl->col1);
|
|
|
|
|
dln->col2= MEM_dupallocN(dl->col2);
|
|
|
|
|
|
|
|
|
|
dl= dl->next;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void addnormalsDispList(Object *ob, ListBase *lb)
|
|
|
|
|
{
|
|
|
|
|
DispList *dl = NULL;
|
|
|
|
|
float *vdata, *ndata, nor[3];
|
|
|
|
|
float *v1, *v2, *v3, *v4;
|
|
|
|
|
float *n1, *n2, *n3, *n4;
|
|
|
|
|
int a, b, p1, p2, p3, p4;
|
|
|
|
|
|
2005-07-27 20:16:41 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
dl= lb->first;
|
|
|
|
|
|
|
|
|
|
while(dl) {
|
|
|
|
|
if(dl->type==DL_INDEX3) {
|
2006-11-20 21:25:02 +00:00
|
|
|
if(dl->nors==NULL) {
|
2002-10-12 11:37:38 +00:00
|
|
|
dl->nors= MEM_callocN(sizeof(float)*3, "dlnors");
|
|
|
|
|
if(dl->verts[2]<0.0) dl->nors[2]= -1.0;
|
|
|
|
|
else dl->nors[2]= 1.0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(dl->type==DL_SURF) {
|
2006-11-20 21:25:02 +00:00
|
|
|
if(dl->nors==NULL) {
|
2002-10-12 11:37:38 +00:00
|
|
|
dl->nors= MEM_callocN(sizeof(float)*3*dl->nr*dl->parts, "dlnors");
|
|
|
|
|
|
|
|
|
|
vdata= dl->verts;
|
|
|
|
|
ndata= dl->nors;
|
|
|
|
|
|
|
|
|
|
for(a=0; a<dl->parts; a++) {
|
|
|
|
|
|
2004-05-29 16:17:46 +00:00
|
|
|
DL_SURFINDEX(dl->flag & DL_CYCL_U, dl->flag & DL_CYCL_V, dl->nr, dl->parts);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
v1= vdata+ 3*p1;
|
|
|
|
|
n1= ndata+ 3*p1;
|
|
|
|
|
v2= vdata+ 3*p2;
|
|
|
|
|
n2= ndata+ 3*p2;
|
|
|
|
|
v3= vdata+ 3*p3;
|
|
|
|
|
n3= ndata+ 3*p3;
|
|
|
|
|
v4= vdata+ 3*p4;
|
|
|
|
|
n4= ndata+ 3*p4;
|
|
|
|
|
|
|
|
|
|
for(; b<dl->nr; b++) {
|
|
|
|
|
|
|
|
|
|
CalcNormFloat4(v1, v3, v4, v2, nor);
|
|
|
|
|
|
|
|
|
|
VecAddf(n1, n1, nor);
|
|
|
|
|
VecAddf(n2, n2, nor);
|
|
|
|
|
VecAddf(n3, n3, nor);
|
|
|
|
|
VecAddf(n4, n4, nor);
|
|
|
|
|
|
|
|
|
|
v2= v1; v1+= 3;
|
|
|
|
|
v4= v3; v3+= 3;
|
|
|
|
|
n2= n1; n1+= 3;
|
|
|
|
|
n4= n3; n3+= 3;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
a= dl->parts*dl->nr;
|
|
|
|
|
v1= ndata;
|
|
|
|
|
while(a--) {
|
2007-04-04 13:18:41 +00:00
|
|
|
Normalize(v1);
|
2002-10-12 11:37:38 +00:00
|
|
|
v1+= 3;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
dl= dl->next;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-28 11:49:22 +00:00
|
|
|
void count_displist(ListBase *lb, int *totvert, int *totface)
|
|
|
|
|
{
|
|
|
|
|
DispList *dl;
|
|
|
|
|
|
|
|
|
|
dl= lb->first;
|
|
|
|
|
while(dl) {
|
|
|
|
|
|
|
|
|
|
switch(dl->type) {
|
|
|
|
|
case DL_SURF:
|
|
|
|
|
*totvert+= dl->nr*dl->parts;
|
|
|
|
|
*totface+= (dl->nr-1)*(dl->parts-1);
|
|
|
|
|
break;
|
|
|
|
|
case DL_INDEX3:
|
|
|
|
|
case DL_INDEX4:
|
|
|
|
|
*totvert+= dl->nr;
|
|
|
|
|
*totface+= dl->parts;
|
|
|
|
|
break;
|
|
|
|
|
case DL_POLY:
|
|
|
|
|
case DL_SEGM:
|
|
|
|
|
*totvert+= dl->nr*dl->parts;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dl= dl->next;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-11-20 21:25:02 +00:00
|
|
|
/* ***************************** shade displist. note colors now are in rgb(a) order ******************** */
|
2006-05-28 11:49:22 +00:00
|
|
|
|
|
|
|
|
/* create default shade input... save cpu cycles with ugly global */
|
2007-04-26 09:01:37 +00:00
|
|
|
/* XXXX bad code warning: local ShadeInput initialize... */
|
2006-05-28 11:49:22 +00:00
|
|
|
static ShadeInput shi;
|
|
|
|
|
static void init_fastshade_shadeinput(void)
|
|
|
|
|
{
|
|
|
|
|
memset(&shi, 0, sizeof(ShadeInput));
|
|
|
|
|
shi.lay= G.scene->lay;
|
|
|
|
|
shi.view[2]= -1.0f;
|
2006-12-05 18:02:43 +00:00
|
|
|
shi.passflag= SCE_PASS_COMBINED;
|
2007-04-26 09:01:37 +00:00
|
|
|
shi.combinedflag= -1;
|
2006-05-28 11:49:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static Render *fastshade_get_render(void)
|
|
|
|
|
{
|
|
|
|
|
Render *re= RE_GetRender("_Shade View_");
|
|
|
|
|
if(re==NULL) {
|
|
|
|
|
re= RE_NewRender("_Shade View_");
|
|
|
|
|
|
2007-11-28 22:21:12 +00:00
|
|
|
RE_Database_Baking(re, G.scene, 0, 0); /* 0= no faces */
|
2006-05-28 11:49:22 +00:00
|
|
|
}
|
|
|
|
|
return re;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* called on file reading */
|
|
|
|
|
void fastshade_free_render(void)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2006-05-28 11:49:22 +00:00
|
|
|
Render *re= RE_GetRender("_Shade View_");
|
|
|
|
|
|
|
|
|
|
if(re) {
|
|
|
|
|
RE_Database_Free(re);
|
|
|
|
|
RE_FreeRender(re);
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-03-27 16:15:44 +00:00
|
|
|
|
2006-12-22 07:41:29 +00:00
|
|
|
static int fastshade_customdata_layer_num(int n, int active)
|
|
|
|
|
{
|
|
|
|
|
/* make the active layer the first */
|
|
|
|
|
if (n == active) return 0;
|
|
|
|
|
else if (n < active) return n+1;
|
|
|
|
|
else return n;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void fastshade_customdata(CustomData *fdata, int a, int j, Material *ma)
|
2006-05-28 11:49:22 +00:00
|
|
|
{
|
2006-12-22 07:41:29 +00:00
|
|
|
CustomDataLayer *layer;
|
|
|
|
|
MTFace *mtface;
|
|
|
|
|
int index, n, needuv= ma->texco & TEXCO_UV;
|
|
|
|
|
char *vertcol;
|
2006-12-21 13:47:27 +00:00
|
|
|
|
2006-12-22 07:41:29 +00:00
|
|
|
shi.totuv= 0;
|
|
|
|
|
shi.totcol= 0;
|
|
|
|
|
|
|
|
|
|
for(index=0; index<fdata->totlayer; index++) {
|
|
|
|
|
layer= &fdata->layers[index];
|
|
|
|
|
|
|
|
|
|
if(needuv && layer->type == CD_MTFACE && shi.totuv < MAX_MTFACE) {
|
2007-05-02 01:40:27 +00:00
|
|
|
n= fastshade_customdata_layer_num(shi.totuv, layer->active_rnd);
|
2006-12-22 07:41:29 +00:00
|
|
|
mtface= &((MTFace*)layer->data)[a];
|
|
|
|
|
|
|
|
|
|
shi.uv[shi.totuv].uv[0]= 2.0f*mtface->uv[j][0]-1.0f;
|
|
|
|
|
shi.uv[shi.totuv].uv[1]= 2.0f*mtface->uv[j][1]-1.0f;
|
|
|
|
|
shi.uv[shi.totuv].uv[2]= 1.0f;
|
|
|
|
|
|
|
|
|
|
shi.uv[shi.totuv].name= layer->name;
|
|
|
|
|
shi.totuv++;
|
|
|
|
|
}
|
|
|
|
|
else if(layer->type == CD_MCOL && shi.totcol < MAX_MCOL) {
|
2007-05-02 01:40:27 +00:00
|
|
|
n= fastshade_customdata_layer_num(shi.totcol, layer->active_rnd);
|
2006-12-22 07:41:29 +00:00
|
|
|
vertcol= (char*)&((MCol*)layer->data)[a*4 + j];
|
|
|
|
|
|
|
|
|
|
shi.col[shi.totcol].col[0]= ((float)vertcol[3])/255.0f;
|
|
|
|
|
shi.col[shi.totcol].col[1]= ((float)vertcol[2])/255.0f;
|
|
|
|
|
shi.col[shi.totcol].col[2]= ((float)vertcol[1])/255.0f;
|
|
|
|
|
|
|
|
|
|
shi.col[shi.totcol].name= layer->name;
|
|
|
|
|
shi.totcol++;
|
|
|
|
|
}
|
2006-05-28 11:49:22 +00:00
|
|
|
}
|
2006-12-22 07:41:29 +00:00
|
|
|
|
|
|
|
|
if(needuv && shi.totuv == 0)
|
|
|
|
|
VECCOPY(shi.uv[0].uv, shi.lo);
|
|
|
|
|
|
|
|
|
|
if(shi.totcol)
|
|
|
|
|
VECCOPY(shi.vcol, shi.col[0].col);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void fastshade(float *co, float *nor, float *orco, Material *ma, char *col1, char *col2)
|
|
|
|
|
{
|
|
|
|
|
ShadeResult shr;
|
|
|
|
|
int a;
|
2006-05-28 11:49:22 +00:00
|
|
|
|
|
|
|
|
VECCOPY(shi.co, co);
|
|
|
|
|
shi.vn[0]= -nor[0];
|
|
|
|
|
shi.vn[1]= -nor[1];
|
|
|
|
|
shi.vn[2]= -nor[2];
|
|
|
|
|
VECCOPY(shi.vno, shi.vn);
|
2006-11-19 14:12:56 +00:00
|
|
|
VECCOPY(shi.facenor, shi.vn);
|
2006-05-28 11:49:22 +00:00
|
|
|
|
|
|
|
|
if(ma->texco) {
|
|
|
|
|
VECCOPY(shi.lo, orco);
|
|
|
|
|
|
|
|
|
|
if(ma->texco & TEXCO_GLOB) {
|
|
|
|
|
VECCOPY(shi.gl, shi.lo);
|
|
|
|
|
}
|
|
|
|
|
if(ma->texco & TEXCO_WINDOW) {
|
|
|
|
|
VECCOPY(shi.winco, shi.lo);
|
|
|
|
|
}
|
|
|
|
|
if(ma->texco & TEXCO_STICKY) {
|
|
|
|
|
VECCOPY(shi.sticky, shi.lo);
|
|
|
|
|
}
|
|
|
|
|
if(ma->texco & TEXCO_OBJECT) {
|
|
|
|
|
VECCOPY(shi.co, shi.lo);
|
|
|
|
|
}
|
|
|
|
|
if(ma->texco & TEXCO_NORM) {
|
|
|
|
|
VECCOPY(shi.orn, shi.vn);
|
|
|
|
|
}
|
|
|
|
|
if(ma->texco & TEXCO_REFL) {
|
|
|
|
|
float inp= 2.0*(shi.vn[2]);
|
|
|
|
|
shi.ref[0]= (inp*shi.vn[0]);
|
|
|
|
|
shi.ref[1]= (inp*shi.vn[1]);
|
|
|
|
|
shi.ref[2]= (-1.0+inp*shi.vn[2]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
shi.mat= ma; /* set each time... node shaders change it */
|
|
|
|
|
RE_shade_external(NULL, &shi, &shr);
|
|
|
|
|
|
|
|
|
|
a= 256.0f*(shr.combined[0]);
|
2006-11-20 21:25:02 +00:00
|
|
|
col1[0]= CLAMPIS(a, 0, 255);
|
2006-05-28 11:49:22 +00:00
|
|
|
a= 256.0f*(shr.combined[1]);
|
|
|
|
|
col1[1]= CLAMPIS(a, 0, 255);
|
2006-11-20 21:25:02 +00:00
|
|
|
a= 256.0f*(shr.combined[2]);
|
|
|
|
|
col1[2]= CLAMPIS(a, 0, 255);
|
2006-05-28 11:49:22 +00:00
|
|
|
|
|
|
|
|
if(col2) {
|
|
|
|
|
shi.vn[0]= -shi.vn[0];
|
|
|
|
|
shi.vn[1]= -shi.vn[1];
|
|
|
|
|
shi.vn[2]= -shi.vn[2];
|
|
|
|
|
|
|
|
|
|
shi.mat= ma; /* set each time... node shaders change it */
|
|
|
|
|
RE_shade_external(NULL, &shi, &shr);
|
|
|
|
|
|
|
|
|
|
a= 256.0f*(shr.combined[0]);
|
2006-11-20 21:25:02 +00:00
|
|
|
col2[0]= CLAMPIS(a, 0, 255);
|
2006-05-28 11:49:22 +00:00
|
|
|
a= 256.0f*(shr.combined[1]);
|
|
|
|
|
col2[1]= CLAMPIS(a, 0, 255);
|
2006-11-20 21:25:02 +00:00
|
|
|
a= 256.0f*(shr.combined[2]);
|
|
|
|
|
col2[2]= CLAMPIS(a, 0, 255);
|
2006-05-28 11:49:22 +00:00
|
|
|
}
|
2005-07-27 20:16:41 +00:00
|
|
|
}
|
|
|
|
|
|
2006-05-28 11:49:22 +00:00
|
|
|
static void init_fastshade_for_ob(Render *re, Object *ob, int *need_orco_r, float mat[4][4], float imat[3][3])
|
|
|
|
|
{
|
|
|
|
|
float tmat[4][4];
|
|
|
|
|
float amb[3]= {0.0f, 0.0f, 0.0f};
|
|
|
|
|
int a;
|
|
|
|
|
|
|
|
|
|
/* initialize globals in render */
|
|
|
|
|
RE_shade_external(re, NULL, NULL);
|
|
|
|
|
|
|
|
|
|
/* initialize global here */
|
|
|
|
|
init_fastshade_shadeinput();
|
|
|
|
|
|
|
|
|
|
RE_DataBase_GetView(re, tmat);
|
|
|
|
|
Mat4MulMat4(mat, ob->obmat, tmat);
|
|
|
|
|
|
|
|
|
|
Mat4Invert(tmat, mat);
|
|
|
|
|
Mat3CpyMat4(imat, tmat);
|
|
|
|
|
if(ob->transflag & OB_NEG_SCALE) Mat3MulFloat((float *)imat, -1.0);
|
|
|
|
|
|
|
|
|
|
if (need_orco_r) *need_orco_r= 0;
|
|
|
|
|
for(a=0; a<ob->totcol; a++) {
|
|
|
|
|
Material *ma= give_current_material(ob, a+1);
|
|
|
|
|
if(ma) {
|
|
|
|
|
init_render_material(ma, 0, amb);
|
|
|
|
|
|
|
|
|
|
if(ma->texco & TEXCO_ORCO) {
|
|
|
|
|
if (need_orco_r) *need_orco_r= 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void end_fastshade_for_ob(Object *ob)
|
|
|
|
|
{
|
|
|
|
|
int a;
|
|
|
|
|
|
|
|
|
|
for(a=0; a<ob->totcol; a++) {
|
|
|
|
|
Material *ma= give_current_material(ob, a+1);
|
|
|
|
|
if(ma)
|
|
|
|
|
end_render_material(ma);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void mesh_create_shadedColors(Render *re, Object *ob, int onlyForMesh, unsigned int **col1_r, unsigned int **col2_r)
|
2005-07-27 20:16:41 +00:00
|
|
|
{
|
|
|
|
|
Mesh *me= ob->data;
|
|
|
|
|
DerivedMesh *dm;
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
MVert *mvert;
|
|
|
|
|
MFace *mface;
|
2005-07-27 20:16:41 +00:00
|
|
|
unsigned int *col1, *col2;
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
float *orco, *vnors, *nors, imat[3][3], mat[4][4], vec[3];
|
2006-12-22 07:41:29 +00:00
|
|
|
int a, i, need_orco, totface, totvert;
|
2006-12-05 17:42:03 +00:00
|
|
|
CustomDataMask dataMask = CD_MASK_BAREMESH | CD_MASK_MCOL
|
|
|
|
|
| CD_MASK_MTFACE | CD_MASK_NORMAL;
|
2005-07-27 20:16:41 +00:00
|
|
|
|
2007-12-05 12:40:54 +00:00
|
|
|
|
2006-05-28 11:49:22 +00:00
|
|
|
init_fastshade_for_ob(re, ob, &need_orco, mat, imat);
|
2005-07-27 20:16:41 +00:00
|
|
|
|
2007-12-05 12:40:54 +00:00
|
|
|
if(need_orco)
|
|
|
|
|
dataMask |= CD_MASK_ORCO;
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
|
|
|
|
|
if (onlyForMesh)
|
2006-12-05 17:42:03 +00:00
|
|
|
dm = mesh_get_derived_deform(ob, dataMask);
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
else
|
2006-12-05 17:42:03 +00:00
|
|
|
dm = mesh_get_derived_final(ob, dataMask);
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
|
|
|
|
|
mvert = dm->getVertArray(dm);
|
|
|
|
|
mface = dm->getFaceArray(dm);
|
|
|
|
|
nors = dm->getFaceDataArray(dm, CD_NORMAL);
|
|
|
|
|
totvert = dm->getNumVerts(dm);
|
|
|
|
|
totface = dm->getNumFaces(dm);
|
2007-12-05 12:40:54 +00:00
|
|
|
orco= dm->getVertDataArray(dm, CD_ORCO);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-07-27 20:16:41 +00:00
|
|
|
if (onlyForMesh) {
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
col1 = *col1_r;
|
|
|
|
|
col2 = NULL;
|
2005-07-27 20:16:41 +00:00
|
|
|
} else {
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
*col1_r = col1 = MEM_mallocN(sizeof(*col1)*totface*4, "col1");
|
2005-03-29 06:46:11 +00:00
|
|
|
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
if (col2_r && (me->flag & ME_TWOSIDED))
|
2006-12-05 17:42:03 +00:00
|
|
|
col2 = MEM_mallocN(sizeof(*col2)*totface*4, "col2");
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
else
|
|
|
|
|
col2 = NULL;
|
|
|
|
|
|
|
|
|
|
if (col2_r) *col2_r = col2;
|
2005-07-27 20:16:41 +00:00
|
|
|
}
|
|
|
|
|
|
- added data arguments to deformer modifiers, in case someone wants
to write one that is based on geometry (and not just vertex position)
- added editmode versions of modifier deform/apply calls and flag
to tag modifiers that support editmode
- added isFinalCalc param to applyModifier, basically a switch to let
subsurf know if it is calc'ng orco or not (so it can deal with cache
appropriately). This is kinda hacky and perhaps I can come up with
a better solution (its also a waste to do a complete subdivide just
to get vertex locations).
- changed ccgsubsurf to not preallocate hash's to be approximately correct
size... this was probably not a big performance savings but means that
the order of faces returned by the iterator can vary after the first
call, this messes up orco calculation so dropped for time being.
- minor bug fix, meshes with only key didn't get vertex normals correctly
calc'd
- updated editmesh derivedmesh to support auxiliary locations
- changed mesh_calc_modifiers to alloc deformVerts on demand
- added editmesh_calc_modifiers for calculating editmesh cage and final
derivedmesh's
- bug fix, update shadedisplist to always calc colors (even if totvert==0)
- changed load_editMesh and make_edge to build me->medge even if totedge==0
(incremental subsurf checks this)
todo: add drawFacesTex for ccgderivedmesh
So, modifiers in editmode are back (which means auto-mirror
in edit mode works now) although still not finished. Currently
no cage is computed, the cage is always the base mesh (in
other words, Optimal edge style editing is off), and the final
mesh currently includes all modifiers that work in edit mode
(including lattice and curve). At some point there will be toggles
for which modifiers affect the final/cage editmode derivedmesh's.
Also, very nice new feature is that incremental subsurf in object
mode returns a ccgderivedmesh object instead of copying to a new
displistmesh. This can make a *huge* speed difference, and is very
nice for working with deformed armatures (esp. with only small
per frame changes).
2005-07-22 07:37:15 +00:00
|
|
|
/* vertexnormals */
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
vnors= MEM_mallocN(totvert*3*sizeof(float), "vnors disp");
|
|
|
|
|
for (a=0; a<totvert; a++) {
|
|
|
|
|
MVert *mv = &mvert[a];
|
2005-07-27 20:16:41 +00:00
|
|
|
float *vn= &vnors[a*3];
|
|
|
|
|
float xn= mv->no[0];
|
|
|
|
|
float yn= mv->no[1];
|
|
|
|
|
float zn= mv->no[2];
|
|
|
|
|
|
- added data arguments to deformer modifiers, in case someone wants
to write one that is based on geometry (and not just vertex position)
- added editmode versions of modifier deform/apply calls and flag
to tag modifiers that support editmode
- added isFinalCalc param to applyModifier, basically a switch to let
subsurf know if it is calc'ng orco or not (so it can deal with cache
appropriately). This is kinda hacky and perhaps I can come up with
a better solution (its also a waste to do a complete subdivide just
to get vertex locations).
- changed ccgsubsurf to not preallocate hash's to be approximately correct
size... this was probably not a big performance savings but means that
the order of faces returned by the iterator can vary after the first
call, this messes up orco calculation so dropped for time being.
- minor bug fix, meshes with only key didn't get vertex normals correctly
calc'd
- updated editmesh derivedmesh to support auxiliary locations
- changed mesh_calc_modifiers to alloc deformVerts on demand
- added editmesh_calc_modifiers for calculating editmesh cage and final
derivedmesh's
- bug fix, update shadedisplist to always calc colors (even if totvert==0)
- changed load_editMesh and make_edge to build me->medge even if totedge==0
(incremental subsurf checks this)
todo: add drawFacesTex for ccgderivedmesh
So, modifiers in editmode are back (which means auto-mirror
in edit mode works now) although still not finished. Currently
no cage is computed, the cage is always the base mesh (in
other words, Optimal edge style editing is off), and the final
mesh currently includes all modifiers that work in edit mode
(including lattice and curve). At some point there will be toggles
for which modifiers affect the final/cage editmode derivedmesh's.
Also, very nice new feature is that incremental subsurf in object
mode returns a ccgderivedmesh object instead of copying to a new
displistmesh. This can make a *huge* speed difference, and is very
nice for working with deformed armatures (esp. with only small
per frame changes).
2005-07-22 07:37:15 +00:00
|
|
|
/* transpose ! */
|
2005-07-27 20:16:41 +00:00
|
|
|
vn[0]= imat[0][0]*xn+imat[0][1]*yn+imat[0][2]*zn;
|
|
|
|
|
vn[1]= imat[1][0]*xn+imat[1][1]*yn+imat[1][2]*zn;
|
|
|
|
|
vn[2]= imat[2][0]*xn+imat[2][1]*yn+imat[2][2]*zn;
|
2007-04-04 13:18:41 +00:00
|
|
|
Normalize(vn);
|
2005-07-27 20:16:41 +00:00
|
|
|
}
|
|
|
|
|
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
for (i=0; i<totface; i++) {
|
|
|
|
|
MFace *mf= &mface[i];
|
2006-11-19 14:12:56 +00:00
|
|
|
Material *ma= give_current_material(ob, mf->mat_nr+1);
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
int j, vidx[4], nverts= mf->v4?4:3;
|
|
|
|
|
unsigned char *col1base= (unsigned char*) &col1[i*4];
|
|
|
|
|
unsigned char *col2base= (unsigned char*) (col2?&col2[i*4]:NULL);
|
|
|
|
|
float nor[3], n1[3];
|
|
|
|
|
|
2006-05-28 11:49:22 +00:00
|
|
|
if(ma==NULL) ma= &defmaterial;
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
|
|
|
|
|
vidx[0]= mf->v1;
|
|
|
|
|
vidx[1]= mf->v2;
|
|
|
|
|
vidx[2]= mf->v3;
|
|
|
|
|
vidx[3]= mf->v4;
|
|
|
|
|
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
if (nors) {
|
|
|
|
|
VECCOPY(nor, &nors[i*3]);
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
} else {
|
|
|
|
|
if (mf->v4)
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
CalcNormFloat4(mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co, mvert[mf->v4].co, nor);
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
else
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
CalcNormFloat(mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co, nor);
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
}
|
2005-07-17 18:37:27 +00:00
|
|
|
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2];
|
|
|
|
|
n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2];
|
|
|
|
|
n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2];
|
2007-04-04 13:18:41 +00:00
|
|
|
Normalize(n1);
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
|
|
|
|
|
for (j=0; j<nverts; j++) {
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
MVert *mv= &mvert[vidx[j]];
|
2006-10-26 23:34:44 +00:00
|
|
|
char *col1= (char*)&col1base[j*4];
|
|
|
|
|
char *col2= (char*)(col2base?&col2base[j*4]:NULL);
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
float *vn = (mf->flag & ME_SMOOTH)?&vnors[3*vidx[j]]:n1;
|
2006-11-19 14:12:56 +00:00
|
|
|
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
VECCOPY(vec, mv->co);
|
|
|
|
|
Mat4MulVecfl(mat, vec);
|
2006-11-19 14:12:56 +00:00
|
|
|
vec[0]+= 0.001*vn[0];
|
|
|
|
|
vec[1]+= 0.001*vn[1];
|
|
|
|
|
vec[2]+= 0.001*vn[2];
|
2006-12-22 07:41:29 +00:00
|
|
|
|
|
|
|
|
fastshade_customdata(&dm->faceData, i, j, ma);
|
|
|
|
|
fastshade(vec, vn, orco?&orco[vidx[j]*3]:mv->co, ma, col1, col2);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
}
|
2005-07-27 20:16:41 +00:00
|
|
|
MEM_freeN(vnors);
|
2005-07-17 18:37:27 +00:00
|
|
|
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
dm->release(dm);
|
2005-07-27 20:16:41 +00:00
|
|
|
|
2006-05-28 11:49:22 +00:00
|
|
|
end_fastshade_for_ob(ob);
|
2005-07-27 20:16:41 +00:00
|
|
|
}
|
|
|
|
|
|
2006-06-21 15:14:44 +00:00
|
|
|
void shadeMeshMCol(Object *ob, Mesh *me)
|
|
|
|
|
{
|
2006-11-20 21:25:02 +00:00
|
|
|
int a;
|
|
|
|
|
char *cp;
|
2006-12-22 07:41:29 +00:00
|
|
|
unsigned int *mcol= (unsigned int*)me->mcol;
|
2006-11-20 21:25:02 +00:00
|
|
|
|
2006-06-21 15:14:44 +00:00
|
|
|
Render *re= fastshade_get_render();
|
2006-12-22 07:41:29 +00:00
|
|
|
mesh_create_shadedColors(re, ob, 1, &mcol, NULL);
|
|
|
|
|
me->mcol= (MCol*)mcol;
|
2006-12-21 13:47:27 +00:00
|
|
|
|
2006-11-20 21:25:02 +00:00
|
|
|
/* swap bytes */
|
|
|
|
|
for(cp= (char *)me->mcol, a= 4*me->totface; a>0; a--, cp+=4) {
|
|
|
|
|
SWAP(char, cp[0], cp[3]);
|
|
|
|
|
SWAP(char, cp[1], cp[2]);
|
|
|
|
|
}
|
2006-06-21 15:14:44 +00:00
|
|
|
}
|
|
|
|
|
|
Big commit with work on Groups & Libraries:
-> Any Group Duplicate now can get local timing and local NLA override. This
enables to control the entire animation system of the Group.
Two methods for this have been implemented.
1) The quick way: just give the duplicator a "Startframe" offset.
2) Advanced: in the NLA Editor you can add ActionStrips to the duplicator
to override NLA/action of any Grouped Object.
For "Group NLA" to work, an ActionStrip needs to know which Object in a
group it controls. On adding a strip, the code checks if an Action was
already used by an Object in the Group, and assigns it automatic to that
Object.
You can also set this in the Nkey "Properties" panel for the strip.
Change in NLA: the SHIFT+A "Add strip" command now always adds strips to
the active Object. (It used to check where mouse was). This allows to add
NLA strips to Objects that didn't have actions/nla yet.
Important note: In Blender, duplicates are fully procedural and generated
on the fly for each redraw. This means that redraw speed equals to stepping
through frames, when using animated Duplicated Groups.
-> Recoded entire duplicator system
The old method was antique and clumsy, using globals and full temporal
copies of Object. The new system is nicer in control, faster, and since it
doesn't use temporal object copies anymore, it works better with Derived
Mesh and DisplayList and rendering.
By centralizing the code for duplicating, more options can be easier added.
Features to note:
- Duplicates now draw selected/unselected based on its Duplicator setting.
- Same goes for the drawtype (wire, solid, selection outline, etc)
- Duplicated Groups can be normally selected too
Bonus goodie: SHIFT+A (Toolbox) now has entry "Add group" too, with a
listing of all groups, allowing to add Group instances immediate.
-> Library System
- SHIFT+F4 data browse now shows the entire path for linked data
- Outliner draws Library Icons to denote linked data
- Outliner operation added: "Make Local" for library data.
- Outliner now also draws Groups in regular view, allowing to unlink too.
-> Fixes
- depsgraph missed signal update for bone-parented Objects
- on reading file, the entire database was tagged to "recalc" fully,
causing unnecessary slowdown on reading.
Might have missed stuff... :)
2005-12-11 13:23:30 +00:00
|
|
|
/* has base pointer, to check for layer */
|
2006-05-28 11:49:22 +00:00
|
|
|
/* called from drawobject.c */
|
Big commit with work on Groups & Libraries:
-> Any Group Duplicate now can get local timing and local NLA override. This
enables to control the entire animation system of the Group.
Two methods for this have been implemented.
1) The quick way: just give the duplicator a "Startframe" offset.
2) Advanced: in the NLA Editor you can add ActionStrips to the duplicator
to override NLA/action of any Grouped Object.
For "Group NLA" to work, an ActionStrip needs to know which Object in a
group it controls. On adding a strip, the code checks if an Action was
already used by an Object in the Group, and assigns it automatic to that
Object.
You can also set this in the Nkey "Properties" panel for the strip.
Change in NLA: the SHIFT+A "Add strip" command now always adds strips to
the active Object. (It used to check where mouse was). This allows to add
NLA strips to Objects that didn't have actions/nla yet.
Important note: In Blender, duplicates are fully procedural and generated
on the fly for each redraw. This means that redraw speed equals to stepping
through frames, when using animated Duplicated Groups.
-> Recoded entire duplicator system
The old method was antique and clumsy, using globals and full temporal
copies of Object. The new system is nicer in control, faster, and since it
doesn't use temporal object copies anymore, it works better with Derived
Mesh and DisplayList and rendering.
By centralizing the code for duplicating, more options can be easier added.
Features to note:
- Duplicates now draw selected/unselected based on its Duplicator setting.
- Same goes for the drawtype (wire, solid, selection outline, etc)
- Duplicated Groups can be normally selected too
Bonus goodie: SHIFT+A (Toolbox) now has entry "Add group" too, with a
listing of all groups, allowing to add Group instances immediate.
-> Library System
- SHIFT+F4 data browse now shows the entire path for linked data
- Outliner draws Library Icons to denote linked data
- Outliner operation added: "Make Local" for library data.
- Outliner now also draws Groups in regular view, allowing to unlink too.
-> Fixes
- depsgraph missed signal update for bone-parented Objects
- on reading file, the entire database was tagged to "recalc" fully,
causing unnecessary slowdown on reading.
Might have missed stuff... :)
2005-12-11 13:23:30 +00:00
|
|
|
void shadeDispList(Base *base)
|
2005-07-27 20:16:41 +00:00
|
|
|
{
|
Big commit with work on Groups & Libraries:
-> Any Group Duplicate now can get local timing and local NLA override. This
enables to control the entire animation system of the Group.
Two methods for this have been implemented.
1) The quick way: just give the duplicator a "Startframe" offset.
2) Advanced: in the NLA Editor you can add ActionStrips to the duplicator
to override NLA/action of any Grouped Object.
For "Group NLA" to work, an ActionStrip needs to know which Object in a
group it controls. On adding a strip, the code checks if an Action was
already used by an Object in the Group, and assigns it automatic to that
Object.
You can also set this in the Nkey "Properties" panel for the strip.
Change in NLA: the SHIFT+A "Add strip" command now always adds strips to
the active Object. (It used to check where mouse was). This allows to add
NLA strips to Objects that didn't have actions/nla yet.
Important note: In Blender, duplicates are fully procedural and generated
on the fly for each redraw. This means that redraw speed equals to stepping
through frames, when using animated Duplicated Groups.
-> Recoded entire duplicator system
The old method was antique and clumsy, using globals and full temporal
copies of Object. The new system is nicer in control, faster, and since it
doesn't use temporal object copies anymore, it works better with Derived
Mesh and DisplayList and rendering.
By centralizing the code for duplicating, more options can be easier added.
Features to note:
- Duplicates now draw selected/unselected based on its Duplicator setting.
- Same goes for the drawtype (wire, solid, selection outline, etc)
- Duplicated Groups can be normally selected too
Bonus goodie: SHIFT+A (Toolbox) now has entry "Add group" too, with a
listing of all groups, allowing to add Group instances immediate.
-> Library System
- SHIFT+F4 data browse now shows the entire path for linked data
- Outliner draws Library Icons to denote linked data
- Outliner operation added: "Make Local" for library data.
- Outliner now also draws Groups in regular view, allowing to unlink too.
-> Fixes
- depsgraph missed signal update for bone-parented Objects
- on reading file, the entire database was tagged to "recalc" fully,
causing unnecessary slowdown on reading.
Might have missed stuff... :)
2005-12-11 13:23:30 +00:00
|
|
|
Object *ob= base->object;
|
2005-07-27 20:16:41 +00:00
|
|
|
DispList *dl, *dlob;
|
|
|
|
|
Material *ma = NULL;
|
|
|
|
|
Curve *cu;
|
2006-05-28 11:49:22 +00:00
|
|
|
Render *re;
|
2005-07-27 20:16:41 +00:00
|
|
|
float imat[3][3], mat[4][4], vec[3];
|
|
|
|
|
float *fp, *nor, n1[3];
|
|
|
|
|
unsigned int *col1;
|
2006-03-27 16:15:44 +00:00
|
|
|
int a, need_orco;
|
2006-05-28 11:49:22 +00:00
|
|
|
|
|
|
|
|
re= fastshade_get_render();
|
|
|
|
|
|
2005-07-27 20:16:41 +00:00
|
|
|
dl = find_displist(&ob->disp, DL_VERTCOL);
|
|
|
|
|
if (dl) {
|
|
|
|
|
BLI_remlink(&ob->disp, dl);
|
|
|
|
|
free_disp_elem(dl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(ob->type==OB_MESH) {
|
|
|
|
|
dl= MEM_callocN(sizeof(DispList), "displistshade");
|
|
|
|
|
dl->type= DL_VERTCOL;
|
2005-07-17 18:37:27 +00:00
|
|
|
|
2006-05-28 11:49:22 +00:00
|
|
|
mesh_create_shadedColors(re, ob, 0, &dl->col1, &dl->col2);
|
2007-01-22 03:57:41 +00:00
|
|
|
|
|
|
|
|
/* add dl to ob->disp after mesh_create_shadedColors, because it
|
|
|
|
|
might indirectly free ob->disp */
|
|
|
|
|
BLI_addtail(&ob->disp, dl);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2006-05-28 11:49:22 +00:00
|
|
|
else {
|
2005-07-27 20:16:41 +00:00
|
|
|
|
2006-05-28 11:49:22 +00:00
|
|
|
init_fastshade_for_ob(re, ob, &need_orco, mat, imat);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2006-05-28 11:49:22 +00:00
|
|
|
if ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT) {
|
|
|
|
|
|
|
|
|
|
/* now we need the normals */
|
|
|
|
|
cu= ob->data;
|
|
|
|
|
dl= cu->disp.first;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2006-05-28 11:49:22 +00:00
|
|
|
while(dl) {
|
|
|
|
|
dlob= MEM_callocN(sizeof(DispList), "displistshade");
|
|
|
|
|
BLI_addtail(&ob->disp, dlob);
|
|
|
|
|
dlob->type= DL_VERTCOL;
|
|
|
|
|
dlob->parts= dl->parts;
|
|
|
|
|
dlob->nr= dl->nr;
|
|
|
|
|
|
|
|
|
|
if(dl->type==DL_INDEX3) {
|
|
|
|
|
col1= dlob->col1= MEM_mallocN(sizeof(int)*dl->nr, "col1");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
col1= dlob->col1= MEM_mallocN(sizeof(int)*dl->parts*dl->nr, "col1");
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2006-05-28 11:49:22 +00:00
|
|
|
ma= give_current_material(ob, dl->col+1);
|
|
|
|
|
if(ma==NULL) ma= &defmaterial;
|
|
|
|
|
|
|
|
|
|
if(dl->type==DL_INDEX3) {
|
|
|
|
|
if(dl->nors) {
|
|
|
|
|
/* there's just one normal */
|
|
|
|
|
n1[0]= imat[0][0]*dl->nors[0]+imat[0][1]*dl->nors[1]+imat[0][2]*dl->nors[2];
|
|
|
|
|
n1[1]= imat[1][0]*dl->nors[0]+imat[1][1]*dl->nors[1]+imat[1][2]*dl->nors[2];
|
|
|
|
|
n1[2]= imat[2][0]*dl->nors[0]+imat[2][1]*dl->nors[1]+imat[2][2]*dl->nors[2];
|
2007-04-04 13:18:41 +00:00
|
|
|
Normalize(n1);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2006-05-28 11:49:22 +00:00
|
|
|
fp= dl->verts;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2006-05-28 11:49:22 +00:00
|
|
|
a= dl->nr;
|
|
|
|
|
while(a--) {
|
|
|
|
|
VECCOPY(vec, fp);
|
|
|
|
|
Mat4MulVecfl(mat, vec);
|
|
|
|
|
|
2006-12-22 07:41:29 +00:00
|
|
|
fastshade(vec, n1, fp, ma, (char *)col1, NULL);
|
2006-05-28 11:49:22 +00:00
|
|
|
|
|
|
|
|
fp+= 3; col1++;
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
2006-05-28 11:49:22 +00:00
|
|
|
else if(dl->type==DL_SURF) {
|
|
|
|
|
if(dl->nors) {
|
|
|
|
|
a= dl->nr*dl->parts;
|
|
|
|
|
fp= dl->verts;
|
|
|
|
|
nor= dl->nors;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2006-05-28 11:49:22 +00:00
|
|
|
while(a--) {
|
|
|
|
|
VECCOPY(vec, fp);
|
|
|
|
|
Mat4MulVecfl(mat, vec);
|
|
|
|
|
|
|
|
|
|
n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2];
|
|
|
|
|
n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2];
|
|
|
|
|
n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2];
|
2007-04-04 13:18:41 +00:00
|
|
|
Normalize(n1);
|
2006-05-28 11:49:22 +00:00
|
|
|
|
2006-12-22 07:41:29 +00:00
|
|
|
fastshade(vec, n1, fp, ma, (char *)col1, NULL);
|
2006-05-28 11:49:22 +00:00
|
|
|
|
|
|
|
|
fp+= 3; nor+= 3; col1++;
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
2006-05-28 11:49:22 +00:00
|
|
|
dl= dl->next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
2006-05-28 11:49:22 +00:00
|
|
|
else if(ob->type==OB_MBALL) {
|
|
|
|
|
/* there are normals already */
|
|
|
|
|
dl= ob->disp.first;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2006-05-28 11:49:22 +00:00
|
|
|
while(dl) {
|
|
|
|
|
|
|
|
|
|
if(dl->type==DL_INDEX4) {
|
|
|
|
|
if(dl->nors) {
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2006-05-28 11:49:22 +00:00
|
|
|
if(dl->col1) MEM_freeN(dl->col1);
|
|
|
|
|
col1= dl->col1= MEM_mallocN(sizeof(int)*dl->nr, "col1");
|
|
|
|
|
|
|
|
|
|
ma= give_current_material(ob, dl->col+1);
|
|
|
|
|
if(ma==NULL) ma= &defmaterial;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2006-05-28 11:49:22 +00:00
|
|
|
fp= dl->verts;
|
|
|
|
|
nor= dl->nors;
|
|
|
|
|
|
|
|
|
|
a= dl->nr;
|
|
|
|
|
while(a--) {
|
|
|
|
|
VECCOPY(vec, fp);
|
|
|
|
|
Mat4MulVecfl(mat, vec);
|
|
|
|
|
|
|
|
|
|
/* transpose ! */
|
|
|
|
|
n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2];
|
|
|
|
|
n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2];
|
|
|
|
|
n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2];
|
2007-04-04 13:18:41 +00:00
|
|
|
Normalize(n1);
|
2006-05-28 11:49:22 +00:00
|
|
|
|
2006-12-22 07:41:29 +00:00
|
|
|
fastshade(vec, n1, fp, ma, (char *)col1, NULL);
|
2006-05-28 11:49:22 +00:00
|
|
|
|
|
|
|
|
fp+= 3; col1++; nor+= 3;
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
2006-05-28 11:49:22 +00:00
|
|
|
dl= dl->next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
2006-05-28 11:49:22 +00:00
|
|
|
|
|
|
|
|
end_fastshade_for_ob(ob);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-28 11:49:22 +00:00
|
|
|
/* frees render and shade part of displists */
|
2006-12-08 09:40:44 +00:00
|
|
|
/* note: dont do a shade again, until a redraw happens */
|
2002-10-12 11:37:38 +00:00
|
|
|
void reshadeall_displist(void)
|
|
|
|
|
{
|
|
|
|
|
Base *base;
|
|
|
|
|
Object *ob;
|
|
|
|
|
|
2006-05-28 11:49:22 +00:00
|
|
|
fastshade_free_render();
|
2002-10-12 11:37:38 +00:00
|
|
|
|
Big commit with work on Groups & Libraries:
-> Any Group Duplicate now can get local timing and local NLA override. This
enables to control the entire animation system of the Group.
Two methods for this have been implemented.
1) The quick way: just give the duplicator a "Startframe" offset.
2) Advanced: in the NLA Editor you can add ActionStrips to the duplicator
to override NLA/action of any Grouped Object.
For "Group NLA" to work, an ActionStrip needs to know which Object in a
group it controls. On adding a strip, the code checks if an Action was
already used by an Object in the Group, and assigns it automatic to that
Object.
You can also set this in the Nkey "Properties" panel for the strip.
Change in NLA: the SHIFT+A "Add strip" command now always adds strips to
the active Object. (It used to check where mouse was). This allows to add
NLA strips to Objects that didn't have actions/nla yet.
Important note: In Blender, duplicates are fully procedural and generated
on the fly for each redraw. This means that redraw speed equals to stepping
through frames, when using animated Duplicated Groups.
-> Recoded entire duplicator system
The old method was antique and clumsy, using globals and full temporal
copies of Object. The new system is nicer in control, faster, and since it
doesn't use temporal object copies anymore, it works better with Derived
Mesh and DisplayList and rendering.
By centralizing the code for duplicating, more options can be easier added.
Features to note:
- Duplicates now draw selected/unselected based on its Duplicator setting.
- Same goes for the drawtype (wire, solid, selection outline, etc)
- Duplicated Groups can be normally selected too
Bonus goodie: SHIFT+A (Toolbox) now has entry "Add group" too, with a
listing of all groups, allowing to add Group instances immediate.
-> Library System
- SHIFT+F4 data browse now shows the entire path for linked data
- Outliner draws Library Icons to denote linked data
- Outliner operation added: "Make Local" for library data.
- Outliner now also draws Groups in regular view, allowing to unlink too.
-> Fixes
- depsgraph missed signal update for bone-parented Objects
- on reading file, the entire database was tagged to "recalc" fully,
causing unnecessary slowdown on reading.
Might have missed stuff... :)
2005-12-11 13:23:30 +00:00
|
|
|
for(base= G.scene->base.first; base; base= base->next) {
|
|
|
|
|
ob= base->object;
|
2008-09-19 21:52:15 +00:00
|
|
|
|
|
|
|
|
if(ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL))
|
|
|
|
|
freedisplist(&ob->disp);
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
if(base->lay & G.scene->lay) {
|
2003-04-25 15:48:11 +00:00
|
|
|
/* Metaballs have standard displist at the Object */
|
Big commit with work on Groups & Libraries:
-> Any Group Duplicate now can get local timing and local NLA override. This
enables to control the entire animation system of the Group.
Two methods for this have been implemented.
1) The quick way: just give the duplicator a "Startframe" offset.
2) Advanced: in the NLA Editor you can add ActionStrips to the duplicator
to override NLA/action of any Grouped Object.
For "Group NLA" to work, an ActionStrip needs to know which Object in a
group it controls. On adding a strip, the code checks if an Action was
already used by an Object in the Group, and assigns it automatic to that
Object.
You can also set this in the Nkey "Properties" panel for the strip.
Change in NLA: the SHIFT+A "Add strip" command now always adds strips to
the active Object. (It used to check where mouse was). This allows to add
NLA strips to Objects that didn't have actions/nla yet.
Important note: In Blender, duplicates are fully procedural and generated
on the fly for each redraw. This means that redraw speed equals to stepping
through frames, when using animated Duplicated Groups.
-> Recoded entire duplicator system
The old method was antique and clumsy, using globals and full temporal
copies of Object. The new system is nicer in control, faster, and since it
doesn't use temporal object copies anymore, it works better with Derived
Mesh and DisplayList and rendering.
By centralizing the code for duplicating, more options can be easier added.
Features to note:
- Duplicates now draw selected/unselected based on its Duplicator setting.
- Same goes for the drawtype (wire, solid, selection outline, etc)
- Duplicated Groups can be normally selected too
Bonus goodie: SHIFT+A (Toolbox) now has entry "Add group" too, with a
listing of all groups, allowing to add Group instances immediate.
-> Library System
- SHIFT+F4 data browse now shows the entire path for linked data
- Outliner draws Library Icons to denote linked data
- Outliner operation added: "Make Local" for library data.
- Outliner now also draws Groups in regular view, allowing to unlink too.
-> Fixes
- depsgraph missed signal update for bone-parented Objects
- on reading file, the entire database was tagged to "recalc" fully,
causing unnecessary slowdown on reading.
Might have missed stuff... :)
2005-12-11 13:23:30 +00:00
|
|
|
if(ob->type==OB_MBALL) shadeDispList(base);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-28 11:49:22 +00:00
|
|
|
/* ****************** make displists ********************* */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-08-14 06:08:41 +00:00
|
|
|
static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
Nurb *nu;
|
|
|
|
|
DispList *dl;
|
|
|
|
|
BezTriple *bezt, *prevbezt;
|
|
|
|
|
BPoint *bp;
|
|
|
|
|
float *data, *v1, *v2;
|
2006-02-07 19:59:02 +00:00
|
|
|
int a, len, resolu;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
nu= nubase->first;
|
|
|
|
|
while(nu) {
|
|
|
|
|
if(nu->hide==0) {
|
2006-02-07 19:59:02 +00:00
|
|
|
|
|
|
|
|
if(G.rendering && cu->resolu_ren!=0)
|
|
|
|
|
resolu= cu->resolu_ren;
|
|
|
|
|
else
|
|
|
|
|
resolu= nu->resolu;
|
|
|
|
|
|
2008-05-26 09:50:46 +00:00
|
|
|
if(!check_valid_nurb_u(nu));
|
2006-11-03 15:55:43 +00:00
|
|
|
else if((nu->type & 7)==CU_BEZIER) {
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2003-04-25 15:48:11 +00:00
|
|
|
/* count */
|
2002-10-12 11:37:38 +00:00
|
|
|
len= 0;
|
|
|
|
|
a= nu->pntsu-1;
|
2006-08-13 07:37:51 +00:00
|
|
|
if(nu->flagu & CU_CYCLIC) a++;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
prevbezt= nu->bezt;
|
|
|
|
|
bezt= prevbezt+1;
|
|
|
|
|
while(a--) {
|
2006-08-13 07:37:51 +00:00
|
|
|
if(a==0 && (nu->flagu & CU_CYCLIC)) bezt= nu->bezt;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
if(prevbezt->h2==HD_VECT && bezt->h1==HD_VECT) len++;
|
2006-02-07 19:59:02 +00:00
|
|
|
else len+= resolu;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2006-08-13 07:37:51 +00:00
|
|
|
if(a==0 && (nu->flagu & CU_CYCLIC)==0) len++;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
prevbezt= bezt;
|
|
|
|
|
bezt++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dl= MEM_callocN(sizeof(DispList), "makeDispListbez");
|
2005-07-16 19:07:02 +00:00
|
|
|
/* len+1 because of 'forward_diff_bezier' function */
|
2002-10-12 11:37:38 +00:00
|
|
|
dl->verts= MEM_callocN( (len+1)*3*sizeof(float), "dlverts");
|
|
|
|
|
BLI_addtail(dispbase, dl);
|
|
|
|
|
dl->parts= 1;
|
|
|
|
|
dl->nr= len;
|
|
|
|
|
dl->col= nu->mat_nr;
|
2005-06-17 21:04:27 +00:00
|
|
|
dl->charidx= nu->charidx;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
data= dl->verts;
|
|
|
|
|
|
2008-05-26 12:50:00 +00:00
|
|
|
if(nu->flagu & CU_CYCLIC) {
|
2002-10-12 11:37:38 +00:00
|
|
|
dl->type= DL_POLY;
|
|
|
|
|
a= nu->pntsu;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
dl->type= DL_SEGM;
|
|
|
|
|
a= nu->pntsu-1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
prevbezt= nu->bezt;
|
|
|
|
|
bezt= prevbezt+1;
|
|
|
|
|
|
|
|
|
|
while(a--) {
|
|
|
|
|
if(a==0 && dl->type== DL_POLY) bezt= nu->bezt;
|
|
|
|
|
|
|
|
|
|
if(prevbezt->h2==HD_VECT && bezt->h1==HD_VECT) {
|
|
|
|
|
VECCOPY(data, prevbezt->vec[1]);
|
|
|
|
|
data+= 3;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
v1= prevbezt->vec[1];
|
|
|
|
|
v2= bezt->vec[0];
|
2006-02-07 19:59:02 +00:00
|
|
|
forward_diff_bezier(v1[0], v1[3], v2[0], v2[3], data, resolu, 3);
|
|
|
|
|
forward_diff_bezier(v1[1], v1[4], v2[1], v2[4], data+1, resolu, 3);
|
|
|
|
|
forward_diff_bezier(v1[2], v1[5], v2[2], v2[5], data+2, resolu, 3);
|
|
|
|
|
data+= 3*resolu;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(a==0 && dl->type==DL_SEGM) {
|
|
|
|
|
VECCOPY(data, bezt->vec[1]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
prevbezt= bezt;
|
|
|
|
|
bezt++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if((nu->type & 7)==CU_NURBS) {
|
2008-09-23 06:26:48 +00:00
|
|
|
len= (resolu*SEGMENTSU(nu))+1;
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
dl= MEM_callocN(sizeof(DispList), "makeDispListsurf");
|
|
|
|
|
dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts");
|
|
|
|
|
BLI_addtail(dispbase, dl);
|
|
|
|
|
dl->parts= 1;
|
|
|
|
|
dl->nr= len;
|
|
|
|
|
dl->col= nu->mat_nr;
|
2006-02-02 12:13:08 +00:00
|
|
|
dl->charidx = nu->charidx;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
data= dl->verts;
|
2008-05-26 12:50:00 +00:00
|
|
|
if(nu->flagu & CU_CYCLIC) dl->type= DL_POLY;
|
2002-10-12 11:37:38 +00:00
|
|
|
else dl->type= DL_SEGM;
|
2008-09-23 13:35:32 +00:00
|
|
|
makeNurbcurve(nu, data, NULL, NULL, resolu);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
else if((nu->type & 7)==CU_POLY) {
|
|
|
|
|
len= nu->pntsu;
|
|
|
|
|
dl= MEM_callocN(sizeof(DispList), "makeDispListpoly");
|
|
|
|
|
dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts");
|
|
|
|
|
BLI_addtail(dispbase, dl);
|
|
|
|
|
dl->parts= 1;
|
|
|
|
|
dl->nr= len;
|
|
|
|
|
dl->col= nu->mat_nr;
|
More text object fancyness, and fixes:
- "Flush" is now split into two seperate Alignment modes "Flush" and
"Justify":
- Justify does exactly the same as a normal word processor's justify
function does, and in addition, it uses *whitespace* instead of
*character spacing* (kerning) to fill lines. Much more readable.
- Flush is pretty much the old Blender "Flush" mode - and as such it
uses character spacing to fill lines. Just as Justify, this only
works with at least one textframe.
- Underlining for text objects. Not a lot to explain. New button "U" in
the editbuttons, and CTRL-U as hotkey toggle underlining for newly
entered characters or for the selection, just like CTRL-B/CTRL-I do for
bold/italic.
Underline height (thickness) and Underline position (vertical) can be
set in the editbuttons.
Implemented as CU_POLY polygon curves.
- The B, U and i buttons (and the corresponding CTRL-B/U/I keystrokes)
have been fixed to only affect *one* attribute at a time. Formerly,
hitting CTRL-B when no other style was active, on a text portion with
italics text, for example, would kill the italics and just apply bold.
Now, these attributes always add or substract only, but do not
replace the style.
- In the past, there were bugs with material indices uninitialized, and
thus crashes in the renderer with illegal material indices.
Even though I assume they have been fixed, I've put in a check that
checks (hah) if the material index of a character is illegal (bigger
than ob->totcol), and then sets it to zero, and spits out a warning
on stderr.
If you see such warnings, please report and link to the .blend.
- Bugfix: All alignment modes only worked if there were at least *two*
lines of text in the text object. Fixed
There's now a regression test file for text objects, please add to the
corresponding repository:
http://blender.instinctive.de/downloads/release/demo/text-regression.blend.gz
2005-08-29 12:46:07 +00:00
|
|
|
dl->charidx = nu->charidx;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
data= dl->verts;
|
2008-05-26 12:50:00 +00:00
|
|
|
if(nu->flagu & CU_CYCLIC) dl->type= DL_POLY;
|
2002-10-12 11:37:38 +00:00
|
|
|
else dl->type= DL_SEGM;
|
|
|
|
|
|
|
|
|
|
a= len;
|
|
|
|
|
bp= nu->bp;
|
|
|
|
|
while(a--) {
|
|
|
|
|
VECCOPY(data, bp->vec);
|
|
|
|
|
bp++;
|
|
|
|
|
data+= 3;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
nu= nu->next;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-05-27 09:51:07 +00:00
|
|
|
void filldisplist(ListBase *dispbase, ListBase *to)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
EditVert *eve, *v1, *vlast;
|
2005-03-30 06:39:55 +00:00
|
|
|
EditFace *efa;
|
2002-10-12 11:37:38 +00:00
|
|
|
DispList *dlnew=0, *dl;
|
|
|
|
|
float *f1;
|
2005-06-17 21:04:27 +00:00
|
|
|
int colnr=0, charidx=0, cont=1, tot, a, *index;
|
2002-10-12 11:37:38 +00:00
|
|
|
long totvert;
|
|
|
|
|
|
|
|
|
|
if(dispbase==0) return;
|
|
|
|
|
if(dispbase->first==0) return;
|
|
|
|
|
|
|
|
|
|
while(cont) {
|
|
|
|
|
cont= 0;
|
|
|
|
|
totvert=0;
|
|
|
|
|
|
|
|
|
|
dl= dispbase->first;
|
|
|
|
|
while(dl) {
|
|
|
|
|
|
|
|
|
|
if(dl->type==DL_POLY) {
|
2005-06-17 21:04:27 +00:00
|
|
|
if(charidx<dl->charidx) cont= 1;
|
|
|
|
|
else if(charidx==dl->charidx) {
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
colnr= dl->col;
|
2005-06-17 21:04:27 +00:00
|
|
|
charidx= dl->charidx;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2003-04-25 15:48:11 +00:00
|
|
|
/* make editverts and edges */
|
2002-10-12 11:37:38 +00:00
|
|
|
f1= dl->verts;
|
|
|
|
|
a= dl->nr;
|
|
|
|
|
eve= v1= 0;
|
|
|
|
|
|
|
|
|
|
while(a--) {
|
|
|
|
|
vlast= eve;
|
|
|
|
|
|
|
|
|
|
eve= BLI_addfillvert(f1);
|
|
|
|
|
totvert++;
|
|
|
|
|
|
|
|
|
|
if(vlast==0) v1= eve;
|
|
|
|
|
else {
|
|
|
|
|
BLI_addfilledge(vlast, eve);
|
|
|
|
|
}
|
|
|
|
|
f1+=3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(eve!=0 && v1!=0) {
|
|
|
|
|
BLI_addfilledge(eve, v1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
dl= dl->next;
|
|
|
|
|
}
|
|
|
|
|
|
2005-08-14 06:08:41 +00:00
|
|
|
if(totvert && BLI_edgefill(0, (G.obedit && G.obedit->actcol)?(G.obedit->actcol-1):0)) {
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2004-09-18 20:15:37 +00:00
|
|
|
/* count faces */
|
2002-10-12 11:37:38 +00:00
|
|
|
tot= 0;
|
2005-03-30 06:39:55 +00:00
|
|
|
efa= fillfacebase.first;
|
|
|
|
|
while(efa) {
|
2002-10-12 11:37:38 +00:00
|
|
|
tot++;
|
2005-03-30 06:39:55 +00:00
|
|
|
efa= efa->next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(tot) {
|
|
|
|
|
dlnew= MEM_callocN(sizeof(DispList), "filldisplist");
|
|
|
|
|
dlnew->type= DL_INDEX3;
|
|
|
|
|
dlnew->col= colnr;
|
|
|
|
|
dlnew->nr= totvert;
|
|
|
|
|
dlnew->parts= tot;
|
|
|
|
|
|
|
|
|
|
dlnew->index= MEM_mallocN(tot*3*sizeof(int), "dlindex");
|
|
|
|
|
dlnew->verts= MEM_mallocN(totvert*3*sizeof(float), "dlverts");
|
|
|
|
|
|
2003-04-25 15:48:11 +00:00
|
|
|
/* vert data */
|
2002-10-12 11:37:38 +00:00
|
|
|
f1= dlnew->verts;
|
|
|
|
|
totvert= 0;
|
|
|
|
|
eve= fillvertbase.first;
|
|
|
|
|
while(eve) {
|
|
|
|
|
VECCOPY(f1, eve->co);
|
|
|
|
|
f1+= 3;
|
|
|
|
|
|
2003-04-25 15:48:11 +00:00
|
|
|
/* index number */
|
2006-01-03 17:22:42 +00:00
|
|
|
eve->tmp.l = totvert;
|
2002-10-12 11:37:38 +00:00
|
|
|
totvert++;
|
|
|
|
|
|
|
|
|
|
eve= eve->next;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-25 15:48:11 +00:00
|
|
|
/* index data */
|
2005-03-30 06:39:55 +00:00
|
|
|
efa= fillfacebase.first;
|
2002-10-12 11:37:38 +00:00
|
|
|
index= dlnew->index;
|
2005-03-30 06:39:55 +00:00
|
|
|
while(efa) {
|
2008-08-17 17:08:00 +00:00
|
|
|
index[0]= (intptr_t)efa->v1->tmp.l;
|
|
|
|
|
index[1]= (intptr_t)efa->v2->tmp.l;
|
|
|
|
|
index[2]= (intptr_t)efa->v3->tmp.l;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
index+= 3;
|
2005-03-30 06:39:55 +00:00
|
|
|
efa= efa->next;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BLI_addhead(to, dlnew);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
BLI_end_edgefill();
|
|
|
|
|
|
2005-06-17 21:04:27 +00:00
|
|
|
charidx++;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2003-04-25 15:48:11 +00:00
|
|
|
/* do not free polys, needed for wireframe display */
|
2005-06-17 21:04:27 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase)
|
|
|
|
|
{
|
|
|
|
|
ListBase front, back;
|
|
|
|
|
DispList *dl, *dlnew;
|
|
|
|
|
float *fp, *fp1;
|
|
|
|
|
int a, dpoly;
|
|
|
|
|
|
|
|
|
|
front.first= front.last= back.first= back.last= 0;
|
|
|
|
|
|
|
|
|
|
dl= dispbase->first;
|
|
|
|
|
while(dl) {
|
|
|
|
|
if(dl->type==DL_SURF) {
|
2004-10-31 13:51:36 +00:00
|
|
|
if( (dl->flag & DL_CYCL_V) && (dl->flag & DL_CYCL_U)==0 ) {
|
|
|
|
|
if( (cu->flag & CU_BACK) && (dl->flag & DL_BACK_CURVE) ) {
|
2002-10-12 11:37:38 +00:00
|
|
|
dlnew= MEM_callocN(sizeof(DispList), "filldisp");
|
|
|
|
|
BLI_addtail(&front, dlnew);
|
|
|
|
|
dlnew->verts= fp1= MEM_mallocN(sizeof(float)*3*dl->parts, "filldisp1");
|
|
|
|
|
dlnew->nr= dl->parts;
|
|
|
|
|
dlnew->parts= 1;
|
|
|
|
|
dlnew->type= DL_POLY;
|
|
|
|
|
dlnew->col= dl->col;
|
2006-02-02 12:13:08 +00:00
|
|
|
dlnew->charidx = dl->charidx;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
fp= dl->verts;
|
|
|
|
|
dpoly= 3*dl->nr;
|
|
|
|
|
|
|
|
|
|
a= dl->parts;
|
|
|
|
|
while(a--) {
|
|
|
|
|
VECCOPY(fp1, fp);
|
|
|
|
|
fp1+= 3;
|
|
|
|
|
fp+= dpoly;
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-10-31 13:51:36 +00:00
|
|
|
if( (cu->flag & CU_FRONT) && (dl->flag & DL_FRONT_CURVE) ) {
|
2002-10-12 11:37:38 +00:00
|
|
|
dlnew= MEM_callocN(sizeof(DispList), "filldisp");
|
|
|
|
|
BLI_addtail(&back, dlnew);
|
|
|
|
|
dlnew->verts= fp1= MEM_mallocN(sizeof(float)*3*dl->parts, "filldisp1");
|
|
|
|
|
dlnew->nr= dl->parts;
|
|
|
|
|
dlnew->parts= 1;
|
|
|
|
|
dlnew->type= DL_POLY;
|
|
|
|
|
dlnew->col= dl->col;
|
2006-02-02 12:13:08 +00:00
|
|
|
dlnew->charidx= dl->charidx;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
fp= dl->verts+3*(dl->nr-1);
|
|
|
|
|
dpoly= 3*dl->nr;
|
|
|
|
|
|
|
|
|
|
a= dl->parts;
|
|
|
|
|
while(a--) {
|
|
|
|
|
VECCOPY(fp1, fp);
|
|
|
|
|
fp1+= 3;
|
|
|
|
|
fp+= dpoly;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
dl= dl->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
filldisplist(&front, dispbase);
|
|
|
|
|
filldisplist(&back, dispbase);
|
|
|
|
|
|
|
|
|
|
freedisplist(&front);
|
|
|
|
|
freedisplist(&back);
|
|
|
|
|
|
|
|
|
|
filldisplist(dispbase, dispbase);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2004-10-30 20:46:10 +00:00
|
|
|
void curve_to_filledpoly(Curve *cu, ListBase *nurb, ListBase *dispbase)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
if(cu->flag & CU_3D) return;
|
|
|
|
|
|
2005-08-14 06:08:41 +00:00
|
|
|
if(dispbase->first && ((DispList*) dispbase->first)->type==DL_SURF) {
|
|
|
|
|
bevels_to_filledpoly(cu, dispbase);
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
else {
|
2005-08-14 06:08:41 +00:00
|
|
|
filldisplist(dispbase, dispbase);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-08-29 09:21:52 +00:00
|
|
|
/* taper rules:
|
|
|
|
|
- only 1 curve
|
|
|
|
|
- first point left, last point right
|
|
|
|
|
- based on subdivided points in original curve, not on points in taper curve (still)
|
|
|
|
|
*/
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
float calc_taper(Object *taperobj, int cur, int tot)
|
2004-08-29 09:21:52 +00:00
|
|
|
{
|
|
|
|
|
Curve *cu;
|
|
|
|
|
DispList *dl;
|
|
|
|
|
|
|
|
|
|
if(taperobj==NULL) return 1.0;
|
|
|
|
|
|
|
|
|
|
cu= taperobj->data;
|
|
|
|
|
dl= cu->disp.first;
|
|
|
|
|
if(dl==NULL) {
|
2005-08-14 06:08:41 +00:00
|
|
|
makeDispListCurveTypes(taperobj, 0);
|
2004-08-29 09:21:52 +00:00
|
|
|
dl= cu->disp.first;
|
|
|
|
|
}
|
|
|
|
|
if(dl) {
|
|
|
|
|
float fac= ((float)cur)/(float)(tot-1);
|
|
|
|
|
float minx, dx, *fp;
|
|
|
|
|
int a;
|
|
|
|
|
|
|
|
|
|
/* horizontal size */
|
|
|
|
|
minx= dl->verts[0];
|
|
|
|
|
dx= dl->verts[3*(dl->nr-1)] - minx;
|
|
|
|
|
if(dx>0.0) {
|
|
|
|
|
|
|
|
|
|
fp= dl->verts;
|
|
|
|
|
for(a=0; a<dl->nr; a++, fp+=3) {
|
|
|
|
|
if( (fp[0]-minx)/dx >= fac) {
|
|
|
|
|
/* interpolate with prev */
|
|
|
|
|
if(a>0) {
|
|
|
|
|
float fac1= (fp[-3]-minx)/dx;
|
|
|
|
|
float fac2= (fp[0]-minx)/dx;
|
|
|
|
|
if(fac1!=fac2)
|
|
|
|
|
return fp[1]*(fac1-fac)/(fac1-fac2) + fp[-2]*(fac-fac2)/(fac1-fac2);
|
|
|
|
|
}
|
|
|
|
|
return fp[1];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return fp[-2]; // last y coord
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1.0;
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-14 15:48:01 +00:00
|
|
|
void makeDispListMBall(Object *ob)
|
|
|
|
|
{
|
Big commit with work on Groups & Libraries:
-> Any Group Duplicate now can get local timing and local NLA override. This
enables to control the entire animation system of the Group.
Two methods for this have been implemented.
1) The quick way: just give the duplicator a "Startframe" offset.
2) Advanced: in the NLA Editor you can add ActionStrips to the duplicator
to override NLA/action of any Grouped Object.
For "Group NLA" to work, an ActionStrip needs to know which Object in a
group it controls. On adding a strip, the code checks if an Action was
already used by an Object in the Group, and assigns it automatic to that
Object.
You can also set this in the Nkey "Properties" panel for the strip.
Change in NLA: the SHIFT+A "Add strip" command now always adds strips to
the active Object. (It used to check where mouse was). This allows to add
NLA strips to Objects that didn't have actions/nla yet.
Important note: In Blender, duplicates are fully procedural and generated
on the fly for each redraw. This means that redraw speed equals to stepping
through frames, when using animated Duplicated Groups.
-> Recoded entire duplicator system
The old method was antique and clumsy, using globals and full temporal
copies of Object. The new system is nicer in control, faster, and since it
doesn't use temporal object copies anymore, it works better with Derived
Mesh and DisplayList and rendering.
By centralizing the code for duplicating, more options can be easier added.
Features to note:
- Duplicates now draw selected/unselected based on its Duplicator setting.
- Same goes for the drawtype (wire, solid, selection outline, etc)
- Duplicated Groups can be normally selected too
Bonus goodie: SHIFT+A (Toolbox) now has entry "Add group" too, with a
listing of all groups, allowing to add Group instances immediate.
-> Library System
- SHIFT+F4 data browse now shows the entire path for linked data
- Outliner draws Library Icons to denote linked data
- Outliner operation added: "Make Local" for library data.
- Outliner now also draws Groups in regular view, allowing to unlink too.
-> Fixes
- depsgraph missed signal update for bone-parented Objects
- on reading file, the entire database was tagged to "recalc" fully,
causing unnecessary slowdown on reading.
Might have missed stuff... :)
2005-12-11 13:23:30 +00:00
|
|
|
if(!ob || ob->type!=OB_MBALL) return;
|
2005-07-14 15:48:01 +00:00
|
|
|
|
|
|
|
|
freedisplist(&(ob->disp));
|
|
|
|
|
|
|
|
|
|
if(ob->type==OB_MBALL) {
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
if(ob==find_basis_mball(ob)) {
|
|
|
|
|
metaball_polygonize(ob);
|
|
|
|
|
tex_space_mball(ob);
|
2003-10-14 12:09:57 +00:00
|
|
|
|
2005-08-14 06:08:41 +00:00
|
|
|
object_deform_mball(ob);
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2005-07-14 15:48:01 +00:00
|
|
|
|
|
|
|
|
boundbox_displist(ob);
|
|
|
|
|
}
|
2005-08-14 12:17:34 +00:00
|
|
|
|
|
|
|
|
static ModifierData *curve_get_tesselate_point(Object *ob, int forRender, int editmode)
|
|
|
|
|
{
|
2005-08-15 10:30:53 +00:00
|
|
|
ModifierData *md = modifiers_getVirtualModifierList(ob);
|
|
|
|
|
ModifierData *preTesselatePoint;
|
2006-08-28 01:12:36 +00:00
|
|
|
int required_mode;
|
|
|
|
|
|
|
|
|
|
if(forRender) required_mode = eModifierMode_Render;
|
|
|
|
|
else required_mode = eModifierMode_Realtime;
|
|
|
|
|
|
|
|
|
|
if(editmode) required_mode |= eModifierMode_Editmode;
|
2005-08-14 12:17:34 +00:00
|
|
|
|
|
|
|
|
preTesselatePoint = NULL;
|
2005-08-15 10:30:53 +00:00
|
|
|
for (; md; md=md->next) {
|
2005-08-14 12:17:34 +00:00
|
|
|
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
|
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
if ((md->mode & required_mode) != required_mode) continue;
|
2005-08-14 12:17:34 +00:00
|
|
|
if (mti->isDisabled && mti->isDisabled(md)) continue;
|
|
|
|
|
|
2008-05-22 17:06:46 +00:00
|
|
|
if (ELEM3(md->type, eModifierType_Hook, eModifierType_Softbody, eModifierType_MeshDeform)) {
|
2005-08-14 12:17:34 +00:00
|
|
|
preTesselatePoint = md;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return preTesselatePoint;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void curve_calc_modifiers_pre(Object *ob, ListBase *nurb, int forRender, float (**originalVerts_r)[3], float (**deformedVerts_r)[3], int *numVerts_r)
|
|
|
|
|
{
|
|
|
|
|
int editmode = (!forRender && ob==G.obedit);
|
2005-08-15 10:30:53 +00:00
|
|
|
ModifierData *md = modifiers_getVirtualModifierList(ob);
|
|
|
|
|
ModifierData *preTesselatePoint = curve_get_tesselate_point(ob, forRender, editmode);
|
2005-08-14 12:17:34 +00:00
|
|
|
int numVerts = 0;
|
|
|
|
|
float (*originalVerts)[3] = NULL;
|
|
|
|
|
float (*deformedVerts)[3] = NULL;
|
2006-08-28 01:12:36 +00:00
|
|
|
int required_mode;
|
|
|
|
|
|
|
|
|
|
if(forRender) required_mode = eModifierMode_Render;
|
|
|
|
|
else required_mode = eModifierMode_Realtime;
|
|
|
|
|
|
|
|
|
|
if(editmode) required_mode |= eModifierMode_Editmode;
|
2005-08-14 12:17:34 +00:00
|
|
|
|
2005-09-26 15:34:21 +00:00
|
|
|
if(ob!=G.obedit && do_ob_key(ob)) {
|
|
|
|
|
deformedVerts = curve_getVertexCos(ob->data, nurb, &numVerts);
|
|
|
|
|
originalVerts = MEM_dupallocN(deformedVerts);
|
|
|
|
|
}
|
|
|
|
|
|
2005-08-14 12:17:34 +00:00
|
|
|
if (preTesselatePoint) {
|
2005-08-15 10:30:53 +00:00
|
|
|
for (; md; md=md->next) {
|
2005-08-14 12:17:34 +00:00
|
|
|
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
|
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
if ((md->mode & required_mode) != required_mode) continue;
|
2005-08-14 12:17:34 +00:00
|
|
|
if (mti->isDisabled && mti->isDisabled(md)) continue;
|
|
|
|
|
if (mti->type!=eModifierTypeType_OnlyDeform) continue;
|
|
|
|
|
|
|
|
|
|
if (!deformedVerts) {
|
|
|
|
|
deformedVerts = curve_getVertexCos(ob->data, nurb, &numVerts);
|
|
|
|
|
originalVerts = MEM_dupallocN(deformedVerts);
|
|
|
|
|
}
|
2005-11-17 11:40:57 +00:00
|
|
|
|
2005-08-14 12:17:34 +00:00
|
|
|
mti->deformVerts(md, ob, NULL, deformedVerts, numVerts);
|
|
|
|
|
|
|
|
|
|
if (md==preTesselatePoint)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (deformedVerts) {
|
|
|
|
|
curve_applyVertexCos(ob->data, nurb, deformedVerts);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*originalVerts_r = originalVerts;
|
|
|
|
|
*deformedVerts_r = deformedVerts;
|
|
|
|
|
*numVerts_r = numVerts;
|
|
|
|
|
}
|
|
|
|
|
|
2008-09-29 17:08:11 +00:00
|
|
|
static void curve_calc_modifiers_post(Object *ob, ListBase *nurb, ListBase *dispbase, int forRender, float (*originalVerts)[3], float (*deformedVerts)[3])
|
2005-08-14 12:17:34 +00:00
|
|
|
{
|
|
|
|
|
int editmode = (!forRender && ob==G.obedit);
|
2005-08-15 10:30:53 +00:00
|
|
|
ModifierData *md = modifiers_getVirtualModifierList(ob);
|
|
|
|
|
ModifierData *preTesselatePoint = curve_get_tesselate_point(ob, forRender, editmode);
|
2005-08-14 12:17:34 +00:00
|
|
|
DispList *dl;
|
2006-08-28 01:12:36 +00:00
|
|
|
int required_mode;
|
|
|
|
|
|
|
|
|
|
if(forRender) required_mode = eModifierMode_Render;
|
|
|
|
|
else required_mode = eModifierMode_Realtime;
|
|
|
|
|
|
|
|
|
|
if(editmode) required_mode |= eModifierMode_Editmode;
|
2005-08-14 12:17:34 +00:00
|
|
|
|
|
|
|
|
if (preTesselatePoint) {
|
|
|
|
|
md = preTesselatePoint->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (; md; md=md->next) {
|
|
|
|
|
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
|
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
if ((md->mode & required_mode) != required_mode) continue;
|
2005-08-14 12:17:34 +00:00
|
|
|
if (mti->isDisabled && mti->isDisabled(md)) continue;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
if (mti->type!=eModifierTypeType_OnlyDeform && mti->type!=eModifierTypeType_DeformOrConstruct) continue;
|
2005-08-14 12:17:34 +00:00
|
|
|
|
|
|
|
|
for (dl=dispbase->first; dl; dl=dl->next) {
|
|
|
|
|
mti->deformVerts(md, ob, NULL, (float(*)[3]) dl->verts, (dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (deformedVerts) {
|
|
|
|
|
curve_applyVertexCos(ob->data, nurb, originalVerts);
|
|
|
|
|
MEM_freeN(originalVerts);
|
|
|
|
|
MEM_freeN(deformedVerts);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-20 21:25:02 +00:00
|
|
|
static void displist_surf_indices(DispList *dl)
|
|
|
|
|
{
|
|
|
|
|
int a, b, p1, p2, p3, p4;
|
|
|
|
|
int *index;
|
|
|
|
|
|
|
|
|
|
dl->totindex= 0;
|
|
|
|
|
|
|
|
|
|
index=dl->index= MEM_mallocN( 4*sizeof(int)*(dl->parts+1)*(dl->nr+1), "index array nurbs");
|
|
|
|
|
|
|
|
|
|
for(a=0; a<dl->parts; a++) {
|
|
|
|
|
|
|
|
|
|
DL_SURFINDEX(dl->flag & DL_CYCL_U, dl->flag & DL_CYCL_V, dl->nr, dl->parts);
|
|
|
|
|
|
|
|
|
|
for(; b<dl->nr; b++, index+=4) {
|
|
|
|
|
index[0]= p1;
|
|
|
|
|
index[1]= p2;
|
|
|
|
|
index[2]= p4;
|
|
|
|
|
index[3]= p3;
|
|
|
|
|
|
|
|
|
|
dl->totindex++;
|
|
|
|
|
|
|
|
|
|
p2= p1; p1++;
|
|
|
|
|
p4= p3; p3++;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2005-08-14 06:08:41 +00:00
|
|
|
void makeDispListSurf(Object *ob, ListBase *dispbase, int forRender)
|
2005-07-14 15:48:01 +00:00
|
|
|
{
|
2005-08-14 12:17:34 +00:00
|
|
|
ListBase *nubase;
|
2005-07-14 15:48:01 +00:00
|
|
|
Nurb *nu;
|
2005-08-14 06:08:41 +00:00
|
|
|
Curve *cu = ob->data;
|
|
|
|
|
DispList *dl;
|
|
|
|
|
float *data;
|
|
|
|
|
int len;
|
2005-08-14 12:17:34 +00:00
|
|
|
int numVerts;
|
|
|
|
|
float (*originalVerts)[3];
|
|
|
|
|
float (*deformedVerts)[3];
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-08-14 12:17:34 +00:00
|
|
|
if(!forRender && ob==G.obedit) {
|
|
|
|
|
nubase= &editNurb;
|
|
|
|
|
}
|
2005-08-14 06:08:41 +00:00
|
|
|
else {
|
2005-08-14 12:17:34 +00:00
|
|
|
nubase= &cu->nurb;
|
2005-08-14 06:08:41 +00:00
|
|
|
}
|
2005-08-14 12:17:34 +00:00
|
|
|
|
|
|
|
|
curve_calc_modifiers_pre(ob, nubase, forRender, &originalVerts, &deformedVerts, &numVerts);
|
|
|
|
|
|
|
|
|
|
for (nu=nubase->first; nu; nu=nu->next) {
|
2005-08-14 06:08:41 +00:00
|
|
|
if(forRender || nu->hide==0) {
|
|
|
|
|
if(nu->pntsv==1) {
|
2008-09-23 06:26:48 +00:00
|
|
|
len= nu->resolu*SEGMENTSU(nu)+1;
|
2005-08-14 06:08:41 +00:00
|
|
|
|
|
|
|
|
dl= MEM_callocN(sizeof(DispList), "makeDispListsurf");
|
|
|
|
|
dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts");
|
|
|
|
|
|
|
|
|
|
BLI_addtail(dispbase, dl);
|
|
|
|
|
dl->parts= 1;
|
|
|
|
|
dl->nr= len;
|
|
|
|
|
dl->col= nu->mat_nr;
|
2006-02-02 12:13:08 +00:00
|
|
|
dl->charidx= nu->charidx;
|
2005-08-14 06:08:41 +00:00
|
|
|
dl->rt= nu->flag;
|
|
|
|
|
|
|
|
|
|
data= dl->verts;
|
2008-05-26 12:50:00 +00:00
|
|
|
if(nu->flagu & CU_CYCLIC) dl->type= DL_POLY;
|
2005-08-14 06:08:41 +00:00
|
|
|
else dl->type= DL_SEGM;
|
|
|
|
|
|
2008-09-23 13:35:32 +00:00
|
|
|
makeNurbcurve(nu, data, NULL, NULL, nu->resolu);
|
2005-08-14 06:08:41 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2008-09-26 19:00:49 +00:00
|
|
|
len= (nu->pntsu*nu->resolu) * (nu->pntsv*nu->resolv);
|
2005-08-14 06:08:41 +00:00
|
|
|
|
|
|
|
|
dl= MEM_callocN(sizeof(DispList), "makeDispListsurf");
|
|
|
|
|
dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts");
|
|
|
|
|
BLI_addtail(dispbase, dl);
|
2005-08-11 22:27:53 +00:00
|
|
|
|
2005-08-14 06:08:41 +00:00
|
|
|
dl->col= nu->mat_nr;
|
2006-02-02 12:13:08 +00:00
|
|
|
dl->charidx= nu->charidx;
|
2005-08-14 06:08:41 +00:00
|
|
|
dl->rt= nu->flag;
|
|
|
|
|
|
|
|
|
|
data= dl->verts;
|
|
|
|
|
dl->type= DL_SURF;
|
2008-09-26 19:00:49 +00:00
|
|
|
|
|
|
|
|
dl->parts= (nu->pntsu*nu->resolu); /* in reverse, because makeNurbfaces works that way */
|
|
|
|
|
dl->nr= (nu->pntsv*nu->resolv);
|
2005-08-14 06:08:41 +00:00
|
|
|
if(nu->flagv & CU_CYCLIC) dl->flag|= DL_CYCL_U; /* reverse too! */
|
|
|
|
|
if(nu->flagu & CU_CYCLIC) dl->flag|= DL_CYCL_V;
|
2005-08-11 22:27:53 +00:00
|
|
|
|
2005-08-14 06:08:41 +00:00
|
|
|
makeNurbfaces(nu, data, 0);
|
2006-11-20 21:25:02 +00:00
|
|
|
|
|
|
|
|
/* gl array drawing: using indices */
|
|
|
|
|
displist_surf_indices(dl);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
2005-08-14 06:08:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!forRender) {
|
2002-10-12 11:37:38 +00:00
|
|
|
tex_space_curve(cu);
|
2005-08-14 06:08:41 +00:00
|
|
|
}
|
|
|
|
|
|
2005-08-14 12:17:34 +00:00
|
|
|
curve_calc_modifiers_post(ob, nubase, dispbase, forRender, originalVerts, deformedVerts);
|
2005-08-14 06:08:41 +00:00
|
|
|
}
|
2005-10-03 14:13:47 +00:00
|
|
|
|
2005-08-14 06:08:41 +00:00
|
|
|
void makeDispListCurveTypes(Object *ob, int forOrco)
|
|
|
|
|
{
|
|
|
|
|
Curve *cu = ob->data;
|
|
|
|
|
ListBase *dispbase;
|
2005-12-07 19:47:22 +00:00
|
|
|
|
|
|
|
|
/* we do allow duplis... this is only displist on curve level */
|
|
|
|
|
if(!ELEM3(ob->type, OB_SURF, OB_CURVE, OB_FONT)) return;
|
2004-09-14 19:03:11 +00:00
|
|
|
|
2005-08-14 06:08:41 +00:00
|
|
|
freedisplist(&(ob->disp));
|
|
|
|
|
dispbase= &(cu->disp);
|
|
|
|
|
freedisplist(dispbase);
|
|
|
|
|
|
|
|
|
|
if(ob->type==OB_SURF) {
|
|
|
|
|
makeDispListSurf(ob, dispbase, 0);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
else if ELEM(ob->type, OB_CURVE, OB_FONT) {
|
2005-10-03 20:24:10 +00:00
|
|
|
ListBase dlbev;
|
2005-08-14 12:17:34 +00:00
|
|
|
float (*originalVerts)[3];
|
|
|
|
|
float (*deformedVerts)[3];
|
2005-10-06 21:43:56 +00:00
|
|
|
int obedit= (G.obedit && G.obedit->data==ob->data && G.obedit->type==OB_CURVE);
|
2005-08-14 12:17:34 +00:00
|
|
|
ListBase *nubase = obedit?&editNurb:&cu->nurb;
|
2005-10-03 14:13:47 +00:00
|
|
|
int numVerts;
|
|
|
|
|
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
BLI_freelistN(&(cu->bev));
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
if(cu->path) free_path(cu->path);
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
cu->path= NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
if(ob->type==OB_FONT) text_to_curve(ob, 0);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-08-14 12:17:34 +00:00
|
|
|
if(!forOrco) curve_calc_modifiers_pre(ob, nubase, 0, &originalVerts, &deformedVerts, &numVerts);
|
2005-08-14 06:08:41 +00:00
|
|
|
|
|
|
|
|
makeBevelList(ob);
|
|
|
|
|
|
2006-08-13 07:37:51 +00:00
|
|
|
/* If curve has no bevel will return nothing */
|
2005-10-03 14:13:47 +00:00
|
|
|
makebevelcurve(ob, &dlbev);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2006-06-06 10:09:44 +00:00
|
|
|
/* no bevel or extrude, and no width correction? */
|
|
|
|
|
if (!dlbev.first && cu->width==1.0f) {
|
2005-10-03 14:13:47 +00:00
|
|
|
curve_to_displist(cu, nubase, dispbase);
|
|
|
|
|
} else {
|
|
|
|
|
float widfac= cu->width-1.0;
|
|
|
|
|
BevList *bl= cu->bev.first;
|
|
|
|
|
Nurb *nu= nubase->first;
|
2005-08-14 06:08:41 +00:00
|
|
|
|
2005-10-03 14:13:47 +00:00
|
|
|
for (; bl && nu; bl=bl->next,nu=nu->next) {
|
2006-06-06 10:09:44 +00:00
|
|
|
DispList *dl;
|
|
|
|
|
float *fp1, *data;
|
|
|
|
|
BevPoint *bevp;
|
|
|
|
|
int a,b;
|
2005-10-03 14:13:47 +00:00
|
|
|
|
2007-12-03 22:42:48 +00:00
|
|
|
if (bl->nr) { /* blank bevel lists can happen */
|
2004-10-31 13:51:36 +00:00
|
|
|
|
2007-12-03 22:42:48 +00:00
|
|
|
/* exception handling; curve without bevel or extrude, with width correction */
|
|
|
|
|
if(dlbev.first==NULL) {
|
|
|
|
|
dl= MEM_callocN(sizeof(DispList), "makeDispListbev");
|
|
|
|
|
dl->verts= MEM_callocN(3*sizeof(float)*bl->nr, "dlverts");
|
2006-06-06 10:09:44 +00:00
|
|
|
BLI_addtail(dispbase, dl);
|
|
|
|
|
|
2007-12-03 22:42:48 +00:00
|
|
|
if(bl->poly!= -1) dl->type= DL_POLY;
|
|
|
|
|
else dl->type= DL_SEGM;
|
|
|
|
|
|
|
|
|
|
if(dl->type==DL_SEGM) dl->flag = (DL_FRONT_CURVE|DL_BACK_CURVE);
|
2006-06-06 10:09:44 +00:00
|
|
|
|
2007-12-03 22:42:48 +00:00
|
|
|
dl->parts= 1;
|
|
|
|
|
dl->nr= bl->nr;
|
2006-06-06 10:09:44 +00:00
|
|
|
dl->col= nu->mat_nr;
|
|
|
|
|
dl->charidx= nu->charidx;
|
|
|
|
|
dl->rt= nu->flag;
|
2007-12-03 22:42:48 +00:00
|
|
|
|
|
|
|
|
a= dl->nr;
|
2006-06-06 10:09:44 +00:00
|
|
|
bevp= (BevPoint *)(bl+1);
|
2007-12-03 22:42:48 +00:00
|
|
|
data= dl->verts;
|
|
|
|
|
while(a--) {
|
|
|
|
|
data[0]= bevp->x+widfac*bevp->sina;
|
|
|
|
|
data[1]= bevp->y+widfac*bevp->cosa;
|
|
|
|
|
data[2]= bevp->z;
|
|
|
|
|
bevp++;
|
|
|
|
|
data+=3;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
DispList *dlb;
|
|
|
|
|
|
|
|
|
|
for (dlb=dlbev.first; dlb; dlb=dlb->next) {
|
|
|
|
|
|
|
|
|
|
/* for each part of the bevel use a separate displblock */
|
|
|
|
|
dl= MEM_callocN(sizeof(DispList), "makeDispListbev1");
|
|
|
|
|
dl->verts= data= MEM_callocN(3*sizeof(float)*dlb->nr*bl->nr, "dlverts");
|
|
|
|
|
BLI_addtail(dispbase, dl);
|
|
|
|
|
|
|
|
|
|
dl->type= DL_SURF;
|
2006-06-06 10:09:44 +00:00
|
|
|
|
2007-12-03 22:42:48 +00:00
|
|
|
dl->flag= dlb->flag & (DL_FRONT_CURVE|DL_BACK_CURVE);
|
|
|
|
|
if(dlb->type==DL_POLY) dl->flag |= DL_CYCL_U;
|
|
|
|
|
if(bl->poly>=0) dl->flag |= DL_CYCL_V;
|
|
|
|
|
|
|
|
|
|
dl->parts= bl->nr;
|
|
|
|
|
dl->nr= dlb->nr;
|
|
|
|
|
dl->col= nu->mat_nr;
|
|
|
|
|
dl->charidx= nu->charidx;
|
|
|
|
|
dl->rt= nu->flag;
|
|
|
|
|
dl->bevelSplitFlag= MEM_callocN(sizeof(*dl->col2)*((bl->nr+0x1F)>>5), "col2");
|
|
|
|
|
bevp= (BevPoint *)(bl+1);
|
|
|
|
|
|
|
|
|
|
/* for each point of poly make a bevel piece */
|
|
|
|
|
bevp= (BevPoint *)(bl+1);
|
|
|
|
|
for(a=0; a<bl->nr; a++,bevp++) {
|
|
|
|
|
float fac=1.0;
|
|
|
|
|
if (cu->taperobj==NULL) {
|
|
|
|
|
if ( (cu->bevobj!=NULL) || !((cu->flag & CU_FRONT) || (cu->flag & CU_BACK)) )
|
2008-09-23 13:35:32 +00:00
|
|
|
fac = bevp->radius;
|
2007-12-03 22:42:48 +00:00
|
|
|
} else {
|
|
|
|
|
fac = calc_taper(cu->taperobj, a, bl->nr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (bevp->f1) {
|
|
|
|
|
dl->bevelSplitFlag[a>>5] |= 1<<(a&0x1F);
|
2006-06-06 10:09:44 +00:00
|
|
|
}
|
2007-12-03 22:42:48 +00:00
|
|
|
|
|
|
|
|
/* rotate bevel piece and write in data */
|
|
|
|
|
fp1= dlb->verts;
|
|
|
|
|
for (b=0; b<dlb->nr; b++,fp1+=3,data+=3) {
|
|
|
|
|
if(cu->flag & CU_3D) {
|
|
|
|
|
float vec[3];
|
|
|
|
|
|
|
|
|
|
vec[0]= fp1[1]+widfac;
|
|
|
|
|
vec[1]= fp1[2];
|
|
|
|
|
vec[2]= 0.0;
|
|
|
|
|
|
|
|
|
|
Mat3MulVecfl(bevp->mat, vec);
|
|
|
|
|
|
|
|
|
|
data[0]= bevp->x+ fac*vec[0];
|
|
|
|
|
data[1]= bevp->y+ fac*vec[1];
|
|
|
|
|
data[2]= bevp->z+ fac*vec[2];
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
data[0]= bevp->x+ fac*(widfac+fp1[1])*bevp->sina;
|
|
|
|
|
data[1]= bevp->y+ fac*(widfac+fp1[1])*bevp->cosa;
|
|
|
|
|
data[2]= bevp->z+ fac*fp1[2];
|
|
|
|
|
}
|
2006-06-06 10:09:44 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2007-12-03 22:42:48 +00:00
|
|
|
|
|
|
|
|
/* gl array drawing: using indices */
|
|
|
|
|
displist_surf_indices(dl);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-08-14 06:08:41 +00:00
|
|
|
|
2006-06-06 10:09:44 +00:00
|
|
|
}
|
2006-06-09 23:01:22 +00:00
|
|
|
freedisplist(&dlbev);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2005-10-03 14:13:47 +00:00
|
|
|
|
|
|
|
|
curve_to_filledpoly(cu, nubase, dispbase);
|
|
|
|
|
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
if(cu->flag & CU_PATH) calc_curvepath(ob);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-08-14 12:17:34 +00:00
|
|
|
if(!forOrco) curve_calc_modifiers_post(ob, nubase, &cu->disp, 0, originalVerts, deformedVerts);
|
2002-10-12 11:37:38 +00:00
|
|
|
tex_space_curve(cu);
|
|
|
|
|
}
|
2004-05-29 16:17:46 +00:00
|
|
|
|
2004-09-14 19:03:11 +00:00
|
|
|
boundbox_displist(ob);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void imagestodisplist(void)
|
|
|
|
|
{
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
/* removed */
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2006-08-15 11:33:00 +00:00
|
|
|
/* this is confusing, there's also min_max_object, appplying the obmat... */
|
2005-07-17 04:17:33 +00:00
|
|
|
static void boundbox_displist(Object *ob)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
BoundBox *bb=0;
|
|
|
|
|
float min[3], max[3];
|
|
|
|
|
DispList *dl;
|
|
|
|
|
float *vert;
|
|
|
|
|
int a, tot=0;
|
|
|
|
|
|
|
|
|
|
INIT_MINMAX(min, max);
|
|
|
|
|
|
2005-07-17 17:41:03 +00:00
|
|
|
if(ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
|
2002-10-12 11:37:38 +00:00
|
|
|
Curve *cu= ob->data;
|
2006-08-15 11:33:00 +00:00
|
|
|
int doit= 0;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
if(cu->bb==0) cu->bb= MEM_callocN(sizeof(BoundBox), "boundbox");
|
|
|
|
|
bb= cu->bb;
|
|
|
|
|
|
|
|
|
|
dl= cu->disp.first;
|
|
|
|
|
|
|
|
|
|
while (dl) {
|
2005-08-14 06:08:41 +00:00
|
|
|
if(dl->type==DL_INDEX3) tot= dl->nr;
|
2002-10-12 11:37:38 +00:00
|
|
|
else tot= dl->nr*dl->parts;
|
|
|
|
|
|
|
|
|
|
vert= dl->verts;
|
|
|
|
|
for(a=0; a<tot; a++, vert+=3) {
|
2006-08-15 11:33:00 +00:00
|
|
|
doit= 1;
|
2002-10-12 11:37:38 +00:00
|
|
|
DO_MINMAX(vert, min, max);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dl= dl->next;
|
|
|
|
|
}
|
2006-08-15 11:33:00 +00:00
|
|
|
|
|
|
|
|
if(!doit) {
|
|
|
|
|
min[0] = min[1] = min[2] = -1.0f;
|
|
|
|
|
max[0] = max[1] = max[2] = 1.0f;
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(bb) {
|
2005-07-18 17:33:51 +00:00
|
|
|
boundbox_set_from_min_max(bb, min, max);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|