This repository has been archived on 2023-10-09. You can view files and clone it, but cannot push or open issues or pull requests.
Files
blender-archive/source/blender/editors/curve/curve_ops.c

171 lines
6.1 KiB
C
Raw Normal View History

/*
* 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,
2010-02-12 13:34:04 +00:00
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2009 Blender Foundation.
* All rights reserved.
*/
/** \file
* \ingroup edcurve
2011-02-27 20:29:51 +00:00
*/
#include <stdlib.h>
#include <math.h>
#include "DNA_curve_types.h"
#include "DNA_scene_types.h"
#include "RNA_access.h"
#include "WM_api.h"
#include "WM_types.h"
#include "ED_curve.h"
#include "ED_object.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_transform.h"
#include "curve_intern.h"
/************************* registration ****************************/
void ED_operatortypes_curve(void)
{
2009-04-12 22:43:07 +00:00
WM_operatortype_append(FONT_OT_text_insert);
WM_operatortype_append(FONT_OT_line_break);
WM_operatortype_append(FONT_OT_case_toggle);
WM_operatortype_append(FONT_OT_case_set);
WM_operatortype_append(FONT_OT_style_toggle);
WM_operatortype_append(FONT_OT_style_set);
WM_operatortype_append(FONT_OT_select_all);
2009-04-12 22:43:07 +00:00
WM_operatortype_append(FONT_OT_text_copy);
WM_operatortype_append(FONT_OT_text_cut);
WM_operatortype_append(FONT_OT_text_paste);
WM_operatortype_append(FONT_OT_text_paste_from_file);
WM_operatortype_append(FONT_OT_move);
WM_operatortype_append(FONT_OT_move_select);
WM_operatortype_append(FONT_OT_delete);
WM_operatortype_append(FONT_OT_change_character);
WM_operatortype_append(FONT_OT_change_spacing);
WM_operatortype_append(FONT_OT_open);
WM_operatortype_append(FONT_OT_unlink);
WM_operatortype_append(FONT_OT_textbox_add);
WM_operatortype_append(FONT_OT_textbox_remove);
WM_operatortype_append(CURVE_OT_hide);
WM_operatortype_append(CURVE_OT_reveal);
WM_operatortype_append(CURVE_OT_separate);
WM_operatortype_append(CURVE_OT_split);
WM_operatortype_append(CURVE_OT_duplicate);
WM_operatortype_append(CURVE_OT_delete);
WM_operatortype_append(CURVE_OT_dissolve_verts);
WM_operatortype_append(CURVE_OT_spline_type_set);
WM_operatortype_append(CURVE_OT_radius_set);
WM_operatortype_append(CURVE_OT_spline_weight_set);
WM_operatortype_append(CURVE_OT_handle_type_set);
WM_operatortype_append(CURVE_OT_normals_make_consistent);
WM_operatortype_append(CURVE_OT_decimate);
WM_operatortype_append(CURVE_OT_shade_smooth);
WM_operatortype_append(CURVE_OT_shade_flat);
WM_operatortype_append(CURVE_OT_tilt_clear);
WM_operatortype_append(CURVE_OT_primitive_bezier_curve_add);
2010-05-23 02:02:04 +00:00
WM_operatortype_append(CURVE_OT_primitive_bezier_circle_add);
WM_operatortype_append(CURVE_OT_primitive_nurbs_curve_add);
WM_operatortype_append(CURVE_OT_primitive_nurbs_circle_add);
WM_operatortype_append(CURVE_OT_primitive_nurbs_path_add);
WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_curve_add);
WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_circle_add);
WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_surface_add);
WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_cylinder_add);
WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_sphere_add);
2010-09-01 20:18:31 +00:00
WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_torus_add);
WM_operatortype_append(CURVE_OT_smooth);
WM_operatortype_append(CURVE_OT_smooth_weight);
WM_operatortype_append(CURVE_OT_smooth_radius);
WM_operatortype_append(CURVE_OT_smooth_tilt);
WM_operatortype_append(CURVE_OT_de_select_first);
WM_operatortype_append(CURVE_OT_de_select_last);
WM_operatortype_append(CURVE_OT_select_all);
WM_operatortype_append(CURVE_OT_select_linked);
WM_operatortype_append(CURVE_OT_select_linked_pick);
WM_operatortype_append(CURVE_OT_select_row);
WM_operatortype_append(CURVE_OT_select_next);
WM_operatortype_append(CURVE_OT_select_previous);
WM_operatortype_append(CURVE_OT_select_more);
WM_operatortype_append(CURVE_OT_select_less);
WM_operatortype_append(CURVE_OT_select_random);
WM_operatortype_append(CURVE_OT_select_nth);
WM_operatortype_append(CURVE_OT_select_similar);
WM_operatortype_append(CURVE_OT_shortest_path_pick);
WM_operatortype_append(CURVE_OT_switch_direction);
WM_operatortype_append(CURVE_OT_subdivide);
WM_operatortype_append(CURVE_OT_make_segment);
WM_operatortype_append(CURVE_OT_spin);
2009-04-12 22:43:07 +00:00
WM_operatortype_append(CURVE_OT_vertex_add);
WM_operatortype_append(CURVE_OT_draw);
WM_operatortype_append(CURVE_OT_extrude);
WM_operatortype_append(CURVE_OT_cyclic_toggle);
Move curve's boundbox and texspace calculation out of modifier stack There were several issues with how bounding box and texture space are calculated: - This was done at the same time as applying modifiers, meaning if several objects are sharing the same curve datablock, bounding box and texture space will be calculated multiple times. Further, allocating bounding box wasn't safe for threading. - Bounding box and texture space were evaluated after pre-tessellation modifiers are applied. This means Curve-level data is actually depends on object data, and it's really bad because different objects could have different modifiers and this leads to conflicts (curve's data depends on object evaluation order) and doesn't behave in a predictable way. This commit moves bounding box and texture space evaluation from modifier stack to own utility functions, just like it's was done for meshes. This makes curve objects update thread-safe, but gives some limitations as well. Namely, with such approach it's not so clear how to preserve the same behavior of texture space: before this change texture space and bounding box would match beveled curve as accurate as possible. Old behavior was nice for quick texturing -- in most cases you didn't need to modify texture space at all. But texture space was depending on render/preview settings which could easily lead to situations, when final result would be far different from preview one. Now we're using CV points coordinates and their radius to approximate the bounding box. This doesn't give the same exact texture space, but it helps a lot keeping texture space in a nice predictable way. We could make approximation smarter in the future, but fir now added operator to match texture space to fully tessellated curve called "Match Texture Space". Review link: https://codereview.appspot.com/15410043/ Brief description: http://wiki.blender.org/index.php/User:Nazg-gul/GSoC-2013/Results#Curve_Texture_Space
2013-10-20 14:41:33 +02:00
WM_operatortype_append(CURVE_OT_match_texture_space);
}
void ED_operatormacros_curve(void)
{
wmOperatorType *ot;
wmOperatorTypeMacro *otmacro;
ot = WM_operatortype_append_macro("CURVE_OT_duplicate_move", "Add Duplicate", "Duplicate curve and move",
2012-06-05 21:54:21 +00:00
OPTYPE_UNDO | OPTYPE_REGISTER);
WM_operatortype_macro_define(ot, "CURVE_OT_duplicate");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
RNA_enum_set(otmacro->ptr, "proportional", 0);
RNA_boolean_set(otmacro->ptr, "mirror", false);
ot = WM_operatortype_append_macro("CURVE_OT_extrude_move", "Extrude Curve and Move",
2012-06-05 21:54:21 +00:00
"Extrude curve and move result", OPTYPE_UNDO | OPTYPE_REGISTER);
WM_operatortype_macro_define(ot, "CURVE_OT_extrude");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
RNA_enum_set(otmacro->ptr, "proportional", 0);
RNA_boolean_set(otmacro->ptr, "mirror", false);
}
void ED_keymap_curve(wmKeyConfig *keyconf)
{
/* only set in editmode font, by space_view3d listener */
wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Font", 0, 0);
keymap->poll = ED_operator_editfont;
/* only set in editmode curve, by space_view3d listener */
keymap = WM_keymap_ensure(keyconf, "Curve", 0, 0);
keymap->poll = ED_operator_editsurfcurve;
}