svn merge -r 16215:16231 https://svn.blender.org/svnroot/bf-blender/trunk/blender
This commit is contained in:
@@ -494,6 +494,9 @@
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\blenkernel\intern\script.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\blenkernel\intern\shrinkwrap.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\blenkernel\intern\softbody.c">
|
||||
</File>
|
||||
@@ -708,6 +711,9 @@
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\blenkernel\BKE_script.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\blenkernel\BKE_shrinkwrap.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\blenkernel\BKE_softbody.h">
|
||||
</File>
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
information, claims of third parties, damages as a result of injury to
|
||||
any person, or any other loss) arising out of or in connection with the
|
||||
license granted under this License Agreement or the use of or inability
|
||||
to use the Software, even if VF has been advised of the possibility of
|
||||
to use the Software, even if BF has been advised of the possibility of
|
||||
such damages.
|
||||
|
||||
5. User warning and indemnification
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
struct Object;
|
||||
struct ListBase;
|
||||
struct bDeformGroup;
|
||||
struct MDeformVert;
|
||||
|
||||
void copy_defgroups (struct ListBase *lb1, struct ListBase *lb2);
|
||||
struct bDeformGroup *copy_defgroup (struct bDeformGroup *ingroup);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* This program is free software; you can redistribute it and/orw
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
@@ -7405,7 +7405,6 @@ static void simpledeformModifier_updateDepgraph(ModifierData *md, DagForest *for
|
||||
dag_add_relation(forest, dag_get_node(forest, smd->origin), obNode, DAG_RL_OB_DATA, "SimpleDeform Modifier");
|
||||
}
|
||||
|
||||
|
||||
/***/
|
||||
|
||||
static ModifierTypeInfo typeArr[NUM_MODIFIER_TYPES];
|
||||
@@ -7733,7 +7732,6 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type)
|
||||
| eModifierTypeFlag_AcceptsCVs
|
||||
| eModifierTypeFlag_SupportsEditmode
|
||||
| eModifierTypeFlag_EnableInEditmode;
|
||||
|
||||
mti->initData = shrinkwrapModifier_initData;
|
||||
mti->copyData = shrinkwrapModifier_copyData;
|
||||
mti->requiredDataMask = shrinkwrapModifier_requiredDataMask;
|
||||
@@ -7757,7 +7755,6 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type)
|
||||
mti->foreachObjectLink = simpledeformModifier_foreachObjectLink;
|
||||
mti->updateDepgraph = simpledeformModifier_updateDepgraph;
|
||||
|
||||
|
||||
typeArrInit = 0;
|
||||
#undef INIT_TYPE
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
#define OUT_OF_MEMORY() ((void)printf("Shrinkwrap: Out of memory\n"))
|
||||
|
||||
/* Benchmark macros */
|
||||
#ifndef _WIN32
|
||||
#if !defined(_WIN32) && 0
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
@@ -166,11 +166,6 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM
|
||||
//TODO currently we need a copy in case object_get_derived_final returns an emDM that does not defines getVertArray or getFace array
|
||||
calc.target = CDDM_copy( object_get_derived_final(smd->target, CD_MASK_BAREMESH) );
|
||||
|
||||
if(!calc.target)
|
||||
{
|
||||
printf("Target derived mesh is null! :S\n");
|
||||
}
|
||||
|
||||
//TODO there might be several "bugs" on non-uniform scales matrixs.. because it will no longer be nearest surface, not sphere projection
|
||||
//because space has been deformed
|
||||
space_transform_setup(&calc.local2target, ob, smd->target);
|
||||
@@ -182,12 +177,6 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM
|
||||
//Projecting target defined - lets work!
|
||||
if(calc.target)
|
||||
{
|
||||
|
||||
printf("Shrinkwrap (%s)%d over (%s)%d\n",
|
||||
calc.ob->id.name, calc.numVerts,
|
||||
calc.smd->target->id.name, calc.target->getNumVerts(calc.target)
|
||||
);
|
||||
|
||||
switch(smd->shrinkType)
|
||||
{
|
||||
case MOD_SHRINKWRAP_NEAREST_SURFACE:
|
||||
@@ -447,7 +436,7 @@ do
|
||||
{
|
||||
float *co = calc->vertexCos[i];
|
||||
float tmp_co[3], tmp_no[3];
|
||||
float lim = 1000; //TODO: we should use FLT_MAX here, but sweepsphere code isnt prepared for that
|
||||
float lim = 10000.0f; //TODO: we should use FLT_MAX here, but sweepsphere code isnt prepared for that
|
||||
float weight = vertexgroup_get_vertex_weight(dvert, i, vgroup);
|
||||
|
||||
if(weight == 0.0f) continue;
|
||||
|
||||
@@ -61,6 +61,10 @@
|
||||
|
||||
// These definitions are also in arithb for simplicity
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
@@ -116,5 +120,9 @@ int closedir (DIR *dp);
|
||||
void get_default_root(char *root);
|
||||
int check_file_chars(char *filename);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __WINSTUFF_H__ */
|
||||
|
||||
|
||||
@@ -43,7 +43,6 @@ struct bGPDframe;
|
||||
/* Temporary 'Stroke Point' data */
|
||||
typedef struct tGPspoint {
|
||||
short x, y; /* x and y coordinates of cursor (in relative to area) */
|
||||
float xf, yf; /* same as x and y, but as floats */
|
||||
float pressure; /* pressure of tablet at this point */
|
||||
} tGPspoint;
|
||||
|
||||
|
||||
@@ -28,15 +28,18 @@
|
||||
#ifndef BIF_DRAWGPENCIL_H
|
||||
#define BIF_DRAWGPENCIL_H
|
||||
|
||||
|
||||
struct bGPdata;
|
||||
struct ScrArea;
|
||||
struct View3D;
|
||||
struct SpaceNode;
|
||||
struct SpaceSeq;
|
||||
struct bGPdata;
|
||||
struct uiBlock;
|
||||
struct ImBuf;
|
||||
|
||||
short draw_gpencil_panel(struct uiBlock *block, struct bGPdata *gpd, struct ScrArea *sa);
|
||||
|
||||
void draw_gpencil_2dimage(struct ScrArea *sa, struct ImBuf *ibuf);
|
||||
void draw_gpencil_2dview(struct ScrArea *sa, short onlyv2d);
|
||||
void draw_gpencil_3dview(struct ScrArea *sa, short only3d);
|
||||
void draw_gpencil_oglrender(struct View3D *v3d, int winx, int winy);
|
||||
|
||||
@@ -59,8 +59,10 @@ typedef struct bGPDstroke {
|
||||
#define GP_STROKE_3DSPACE (1<<0)
|
||||
/* stroke is in 2d-space */
|
||||
#define GP_STROKE_2DSPACE (1<<1)
|
||||
/* stroke is in 2d-space (but with special 'image' scaling) */
|
||||
#define GP_STROKE_2DIMAGE (1<<2)
|
||||
/* stroke is an "eraser" stroke */
|
||||
#define GP_STROKE_ERASER (1<<2)
|
||||
#define GP_STROKE_ERASER (1<<15)
|
||||
|
||||
|
||||
/* Grease-Pencil Annotations - 'Frame'
|
||||
|
||||
@@ -247,6 +247,7 @@ typedef struct SpaceImage {
|
||||
float xof, yof; /* user defined offset, image is centered */
|
||||
float centx, centy; /* storage for offset while render drawing */
|
||||
|
||||
struct bGPdata *gpd; /* grease pencil data */
|
||||
} SpaceImage;
|
||||
|
||||
typedef struct SpaceNla {
|
||||
|
||||
@@ -804,7 +804,7 @@ static PyObject *Part_GetLoc( BPy_PartSys * self, PyObject * args )
|
||||
{
|
||||
ParticleSystem *psys = 0L;
|
||||
Object *ob = 0L;
|
||||
PyObject *partlist,*seglist;
|
||||
PyObject *partlist,*seglist=0L;
|
||||
ParticleCacheKey **cache,*path;
|
||||
PyObject* loc = 0L;
|
||||
ParticleKey state;
|
||||
@@ -1107,7 +1107,7 @@ static PyObject *Part_GetSize( BPy_PartSys * self, PyObject * args )
|
||||
ParticleSystem *psys = 0L;
|
||||
ParticleData *data;
|
||||
Object *ob = 0L;
|
||||
PyObject *partlist,*tuple;
|
||||
PyObject *partlist,*tuple=0L;
|
||||
DerivedMesh* dm;
|
||||
float vm[4][4],wm[4][4];
|
||||
float size;
|
||||
@@ -1217,7 +1217,7 @@ static PyObject *Part_GetAge( BPy_PartSys * self, PyObject * args )
|
||||
ParticleSystem *psys = 0L;
|
||||
ParticleData *data;
|
||||
Object *ob = 0L;
|
||||
PyObject *partlist,*tuple;
|
||||
PyObject *partlist,*tuple=0L;
|
||||
DerivedMesh* dm;
|
||||
float vm[4][4],wm[4][4];
|
||||
float life;
|
||||
|
||||
@@ -37,6 +37,9 @@
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "IMB_imbuf.h"
|
||||
#include "IMB_imbuf_types.h"
|
||||
|
||||
#include "BMF_Api.h"
|
||||
|
||||
#include "BLI_arithb.h"
|
||||
@@ -317,6 +320,7 @@ enum {
|
||||
GP_DRAWDATA_NOSTATUS = (1<<0), /* don't draw status info */
|
||||
GP_DRAWDATA_ONLY3D = (1<<1), /* only draw 3d-strokes */
|
||||
GP_DRAWDATA_ONLYV2D = (1<<2), /* only draw 'canvas' strokes */
|
||||
GP_DRAWDATA_ONLYI2D = (1<<3), /* only draw 'image' strokes */
|
||||
};
|
||||
|
||||
/* ----- Tool Buffer Drawing ------ */
|
||||
@@ -446,7 +450,7 @@ static void gp_draw_stroke_3d (bGPDspoint *points, int totpoints, short thicknes
|
||||
static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness, short dflag, short sflag, short debug, int winx, int winy)
|
||||
{
|
||||
/* if thickness is less than 3, 'smooth' opengl lines look better */
|
||||
if ((thickness < 3) || (G.rt==0)) {
|
||||
if (thickness < 3) {
|
||||
bGPDspoint *pt;
|
||||
int i;
|
||||
|
||||
@@ -466,18 +470,18 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness,
|
||||
}
|
||||
else { /* tesselation code: currently only enabled with rt != 0 */
|
||||
bGPDspoint *pt1, *pt2;
|
||||
float p0[2], p1[2], pm[2];
|
||||
float pm[2];
|
||||
int i;
|
||||
|
||||
glShadeModel(GL_FLAT);
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
for (i=0, pt1=points, pt2=points+1; i < (totpoints-1); i++, pt1++, pt2++) {
|
||||
float s0[2], s1[2]; /* segment 'center' points */
|
||||
float t0[2], t1[2]; /* tesselated coordinates */
|
||||
float m1[2], m2[2]; /* gradient and normal */
|
||||
float pthick, dist; /* thickness at segment point, and length of segment */
|
||||
float sminorang; /* minor angle between strokes */
|
||||
float mt[2], sc[2]; /* gradient for thickness, point for end-cap */
|
||||
float pthick; /* thickness at segment point */
|
||||
|
||||
/* get x and y coordinates from points */
|
||||
if (sflag & GP_STROKE_2DSPACE) {
|
||||
@@ -494,91 +498,123 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness,
|
||||
/* calculate gradient and normal - 'angle'=(ny/nx) */
|
||||
m1[1]= s1[1] - s0[1];
|
||||
m1[0]= s1[0] - s0[0];
|
||||
dist = Vec2Lenf(s0, s1);
|
||||
m2[1]= -(m1[0]) / dist;
|
||||
m2[0]= m1[1] / dist;
|
||||
Normalize2(m1);
|
||||
m2[1]= -m1[0];
|
||||
m2[0]= m1[1];
|
||||
|
||||
/* if the first segment, initialise the first segment using segment's normal */
|
||||
if (i == 0) {
|
||||
pthick= (pt1->pressure * thickness);
|
||||
/* always use pressure from first point here */
|
||||
pthick= (pt1->pressure * thickness);
|
||||
|
||||
/* if the first segment, start of segment is segment's normal */
|
||||
if (i == 0) {
|
||||
/* draw start cap first
|
||||
* - make points slightly closer to center (about halfway across)
|
||||
*/
|
||||
mt[0]= m2[0] * pthick * 0.5;
|
||||
mt[1]= m2[1] * pthick * 0.5;
|
||||
sc[0]= s0[0] - (m1[0] * pthick * 0.75);
|
||||
sc[1]= s0[1] - (m1[1] * pthick * 0.75);
|
||||
|
||||
// TODO: also draw/do a round end-cap first
|
||||
t0[0]= sc[0] - mt[0];
|
||||
t0[1]= sc[1] - mt[1];
|
||||
t1[0]= sc[0] + mt[0];
|
||||
t1[1]= sc[1] + mt[1];
|
||||
|
||||
p0[0]= s0[0] - (pthick * m2[0]);
|
||||
p0[1]= s0[1] - (pthick * m2[1]);
|
||||
p1[0]= s1[0] + (pthick * m2[0]);
|
||||
p1[1]= s1[1] + (pthick * m2[1]);
|
||||
glVertex2fv(t0);
|
||||
glVertex2fv(t1);
|
||||
|
||||
Vec2Copyf(pm, m1);
|
||||
/* calculate points for start of segment */
|
||||
mt[0]= m2[0] * pthick;
|
||||
mt[1]= m2[1] * pthick;
|
||||
|
||||
t0[0]= s0[0] - mt[0];
|
||||
t0[1]= s0[1] - mt[1];
|
||||
t1[0]= s0[0] + mt[0];
|
||||
t1[1]= s0[1] + mt[1];
|
||||
|
||||
/* draw this line twice (first to finish off start cap, then for stroke) */
|
||||
glVertex2fv(t1);
|
||||
glVertex2fv(t0);
|
||||
glVertex2fv(t0);
|
||||
glVertex2fv(t1);
|
||||
}
|
||||
|
||||
/* if the minor angle between the current segment and the previous one is less than 90 degrees */
|
||||
if (i)
|
||||
sminorang= NormalizedVecAngle2_2D(pm, m1);
|
||||
else
|
||||
sminorang= 0.0f;
|
||||
|
||||
if ((IS_EQ(sminorang, 0)==0) && (abs(sminorang) < M_PI_2) )
|
||||
{
|
||||
float closep[2];
|
||||
/* if not the first segment, use bisector of angle between segments */
|
||||
else {
|
||||
float mb[2]; /* bisector normal */
|
||||
float athick, dfac; /* actual thickness, difference between thicknesses */
|
||||
|
||||
/* recalculate startpoint of segment, where the new start-line:
|
||||
* - starts a new gl-quad-strip
|
||||
* - uses the vert of old startpoint closer to our endpoint
|
||||
* - distance between new startpoints = distance between old startpoints
|
||||
* - new startpoints occur on same gradient as old segment does (has potential for some 'minor' overlap, but ok)
|
||||
/* calculate gradient of bisector (as average of normals) */
|
||||
mb[0]= (pm[0] + m2[0]) / 2;
|
||||
mb[1]= (pm[1] + m2[1]) / 2;
|
||||
Normalize2(mb);
|
||||
|
||||
/* calculate gradient to apply
|
||||
* - as basis, use just pthick * bisector gradient
|
||||
* - if cross-section not as thick as it should be, add extra padding to fix it
|
||||
*/
|
||||
mt[0]= mb[0] * pthick;
|
||||
mt[1]= mb[1] * pthick;
|
||||
athick= Vec2Length(mt);
|
||||
dfac= pthick - (athick * 2);
|
||||
if ( ((athick * 2) < pthick) && (IS_EQ(athick, pthick)==0) )
|
||||
{
|
||||
mt[0] += (mb[0] * dfac);
|
||||
mt[1] += (mb[1] * dfac);
|
||||
}
|
||||
|
||||
/* find the closer vertex, and distance between startpoints */
|
||||
if (Vec2Lenf(p0, s1) > Vec2Lenf(p1, s1))
|
||||
Vec2Copyf(closep, p1);
|
||||
else
|
||||
Vec2Copyf(closep, p0);
|
||||
|
||||
/* determine which side this closer vertex should be on */
|
||||
pthick= (pt1->pressure * thickness * 2);
|
||||
if ( ((closep[0] - s0[0]) > 0) || ((closep[1] - s0[1]) > 0) ) {
|
||||
/* assumes this is the 'second' point, (i.e. the 'plus' one), so the other is subtracting */
|
||||
p0[0]= closep[0] - (pthick * pm[0]);
|
||||
p0[1]= closep[1] - (pthick * pm[1]);
|
||||
p1[0]= closep[0];
|
||||
p1[1]= closep[1];
|
||||
}
|
||||
else if ( ((closep[0] - s0[0]) < 0) || ((closep[1] - s0[1]) < 0) ) {
|
||||
/* assumes this is the 'first' point, (i.e. the 'minus' one), so the other is adding */
|
||||
p0[0]= closep[0];
|
||||
p0[1]= closep[1];
|
||||
p1[0]= closep[0] + (pthick * pm[0]);
|
||||
p1[1]= closep[1] + (pthick * pm[1]);
|
||||
}
|
||||
/* calculate points for start of segment */
|
||||
t0[0]= s0[0] - mt[0];
|
||||
t0[1]= s0[1] - mt[1];
|
||||
t1[0]= s0[0] + mt[0];
|
||||
t1[1]= s0[1] + mt[1];
|
||||
|
||||
/* reset gl-states! */
|
||||
glEnd();
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
/* draw this line twice (once for end of current segment, and once for start of next) */
|
||||
glVertex2fv(t1);
|
||||
glVertex2fv(t0);
|
||||
glVertex2fv(t0);
|
||||
glVertex2fv(t1);
|
||||
}
|
||||
|
||||
/* do the end of this segment */
|
||||
pthick= (pt2->pressure * thickness);
|
||||
t0[0] = s1[0] - (pthick * m2[0]);
|
||||
t0[1] = s1[1] - (pthick * m2[1]);
|
||||
t1[0] = s1[0] + (pthick * m2[0]);
|
||||
t1[1] = s1[1] + (pthick * m2[1]);
|
||||
|
||||
/* draw this segment */
|
||||
glVertex2f(p0[0], p0[1]);
|
||||
glVertex2f(p1[0], p1[1]);
|
||||
glVertex2f(t0[0], t0[1]);
|
||||
glVertex2f(t1[0], t1[1]);
|
||||
|
||||
// TODO: draw end cap if last segment
|
||||
/* if last segment, also draw end of segment (defined as segment's normal) */
|
||||
if (i == totpoints-2) {
|
||||
|
||||
/* for once, we use second point's pressure (otherwise it won't be drawn) */
|
||||
pthick= (pt2->pressure * thickness);
|
||||
|
||||
/* calculate points for end of segment */
|
||||
mt[0]= m2[0] * pthick;
|
||||
mt[1]= m2[1] * pthick;
|
||||
|
||||
t0[0]= s1[0] - mt[0];
|
||||
t0[1]= s1[1] - mt[1];
|
||||
t1[0]= s1[0] + mt[0];
|
||||
t1[1]= s1[1] + mt[1];
|
||||
|
||||
/* draw this line twice (once for end of stroke, and once for endcap)*/
|
||||
glVertex2fv(t1);
|
||||
glVertex2fv(t0);
|
||||
glVertex2fv(t0);
|
||||
glVertex2fv(t1);
|
||||
|
||||
|
||||
/* draw end cap as last step
|
||||
* - make points slightly closer to center (about halfway across)
|
||||
*/
|
||||
mt[0]= m2[0] * pthick * 0.5;
|
||||
mt[1]= m2[1] * pthick * 0.5;
|
||||
sc[0]= s1[0] + (m1[0] * pthick * 0.75);
|
||||
sc[1]= s1[1] + (m1[1] * pthick * 0.75);
|
||||
|
||||
t0[0]= sc[0] - mt[0];
|
||||
t0[1]= sc[1] - mt[1];
|
||||
t1[0]= sc[0] + mt[0];
|
||||
t1[1]= sc[1] + mt[1];
|
||||
|
||||
glVertex2fv(t1);
|
||||
glVertex2fv(t0);
|
||||
}
|
||||
|
||||
/* store current points for next segment to use */
|
||||
Vec2Copyf(p0, t0);
|
||||
Vec2Copyf(p1, t1);
|
||||
Vec2Copyf(pm, m1);
|
||||
/* store stroke's 'natural' normal for next stroke to use */
|
||||
Vec2Copyf(pm, m2);
|
||||
}
|
||||
|
||||
glEnd();
|
||||
@@ -626,6 +662,10 @@ static void gp_draw_strokes (bGPDframe *gpf, int winx, int winy, int dflag, shor
|
||||
continue;
|
||||
if (!(dflag & GP_DRAWDATA_ONLYV2D) && (gps->flag & GP_STROKE_2DSPACE))
|
||||
continue;
|
||||
if ((dflag & GP_DRAWDATA_ONLYI2D) && !(gps->flag & GP_STROKE_2DIMAGE))
|
||||
continue;
|
||||
if (!(dflag & GP_DRAWDATA_ONLYI2D) && (gps->flag & GP_STROKE_2DIMAGE))
|
||||
continue;
|
||||
if ((gps->points == 0) || (gps->totpoints < 1))
|
||||
continue;
|
||||
|
||||
@@ -796,6 +836,22 @@ static void gp_draw_data (bGPdata *gpd, int winx, int winy, int dflag)
|
||||
|
||||
/* ----- Grease Pencil Sketches Drawing API ------ */
|
||||
|
||||
/* draw grease-pencil sketches to specified 2d-view that uses ibuf corrections */
|
||||
void draw_gpencil_2dimage (ScrArea *sa, ImBuf *ibuf)
|
||||
{
|
||||
bGPdata *gpd;
|
||||
int dflag = 0;
|
||||
|
||||
/* check that we have grease-pencil stuff to draw */
|
||||
if (ELEM(NULL, sa, ibuf)) return;
|
||||
gpd= gpencil_data_getactive(sa);
|
||||
if (gpd == NULL) return;
|
||||
|
||||
/* draw it! */
|
||||
dflag = (GP_DRAWDATA_ONLYI2D|GP_DRAWDATA_NOSTATUS);
|
||||
gp_draw_data(gpd, sa->winx, sa->winy, dflag);
|
||||
}
|
||||
|
||||
/* draw grease-pencil sketches to specified 2d-view assuming that matrices are already set correctly
|
||||
* Note: this gets called twice - first time with onlyv2d=1 to draw 'canvas' strokes, second time with onlyv2d=0 for screen-aligned strokes
|
||||
*/
|
||||
|
||||
@@ -39,6 +39,9 @@
|
||||
|
||||
#include "BMF_Api.h"
|
||||
|
||||
#include "IMB_imbuf.h"
|
||||
#include "IMB_imbuf_types.h"
|
||||
|
||||
#include "BLI_arithb.h"
|
||||
#include "BLI_blenlib.h"
|
||||
|
||||
@@ -312,11 +315,17 @@ bGPdata *gpencil_data_getactive (ScrArea *sa)
|
||||
{
|
||||
SpaceSeq *sseq= sa->spacedata.first;
|
||||
|
||||
/* only applicable for "Image Preview" mode */
|
||||
/* only applicable for image modes */
|
||||
if (sseq->mainb)
|
||||
return sseq->gpd;
|
||||
}
|
||||
break;
|
||||
case SPACE_IMAGE:
|
||||
{
|
||||
SpaceImage *sima= sa->spacedata.first;
|
||||
return sima->gpd;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* nothing found */
|
||||
@@ -379,6 +388,17 @@ short gpencil_data_setactive (ScrArea *sa, bGPdata *gpd)
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SPACE_IMAGE:
|
||||
{
|
||||
SpaceImage *sima= sa->spacedata.first;
|
||||
|
||||
if (sima->gpd)
|
||||
free_gpencil_data(sima->gpd);
|
||||
sima->gpd= gpd;
|
||||
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* failed to add */
|
||||
@@ -589,7 +609,7 @@ void gpencil_layer_delactive (bGPdata *gpd)
|
||||
}
|
||||
|
||||
/* ************************************************** */
|
||||
/* GREASE-PENCIL EDITING MODE - Tools */
|
||||
/* GREASE-PENCIL EDITING - Tools */
|
||||
|
||||
/* --------- Data Deletion ---------- */
|
||||
|
||||
@@ -679,6 +699,7 @@ void gpencil_delete_menu (void)
|
||||
typedef struct tGPsdata {
|
||||
ScrArea *sa; /* area where painting originated */
|
||||
View2D *v2d; /* needed for GP_STROKE_2DSPACE */
|
||||
ImBuf *ibuf; /* needed for GP_STROKE_2DIMAGE */
|
||||
|
||||
bGPdata *gpd; /* gp-datablock layer comes from */
|
||||
bGPDlayer *gpl; /* layer we're working on */
|
||||
@@ -800,6 +821,16 @@ static void gp_session_initpaint (tGPsdata *p)
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SPACE_IMAGE:
|
||||
{
|
||||
SpaceImage *sima= curarea->spacedata.first;
|
||||
|
||||
/* set the current area */
|
||||
p->sa= curarea;
|
||||
p->v2d= &sima->v2d;
|
||||
//p->ibuf= BKE_image_get_ibuf(sima->image, &sima->iuser);
|
||||
}
|
||||
break;
|
||||
/* unsupported views */
|
||||
default:
|
||||
{
|
||||
@@ -869,6 +900,7 @@ static short gp_stroke_filtermval (tGPsdata *p, short mval[2], short pmval[2])
|
||||
return 1;
|
||||
|
||||
/* check if the distance since the last point is significant enough */
|
||||
// future optimisation: sqrt here may be too slow?
|
||||
else if (sqrt(dx*dx + dy*dy) > MIN_EUCLIDEAN_PX)
|
||||
return 1;
|
||||
|
||||
@@ -884,7 +916,7 @@ static void gp_stroke_convertcoords (tGPsdata *p, short mval[], float out[])
|
||||
|
||||
/* in 3d-space - pt->x/y/z are 3 side-by-side floats */
|
||||
if (gpd->sbuffer_sflag & GP_STROKE_3DSPACE) {
|
||||
short mx=mval[0], my=mval[1];
|
||||
const short mx=mval[0], my=mval[1];
|
||||
float *fp= give_cursor();
|
||||
float dvec[3];
|
||||
|
||||
@@ -904,6 +936,26 @@ static void gp_stroke_convertcoords (tGPsdata *p, short mval[], float out[])
|
||||
out[1]= y;
|
||||
}
|
||||
|
||||
/* 2d - on image 'canvas' (asume that p->v2d is set) */
|
||||
else if ( (gpd->sbuffer_sflag & GP_STROKE_2DIMAGE) &&
|
||||
(p->v2d) && (p->ibuf) )
|
||||
{
|
||||
ImBuf *ibuf= p->ibuf;
|
||||
float x, y;
|
||||
|
||||
/* convert to 'canvas' coordinates, then adjust for view */
|
||||
areamouseco_to_ipoco(p->v2d, mval, &x, &y);
|
||||
|
||||
if (ibuf) {
|
||||
out[0]= x*ibuf->x;
|
||||
out[1]= y*ibuf->y;
|
||||
}
|
||||
else {
|
||||
out[0]= x;
|
||||
out[1]= y;
|
||||
}
|
||||
}
|
||||
|
||||
/* 2d - relative to screen (viewport area) */
|
||||
else {
|
||||
out[0] = (float)(mval[0]) / (float)(p->sa->winx) * 1000;
|
||||
@@ -927,8 +979,6 @@ static short gp_stroke_addpoint (tGPsdata *p, short mval[2], float pressure)
|
||||
/* store settings */
|
||||
pt->x= mval[0];
|
||||
pt->y= mval[1];
|
||||
pt->xf= (float)mval[0];
|
||||
pt->yf= (float)mval[0];
|
||||
pt->pressure= pressure;
|
||||
|
||||
/* increment counters */
|
||||
|
||||
@@ -384,8 +384,12 @@ void BL_ConvertActuators(char* maggiename,
|
||||
else
|
||||
{
|
||||
/* but we need to convert the samplename into absolute pathname first */
|
||||
BLI_convertstringcode(soundact->sound->name, maggiename);
|
||||
samplename = soundact->sound->name;
|
||||
char fullpath[sizeof(soundact->sound->name)];
|
||||
|
||||
/* dont modify soundact->sound->name, only change a copy */
|
||||
BLI_strncpy(fullpath, soundact->sound->name, sizeof(fullpath));
|
||||
BLI_convertstringcode(fullpath, maggiename);
|
||||
samplename = fullpath;
|
||||
|
||||
/* and now we can load it */
|
||||
if (soundscene->LoadSample(samplename, NULL, 0) > -1)
|
||||
|
||||
@@ -30,7 +30,13 @@
|
||||
|
||||
#include "GL/glew.h"
|
||||
|
||||
// directory header for py function getBlendFileList
|
||||
#include <stdlib.h>
|
||||
#ifndef WIN32
|
||||
#include <dirent.h>
|
||||
#else
|
||||
#include "BLI_winstuff.h"
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#pragma warning (disable : 4786)
|
||||
@@ -112,9 +118,7 @@ static PyObject* gPyGetRandomFloat(PyObject*)
|
||||
return PyFloat_FromDouble(MT_random());
|
||||
}
|
||||
|
||||
static PyObject* gPySetGravity(PyObject*,
|
||||
PyObject* args,
|
||||
PyObject*)
|
||||
static PyObject* gPySetGravity(PyObject*, PyObject* args)
|
||||
{
|
||||
MT_Vector3 vec = MT_Vector3(0., 0., 0.);
|
||||
if (PyVecArgTo(args, vec))
|
||||
@@ -138,9 +142,7 @@ file to make a full path name (doesn't change during the game, even if you load\
|
||||
other .blend).\n\
|
||||
The function also converts the directory separator to the local file system format.";
|
||||
|
||||
static PyObject* gPyExpandPath(PyObject*,
|
||||
PyObject* args,
|
||||
PyObject*)
|
||||
static PyObject* gPyExpandPath(PyObject*, PyObject* args)
|
||||
{
|
||||
char expanded[FILE_MAXDIR + FILE_MAXFILE];
|
||||
char* filename;
|
||||
@@ -185,9 +187,7 @@ static PyObject* gPyGetSpectrum(PyObject*)
|
||||
|
||||
|
||||
|
||||
static PyObject* gPyStartDSP(PyObject*,
|
||||
PyObject* args,
|
||||
PyObject*)
|
||||
static PyObject* gPyStartDSP(PyObject*, PyObject* args)
|
||||
{
|
||||
SND_IAudioDevice* audiodevice = SND_DeviceManager::Instance();
|
||||
|
||||
@@ -205,9 +205,7 @@ static PyObject* gPyStartDSP(PyObject*,
|
||||
|
||||
|
||||
|
||||
static PyObject* gPyStopDSP(PyObject*,
|
||||
PyObject* args,
|
||||
PyObject*)
|
||||
static PyObject* gPyStopDSP(PyObject*, PyObject* args)
|
||||
{
|
||||
SND_IAudioDevice* audiodevice = SND_DeviceManager::Instance();
|
||||
|
||||
@@ -223,9 +221,7 @@ static PyObject* gPyStopDSP(PyObject*,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static PyObject* gPySetLogicTicRate(PyObject*,
|
||||
PyObject* args,
|
||||
PyObject*)
|
||||
static PyObject* gPySetLogicTicRate(PyObject*, PyObject* args)
|
||||
{
|
||||
float ticrate;
|
||||
if (PyArg_ParseTuple(args, "f", &ticrate))
|
||||
@@ -242,9 +238,7 @@ static PyObject* gPyGetLogicTicRate(PyObject*)
|
||||
return PyFloat_FromDouble(KX_KetsjiEngine::GetTicRate());
|
||||
}
|
||||
|
||||
static PyObject* gPySetPhysicsTicRate(PyObject*,
|
||||
PyObject* args,
|
||||
PyObject*)
|
||||
static PyObject* gPySetPhysicsTicRate(PyObject*, PyObject* args)
|
||||
{
|
||||
float ticrate;
|
||||
if (PyArg_ParseTuple(args, "f", &ticrate))
|
||||
@@ -257,9 +251,7 @@ static PyObject* gPySetPhysicsTicRate(PyObject*,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static PyObject* gPySetPhysicsDebug(PyObject*,
|
||||
PyObject* args,
|
||||
PyObject*)
|
||||
static PyObject* gPySetPhysicsDebug(PyObject*, PyObject* args)
|
||||
{
|
||||
int debugMode;
|
||||
if (PyArg_ParseTuple(args, "i", &debugMode))
|
||||
@@ -278,6 +270,44 @@ static PyObject* gPyGetPhysicsTicRate(PyObject*)
|
||||
return PyFloat_FromDouble(PHY_GetActiveEnvironment()->getFixedTimeStep());
|
||||
}
|
||||
|
||||
static PyObject* gPyGetBlendFileList(PyObject*, PyObject* args)
|
||||
{
|
||||
char cpath[sizeof(G.sce)];
|
||||
char *searchpath = NULL;
|
||||
PyObject* list;
|
||||
|
||||
DIR *dp;
|
||||
struct dirent *dirp;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|s", &searchpath))
|
||||
return NULL;
|
||||
|
||||
list = PyList_New(0);
|
||||
|
||||
if (searchpath) {
|
||||
BLI_strncpy(cpath, searchpath, FILE_MAXDIR + FILE_MAXFILE);
|
||||
BLI_convertstringcode(cpath, G.sce);
|
||||
} else {
|
||||
/* Get the dir only */
|
||||
BLI_split_dirfile_basic(G.sce, cpath, NULL);
|
||||
}
|
||||
|
||||
if((dp = opendir(cpath)) == NULL) {
|
||||
/* todo, show the errno, this shouldnt happen anyway if the blendfile is readable */
|
||||
fprintf(stderr, "Could not read directoty () failed, code %d (%s)\n", cpath, errno, strerror(errno));
|
||||
return list;
|
||||
}
|
||||
|
||||
while ((dirp = readdir(dp)) != NULL) {
|
||||
if (BLI_testextensie(dirp->d_name, ".blend")) {
|
||||
PyList_Append(list, PyString_FromString(dirp->d_name));
|
||||
}
|
||||
}
|
||||
|
||||
closedir(dp);
|
||||
return list;
|
||||
}
|
||||
|
||||
static STR_String gPyGetCurrentScene_doc =
|
||||
"getCurrentScene()\n"
|
||||
"Gets a reference to the current scene.\n";
|
||||
@@ -377,14 +407,13 @@ static struct PyMethodDef game_methods[] = {
|
||||
{"setLogicTicRate", (PyCFunction) gPySetLogicTicRate, METH_VARARGS, "Sets the logic tic rate"},
|
||||
{"getPhysicsTicRate", (PyCFunction) gPyGetPhysicsTicRate, METH_NOARGS, "Gets the physics tic rate"},
|
||||
{"setPhysicsTicRate", (PyCFunction) gPySetPhysicsTicRate, METH_VARARGS, "Sets the physics tic rate"},
|
||||
{"getBlendFileList", (PyCFunction)gPyGetBlendFileList, METH_VARARGS, "Gets a list of blend files in the same directory as the current blend file"},
|
||||
{"PrintGLInfo", (PyCFunction)pyPrintExt, METH_NOARGS, "Prints GL Extension Info"},
|
||||
{NULL, (PyCFunction) NULL, 0, NULL }
|
||||
};
|
||||
|
||||
|
||||
static PyObject* gPyGetWindowHeight(PyObject*,
|
||||
PyObject* args,
|
||||
PyObject*)
|
||||
static PyObject* gPyGetWindowHeight(PyObject*, PyObject* args)
|
||||
{
|
||||
int height = (gp_Canvas ? gp_Canvas->GetHeight() : 0);
|
||||
|
||||
@@ -394,9 +423,7 @@ static PyObject* gPyGetWindowHeight(PyObject*,
|
||||
|
||||
|
||||
|
||||
static PyObject* gPyGetWindowWidth(PyObject*,
|
||||
PyObject* args,
|
||||
PyObject*)
|
||||
static PyObject* gPyGetWindowWidth(PyObject*, PyObject* args)
|
||||
{
|
||||
|
||||
|
||||
@@ -411,9 +438,7 @@ static PyObject* gPyGetWindowWidth(PyObject*,
|
||||
// temporarility visibility thing, will be moved to rasterizer/renderer later
|
||||
bool gUseVisibilityTemp = false;
|
||||
|
||||
static PyObject* gPyEnableVisibility(PyObject*,
|
||||
PyObject* args,
|
||||
PyObject*)
|
||||
static PyObject* gPyEnableVisibility(PyObject*, PyObject* args)
|
||||
{
|
||||
int visible;
|
||||
if (PyArg_ParseTuple(args,"i",&visible))
|
||||
@@ -429,9 +454,7 @@ static PyObject* gPyEnableVisibility(PyObject*,
|
||||
|
||||
|
||||
|
||||
static PyObject* gPyShowMouse(PyObject*,
|
||||
PyObject* args,
|
||||
PyObject*)
|
||||
static PyObject* gPyShowMouse(PyObject*, PyObject* args)
|
||||
{
|
||||
int visible;
|
||||
if (PyArg_ParseTuple(args,"i",&visible))
|
||||
@@ -455,9 +478,7 @@ static PyObject* gPyShowMouse(PyObject*,
|
||||
|
||||
|
||||
|
||||
static PyObject* gPySetMousePosition(PyObject*,
|
||||
PyObject* args,
|
||||
PyObject*)
|
||||
static PyObject* gPySetMousePosition(PyObject*, PyObject* args)
|
||||
{
|
||||
int x,y;
|
||||
if (PyArg_ParseTuple(args,"ii",&x,&y))
|
||||
@@ -472,9 +493,7 @@ static PyObject* gPySetMousePosition(PyObject*,
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
static PyObject* gPySetEyeSeparation(PyObject*,
|
||||
PyObject* args,
|
||||
PyObject*)
|
||||
static PyObject* gPySetEyeSeparation(PyObject*, PyObject* args)
|
||||
{
|
||||
float sep;
|
||||
if (PyArg_ParseTuple(args, "f", &sep))
|
||||
@@ -496,9 +515,7 @@ static PyObject* gPyGetEyeSeparation(PyObject*, PyObject*, PyObject*)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static PyObject* gPySetFocalLength(PyObject*,
|
||||
PyObject* args,
|
||||
PyObject*)
|
||||
static PyObject* gPySetFocalLength(PyObject*, PyObject* args)
|
||||
{
|
||||
float focus;
|
||||
if (PyArg_ParseTuple(args, "f", &focus))
|
||||
@@ -518,9 +535,7 @@ static PyObject* gPyGetFocalLength(PyObject*, PyObject*, PyObject*)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static PyObject* gPySetBackgroundColor(PyObject*,
|
||||
PyObject* args,
|
||||
PyObject*)
|
||||
static PyObject* gPySetBackgroundColor(PyObject*, PyObject* args)
|
||||
{
|
||||
|
||||
MT_Vector4 vec = MT_Vector4(0., 0., 0.3, 0.);
|
||||
@@ -538,9 +553,7 @@ static PyObject* gPySetBackgroundColor(PyObject*,
|
||||
|
||||
|
||||
|
||||
static PyObject* gPySetMistColor(PyObject*,
|
||||
PyObject* args,
|
||||
PyObject*)
|
||||
static PyObject* gPySetMistColor(PyObject*, PyObject* args)
|
||||
{
|
||||
|
||||
MT_Vector3 vec = MT_Vector3(0., 0., 0.);
|
||||
@@ -558,9 +571,7 @@ static PyObject* gPySetMistColor(PyObject*,
|
||||
|
||||
|
||||
|
||||
static PyObject* gPySetMistStart(PyObject*,
|
||||
PyObject* args,
|
||||
PyObject*)
|
||||
static PyObject* gPySetMistStart(PyObject*, PyObject* args)
|
||||
{
|
||||
|
||||
float miststart;
|
||||
@@ -579,9 +590,7 @@ static PyObject* gPySetMistStart(PyObject*,
|
||||
|
||||
|
||||
|
||||
static PyObject* gPySetMistEnd(PyObject*,
|
||||
PyObject* args,
|
||||
PyObject*)
|
||||
static PyObject* gPySetMistEnd(PyObject*, PyObject* args)
|
||||
{
|
||||
|
||||
float mistend;
|
||||
@@ -599,9 +608,7 @@ static PyObject* gPySetMistEnd(PyObject*,
|
||||
}
|
||||
|
||||
|
||||
static PyObject* gPySetAmbientColor(PyObject*,
|
||||
PyObject* args,
|
||||
PyObject*)
|
||||
static PyObject* gPySetAmbientColor(PyObject*, PyObject* args)
|
||||
{
|
||||
|
||||
MT_Vector3 vec = MT_Vector3(0., 0., 0.);
|
||||
@@ -620,9 +627,7 @@ static PyObject* gPySetAmbientColor(PyObject*,
|
||||
|
||||
|
||||
|
||||
static PyObject* gPyMakeScreenshot(PyObject*,
|
||||
PyObject* args,
|
||||
PyObject*)
|
||||
static PyObject* gPyMakeScreenshot(PyObject*, PyObject* args)
|
||||
{
|
||||
char* filename;
|
||||
if (PyArg_ParseTuple(args,"s",&filename))
|
||||
@@ -638,9 +643,7 @@ static PyObject* gPyMakeScreenshot(PyObject*,
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
static PyObject* gPyEnableMotionBlur(PyObject*,
|
||||
PyObject* args,
|
||||
PyObject*)
|
||||
static PyObject* gPyEnableMotionBlur(PyObject*, PyObject* args)
|
||||
{
|
||||
float motionblurvalue;
|
||||
if (PyArg_ParseTuple(args,"f",&motionblurvalue))
|
||||
@@ -656,9 +659,7 @@ static PyObject* gPyEnableMotionBlur(PyObject*,
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
static PyObject* gPyDisableMotionBlur(PyObject*,
|
||||
PyObject* args,
|
||||
PyObject*)
|
||||
static PyObject* gPyDisableMotionBlur(PyObject*, PyObject* args)
|
||||
{
|
||||
if(gp_Rasterizer)
|
||||
{
|
||||
|
||||
@@ -30,6 +30,10 @@ SET(INC
|
||||
.
|
||||
../common
|
||||
../../../../extern/bullet2/src
|
||||
../../../../intern/moto/include
|
||||
../../../kernel/gen_system
|
||||
../../../../intern/string
|
||||
../../Rasterizer
|
||||
)
|
||||
|
||||
BLENDERLIB(bf_bullet "${SRC}" "${INC}")
|
||||
|
||||
@@ -14,8 +14,7 @@ Documentation for the GameLogic Module.
|
||||
|
||||
Examples::
|
||||
# To get a controller:
|
||||
import GameLogic
|
||||
co = GameLogic.getCurrentController()
|
||||
co = GameLogic.getCurrentController() # GameLogic is automatically imported
|
||||
|
||||
# To get the game object associated with this controller:
|
||||
obj = co.getOwner()
|
||||
@@ -237,3 +236,13 @@ def expandPath(path):
|
||||
@return: The converted string
|
||||
@rtype: string
|
||||
"""
|
||||
|
||||
def getBlendFileList(path = "//"):
|
||||
"""
|
||||
Returns a list of blend files in the same directory as the open blend file, or from using the option argument.
|
||||
|
||||
@param path: Optional directory argument, will be expanded (like expandPath) into the full path.
|
||||
@type path: string
|
||||
@return: A list of filenames, with no directory prefix
|
||||
@rtype: list
|
||||
"""
|
||||
Reference in New Issue
Block a user