forked from bartvdbraak/blender
scon fixes
This commit is contained in:
parent
d88bb9115f
commit
9a997093d7
@ -175,8 +175,6 @@ void BM_loops_to_corners(BMesh *bm, Mesh *me, int findex,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* BM_data_interp_from_face
|
||||
*
|
||||
@ -218,6 +216,94 @@ void BM_face_interp_from_face(BMesh *bm, BMFace *target, BMFace *source)
|
||||
BLI_array_free(blocks);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static int compute_mdisp_quad(BMLoop *l, float v1[3], float v2[3], float v3[3], float v4[3], float e1[3], float e2[3])
|
||||
{
|
||||
float cent[3];
|
||||
BMLoop *l2;
|
||||
|
||||
/*computer center*/
|
||||
l2 = bm_firstfaceloop(l->f);
|
||||
do {
|
||||
add_v3_v3(v4, l2->v->co);
|
||||
l2 = l2->next;
|
||||
} whlie (l2 != bm_firstfaceloop(l->f));
|
||||
|
||||
mul_v3_fl(v4, 1.0/(float)l->f->len);
|
||||
|
||||
copy_v3_v3(v1, l->prev->v->co);
|
||||
copy_v3_v3(v2, l->v->co);
|
||||
copy_v3_v3(v3, l->next->v->co);
|
||||
|
||||
sub_v3_v3v3(e1, v1, v4);
|
||||
sub_v3_v3v3(e2, v2, v3);
|
||||
}
|
||||
|
||||
/*tl is loop to project onto, sl is loop whose internal displacement, co, is being
|
||||
projected. x and y are location in loop's mdisps grid of co.*/
|
||||
static int mdisp_in_mdispquad(BMLoop *l, BMLoop *tl, float co, int *x, int *y)
|
||||
{
|
||||
float v1[3], v2[3], v3[3], v4[3], e1[3], e2[3];
|
||||
float dir[3], uv[3], hit[3];
|
||||
float eps = FLT_EPSILON*7;
|
||||
|
||||
computer_mdisp_quad(tl, v1, v2, v3, v4, e1, e2);
|
||||
copy_v3_v3(dir, l->f->no);
|
||||
|
||||
/*four tests, two per triangle, once again normal, once along -normal*/
|
||||
ret = isect_ray_tri_epsilon_v3(co, dir, v1, v2, v3, &l, uv, eps);
|
||||
ret = ret || isect_ray_tri_epsilon_v3(co, dir, v1, v3, v4, &l, uv, eps);
|
||||
if (!ret) {
|
||||
negate_v3(dir);
|
||||
ret = ret || isect_ray_tri_epsilon_v3(co, dir, v1, v2, v3, &l, uv, eps);
|
||||
ret = ret || isect_ray_tri_epsilon_v3(co, dir, v1, v3, v4, &l, uv, eps);
|
||||
}
|
||||
if (!ret)
|
||||
return 0;
|
||||
|
||||
mul_v3_fl(dir, l);
|
||||
add_v3_v3v3(hit, co, dir);
|
||||
|
||||
}
|
||||
|
||||
static void bmesh_loop_interp_mdisps(BMesh *bm, BMLoop *target, BMFace *source)
|
||||
{
|
||||
MDisps *mdisps;
|
||||
BMLoop *l2;
|
||||
float x, y, d, v1[3], v2[3], v3[3], v4[3] = {0.0f, 0.0f, 0.0f}, e1[3], e2[3], e3[3], e4[3];
|
||||
int i;
|
||||
|
||||
if (!CustomData_has_layer(&bm->ldata, CD_MDISPS))
|
||||
return;
|
||||
|
||||
mdisps = CustomData_bmesh_get(&bm->ldata, CD_MDISPS);
|
||||
|
||||
computer_mdisp_quad(target, v1, v2, v3, v4, e1, e2);
|
||||
|
||||
d = 1.0f/sqrt(mdisps->totdisp);
|
||||
for (x=0.0f; x<1.0f; x += d) {
|
||||
for (y=0.0f; y<1.0f; y+= d) {
|
||||
float co1[3], co2[3], co[3];
|
||||
|
||||
copy_v3_v3v3(co1, e1);
|
||||
mul_v3_fl(co1, y);
|
||||
copy_v3_v3v3(co1, e2);
|
||||
mul_v3_fl(co1, y);
|
||||
|
||||
sub_v3_v3v3(co, co2, co1);
|
||||
mul_v3_fl(co, x);
|
||||
add_v3_v3v3(co, co1);
|
||||
|
||||
l2 = bm_firstfaceloop(target->f);
|
||||
do {
|
||||
l2 = l2->next;
|
||||
} while (l2 != bm_firstfaceloop(target->f));
|
||||
}
|
||||
}
|
||||
//for (i=0; i<CustomData_number_of_layers(&bm->ldata, CD_MDISPS); i++) {
|
||||
//}
|
||||
}
|
||||
#endif
|
||||
void BM_loop_interp_from_face(BMesh *bm, BMLoop *target, BMFace *source)
|
||||
{
|
||||
BMLoop *l;
|
||||
|
@ -55,6 +55,8 @@
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
||||
#include "ED_mesh.h"
|
||||
|
||||
static void rna_Mesh_update_data(Main *bmain, Scene *scene, PointerRNA *ptr)
|
||||
{
|
||||
ID *id= ptr->id.data;
|
||||
@ -1013,7 +1015,7 @@ static CustomDataLayer *rna_Mesh_uv_texture_new(struct Mesh *me, struct bContext
|
||||
CustomDataLayer *cdl= NULL;
|
||||
int index;
|
||||
|
||||
if(ED_mesh_uv_texture_add(C, NULL, NULL, me, name, FALSE)) {
|
||||
if(ED_mesh_uv_texture_add(C, me, name, FALSE)) {
|
||||
pdata= rna_mesh_pdata(me);
|
||||
index= CustomData_get_named_layer_index(pdata, CD_MTEXPOLY, name);
|
||||
cdl= (index == -1)? NULL: &pdata->layers[index];
|
||||
|
@ -1,606 +0,0 @@
|
||||
/**
|
||||
* $Id$
|
||||
*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* Contributor(s): Arystanbek Dyussenov
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#include "bpy_rna.h"
|
||||
#include "BKE_global.h"
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#define MAX_ARRAY_DIMENSION 10
|
||||
|
||||
typedef void (*ItemConvertFunc)(PyObject *, char *);
|
||||
typedef int (*ItemTypeCheckFunc)(PyObject *);
|
||||
typedef void (*RNA_SetArrayFunc)(PointerRNA *, PropertyRNA *, const char *);
|
||||
typedef void (*RNA_SetIndexFunc)(PointerRNA *, PropertyRNA *, int index, void *);
|
||||
|
||||
/*
|
||||
arr[3][4][5]
|
||||
0 1 2 <- dimension index
|
||||
*/
|
||||
|
||||
/*
|
||||
arr[2] = x
|
||||
|
||||
py_to_array_index(arraydim=0, arrayoffset=0, index=2)
|
||||
validate_array(lvalue_dim=0)
|
||||
... make real index ...
|
||||
*/
|
||||
|
||||
/* arr[3]=x, self->arraydim is 0, lvalue_dim is 1 */
|
||||
/* Ensures that a python sequence has expected number of items/sub-items and items are of desired type. */
|
||||
static int validate_array_type(PyObject *seq, int dim, int totdim, int dimsize[],
|
||||
ItemTypeCheckFunc check_item_type, const char *item_type_str, const char *error_prefix)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* not the last dimension */
|
||||
if (dim + 1 < totdim) {
|
||||
/* check that a sequence contains dimsize[dim] items */
|
||||
|
||||
for (i= 0; i < PySequence_Length(seq); i++) {
|
||||
PyObject *item;
|
||||
int ok= 1;
|
||||
item= PySequence_GetItem(seq, i);
|
||||
|
||||
if (!PySequence_Check(item)) {
|
||||
/* BLI_snprintf(error_str, error_str_size, "expected a sequence of %s", item_type_str); */
|
||||
PyErr_Format(PyExc_TypeError, "%s expected a sequence of %s", error_prefix, item_type_str);
|
||||
ok= 0;
|
||||
}
|
||||
/* arr[3][4][5]
|
||||
dimsize[1]=4
|
||||
dimsize[2]=5
|
||||
|
||||
dim=0 */
|
||||
else if (PySequence_Length(item) != dimsize[dim + 1]) {
|
||||
/* BLI_snprintf(error_str, error_str_size, "sequences of dimension %d should contain %d items", (int)dim + 1, (int)dimsize[dim + 1]); */
|
||||
PyErr_Format(PyExc_ValueError, "%s sequences of dimension %d should contain %d items", error_prefix, (int)dim + 1, (int)dimsize[dim + 1]);
|
||||
ok= 0;
|
||||
}
|
||||
else if (!validate_array_type(item, dim + 1, totdim, dimsize, check_item_type, item_type_str, error_prefix)) {
|
||||
ok= 0;
|
||||
}
|
||||
|
||||
Py_DECREF(item);
|
||||
|
||||
if (!ok)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* check that items are of correct type */
|
||||
for (i= 0; i < PySequence_Length(seq); i++) {
|
||||
PyObject *item= PySequence_GetItem(seq, i);
|
||||
|
||||
if (!check_item_type(item)) {
|
||||
Py_DECREF(item);
|
||||
|
||||
/* BLI_snprintf(error_str, error_str_size, "sequence items should be of type %s", item_type_str); */
|
||||
PyErr_Format(PyExc_TypeError, "sequence items should be of type %s", item_type_str);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Py_DECREF(item);
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Returns the number of items in a single- or multi-dimensional sequence. */
|
||||
static int count_items(PyObject *seq)
|
||||
{
|
||||
int totitem= 0;
|
||||
|
||||
if (PySequence_Check(seq)) {
|
||||
int i;
|
||||
for (i= 0; i < PySequence_Length(seq); i++) {
|
||||
PyObject *item= PySequence_GetItem(seq, i);
|
||||
totitem += count_items(item);
|
||||
Py_DECREF(item);
|
||||
}
|
||||
}
|
||||
else
|
||||
totitem= 1;
|
||||
|
||||
return totitem;
|
||||
}
|
||||
|
||||
/* Modifies property array length if needed and PROP_DYNAMIC flag is set. */
|
||||
static int validate_array_length(PyObject *rvalue, PointerRNA *ptr, PropertyRNA *prop, int lvalue_dim, int *totitem, const char *error_prefix)
|
||||
{
|
||||
int dimsize[MAX_ARRAY_DIMENSION];
|
||||
int tot, totdim, len;
|
||||
|
||||
tot= count_items(rvalue);
|
||||
totdim= RNA_property_array_dimension(ptr, prop, dimsize);
|
||||
|
||||
if ((RNA_property_flag(prop) & PROP_DYNAMIC) && lvalue_dim == 0) {
|
||||
if (RNA_property_array_length(ptr, prop) != tot) {
|
||||
#if 0
|
||||
/* length is flexible */
|
||||
if (!RNA_property_dynamic_array_set_length(ptr, prop, tot)) {
|
||||
/* BLI_snprintf(error_str, error_str_size, "%s.%s: array length cannot be changed to %d", RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), tot); */
|
||||
PyErr_Format(PyExc_ValueError, "%s %s.%s: array length cannot be changed to %d", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), tot);
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
*totitem= tot;
|
||||
return 1;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
len= tot;
|
||||
}
|
||||
else {
|
||||
/* length is a constraint */
|
||||
if (!lvalue_dim) {
|
||||
len= RNA_property_array_length(ptr, prop);
|
||||
}
|
||||
/* array item assignment */
|
||||
else {
|
||||
int i;
|
||||
|
||||
len= 1;
|
||||
|
||||
/* arr[3][4][5]
|
||||
|
||||
arr[2] = x
|
||||
dimsize={4, 5}
|
||||
dimsize[1] = 4
|
||||
dimsize[2] = 5
|
||||
lvalue_dim=0, totdim=3
|
||||
|
||||
arr[2][3] = x
|
||||
lvalue_dim=1
|
||||
|
||||
arr[2][3][4] = x
|
||||
lvalue_dim=2 */
|
||||
for (i= lvalue_dim; i < totdim; i++)
|
||||
len *= dimsize[i];
|
||||
}
|
||||
|
||||
if (tot != len) {
|
||||
/* BLI_snprintf(error_str, error_str_size, "sequence must have length of %d", len); */
|
||||
PyErr_Format(PyExc_ValueError, "%s sequence must have %d items total", error_prefix, len);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
*totitem= len;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int validate_array(PyObject *rvalue, PointerRNA *ptr, PropertyRNA *prop, int lvalue_dim, ItemTypeCheckFunc check_item_type, const char *item_type_str, int *totitem, const char *error_prefix)
|
||||
{
|
||||
int dimsize[MAX_ARRAY_DIMENSION];
|
||||
int totdim= RNA_property_array_dimension(ptr, prop, dimsize);
|
||||
|
||||
/* validate type first because length validation may modify property array length */
|
||||
|
||||
if (!validate_array_type(rvalue, lvalue_dim, totdim, dimsize, check_item_type, item_type_str, error_prefix))
|
||||
return 0;
|
||||
|
||||
return validate_array_length(rvalue, ptr, prop, lvalue_dim, totitem, error_prefix);
|
||||
}
|
||||
|
||||
static char *copy_values(PyObject *seq, PointerRNA *ptr, PropertyRNA *prop, int dim, char *data, unsigned int item_size, int *index, ItemConvertFunc convert_item, RNA_SetIndexFunc rna_set_index)
|
||||
{
|
||||
unsigned int i;
|
||||
int totdim= RNA_property_array_dimension(ptr, prop, NULL);
|
||||
|
||||
for (i= 0; i < PySequence_Length(seq); i++) {
|
||||
PyObject *item= PySequence_GetItem(seq, i);
|
||||
|
||||
if (dim + 1 < totdim) {
|
||||
data= copy_values(item, ptr, prop, dim + 1, data, item_size, index, convert_item, rna_set_index);
|
||||
}
|
||||
else {
|
||||
if (!data) {
|
||||
char value[sizeof(int)];
|
||||
|
||||
convert_item(item, value);
|
||||
rna_set_index(ptr, prop, *index, value);
|
||||
*index = *index + 1;
|
||||
}
|
||||
else {
|
||||
convert_item(item, data);
|
||||
data += item_size;
|
||||
}
|
||||
}
|
||||
|
||||
Py_DECREF(item);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
static int py_to_array(PyObject *py, PointerRNA *ptr, PropertyRNA *prop, ParameterList *parms, char *param_data, ItemTypeCheckFunc check_item_type, const char *item_type_str, int item_size, ItemConvertFunc convert_item, RNA_SetArrayFunc rna_set_array, const char *error_prefix)
|
||||
{
|
||||
int totdim, dim_size[MAX_ARRAY_DIMENSION];
|
||||
int totitem;
|
||||
char *data= NULL;
|
||||
|
||||
totdim= RNA_property_array_dimension(ptr, prop, dim_size);
|
||||
|
||||
if (!validate_array(py, ptr, prop, 0, check_item_type, item_type_str, &totitem, error_prefix)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (totitem) {
|
||||
/* note: this code is confusing */
|
||||
if(param_data && RNA_property_flag(prop) & PROP_DYNAMIC) {
|
||||
/* not freeing allocated mem, RNA_parameter_list_free() will do this */
|
||||
ParameterDynAlloc *param_alloc= (ParameterDynAlloc *)param_data;
|
||||
param_alloc->array_tot= (int)totitem;
|
||||
param_alloc->array= MEM_callocN(item_size * totitem, "py_to_array dyn"); /* freeing param list will free */
|
||||
|
||||
data= param_alloc->array;
|
||||
}
|
||||
else if (param_data) {
|
||||
data= param_data;
|
||||
}
|
||||
else {
|
||||
data= PyMem_MALLOC(item_size * totitem);
|
||||
}
|
||||
|
||||
copy_values(py, ptr, prop, 0, data, item_size, NULL, convert_item, NULL);
|
||||
|
||||
if (param_data==NULL) {
|
||||
/* NULL can only pass through in case RNA property arraylength is 0 (impossible?) */
|
||||
rna_set_array(ptr, prop, data);
|
||||
PyMem_FREE(data);
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int py_to_array_index(PyObject *py, PointerRNA *ptr, PropertyRNA *prop, int lvalue_dim, int arrayoffset, int index, ItemTypeCheckFunc check_item_type, const char *item_type_str, ItemConvertFunc convert_item, RNA_SetIndexFunc rna_set_index, const char *error_prefix)
|
||||
{
|
||||
int totdim, dimsize[MAX_ARRAY_DIMENSION];
|
||||
int totitem, i;
|
||||
|
||||
totdim= RNA_property_array_dimension(ptr, prop, dimsize);
|
||||
|
||||
/* convert index */
|
||||
|
||||
/* arr[3][4][5]
|
||||
|
||||
arr[2] = x
|
||||
lvalue_dim=0, index = 0 + 2 * 4 * 5
|
||||
|
||||
arr[2][3] = x
|
||||
lvalue_dim=1, index = 40 + 3 * 5 */
|
||||
|
||||
lvalue_dim++;
|
||||
|
||||
for (i= lvalue_dim; i < totdim; i++)
|
||||
index *= dimsize[i];
|
||||
|
||||
index += arrayoffset;
|
||||
|
||||
if (!validate_array(py, ptr, prop, lvalue_dim, check_item_type, item_type_str, &totitem, error_prefix))
|
||||
return 0;
|
||||
|
||||
if (totitem)
|
||||
copy_values(py, ptr, prop, lvalue_dim, NULL, 0, &index, convert_item, rna_set_index);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void py_to_float(PyObject *py, char *data)
|
||||
{
|
||||
*(float*)data= (float)PyFloat_AsDouble(py);
|
||||
}
|
||||
|
||||
static void py_to_int(PyObject *py, char *data)
|
||||
{
|
||||
*(int*)data= (int)PyLong_AsSsize_t(py);
|
||||
}
|
||||
|
||||
static void py_to_bool(PyObject *py, char *data)
|
||||
{
|
||||
*(int*)data= (int)PyObject_IsTrue(py);
|
||||
}
|
||||
|
||||
static int py_float_check(PyObject *py)
|
||||
{
|
||||
/* accept both floats and integers */
|
||||
return PyFloat_Check(py) || PyLong_Check(py);
|
||||
}
|
||||
|
||||
static int py_int_check(PyObject *py)
|
||||
{
|
||||
/* accept only integers */
|
||||
return PyLong_Check(py);
|
||||
}
|
||||
|
||||
static int py_bool_check(PyObject *py)
|
||||
{
|
||||
return PyBool_Check(py);
|
||||
}
|
||||
|
||||
static void float_set_index(PointerRNA *ptr, PropertyRNA *prop, int index, void *value)
|
||||
{
|
||||
RNA_property_float_set_index(ptr, prop, index, *(float*)value);
|
||||
}
|
||||
|
||||
static void int_set_index(PointerRNA *ptr, PropertyRNA *prop, int index, void *value)
|
||||
{
|
||||
RNA_property_int_set_index(ptr, prop, index, *(int*)value);
|
||||
}
|
||||
|
||||
static void bool_set_index(PointerRNA *ptr, PropertyRNA *prop, int index, void *value)
|
||||
{
|
||||
RNA_property_boolean_set_index(ptr, prop, index, *(int*)value);
|
||||
}
|
||||
|
||||
int pyrna_py_to_array(PointerRNA *ptr, PropertyRNA *prop, ParameterList *parms, char *param_data, PyObject *py, const char *error_prefix)
|
||||
{
|
||||
int ret;
|
||||
switch (RNA_property_type(prop)) {
|
||||
case PROP_FLOAT:
|
||||
ret= py_to_array(py, ptr, prop, parms, param_data, py_float_check, "float", sizeof(float), py_to_float, (RNA_SetArrayFunc)RNA_property_float_set_array, error_prefix);
|
||||
break;
|
||||
case PROP_INT:
|
||||
ret= py_to_array(py, ptr, prop, parms, param_data, py_int_check, "int", sizeof(int), py_to_int, (RNA_SetArrayFunc)RNA_property_int_set_array, error_prefix);
|
||||
break;
|
||||
case PROP_BOOLEAN:
|
||||
ret= py_to_array(py, ptr, prop, parms, param_data, py_bool_check, "boolean", sizeof(int), py_to_bool, (RNA_SetArrayFunc)RNA_property_boolean_set_array, error_prefix);
|
||||
break;
|
||||
default:
|
||||
PyErr_SetString(PyExc_TypeError, "not an array type");
|
||||
ret= 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int pyrna_py_to_array_index(PointerRNA *ptr, PropertyRNA *prop, int arraydim, int arrayoffset, int index, PyObject *py, const char *error_prefix)
|
||||
{
|
||||
int ret;
|
||||
switch (RNA_property_type(prop)) {
|
||||
case PROP_FLOAT:
|
||||
ret= py_to_array_index(py, ptr, prop, arraydim, arrayoffset, index, py_float_check, "float", py_to_float, float_set_index, error_prefix);
|
||||
break;
|
||||
case PROP_INT:
|
||||
ret= py_to_array_index(py, ptr, prop, arraydim, arrayoffset, index, py_int_check, "int", py_to_int, int_set_index, error_prefix);
|
||||
break;
|
||||
case PROP_BOOLEAN:
|
||||
ret= py_to_array_index(py, ptr, prop, arraydim, arrayoffset, index, py_bool_check, "boolean", py_to_bool, bool_set_index, error_prefix);
|
||||
break;
|
||||
default:
|
||||
PyErr_SetString(PyExc_TypeError, "not an array type");
|
||||
ret= 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static PyObject *pyrna_array_item(PointerRNA *ptr, PropertyRNA *prop, int index)
|
||||
{
|
||||
PyObject *item;
|
||||
|
||||
switch (RNA_property_type(prop)) {
|
||||
case PROP_FLOAT:
|
||||
item= PyFloat_FromDouble(RNA_property_float_get_index(ptr, prop, index));
|
||||
break;
|
||||
case PROP_BOOLEAN:
|
||||
item= PyBool_FromLong(RNA_property_boolean_get_index(ptr, prop, index));
|
||||
break;
|
||||
case PROP_INT:
|
||||
item= PyLong_FromSsize_t(RNA_property_int_get_index(ptr, prop, index));
|
||||
break;
|
||||
default:
|
||||
PyErr_SetString(PyExc_TypeError, "not an array type");
|
||||
item= NULL;
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* XXX this is not used (and never will?) */
|
||||
/* Given an array property, creates an N-dimensional tuple of values. */
|
||||
static PyObject *pyrna_py_from_array_internal(PointerRNA *ptr, PropertyRNA *prop, int dim, int *index)
|
||||
{
|
||||
PyObject *tuple;
|
||||
int i, len;
|
||||
int totdim= RNA_property_array_dimension(ptr, prop, NULL);
|
||||
|
||||
len= RNA_property_multi_array_length(ptr, prop, dim);
|
||||
|
||||
tuple= PyTuple_New(len);
|
||||
|
||||
for (i= 0; i < len; i++) {
|
||||
PyObject *item;
|
||||
|
||||
if (dim + 1 < totdim)
|
||||
item= pyrna_py_from_array_internal(ptr, prop, dim + 1, index);
|
||||
else {
|
||||
item= pyrna_array_item(ptr, prop, *index);
|
||||
*index= *index + 1;
|
||||
}
|
||||
|
||||
if (!item) {
|
||||
Py_DECREF(tuple);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PyTuple_SetItem(tuple, i, item);
|
||||
}
|
||||
|
||||
return tuple;
|
||||
}
|
||||
#endif
|
||||
|
||||
PyObject *pyrna_py_from_array_index(BPy_PropertyArrayRNA *self, PointerRNA *ptr, PropertyRNA *prop, int index)
|
||||
{
|
||||
int totdim, arraydim, arrayoffset, dimsize[MAX_ARRAY_DIMENSION], i, len;
|
||||
BPy_PropertyArrayRNA *ret= NULL;
|
||||
|
||||
arraydim= self ? self->arraydim : 0;
|
||||
arrayoffset = self ? self->arrayoffset : 0;
|
||||
|
||||
/* just in case check */
|
||||
len= RNA_property_multi_array_length(ptr, prop, arraydim);
|
||||
if (index >= len || index < 0) {
|
||||
/* this shouldn't happen because higher level funcs must check for invalid index */
|
||||
if (G.f & G_DEBUG) printf("pyrna_py_from_array_index: invalid index %d for array with length=%d\n", index, len);
|
||||
|
||||
PyErr_SetString(PyExc_IndexError, "out of range");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
totdim= RNA_property_array_dimension(ptr, prop, dimsize);
|
||||
|
||||
if (arraydim + 1 < totdim) {
|
||||
ret= (BPy_PropertyArrayRNA*)pyrna_prop_CreatePyObject(ptr, prop);
|
||||
ret->arraydim= arraydim + 1;
|
||||
|
||||
/* arr[3][4][5]
|
||||
|
||||
x = arr[2]
|
||||
index = 0 + 2 * 4 * 5
|
||||
|
||||
x = arr[2][3]
|
||||
index = offset + 3 * 5 */
|
||||
|
||||
for (i= arraydim + 1; i < totdim; i++)
|
||||
index *= dimsize[i];
|
||||
|
||||
ret->arrayoffset= arrayoffset + index;
|
||||
}
|
||||
else {
|
||||
index = arrayoffset + index;
|
||||
ret= (BPy_PropertyArrayRNA *)pyrna_array_item(ptr, prop, index);
|
||||
}
|
||||
|
||||
return (PyObject*)ret;
|
||||
}
|
||||
|
||||
PyObject *pyrna_py_from_array(PointerRNA *ptr, PropertyRNA *prop)
|
||||
{
|
||||
PyObject *ret;
|
||||
|
||||
ret= pyrna_math_object_from_array(ptr, prop);
|
||||
|
||||
/* is this a maths object? */
|
||||
if (ret) return ret;
|
||||
|
||||
return pyrna_prop_CreatePyObject(ptr, prop);
|
||||
}
|
||||
|
||||
/* TODO, multi-dimensional arrays */
|
||||
int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value)
|
||||
{
|
||||
int len= RNA_property_array_length(ptr, prop);
|
||||
int type;
|
||||
int i;
|
||||
|
||||
if(len==0) /* possible with dynamic arrays */
|
||||
return 0;
|
||||
|
||||
if (RNA_property_array_dimension(ptr, prop, NULL) > 1) {
|
||||
PyErr_SetString(PyExc_TypeError, "PropertyRNA - multi dimensional arrays not supported yet");
|
||||
return -1;
|
||||
}
|
||||
|
||||
type= RNA_property_type(prop);
|
||||
|
||||
switch (type) {
|
||||
case PROP_FLOAT:
|
||||
{
|
||||
float value_f= PyFloat_AsDouble(value);
|
||||
if(value_f==-1 && PyErr_Occurred()) {
|
||||
PyErr_Clear();
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
float tmp[32];
|
||||
float *tmp_arr;
|
||||
|
||||
if(len * sizeof(float) > sizeof(tmp)) {
|
||||
tmp_arr= PyMem_MALLOC(len * sizeof(float));
|
||||
}
|
||||
else {
|
||||
tmp_arr= tmp;
|
||||
}
|
||||
|
||||
RNA_property_float_get_array(ptr, prop, tmp_arr);
|
||||
|
||||
for(i=0; i<len; i++)
|
||||
if(tmp_arr[i] == value_f)
|
||||
break;
|
||||
|
||||
if(tmp_arr != tmp)
|
||||
PyMem_FREE(tmp_arr);
|
||||
|
||||
return i<len ? 1 : 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PROP_BOOLEAN:
|
||||
case PROP_INT:
|
||||
{
|
||||
int value_i= PyLong_AsSsize_t(value);
|
||||
if(value_i==-1 && PyErr_Occurred()) {
|
||||
PyErr_Clear();
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
int tmp[32];
|
||||
int *tmp_arr;
|
||||
|
||||
if(len * sizeof(int) > sizeof(tmp)) {
|
||||
tmp_arr= PyMem_MALLOC(len * sizeof(int));
|
||||
}
|
||||
else {
|
||||
tmp_arr= tmp;
|
||||
}
|
||||
|
||||
if(type==PROP_BOOLEAN)
|
||||
RNA_property_boolean_get_array(ptr, prop, tmp_arr);
|
||||
else
|
||||
RNA_property_int_get_array(ptr, prop, tmp_arr);
|
||||
|
||||
for(i=0; i<len; i++)
|
||||
if(tmp_arr[i] == value_i)
|
||||
break;
|
||||
|
||||
if(tmp_arr != tmp)
|
||||
PyMem_FREE(tmp_arr);
|
||||
|
||||
return i<len ? 1 : 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* should never reach this */
|
||||
PyErr_SetString(PyExc_TypeError, "PropertyRNA - type not in float/bool/int");
|
||||
return -1;
|
||||
}
|
@ -27,6 +27,7 @@
|
||||
#include "RNA_access.h"
|
||||
#include "RNA_types.h"
|
||||
#include "BKE_idprop.h"
|
||||
#include <Python.h>
|
||||
|
||||
extern PyTypeObject pyrna_struct_meta_idprop_Type;
|
||||
extern PyTypeObject pyrna_struct_Type;
|
||||
|
@ -1,169 +0,0 @@
|
||||
/**
|
||||
* $Id: rayobject_blibvh.c 23649 2009-10-06 02:56:11Z jaguarandi $
|
||||
*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2009 Blender Foundation.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The Original Code is: all of this file.
|
||||
*
|
||||
* Contributor(s): André Pinto.
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
#include <assert.h>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
#include "BKE_utildefines.h"
|
||||
#include "BLI_kdopbvh.h"
|
||||
#include "BLI_math.h"
|
||||
#include "RE_raytrace.h"
|
||||
#include "render_types.h"
|
||||
#include "rayobject.h"
|
||||
|
||||
static int RE_rayobject_blibvh_intersect(RayObject *o, Isect *isec);
|
||||
static void RE_rayobject_blibvh_add(RayObject *o, RayObject *ob);
|
||||
static void RE_rayobject_blibvh_done(RayObject *o);
|
||||
static void RE_rayobject_blibvh_free(RayObject *o);
|
||||
static void RE_rayobject_blibvh_bb(RayObject *o, float *min, float *max);
|
||||
|
||||
static float RE_rayobject_blibvh_cost(RayObject *o)
|
||||
{
|
||||
//TODO calculate the expected cost to raycast on this structure
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
static void RE_rayobject_blibvh_hint_bb(RayObject *o, RayHint *hint, float *min, float *max)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static RayObjectAPI bvh_api =
|
||||
{
|
||||
RE_rayobject_blibvh_intersect,
|
||||
RE_rayobject_blibvh_add,
|
||||
RE_rayobject_blibvh_done,
|
||||
RE_rayobject_blibvh_free,
|
||||
RE_rayobject_blibvh_bb,
|
||||
RE_rayobject_blibvh_cost,
|
||||
RE_rayobject_blibvh_hint_bb
|
||||
};
|
||||
|
||||
typedef struct BVHObject
|
||||
{
|
||||
RayObject rayobj;
|
||||
RayObject **leafs, **next_leaf;
|
||||
BVHTree *bvh;
|
||||
float bb[2][3];
|
||||
|
||||
} BVHObject;
|
||||
|
||||
|
||||
RayObject *RE_rayobject_blibvh_create(int size)
|
||||
{
|
||||
BVHObject *obj= (BVHObject*)MEM_callocN(sizeof(BVHObject), "BVHObject");
|
||||
assert( RE_rayobject_isAligned(obj) ); /* RayObject API assumes real data to be 4-byte aligned */
|
||||
|
||||
obj->rayobj.api = &bvh_api;
|
||||
obj->bvh = BLI_bvhtree_new(size, 0.0, 4, 6);
|
||||
obj->next_leaf = obj->leafs = (RayObject**)MEM_callocN(size*sizeof(RayObject*), "BVHObject leafs");
|
||||
|
||||
INIT_MINMAX(obj->bb[0], obj->bb[1]);
|
||||
return RE_rayobject_unalignRayAPI((RayObject*) obj);
|
||||
}
|
||||
|
||||
struct BVHCallbackUserData
|
||||
{
|
||||
Isect *isec;
|
||||
RayObject **leafs;
|
||||
};
|
||||
|
||||
static void bvh_callback(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit)
|
||||
{
|
||||
struct BVHCallbackUserData *data = (struct BVHCallbackUserData*)userdata;
|
||||
Isect *isec = data->isec;
|
||||
RayObject *face = data->leafs[index];
|
||||
|
||||
if(RE_rayobject_intersect(face,isec))
|
||||
{
|
||||
hit->index = index;
|
||||
|
||||
if(isec->mode == RE_RAY_SHADOW)
|
||||
hit->dist = 0;
|
||||
else
|
||||
hit->dist = isec->labda*isec->dist;
|
||||
}
|
||||
}
|
||||
|
||||
static int RE_rayobject_blibvh_intersect(RayObject *o, Isect *isec)
|
||||
{
|
||||
BVHObject *obj = (BVHObject*)o;
|
||||
BVHTreeRayHit hit;
|
||||
float dir[3];
|
||||
struct BVHCallbackUserData data;
|
||||
data.isec = isec;
|
||||
data.leafs = obj->leafs;
|
||||
|
||||
VECCOPY(dir, isec->vec);
|
||||
normalize_v3(dir);
|
||||
|
||||
hit.index = 0;
|
||||
hit.dist = isec->labda*isec->dist;
|
||||
|
||||
return BLI_bvhtree_ray_cast(obj->bvh, isec->start, dir, 0.0, &hit, bvh_callback, (void*)&data);
|
||||
}
|
||||
|
||||
static void RE_rayobject_blibvh_add(RayObject *o, RayObject *ob)
|
||||
{
|
||||
BVHObject *obj = (BVHObject*)o;
|
||||
float min_max[6];
|
||||
INIT_MINMAX(min_max, min_max+3);
|
||||
RE_rayobject_merge_bb(ob, min_max, min_max+3);
|
||||
|
||||
DO_MIN(min_max , obj->bb[0]);
|
||||
DO_MAX(min_max+3, obj->bb[1]);
|
||||
|
||||
BLI_bvhtree_insert(obj->bvh, obj->next_leaf - obj->leafs, min_max, 2 );
|
||||
*(obj->next_leaf++) = ob;
|
||||
}
|
||||
|
||||
static void RE_rayobject_blibvh_done(RayObject *o)
|
||||
{
|
||||
BVHObject *obj = (BVHObject*)o;
|
||||
BLI_bvhtree_balance(obj->bvh);
|
||||
}
|
||||
|
||||
static void RE_rayobject_blibvh_free(RayObject *o)
|
||||
{
|
||||
BVHObject *obj = (BVHObject*)o;
|
||||
|
||||
if(obj->bvh)
|
||||
BLI_bvhtree_free(obj->bvh);
|
||||
|
||||
if(obj->leafs)
|
||||
MEM_freeN(obj->leafs);
|
||||
|
||||
MEM_freeN(obj);
|
||||
}
|
||||
|
||||
static void RE_rayobject_blibvh_bb(RayObject *o, float *min, float *max)
|
||||
{
|
||||
BVHObject *obj = (BVHObject*)o;
|
||||
DO_MIN( obj->bb[0], min );
|
||||
DO_MAX( obj->bb[1], max );
|
||||
}
|
@ -1,207 +0,0 @@
|
||||
/**
|
||||
* $Id: rayobject_instance.c 23763 2009-10-10 18:42:20Z jaguarandi $
|
||||
*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2009 Blender Foundation.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The Original Code is: all of this file.
|
||||
*
|
||||
* Contributor(s): André Pinto.
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
#include <assert.h>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
#include "BKE_utildefines.h"
|
||||
#include "BLI_math.h"
|
||||
#include "RE_raytrace.h"
|
||||
#include "rayobject.h"
|
||||
|
||||
#define RE_COST_INSTANCE (1.0f)
|
||||
|
||||
static int RE_rayobject_instance_intersect(RayObject *o, Isect *isec);
|
||||
static void RE_rayobject_instance_free(RayObject *o);
|
||||
static void RE_rayobject_instance_bb(RayObject *o, float *min, float *max);
|
||||
static float RE_rayobject_instance_cost(RayObject *o);
|
||||
|
||||
static void RE_rayobject_instance_hint_bb(RayObject *o, RayHint *hint, float *min, float *max)
|
||||
{}
|
||||
|
||||
static RayObjectAPI instance_api =
|
||||
{
|
||||
RE_rayobject_instance_intersect,
|
||||
NULL, //static void RE_rayobject_instance_add(RayObject *o, RayObject *ob);
|
||||
NULL, //static void RE_rayobject_instance_done(RayObject *o);
|
||||
RE_rayobject_instance_free,
|
||||
RE_rayobject_instance_bb,
|
||||
RE_rayobject_instance_cost,
|
||||
RE_rayobject_instance_hint_bb
|
||||
};
|
||||
|
||||
typedef struct InstanceRayObject
|
||||
{
|
||||
RayObject rayobj;
|
||||
RayObject *target;
|
||||
|
||||
void *ob; //Object represented by this instance
|
||||
void *target_ob; //Object represented by the inner RayObject, needed to handle self-intersection
|
||||
|
||||
float global2target[4][4];
|
||||
float target2global[4][4];
|
||||
|
||||
} InstanceRayObject;
|
||||
|
||||
|
||||
RayObject *RE_rayobject_instance_create(RayObject *target, float transform[][4], void *ob, void *target_ob)
|
||||
{
|
||||
InstanceRayObject *obj= (InstanceRayObject*)MEM_callocN(sizeof(InstanceRayObject), "InstanceRayObject");
|
||||
assert( RE_rayobject_isAligned(obj) ); /* RayObject API assumes real data to be 4-byte aligned */
|
||||
|
||||
obj->rayobj.api = &instance_api;
|
||||
obj->target = target;
|
||||
obj->ob = ob;
|
||||
obj->target_ob = target_ob;
|
||||
|
||||
copy_m4_m4(obj->target2global, transform);
|
||||
invert_m4_m4(obj->global2target, obj->target2global);
|
||||
|
||||
return RE_rayobject_unalignRayAPI((RayObject*) obj);
|
||||
}
|
||||
|
||||
static int RE_rayobject_instance_intersect(RayObject *o, Isect *isec)
|
||||
{
|
||||
//TODO
|
||||
// *there is probably a faster way to convert between coordinates
|
||||
|
||||
InstanceRayObject *obj = (InstanceRayObject*)o;
|
||||
int res;
|
||||
float start[3], vec[3], labda, dist;
|
||||
int changed = 0, i;
|
||||
|
||||
//TODO - this is disabling self intersection on instances
|
||||
if(isec->orig.ob == obj->ob && obj->ob)
|
||||
{
|
||||
changed = 1;
|
||||
isec->orig.ob = obj->target_ob;
|
||||
}
|
||||
|
||||
|
||||
VECCOPY( start, isec->start );
|
||||
VECCOPY( vec , isec->vec );
|
||||
labda = isec->labda;
|
||||
dist = isec->dist;
|
||||
|
||||
//Transform to target coordinates system
|
||||
VECADD( isec->vec, isec->vec, isec->start );
|
||||
|
||||
mul_m4_v3(obj->global2target, isec->start);
|
||||
mul_m4_v3(obj->global2target, isec->vec );
|
||||
|
||||
isec->dist = len_v3v3( isec->start, isec->vec );
|
||||
VECSUB( isec->vec, isec->vec, isec->start );
|
||||
|
||||
isec->labda *= isec->dist / dist;
|
||||
|
||||
//Update idot_axis and bv_index
|
||||
for(i=0; i<3; i++)
|
||||
{
|
||||
isec->idot_axis[i] = 1.0f / isec->vec[i];
|
||||
|
||||
isec->bv_index[2*i] = isec->idot_axis[i] < 0.0 ? 1 : 0;
|
||||
isec->bv_index[2*i+1] = 1 - isec->bv_index[2*i];
|
||||
|
||||
isec->bv_index[2*i] = i+3*isec->bv_index[2*i];
|
||||
isec->bv_index[2*i+1] = i+3*isec->bv_index[2*i+1];
|
||||
}
|
||||
|
||||
//Raycast
|
||||
res = RE_rayobject_intersect(obj->target, isec);
|
||||
|
||||
//Restore coordinate space coords
|
||||
if(res == 0)
|
||||
{
|
||||
isec->labda = labda;
|
||||
}
|
||||
else
|
||||
{
|
||||
isec->labda *= dist / isec->dist;
|
||||
isec->hit.ob = obj->ob;
|
||||
|
||||
#ifdef RT_USE_LAST_HIT
|
||||
// TODO support for last hit optimization in instances that can jump
|
||||
// directly to the last hit face.
|
||||
// For now it jumps directly to the last-hit instance root node.
|
||||
isec->last_hit = RE_rayobject_unalignRayAPI((RayObject*) obj);
|
||||
#endif
|
||||
}
|
||||
isec->dist = dist;
|
||||
VECCOPY( isec->start, start );
|
||||
VECCOPY( isec->vec, vec );
|
||||
|
||||
if(changed)
|
||||
isec->orig.ob = obj->ob;
|
||||
|
||||
//Update idot_axis and bv_index
|
||||
for(i=0; i<3; i++)
|
||||
{
|
||||
isec->idot_axis[i] = 1.0f / isec->vec[i];
|
||||
|
||||
isec->bv_index[2*i] = isec->idot_axis[i] < 0.0 ? 1 : 0;
|
||||
isec->bv_index[2*i+1] = 1 - isec->bv_index[2*i];
|
||||
|
||||
isec->bv_index[2*i] = i+3*isec->bv_index[2*i];
|
||||
isec->bv_index[2*i+1] = i+3*isec->bv_index[2*i+1];
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static void RE_rayobject_instance_free(RayObject *o)
|
||||
{
|
||||
InstanceRayObject *obj = (InstanceRayObject*)o;
|
||||
MEM_freeN(obj);
|
||||
}
|
||||
|
||||
static float RE_rayobject_instance_cost(RayObject *o)
|
||||
{
|
||||
InstanceRayObject *obj = (InstanceRayObject*)o;
|
||||
return RE_rayobject_cost(obj->target) + RE_COST_INSTANCE;
|
||||
}
|
||||
|
||||
static void RE_rayobject_instance_bb(RayObject *o, float *min, float *max)
|
||||
{
|
||||
//TODO:
|
||||
// *better bb.. calculated without rotations of bb
|
||||
// *maybe cache that better-fitted-BB at the InstanceRayObject
|
||||
InstanceRayObject *obj = (InstanceRayObject*)o;
|
||||
|
||||
float m[3], M[3], t[3];
|
||||
int i, j;
|
||||
INIT_MINMAX(m, M);
|
||||
RE_rayobject_merge_bb(obj->target, m, M);
|
||||
|
||||
//There must be a faster way than rotating all the 8 vertexs of the BB
|
||||
for(i=0; i<8; i++)
|
||||
{
|
||||
for(j=0; j<3; j++) t[j] = i&(1<<j) ? M[j] : m[j];
|
||||
mul_m4_v3(obj->target2global, t);
|
||||
DO_MINMAX(t, min, max);
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,87 +0,0 @@
|
||||
/**
|
||||
* $Id: rayobject_raycounter.c 23649 2009-10-06 02:56:11Z jaguarandi $
|
||||
*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2009 Blender Foundation.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The Original Code is: all of this file.
|
||||
*
|
||||
* Contributor(s): André Pinto.
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
#include "rayobject.h"
|
||||
#include "raycounter.h"
|
||||
|
||||
#ifdef RE_RAYCOUNTER
|
||||
|
||||
void RE_RC_INFO(RayCounter *info)
|
||||
{
|
||||
printf("----------- Raycast counter --------\n");
|
||||
printf("Rays total: %llu\n", info->raycast.test );
|
||||
printf("Rays hit: %llu\n", info->raycast.hit );
|
||||
printf("\n");
|
||||
printf("BB tests: %llu\n", info->bb.test );
|
||||
printf("BB hits: %llu\n", info->bb.hit );
|
||||
printf("\n");
|
||||
printf("SIMD BB tests: %llu\n", info->simd_bb.test );
|
||||
printf("SIMD BB hits: %llu\n", info->simd_bb.hit );
|
||||
printf("\n");
|
||||
printf("Primitives tests: %llu\n", info->faces.test );
|
||||
printf("Primitives hits: %llu\n", info->faces.hit );
|
||||
printf("------------------------------------\n");
|
||||
printf("Shadow last-hit tests per ray: %f\n", info->rayshadow_last_hit.test / ((float)info->raycast.test) );
|
||||
printf("Shadow last-hit hits per ray: %f\n", info->rayshadow_last_hit.hit / ((float)info->raycast.test) );
|
||||
printf("\n");
|
||||
printf("Hint tests per ray: %f\n", info->raytrace_hint.test / ((float)info->raycast.test) );
|
||||
printf("Hint hits per ray: %f\n", info->raytrace_hint.hit / ((float)info->raycast.test) );
|
||||
printf("\n");
|
||||
printf("BB tests per ray: %f\n", info->bb.test / ((float)info->raycast.test) );
|
||||
printf("BB hits per ray: %f\n", info->bb.hit / ((float)info->raycast.test) );
|
||||
printf("\n");
|
||||
printf("SIMD tests per ray: %f\n", info->simd_bb.test / ((float)info->raycast.test) );
|
||||
printf("SIMD hits per ray: %f\n", info->simd_bb.hit / ((float)info->raycast.test) );
|
||||
printf("\n");
|
||||
printf("Primitives tests per ray: %f\n", info->faces.test / ((float)info->raycast.test) );
|
||||
printf("Primitives hits per ray: %f\n", info->faces.hit / ((float)info->raycast.test) );
|
||||
printf("------------------------------------\n");
|
||||
}
|
||||
|
||||
void RE_RC_MERGE(RayCounter *dest, RayCounter *tmp)
|
||||
{
|
||||
dest->faces.test += tmp->faces.test;
|
||||
dest->faces.hit += tmp->faces.hit;
|
||||
|
||||
dest->bb.test += tmp->bb.test;
|
||||
dest->bb.hit += tmp->bb.hit;
|
||||
|
||||
dest->simd_bb.test += tmp->simd_bb.test;
|
||||
dest->simd_bb.hit += tmp->simd_bb.hit;
|
||||
|
||||
dest->raycast.test += tmp->raycast.test;
|
||||
dest->raycast.hit += tmp->raycast.hit;
|
||||
|
||||
dest->rayshadow_last_hit.test += tmp->rayshadow_last_hit.test;
|
||||
dest->rayshadow_last_hit.hit += tmp->rayshadow_last_hit.hit;
|
||||
|
||||
dest->raytrace_hint.test += tmp->raytrace_hint.test;
|
||||
dest->raytrace_hint.hit += tmp->raytrace_hint.hit;
|
||||
}
|
||||
|
||||
#endif
|
@ -2036,11 +2036,7 @@ void setupGamePython(KX_KetsjiEngine* ketsjiengine, KX_Scene* startscene, Main *
|
||||
initVideoTexture();
|
||||
|
||||
/* could be done a lot more nicely, but for now a quick way to get bge.* working */
|
||||
<<<<<<< .working
|
||||
PyRun_SimpleString("sys = __import__('sys');mod = sys.modules['bge'] = type(sys)('bge');mod.__dict__.update({'logic':__import__('GameLogic'), 'render':__import__('Rasterizer'), 'events':__import__('GameKeys'), 'constraints':__import__('PhysicsConstraints'), 'types':__import__('GameTypes')});");
|
||||
=======
|
||||
PyRun_SimpleString("sys = __import__('sys');mod = sys.modules['bge'] = type(sys)('bge');mod.__dict__.update({'logic':__import__('GameLogic'), 'render':__import__('Rasterizer'), 'events':__import__('GameKeys'), 'constraints':__import__('PhysicsConstraints'), 'types':__import__('GameTypes'), 'texture':__import__('VideoTexture')});");
|
||||
>>>>>>> .merge-right.r35190
|
||||
}
|
||||
|
||||
static struct PyModuleDef Rasterizer_module_def = {
|
||||
|
@ -819,9 +819,6 @@ void RAS_OpenGLRasterizer::IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi)
|
||||
current_ms = &ms;
|
||||
current_mesh = ms.m_mesh;
|
||||
current_wireframe = wireframe;
|
||||
<<<<<<< .working
|
||||
MCol *mcol = (MCol*)ms.m_pDerivedMesh->getTessFaceDataArray(ms.m_pDerivedMesh, CD_MCOL);
|
||||
=======
|
||||
// MCol *mcol = (MCol*)ms.m_pDerivedMesh->getFaceDataArray(ms.m_pDerivedMesh, CD_MCOL); /* UNUSED */
|
||||
|
||||
// handle two-side
|
||||
@ -830,7 +827,6 @@ void RAS_OpenGLRasterizer::IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi)
|
||||
else
|
||||
this->SetCullFace(true);
|
||||
|
||||
>>>>>>> .merge-right.r35190
|
||||
if (current_polymat->GetFlag() & RAS_BLENDERGLSL) {
|
||||
// GetMaterialIndex return the original mface material index,
|
||||
// increment by 1 to match what derived mesh is doing
|
||||
|
Loading…
Reference in New Issue
Block a user