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

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

@ -29,6 +29,6 @@
# Bounces make to subdirectories. # Bounces make to subdirectories.
SOURCEDIR = source/blender/editors 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 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 ----------------------- */ /* ------------- xxx macros ----------------------- */
#define BEZSELECTED(bezt) ((bezt->f2 & SELECT) || (bezt->f1 & SELECT) || (bezt->f3 & SELECT)) #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 */ /* OPERATORS */

@ -28,6 +28,15 @@
#ifndef ED_OBJECT_H #ifndef ED_OBJECT_H
#define 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 */ #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. # Makes module object directory and bounces make to subdirectories.
LIBNAME = ed_screen LIBNAME = ed_object
DIR = $(OCGDIR)/blender/$(LIBNAME) DIR = $(OCGDIR)/blender/$(LIBNAME)
include nan_compile.mk include nan_compile.mk
@ -45,6 +45,7 @@ CPPFLAGS += -I../../blenkernel
CPPFLAGS += -I../../blenloader CPPFLAGS += -I../../blenloader
CPPFLAGS += -I../../blenlib CPPFLAGS += -I../../blenlib
CPPFLAGS += -I../../makesdna CPPFLAGS += -I../../makesdna
CPPFLAGS += -I../../makesrna
CPPFLAGS += -I../../imbuf CPPFLAGS += -I../../imbuf
# own include # 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 "BIF_gl.h"
#include "ED_screen.h" #include "ED_screen.h"
#include "ED_object.h"
#include "ED_space_api.h" #include "ED_space_api.h"
#include "ED_anim_api.h" #include "ED_anim_api.h"
@ -81,8 +82,9 @@ void ED_spacetypes_init(void)
/* register operator types for screen and all spaces */ /* register operator types for screen and all spaces */
ED_operatortypes_screen(); ED_operatortypes_screen();
ui_view2d_operatortypes();
ED_operatortypes_anim(); ED_operatortypes_anim();
ED_operatortypes_object();
ui_view2d_operatortypes();
spacetypes = BKE_spacetypes_list(); spacetypes = BKE_spacetypes_list();
for(type=spacetypes->first; type; type=type->next) for(type=spacetypes->first; type; type=type->next)
@ -99,8 +101,9 @@ void ED_spacetypes_keymap(wmWindowManager *wm)
ARegionType *atype; ARegionType *atype;
ED_keymap_screen(wm); ED_keymap_screen(wm);
UI_view2d_keymap(wm);
ED_keymap_anim(wm); ED_keymap_anim(wm);
ED_keymap_object(wm);
UI_view2d_keymap(wm);
spacetypes = BKE_spacetypes_list(); spacetypes = BKE_spacetypes_list();
for(stype=spacetypes->first; stype; stype=stype->next) { for(stype=spacetypes->first; stype; stype=stype->next) {

@ -195,7 +195,10 @@ static void view3d_main_area_init(wmWindowManager *wm, ARegion *ar)
ListBase *keymap; ListBase *keymap;
/* own 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); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, NULL, NULL);
} }

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

@ -28,6 +28,8 @@
#ifndef ED_VIEW3D_INTERN_H #ifndef ED_VIEW3D_INTERN_H
#define ED_VIEW3D_INTERN_H #define ED_VIEW3D_INTERN_H
#include "ED_view3d.h"
/* internal exports only */ /* internal exports only */
struct BoundBox; struct BoundBox;
@ -115,7 +117,6 @@ void ED_VIEW3D_OT_circle_select(struct wmOperatorType *ot);
/* view3d_view.c */ /* view3d_view.c */
void view3d_operator_needs_opengl(const struct bContext *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 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]); 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; } bProperty;
/* property->type */ /* property->type XXX Game Property, not RNA */
#define PROP_BOOL 0 #define GPROP_BOOL 0
#define PROP_INT 1 #define GPROP_INT 1
#define PROP_FLOAT 2 #define GPROP_FLOAT 2
#define PROP_STRING 3 #define GPROP_STRING 3
#define PROP_VECTOR 4 #define GPROP_VECTOR 4
#define PROP_TIME 5 #define GPROP_TIME 5
/* property->flag */ /* property->flag */
#define PROP_DEBUG 1 #define PROP_DEBUG 1

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