예제 #1
0
파일: anim_ops.c 프로젝트: UPBGE/blender
static int previewrange_define_exec(bContext *C, wmOperator *op)
{
	Scene *scene = CTX_data_scene(C);
	ARegion *ar = CTX_wm_region(C);
	float sfra, efra;
	rcti rect;
	
	/* get min/max values from border select rect (already in region coordinates, not screen) */
	WM_operator_properties_border_to_rcti(op, &rect);
	
	/* convert min/max values to frames (i.e. region to 'tot' rect) */
	sfra = UI_view2d_region_to_view_x(&ar->v2d, rect.xmin);
	efra = UI_view2d_region_to_view_x(&ar->v2d, rect.xmax);
	
	/* set start/end frames for preview-range 
	 *	- must clamp within allowable limits
	 *	- end must not be before start (though this won't occur most of the time)
	 */
	FRAMENUMBER_MIN_CLAMP(sfra);
	FRAMENUMBER_MIN_CLAMP(efra);
	if (efra < sfra) efra = sfra;
	
	scene->r.flag |= SCER_PRV_RANGE;
	scene->r.psfra = iroundf(sfra);
	scene->r.pefra = iroundf(efra);
	
	/* send notifiers */
	WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
	
	return OPERATOR_FINISHED;
} 
예제 #2
0
static int previewrange_define_exec(bContext *C, wmOperator *op)
{
    Scene *scene= CTX_data_scene(C);
    ARegion *ar= CTX_wm_region(C);
    float sfra, efra;
    int xmin, xmax;

    /* get min/max values from border select rect (already in region coordinates, not screen) */
    xmin= RNA_int_get(op->ptr, "xmin");
    xmax= RNA_int_get(op->ptr, "xmax");

    /* convert min/max values to frames (i.e. region to 'tot' rect) */
    UI_view2d_region_to_view(&ar->v2d, xmin, 0, &sfra, NULL);
    UI_view2d_region_to_view(&ar->v2d, xmax, 0, &efra, NULL);

    /* set start/end frames for preview-range
     *	- must clamp within allowable limits
     *	- end must not be before start (though this won't occur most of the time)
     */
    FRAMENUMBER_MIN_CLAMP(sfra);
    FRAMENUMBER_MIN_CLAMP(efra);
    if (efra < sfra) efra= sfra;

    scene->r.flag |= SCER_PRV_RANGE;
    scene->r.psfra= (int)floor(sfra + 0.5f);
    scene->r.pefra= (int)floor(efra + 0.5f);

    /* send notifiers */
    WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);

    return OPERATOR_FINISHED;
}
예제 #3
0
파일: anim_ops.c 프로젝트: dfelinto/blender
/* Set the new frame number */
static void change_frame_apply(bContext *C, wmOperator *op)
{
  Main *bmain = CTX_data_main(C);
  Scene *scene = CTX_data_scene(C);
  float frame = RNA_float_get(op->ptr, "frame");
  bool do_snap = RNA_boolean_get(op->ptr, "snap");

  if (do_snap) {
    if (CTX_wm_space_seq(C)) {
      frame = BKE_sequencer_find_next_prev_edit(scene, frame, SEQ_SIDE_BOTH, true, false, false);
    }
    else {
      frame = BKE_scene_frame_snap_by_seconds(scene, 1.0, frame);
    }
  }

  /* set the new frame number */
  if (scene->r.flag & SCER_SHOW_SUBFRAME) {
    CFRA = (int)frame;
    SUBFRA = frame - (int)frame;
  }
  else {
    CFRA = round_fl_to_int(frame);
    SUBFRA = 0.0f;
  }
  FRAMENUMBER_MIN_CLAMP(CFRA);

  /* do updates */
  BKE_sound_seek_scene(bmain, scene);
  WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
}
예제 #4
0
static void change_frame_apply(bContext *C, wmOperator *op)
{
	Scene *scene = CTX_data_scene(C);

	/* set the new frame number */
	CFRA = RNA_int_get(op->ptr, "frame");
	FRAMENUMBER_MIN_CLAMP(CFRA);
	SUBFRA = 0.0f;

	/* do updates */
	sound_seek_scene(CTX_data_main(C), CTX_data_scene(C));
	WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
}
예제 #5
0
파일: anim_ops.c 프로젝트: UPBGE/blender
/* Set the new frame number */
static void change_frame_apply(bContext *C, wmOperator *op)
{
	Main *bmain = CTX_data_main(C);
	Scene *scene = CTX_data_scene(C);
	int frame = RNA_int_get(op->ptr, "frame");
	bool do_snap = RNA_boolean_get(op->ptr, "snap");

	if (do_snap && CTX_wm_space_seq(C)) {
		frame = BKE_sequencer_find_next_prev_edit(scene, frame, SEQ_SIDE_BOTH, true, false, false);
	}

	/* set the new frame number */
	CFRA = frame;
	FRAMENUMBER_MIN_CLAMP(CFRA);
	SUBFRA = 0.0f;
	
	/* do updates */
	BKE_sound_seek_scene(bmain, scene);
	WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
}
예제 #6
0
/* Set the new frame number */
static void graphview_cursor_apply(bContext *C, wmOperator *op)
{
	Main *bmain = CTX_data_main(C);
	Scene *scene = CTX_data_scene(C);
	SpaceIpo *sipo = CTX_wm_space_graph(C);
	
	/* adjust the frame 
	 * NOTE: sync this part of the code with ANIM_OT_change_frame
	 */
	CFRA = RNA_int_get(op->ptr, "frame");
	FRAMENUMBER_MIN_CLAMP(CFRA);
	SUBFRA = 0.f;
	BKE_sound_seek_scene(bmain, scene);
	
	/* set the cursor value */
	sipo->cursorVal = RNA_float_get(op->ptr, "value");
	
	/* send notifiers - notifiers for frame should force an update for both vars ok... */
	WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
}
예제 #7
0
/* Set the new frame number */
static void graphview_cursor_apply(bContext *C, wmOperator *op)
{
	Main *bmain = CTX_data_main(C);
	Scene *scene = CTX_data_scene(C);
	SpaceIpo *sipo = CTX_wm_space_graph(C);
	float frame = RNA_float_get(op->ptr, "frame"); /* this isn't technically "frame", but it'll do... */
	
	/* adjust the frame or the cursor x-value */
	if (sipo->mode == SIPO_MODE_DRIVERS) {
		/* adjust cursor x-value */
		sipo->cursorTime = frame;
	}
	else {
		/* adjust the frame 
		 * NOTE: sync this part of the code with ANIM_OT_change_frame
		 */
		/* 1) frame is rounded to the nearest int, since frames are ints */
		CFRA = round_fl_to_int(frame);
		
		if (scene->r.flag & SCER_LOCK_FRAME_SELECTION) {
			/* Clip to preview range
			 * NOTE: Preview range won't go into negative values,
			 *       so only clamping once should be fine.
			 */
			CLAMP(CFRA, PSFRA, PEFRA);
		}
		else {
			/* Prevent negative frames */
			FRAMENUMBER_MIN_CLAMP(CFRA);
		}
		
		SUBFRA = 0.0f;
		BKE_sound_seek_scene(bmain, scene);
	}
	
	/* set the cursor value */
	sipo->cursorVal = RNA_float_get(op->ptr, "value");
	
	/* send notifiers - notifiers for frame should force an update for both vars ok... */
	WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
}