Object: converted the old horrible editobject.c, now as file:
editors/object/object_edit.c

Still lots of WIP, I've operatorified "Make Parent". Check here
the new API at work: http://pasteall.org/3650/c

IMPORTANT NOTE FOR BRECHT:
game property defines were clashing with RNA, i've renamed game
defines for now.
This commit is contained in:
Ton Roosendaal 2008-12-23 19:47:33 +00:00
parent 93d9e7749d
commit b38f6e7d18
18 changed files with 6015 additions and 71 deletions

@ -103,19 +103,19 @@ void init_property(bProperty *prop)
prop->data= 0;
switch(prop->type) {
case PROP_BOOL:
case GPROP_BOOL:
prop->poin= &prop->data;
break;
case PROP_INT:
case GPROP_INT:
prop->poin= &prop->data;
break;
case PROP_FLOAT:
case GPROP_FLOAT:
prop->poin= &prop->data;
break;
case PROP_STRING:
case GPROP_STRING:
prop->poin= MEM_callocN(MAX_PROPSTRING, "property string");
break;
case PROP_TIME:
case GPROP_TIME:
prop->poin= &prop->data;
break;
}
@ -168,7 +168,7 @@ int compare_property(bProperty *prop, char *str)
float fvalue, ftest;
switch(prop->type) {
case PROP_BOOL:
case GPROP_BOOL:
if(BLI_strcasecmp(str, "true")==0) {
if(prop->data==1) return 0;
else return 1;
@ -177,14 +177,14 @@ int compare_property(bProperty *prop, char *str)
if(prop->data==0) return 0;
else return 1;
}
/* no break, do prop_int too! */
/* no break, do GPROP_int too! */
case PROP_INT:
case GPROP_INT:
return prop->data - atoi(str);
case PROP_FLOAT:
case PROP_TIME:
// WARNING: untested for PROP_TIME
case GPROP_FLOAT:
case GPROP_TIME:
// WARNING: untested for GPROP_TIME
// function isn't used currently
fvalue= *((float *)&prop->data);
ftest= (float)atof(str);
@ -192,7 +192,7 @@ int compare_property(bProperty *prop, char *str)
else if( fvalue < ftest) return -1;
return 0;
case PROP_STRING:
case GPROP_STRING:
return strcmp(prop->poin, str);
}
@ -204,19 +204,19 @@ void set_property(bProperty *prop, char *str)
// extern int Gdfra; /* sector.c */
switch(prop->type) {
case PROP_BOOL:
case GPROP_BOOL:
if(BLI_strcasecmp(str, "true")==0) prop->data= 1;
else if(BLI_strcasecmp(str, "false")==0) prop->data= 0;
else prop->data= (atoi(str)!=0);
break;
case PROP_INT:
case GPROP_INT:
prop->data= atoi(str);
break;
case PROP_FLOAT:
case PROP_TIME:
case GPROP_FLOAT:
case GPROP_TIME:
*((float *)&prop->data)= (float)atof(str);
break;
case PROP_STRING:
case GPROP_STRING:
strcpy(prop->poin, str);
break;
}
@ -228,15 +228,15 @@ void add_property(bProperty *prop, char *str)
// extern int Gdfra; /* sector.c */
switch(prop->type) {
case PROP_BOOL:
case PROP_INT:
case GPROP_BOOL:
case GPROP_INT:
prop->data+= atoi(str);
break;
case PROP_FLOAT:
case PROP_TIME:
case GPROP_FLOAT:
case GPROP_TIME:
*((float *)&prop->data)+= (float)atof(str);
break;
case PROP_STRING:
case GPROP_STRING:
/* strcpy(prop->poin, str); */
break;
}
@ -250,15 +250,15 @@ void set_property_valstr(bProperty *prop, char *str)
if(str == NULL) return;
switch(prop->type) {
case PROP_BOOL:
case PROP_INT:
case GPROP_BOOL:
case GPROP_INT:
sprintf(str, "%d", prop->data);
break;
case PROP_FLOAT:
case PROP_TIME:
case GPROP_FLOAT:
case GPROP_TIME:
sprintf(str, "%f", *((float *)&prop->data));
break;
case PROP_STRING:
case GPROP_STRING:
BLI_strncpy(str, prop->poin, MAX_PROPSTRING);
break;
}

@ -5867,8 +5867,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
while (ob) {
prop= ob->prop.first;
while(prop) {
if (prop->type == PROP_TIME) {
// convert old PROP_TIME values from int to float
if (prop->type == GPROP_TIME) {
// convert old GPROP_TIME values from int to float
*((float *)&prop->data) = (float) prop->data;
}

@ -29,6 +29,6 @@
# Bounces make to subdirectories.
SOURCEDIR = source/blender/editors
DIRS = animation datafiles screen space_outliner space_time space_view3d interface util space_api space_ipo space_image space_node space_buttons space_info space_file space_sound space_action space_nla space_script space_text space_sequencer
DIRS = animation object datafiles screen space_outliner space_time space_view3d interface util space_api space_ipo space_image space_node space_buttons space_info space_file space_sound space_action space_nla space_script space_text space_sequencer
include nan_subdirs.mk

@ -0,0 +1,73 @@
/**
* $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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
*
* Contributor(s): Blender Foundation, Joshua Leung
*
* ***** END GPL LICENSE BLOCK *****
*/
#include <stdlib.h>
#include <math.h>
#include "MEM_guardedalloc.h"
#include "DNA_action_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
#include "DNA_view3d_types.h"
#include "DNA_windowmanager_types.h"
#include "BLI_blenlib.h"
#include "BKE_context.h"
#include "BKE_depsgraph.h"
#include "BKE_utildefines.h"
#include "RNA_access.h"
#include "RNA_define.h"
/* ***************** depsgraph calls and anim updates ************* */
/* generic update flush, reads from context Screen (layers) and scene */
/* this is for compliancy, later it can do all windows etc */
void ED_anim_dag_flush_update(bContext *C)
{
Scene *scene= CTX_data_scene(C);
bScreen *screen= CTX_wm_screen(C);
int layer= scene->lay; /* as minimum this */
if(screen) {
ScrArea *sa;
/* get all used view3d layers */
for(sa= screen->areabase.first; sa; sa= sa->next) {
if(sa->spacetype==SPACE_VIEW3D)
layer |= ((View3D *)sa->spacedata.first)->lay;
}
}
DAG_scene_flush_update(scene, layer, 0);
}

@ -281,6 +281,12 @@ void ANIM_nla_mapping_apply(struct Object *ob, struct Ipo *ipo, short restore, s
/* ------------- xxx macros ----------------------- */
#define BEZSELECTED(bezt) ((bezt->f2 & SELECT) || (bezt->f1 & SELECT) || (bezt->f3 & SELECT))
/* --------- anim_deps.c, animation updates -------- */
/* generic update flush, reads from Context screen (layers) and scene */
void ED_anim_dag_flush_update(struct bContext *C);
/* ************************************************* */
/* OPERATORS */

@ -28,6 +28,15 @@
#ifndef ED_OBJECT_H
#define ED_OBJECT_H
struct wmWindowManager;
struct Object;
void ED_operatortypes_object(void);
void ED_keymap_object(struct wmWindowManager *wm);
/* cleanup */
int object_data_is_libdata(struct Object *ob);
int object_is_libdata(struct Object *ob);
#endif /* ED_OBJECT_H */

@ -0,0 +1,36 @@
/**
* $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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
*
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef ED_VIEW3D_H
#define ED_VIEW3D_H
/* ********* exports for space_view3d/ module ********** */
float *give_cursor(Scene *scene, View3D *v3d);
#endif /* ED_VIEW3D_H */

@ -28,7 +28,7 @@
#
# Makes module object directory and bounces make to subdirectories.
LIBNAME = ed_screen
LIBNAME = ed_object
DIR = $(OCGDIR)/blender/$(LIBNAME)
include nan_compile.mk
@ -45,6 +45,7 @@ CPPFLAGS += -I../../blenkernel
CPPFLAGS += -I../../blenloader
CPPFLAGS += -I../../blenlib
CPPFLAGS += -I../../makesdna
CPPFLAGS += -I../../makesrna
CPPFLAGS += -I../../imbuf
# own include

@ -0,0 +1,11 @@
#!/usr/bin/python
Import ('env')
sources = env.Glob('*.c')
incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf'
incs += ' ../../windowmanager #/intern/guardedalloc'
incs += ' #/intern/guardedalloc #intern/bmfont'
incs += ' ../../makesrna'
env.BlenderLib ( 'bf_editors_object', sources, Split(incs), [], libtype=['core','intern'], priority=[33, 38] )

File diff suppressed because it is too large Load Diff

@ -0,0 +1,39 @@
/**
* $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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
*
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef ED_OBJECT_INTERN_H
#define ED_OBJECT_INTERN_H
/* internal exports only */
/* object_edit.c */
void ED_VIEW3D_OT_make_parent(wmOperatorType *ot);
#endif /* ED_OBJECT_INTERN_H */

@ -0,0 +1,77 @@
/**
* $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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
*
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
*/
#include <stdlib.h>
#include <math.h>
#include "MEM_guardedalloc.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
#include "DNA_userdef_types.h"
#include "DNA_view3d_types.h"
#include "DNA_windowmanager_types.h"
#include "BLI_arithb.h"
#include "BLI_blenlib.h"
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_utildefines.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "WM_api.h"
#include "WM_types.h"
#include "ED_screen.h"
#include "ED_object.h"
#include "object_intern.h"
/* ************************** registration **********************************/
void ED_operatortypes_object(void)
{
WM_operatortype_append(ED_VIEW3D_OT_make_parent);
}
/* note object keymap also for other space? */
void ED_keymap_object(wmWindowManager *wm)
{
ListBase *keymap= WM_keymap_listbase(wm, "View3D Object", SPACE_VIEW3D, 0);
WM_keymap_verify_item(keymap, "ED_VIEW3D_OT_make_parent", PKEY, KM_PRESS, KM_CTRL, 0);
// RNA_int_set(WM_keymap_add_item(keymap, "ED_VIEW3D_OT_viewzoom", PADPLUSKEY, KM_PRESS, 0, 0)->ptr, "delta", 1);
}

@ -38,6 +38,7 @@
#include "BIF_gl.h"
#include "ED_screen.h"
#include "ED_object.h"
#include "ED_space_api.h"
#include "ED_anim_api.h"
@ -81,8 +82,9 @@ void ED_spacetypes_init(void)
/* register operator types for screen and all spaces */
ED_operatortypes_screen();
ui_view2d_operatortypes();
ED_operatortypes_anim();
ED_operatortypes_object();
ui_view2d_operatortypes();
spacetypes = BKE_spacetypes_list();
for(type=spacetypes->first; type; type=type->next)
@ -99,8 +101,9 @@ void ED_spacetypes_keymap(wmWindowManager *wm)
ARegionType *atype;
ED_keymap_screen(wm);
UI_view2d_keymap(wm);
ED_keymap_anim(wm);
ED_keymap_object(wm);
UI_view2d_keymap(wm);
spacetypes = BKE_spacetypes_list();
for(stype=spacetypes->first; stype; stype=stype->next) {

@ -195,7 +195,10 @@ static void view3d_main_area_init(wmWindowManager *wm, ARegion *ar)
ListBase *keymap;
/* own keymap */
keymap= WM_keymap_listbase(wm, "View3D", SPACE_VIEW3D, 0); /* XXX weak? */
keymap= WM_keymap_listbase(wm, "View3D", SPACE_VIEW3D, 0);
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, NULL, NULL);
/* object ops, modal later... */
keymap= WM_keymap_listbase(wm, "View3D Object", SPACE_VIEW3D, 0);
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, NULL, NULL);
}

@ -63,6 +63,7 @@
#include "BKE_utildefines.h" /* for VECCOPY */
#include "ED_screen.h"
#include "ED_object.h"
#include "ED_util.h"
#include "ED_types.h"
@ -109,23 +110,19 @@
if( (v3d->lay & G.obedit->lay)==0 ) return;
/* XXX port over */
void handle_view3d_lock(void) {}
void allqueue(int x, int y) {}
void persptoetsen(int x) {}
void fly(void) {}
void editmesh_align_view_to_selected(void *x, int y) {}
void play_anim(int x) {}
void add_blockhandler(void *x, int y, int z) {}
void toggle_blockhandler(void *x, int y, int z) {}
void view3d_border_zoom(void);
void selectlinks(void) {}
void countall(void) {}
void select_object_grouped() {}
static void handle_view3d_lock(void) {}
static void allqueue(int x, int y) {}
static void persptoetsen(int x) {}
static void fly(void) {}
static void editmesh_align_view_to_selected(void *x, int y) {}
static void play_anim(int x) {}
static void add_blockhandler(void *x, int y, int z) {}
static void toggle_blockhandler(void *x, int y, int z) {}
static void countall(void) {}
extern void borderselect();
int BIF_snappingSupported() {return 1;}
void BIF_undo_push() {}
int retopo_mesh_paint_check() {return 0;}
int object_data_is_libdata() {return 0;}
static int BIF_snappingSupported() {return 1;}
static void BIF_undo_push() {}
static int retopo_mesh_paint_check() {return 0;}
/* view3d handler codes */
#define VIEW3D_HANDLER_BACKGROUND 1
@ -569,7 +566,7 @@ static void do_view3d_viewmenu(bContext *C, void *arg, int event)
toggle_blockhandler(sa, VIEW3D_HANDLER_PREVIEW, 0);
break;
case 19: /* zoom within border */
view3d_border_zoom();
// view3d_border_zoom();
break;
case 20: /* Transform Space Panel */
add_blockhandler(sa, VIEW3D_HANDLER_TRANSFORM, UI_PNL_UNSTOW);

@ -28,6 +28,8 @@
#ifndef ED_VIEW3D_INTERN_H
#define ED_VIEW3D_INTERN_H
#include "ED_view3d.h"
/* internal exports only */
struct BoundBox;
@ -115,7 +117,6 @@ void ED_VIEW3D_OT_circle_select(struct wmOperatorType *ot);
/* view3d_view.c */
void view3d_operator_needs_opengl(const struct bContext *C);
float *give_cursor(Scene *scene, View3D *v3d);
void viewline(ARegion *ar, View3D *v3d, short mval[2], float ray_start[3], float ray_end[3]);
void viewray(ARegion *ar, View3D *v3d, short mval[2], float ray_start[3], float ray_normal[3]);

@ -48,13 +48,13 @@ typedef struct bProperty {
} bProperty;
/* property->type */
#define PROP_BOOL 0
#define PROP_INT 1
#define PROP_FLOAT 2
#define PROP_STRING 3
#define PROP_VECTOR 4
#define PROP_TIME 5
/* property->type XXX Game Property, not RNA */
#define GPROP_BOOL 0
#define GPROP_INT 1
#define GPROP_FLOAT 2
#define GPROP_STRING 3
#define GPROP_VECTOR 4
#define GPROP_TIME 5
/* property->flag */
#define PROP_DEBUG 1

@ -39,15 +39,15 @@ static StructRNA* rna_GameProperty_refine(struct PointerRNA *ptr)
bProperty *property= (bProperty*)ptr->data;
switch(property->type){
case PROP_BOOL:
case GPROP_BOOL:
return &RNA_GameBooleanProperty;
case PROP_INT:
case GPROP_INT:
return &RNA_GameIntProperty;
case PROP_FLOAT:
case GPROP_FLOAT:
return &RNA_GameFloatProperty;
case PROP_STRING:
case GPROP_STRING:
return &RNA_GameStringProperty;
case PROP_TIME:
case GPROP_TIME:
return &RNA_GameTimeProperty;
default:
return &RNA_GameProperty;
@ -76,11 +76,11 @@ void RNA_def_gameproperty(BlenderRNA *brna)
PropertyRNA *prop;
static EnumPropertyItem gameproperty_type_items[] ={
{PROP_BOOL, "BOOL", "Boolean", ""},
{PROP_INT, "INT", "Integer", ""},
{PROP_FLOAT, "FLOAT", "Float", ""},
{PROP_STRING, "STRING", "String", ""},
{PROP_TIME, "TIME", "Time", ""},
{GPROP_BOOL, "BOOL", "Boolean", ""},
{GPROP_INT, "INT", "Integer", ""},
{GPROP_FLOAT, "FLOAT", "Float", ""},
{GPROP_STRING, "STRING", "String", ""},
{GPROP_TIME, "TIME", "Time", ""},
{0, NULL, NULL, NULL}};
/* Base Struct for GameProperty */