t_block *block_copy(t_block *block) { t_context *C=ctx_get(); scene_store(C->scene,1); t_node *clone_node = block_make(block->id.name,block->type); t_block *clone_block = clone_node->data; clone_block->block_state.draw_outline = block->block_state.draw_outline; _add_block(C,clone_block); vcp(clone_block->pos,block->pos); t_link *l; t_brick *b; for(l=block->bricks->first;l;l=l->next) { b=l->data; brick_copy(clone_block,b); } scene_store(C->scene,0); return clone_block; }
void exe_add_brick(t_action *action) { t_context *C = ctx_get(); scene_store(C->scene, 1); t_dict *args = action->args; t_brick *brick = dict_pop_data(args,"brick"); t_block *block=brick->block; t_node *n=add_part_slider_float(C,block,".",NULL); t_brick *b=n->data; b->brick_state.is_versatil=1; lst_lifo( block->bricks); block_brick_set_order( block); block->pos[1] -= b->geom.height; brick_rhizome_setup(b); t_plug *p_in = &b->plug_in; p_in->state.follow_in=1; //p_in->state.can_connect = 0; block->block_state.update_geometry=1; scene_store(C->scene,0); }
void op_add_register(t_context *C,const char *name,void *ptr) { scene_store(C->scene,1); t_dict *dict = register_dict_get(); scene_add_data(C->scene,"app_data", dict->id.name, name, ptr); dict_symbol_add(dict,name,dt_pointer,ptr); scene_store(C->scene,0); }
void add_exe_remove_brick(t_brick *brick) { t_scene *sc = scene_get(); scene_store( sc, 1); t_action *action = action_new("action"); action->act = exe_remove_brick; t_dict *dict = dict_make("args"); action->args = dict; action->brick = brick; dict_symbol_add(action->args,"brick",dt_null,brick); exe_add_action(action); scene_store( sc, 0); }
void exe_remove_brick(t_action *action) { // remove brick t_dict *args = action->args; t_brick *_brick = dict_pop_data(args,"brick"); t_block *block = _brick->block; int remove_connected = _brick->brick_state.remove_connected; t_plug *plug_intern = &_brick->plug_intern; int *slider = plug_intern->data; t_lst *bricks=block->bricks; t_link *first = bricks->first; t_brick *brick=NULL; if(first) brick = first->data; t_context *C = ctx_get(); scene_store( C->scene, 1); if(brick) { // check if bricks are not connected if(brick_delete(brick,remove_connected)) { // remove link from bricks list_link_remove( bricks, first); brick_rhizome_setup(brick); block->tot_bricks--; block->block_state.update_geometry=1; block_brick_set_order( block); block->pos[1] += brick->geom.height; } else { // re-increment slider (*slider)++; } } scene_store( C->scene, 0); }
void add_exe_add_brick(t_brick *brick,t_brick *brick_target,void (* f)(t_action *)) { t_scene *sc = scene_get(); scene_store( sc, 1); t_action *action = action_new("action"); action->act = f; t_dict *dict = dict_make("args"); action->args = dict; action->brick = brick; dict_symbol_add(action->args,"brick",dt_null,brick); dict_symbol_add(action->args,"target",dt_null,brick_target); exe_add_action(action); scene_store( sc, 0); }
t_block *block_dupli(t_block *block) { t_context *C=ctx_get(); scene_store(C->scene,1); t_node *clone_node=add_block(C,block->id.name); t_block *clone_block=clone_node->data; vcp(clone_block->pos,block->pos); clone_block->pos[0]+=10; clone_block->pos[1]+=10; clone_block->block_state.draw_clone_link = 1; t_link *l; t_brick *b; for(l=block->bricks->first;l;l=l->next) { b=l->data; brick_dupli(clone_block,b); } if( block->clone) { clone_block->clone = block->clone; } else { clone_block->clone = block; } t_block *block_parent = clone_block->clone; block_parent->clones+=1; scene_store(C->scene,0); return clone_block; }
void register_set(t_context *C) { //store scene_store(C->scene,1); // func scene_add_data(C->scene,"app_data","func","op_slider", (void *) op_slider); scene_add_data(C->scene,"app_data","func","op_slider_positive", (void *) op_slider_positive); scene_add_data(C->scene,"app_data","func","op_slider_positive_non_zero", (void *) op_slider_positive_non_zero); scene_add_data(C->scene,"app_data","func","op_slider_even_positive_strict", (void *) op_slider_even_positive_strict); scene_add_data(C->scene,"app_data","func","op_cos", (void *) op_cos); scene_add_data(C->scene,"app_data","func","op_sin", (void *) op_sin); scene_add_data(C->scene,"app_data","func","op_add", (void *) op_add); scene_add_data(C->scene,"app_data","func","op_mult", (void *) op_mult); scene_add_data(C->scene,"app_data","func","op_equal", (void *) op_equal); scene_add_data(C->scene,"app_data","func","op_superior", (void *) op_superior); scene_add_data(C->scene,"app_data","func","op_inferior", (void *) op_inferior); scene_add_data(C->scene,"app_data","func","op_clone", (void *) op_clone); scene_add_data(C->scene,"app_data","func","op_plusplus", (void *) op_plusplus); scene_add_data(C->scene,"app_data","func","op_switch", (void *) op_switch); scene_add_data(C->scene,"app_data","func","op_pointer", (void *) op_pointer); scene_add_data(C->scene,"app_data","func","op_camera_rotate_z", (void *) op_camera_rotate_z); scene_add_data(C->scene,"app_data","func","op_camera_rotate_xy", (void *) op_camera_rotate_xy); scene_add_data(C->scene,"app_data","func","op_void_exe", (void *) op_void_exe); scene_add_data(C->scene,"app_data","func","op_void_act", (void *) op_void_act); scene_add_data(C->scene,"app_data","func","op_set_selected", (void *) op_set_selected); scene_add_data(C->scene,"app_data","func","op_rewind", (void *) op_rewind); scene_add_data(C->scene,"app_data","func","op_pipe", (void *) op_pipe); scene_add_data(C->scene,"app_data","func","op_not", (void *) op_not); scene_add_data(C->scene,"app_data","func","op_set_vlst", (void *) op_set_vlst); scene_add_data(C->scene,"app_data","func","op_rnd", (void *) op_rnd); scene_add_data(C->scene,"app_data","func","op_neg", (void *) op_neg); scene_add_data(C->scene,"app_data","func","op_is_last", (void *) op_is_last); scene_add_data(C->scene,"app_data","func","op_vector", (void *) op_vector); scene_add_data(C->scene,"app_data","func","op_bang", (void *) op_bang); scene_add_data(C->scene,"app_data","func","op_do_quit", (void *) op_do_quit); scene_add_data(C->scene,"app_data","func","op_operator", (void *) op_operator); scene_add_data(C->scene,"app_data","func","op_float", (void *) op_float); scene_add_data(C->scene,"app_data","func","op_int", (void *) op_int); scene_add_data(C->scene,"app_data","func","op_const", (void *) op_const); scene_add_data(C->scene,"app_data","func","op_and", (void *) op_and); scene_add_data(C->scene,"app_data","func","op_mod", (void *) op_mod); scene_add_data(C->scene,"app_data","func","op_stack", (void *) op_stack); scene_add_data(C->scene,"app_data","func","op_if", (void *) op_if); scene_add_data(C->scene,"app_data","func","op_geo_point", (void *) op_geo_point); scene_add_data(C->scene,"app_data","func","op_geo_edge", (void *) op_geo_edge); scene_add_data(C->scene,"app_data","func","op_geo_array", (void *) op_geo_array); scene_add_data(C->scene,"app_data","func","op_geometry", (void *) op_geometry); scene_add_data(C->scene,"app_data","func","op_geo", (void *) op_geo); scene_add_data(C->scene,"app_data","func","_op_brick_add", (void *) _op_brick_add); // data scene_add_data(C->scene,"app_data","app","frame", &C->app->frame); scene_add_data(C->scene,"app_data","app","timer", &C->app->timer); scene_add_data(C->scene,"app_data","app","timer low", &C->app->timer_add_low); scene_add_data(C->scene,"app_data","app","sec", &C->app->clock->sec); scene_add_data(C->scene,"app_data","app","msec", &C->app->clock->msec); scene_add_data(C->scene,"app_data","app","loaded_file", &C->app->loaded_file); //store scene_store(C->scene,0); // FUNC t_dict *dict_func = dict_make( "func"); dict_symbol_add(dict_func,"op_slider",dt_pointer, (void *) op_slider); dict_symbol_add(dict_func,"op_slider_positive",dt_pointer, (void *) op_slider_positive); dict_symbol_add(dict_func,"op_slider_positive_non_zero",dt_pointer, (void *) op_slider_positive_non_zero); dict_symbol_add(dict_func,"op_slider_positive_non_zero",dt_pointer, (void *) op_slider_positive_non_zero); dict_symbol_add(dict_func,"op_slider_even_positive_strict",dt_pointer, (void *) op_slider_even_positive_strict); dict_symbol_add(dict_func,"op_cos",dt_pointer, (void *) op_cos); dict_symbol_add(dict_func,"op_sin",dt_pointer, (void *) op_sin); dict_symbol_add(dict_func,"op_add",dt_pointer, (void *) op_add); dict_symbol_add(dict_func,"op_mult",dt_pointer, (void *) op_mult); dict_symbol_add(dict_func,"op_equal",dt_pointer,(void *) op_equal); dict_symbol_add(dict_func,"op_superior",dt_pointer, (void *) op_superior); dict_symbol_add(dict_func,"op_inferior",dt_pointer, (void *) op_inferior); dict_symbol_add(dict_func,"op_clone",dt_pointer, (void *) op_clone); dict_symbol_add(dict_func,"op_plusplus",dt_pointer, (void *) op_plusplus); dict_symbol_add(dict_func,"op_switch",dt_pointer, (void *) op_switch); dict_symbol_add(dict_func,"op_pointer",dt_pointer, (void *) op_pointer); dict_symbol_add(dict_func,"op_camera_rotate_z",dt_pointer, (void *) op_camera_rotate_z); dict_symbol_add(dict_func,"op_camera_rotate_xy",dt_pointer,(void *) op_camera_rotate_xy); dict_symbol_add(dict_func,"op_void_exe",dt_pointer, (void *) op_void_exe); dict_symbol_add(dict_func,"op_void_act",dt_pointer, (void *) op_void_act); dict_symbol_add(dict_func,"op_set_selected",dt_pointer, (void *) op_set_selected); dict_symbol_add(dict_func,"op_rewind",dt_pointer, (void *) op_rewind); dict_symbol_add(dict_func,"op_pipe",dt_pointer, (void *) op_pipe); dict_symbol_add(dict_func,"op_not",dt_pointer, (void *) op_not); dict_symbol_add(dict_func,"op_set_vlst",dt_pointer, (void *) op_set_vlst); dict_symbol_add(dict_func,"op_rnd",dt_pointer, (void *) op_rnd); dict_symbol_add(dict_func,"op_neg",dt_pointer, (void *) op_neg); dict_symbol_add(dict_func,"op_is_last",dt_pointer, (void *) op_is_last); dict_symbol_add(dict_func,"op_vector",dt_pointer,(void *) op_vector); dict_symbol_add(dict_func,"op_bang",dt_pointer, (void *) op_bang); dict_symbol_add(dict_func,"op_operator",dt_pointer, (void *) op_operator); dict_symbol_add(dict_func,"op_float",dt_pointer, (void *) op_float); dict_symbol_add(dict_func,"op_int",dt_pointer,(void *) op_int); dict_symbol_add(dict_func,"op_do_quit",dt_pointer, (void *) op_do_quit); dict_symbol_add(dict_func,"op_const",dt_pointer,(void *) op_const); dict_symbol_add(dict_func,"op_and",dt_pointer, (void *) op_and); dict_symbol_add(dict_func,"op_mod",dt_pointer, (void *) op_mod); dict_symbol_add(dict_func,"op_stack",dt_pointer, (void *) op_stack); dict_symbol_add(dict_func,"op_if",dt_pointer, (void *) op_if); dict_symbol_add(dict_func,"op_geo_point",dt_pointer, (void *) op_geo_point); dict_symbol_add(dict_func,"op_geo_edge",dt_pointer, (void *) op_geo_edge); dict_symbol_add(dict_func,"op_geo_array",dt_pointer, (void *) op_geo_array); dict_symbol_add(dict_func,"op_geometry",dt_pointer, (void *) op_geometry); dict_symbol_add(dict_func,"op_geo",dt_pointer, (void *) op_geo); dict_symbol_add(dict_func,"_op_brick_add",dt_pointer, (void *) _op_brick_add); // APP t_dict *dict_app = dict_make( "app"); dict_symbol_add(dict_app,"frame",dt_pointer,&C->app->frame); dict_symbol_add(dict_app,"timer",dt_pointer,&C->app->timer); dict_symbol_add(dict_app,"timer low",dt_pointer,&C->app->timer_add_low); dict_symbol_add(dict_app,"sec",dt_pointer,&C->app->clock->sec); dict_symbol_add(dict_app,"msec",dt_pointer,&C->app->clock->msec); dict_symbol_add(dict_app,"loaded_file",dt_pointer,&C->app->loaded_file); // MOUSE t_mouse *mouse=C->app->mouse; op_add_register(C,"mouse_x",&mouse->x); op_add_register(C,"mouse_y",&mouse->y); t_keyboard *keyboard=C->app->keyboard; op_add_register(C,"keyboard",&keyboard->key_pressed); // Viewport viewport_register( C); }
void vlst_change_data( t_vlst *vlst,t_vlst *caller) { t_context *C=ctx_get(); if(vlst->count != vlst->count_new) { void *old_ptr=vlst->data; // set count int old_count = vlst->count; vlst->count=vlst->count_new; int new_size=(vlst->size)*(vlst->length)*(vlst->count); void *new_ptr = NULL; if(old_ptr) { // get data,var t_node *node_data=scene_get_data(C->scene,old_ptr); t_node *node_var=scene_get_var(C->scene,old_ptr); // remove data,var scene_node_free(C->scene,node_data); scene_node_free(C->scene,node_var); // realloc new_ptr=realloc(vlst->data,new_size); } else { new_ptr = mem_malloc((vlst->size)*(vlst->length)*(vlst->count)); } if(!new_ptr) printf("[ERROR vls_update_data]\n"); // set new ptr vlst->data=new_ptr; // init vlst_data_init(vlst,old_count); // add new data,var scene_store(C->scene,1); scene_add_data_var(C->scene,"vlst_data","v_data",new_size,vlst->data); scene_store(C->scene,0); // shared vlst (vertex, color , ....) if(vlst->is_linked) { t_vlst *link_vlst = vlst->link; link_vlst->count_new = vlst->count; if(caller) { // prevent infinite loop if(link_vlst->id.id != caller->id.id) { vlst_update_data( link_vlst, vlst); } } else { vlst_update_data( link_vlst, vlst); } } } }
void *op_brick_add(t_brick *brick) { t_context *C = ctx_get(); t_node *node = NULL; t_block *block; t_set *set; // store scene_store(C->scene,1); char *name=brick->id.name; if(is(name,"frame")) node = add_slider_int(C,"frame",&C->app->frame); else if(is(name,"timer")) node = add_slider_float(C,"timer",&C->app->timer); else if(is(name,"timer low")) node = add_slider_float(C,"timer low",&C->app->timer_add_low); else if(is(name,"=")) node = add_operator_double(C,"="); else if(is(name,">")) node = add_operator_double(C,">"); else if(is(name,"<")) node = add_operator_double(C,"<"); else if(is(name,"if")) node = add_if(C); else if(is(name,"mod")) node = add_operator_double(C,"mod"); else if(is(name,"x")) node = add_maths(C,"x"); else if(is(name,"+")) node = add_maths(C,"+"); else if(is(name,"++")) node = add_plusplus(C); else if(is(name,"switch")) node = add_switch(C,"switch",NULL,NULL); else if(is(name,"clone")) node = add_clone(C); else if(is(name,"pipe")) node = add_pipe(C); else if(is(name,"sec")) node = add_slider_int(C,"sec",&C->app->clock->sec); else if(is(name,"min")) node = add_slider_int(C,"min",&C->app->clock->min); else if(is(name,"int")) node = add_slider_int(C,"int",NULL); else if(is(name,"float")) node = add_slider_float(C,"float",NULL); else if(is(name,"10")) node = add_multiplier(C,"10"); else if(is(name,"100")) node = add_multiplier(C,"100"); else if(is(name,".1")) node = add_multiplier(C,".1"); else if(is(name,".01")) node = add_multiplier(C,".01"); else if(is(name,".001")) node = add_multiplier(C,".001"); else if(is(name,"msec")) node = add_slider_int(C,"msec",&C->app->clock->msec); else if(is(name,"cos")) node = add_operator_single(C,"cos",op_cos); else if(is(name,"sin")) node = add_operator_single(C,"sin",op_sin); else if(is(name,"cam_eye_x")) node = add_slider_camera(C,"eye x"); else if(is(name,"cam_eye_y")) node = add_slider_camera(C,"eye y"); else if(is(name,"cam_eye_z")) node = add_slider_camera(C,"eye z"); else if(is(name,"cam_pos_x")) node = add_slider_camera(C,"pos x"); else if(is(name,"cam_pos_y")) node = add_slider_camera(C,"pos y"); else if(is(name,"cam_pos_z")) node = add_slider_camera(C,"pos z"); else if(is(name,"cam_rot_xy")) node = add_slider_float_custom(C,"cam rot xy",op_camera_rotate_xy); else if(is(name,"cam_rot_z")) node = add_slider_float_custom(C,"cam rot z",op_camera_rotate_z); else if(is(name,"pos x")) node = add_slider_object(C,"pos x"); else if(is(name,"pos y")) node = add_slider_object(C,"pos y"); else if(is(name,"pos z")) node = add_slider_object(C,"pos z"); else if(is(name,"rot x")) node = add_slider_object(C,"rot x"); else if(is(name,"rot y")) node = add_slider_object(C,"rot y"); else if(is(name,"rot z")) node = add_slider_object(C,"rot z"); else if(is(name,"scl x")) node = add_slider_object(C,"scl x"); else if(is(name,"scl y")) node = add_slider_object(C,"scl y"); else if(is(name,"scl z")) node = add_slider_object(C,"scl z"); else if(is(name,"red")) node = add_slider_object(C,"red"); else if(is(name,"green")) node = add_slider_object(C,"green"); else if(is(name,"blue")) node = add_slider_object(C,"blue"); else if(is(name,"color")) node = add_slider_object(C,"color"); else if(is(name,"faces")) node = add_slider_object(C,"faces"); else if(is(name,"alpha")) node = add_slider_object(C,"alpha"); else if(is(name,"label")) node = add_label(C,"label"); else if(is(name,"get")) node = add_get(C); else if(is(name,"rewind")) node = add_trigger_always(C,"rewind",op_rewind); else if(is(name,"not")) node = add_slider_int_custom(C,"not",NULL,op_not); else if(is(name,"mouse_x")) node = add_slider_int(C,"mouse x",&C->app->mouse->x); else if(is(name,"mouse_y")) node = add_slider_int(C,"mouse y",&C->app->mouse->y); else if(is(name,"keyboard")) node = add_slider_char(C,"keyboard",&C->app->keyboard->key_pressed); else if(is(name,"rnd")) node = add_slider_int_custom(C,"rnd",NULL,op_rnd); else if(is(name,"neg")) node = add_slider_int_custom(C,"neg",NULL,op_neg); else if(is(name,"abs")) node = add_slider_int_custom( C, "abs", NULL, op_abs); else if(is(name,"last?")) node = add_switch(C,"last?",NULL,op_is_last); else if(is(name,"for")) node = add_for(C); else if(is(name,"vector 3d")) node = add_vector_3d(C); else if(is(name,"vector 2d")) node = add_vector_2d(C); else if(is(name,"bang")) node = add_slider_int_custom(C,"bang",NULL,op_bang); else if(is(name,"quit")) node = add_trigger_always(C,"quit",op_do_quit); else if(is(name,"const")) node = add_const(C); else if(is(name,"and")) node = add_maths(C,"and"); else if(is(name,"stack")) node = add_stack(C); else if(is(name,"mesh")) node = add_slider_object(C,"mesh"); else if(is(name,"vertex")) node = add_brick_mesh(C,"vertex"); else if(is(name,"edges")) node = add_brick_mesh(C,"edges"); else if(is(name,"case")) node = add_case(C,"switch"); // Store scene_store(C->scene,0); term_log("+ brick"); // Switch Desk if(!C->ui->show_sets) show_sets(C); if( node) { block = node->data; set = block->set; set_setup( set); } return NULL; }