Beispiel #1
0
/**
 * Handle the copying of logic data into a new object, including internal logic links update.
 * External links (links between logic bricks of different objects) must be handled separately.
 */
void BKE_sca_logic_copy(Object *ob_new, const Object *ob, const int flag)
{
	copy_sensors(&ob_new->sensors, &ob->sensors, flag);
	copy_controllers(&ob_new->controllers, &ob->controllers, flag);
	copy_actuators(&ob_new->actuators, &ob->actuators, flag);

	for (bSensor *sens = ob_new->sensors.first; sens; sens = sens->next) {
		if (sens->flag & SENS_NEW) {
			for (int a = 0; a < sens->totlinks; a++) {
				if (sens->links[a] && sens->links[a]->mynew) {
					sens->links[a] = sens->links[a]->mynew;
				}
			}
		}
	}

	for (bController *cont = ob_new->controllers.first; cont; cont = cont->next) {
		if (cont->flag & CONT_NEW) {
			for (int a = 0; a < cont->totlinks; a++) {
				if (cont->links[a] && cont->links[a]->mynew) {
					cont->links[a] = cont->links[a]->mynew;
				}
			}
		}
	}
}
Beispiel #2
0
static void copymenu_logicbricks(Scene *scene, View3D *v3d, Object *ob)
{
//XXX no longer used - to be removed - replaced by logicbricks_copy_exec
	Base *base;
	
	for (base= FIRSTBASE; base; base= base->next) {
		if (base->object != ob) {
			if (TESTBASELIB(v3d, base)) {
				
				/* first: free all logic */
				free_sensors(&base->object->sensors);				
				unlink_controllers(&base->object->controllers);
				free_controllers(&base->object->controllers);
				unlink_actuators(&base->object->actuators);
				free_actuators(&base->object->actuators);
				
				/* now copy it, this also works without logicbricks! */
				clear_sca_new_poins_ob(ob);
				copy_sensors(&base->object->sensors, &ob->sensors);
				copy_controllers(&base->object->controllers, &ob->controllers);
				copy_actuators(&base->object->actuators, &ob->actuators);
				set_sca_new_poins_ob(base->object);
				
				/* some menu settings */
				base->object->scavisflag= ob->scavisflag;
				base->object->scaflag= ob->scaflag;
				
				/* set the initial state */
				base->object->state= ob->state;
				base->object->init_state= ob->init_state;
			}
		}
	}
}