本文整理汇总了C++中RNA_float_get函数的典型用法代码示例。如果您正苦于以下问题:C++ RNA_float_get函数的具体用法?C++ RNA_float_get怎么用?C++ RNA_float_get使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RNA_float_get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: arrow2d_draw_geom
static void arrow2d_draw_geom(wmGizmo *gz, const float matrix[4][4], const float color[4])
{
const float size = 0.11f;
const float size_breadth = size / 2.0f;
const float size_length = size * 1.7f;
/* Subtract the length so the arrow fits in the hotspot. */
const float arrow_length = RNA_float_get(gz->ptr, "length") - size_length;
const float arrow_angle = RNA_float_get(gz->ptr, "angle");
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
GPU_matrix_push();
GPU_matrix_mul(matrix);
GPU_matrix_rotate_2d(RAD2DEGF(arrow_angle));
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4fv(color);
immBegin(GPU_PRIM_LINES, 2);
immVertex2f(pos, 0.0f, 0.0f);
immVertex2f(pos, 0.0f, arrow_length);
immEnd();
immBegin(GPU_PRIM_TRIS, 3);
immVertex2f(pos, size_breadth, arrow_length);
immVertex2f(pos, -size_breadth, arrow_length);
immVertex2f(pos, 0.0f, arrow_length + size_length);
immEnd();
immUnbindProgram();
GPU_matrix_pop();
}
示例2: edbm_inset_update_header
static void edbm_inset_update_header(wmOperator *op, bContext *C)
{
InsetData *opdata = op->customdata;
const char *str = IFACE_("Confirm: Enter/LClick, Cancel: (Esc/RClick), Thickness: %s, "
"Depth (Ctrl to tweak): %s (%s), Outset (O): (%s), Boundary (B): (%s), Individual (I): (%s)");
char msg[HEADER_LENGTH];
ScrArea *sa = CTX_wm_area(C);
Scene *sce = CTX_data_scene(C);
if (sa) {
char flts_str[NUM_STR_REP_LEN * 2];
if (hasNumInput(&opdata->num_input))
outputNumInput(&opdata->num_input, flts_str, &sce->unit);
else {
BLI_snprintf(flts_str, NUM_STR_REP_LEN, "%f", RNA_float_get(op->ptr, "thickness"));
BLI_snprintf(flts_str + NUM_STR_REP_LEN, NUM_STR_REP_LEN, "%f", RNA_float_get(op->ptr, "depth"));
}
BLI_snprintf(msg, HEADER_LENGTH, str,
flts_str,
flts_str + NUM_STR_REP_LEN,
WM_bool_as_string(opdata->modify_depth),
WM_bool_as_string(RNA_boolean_get(op->ptr, "use_outset")),
WM_bool_as_string(RNA_boolean_get(op->ptr, "use_boundary")),
WM_bool_as_string(RNA_boolean_get(op->ptr, "use_individual"))
);
ED_area_headerprint(sa, msg);
}
}
示例3: add_primitive_cone_exec
static int add_primitive_cone_exec(bContext *C, wmOperator *op)
{
Object *obedit;
BMEditMesh *em;
float loc[3], rot[3], mat[4][4], dia;
bool enter_editmode;
unsigned int layer;
bool was_editmode;
const int end_fill_type = RNA_enum_get(op->ptr, "end_fill_type");
const bool cap_end = (end_fill_type != 0);
const bool cap_tri = (end_fill_type == 2);
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL);
obedit = make_prim_init(C, CTX_DATA_(BLF_I18NCONTEXT_ID_MESH, "Cone"), &dia, mat, &was_editmode, loc, rot, layer);
em = BKE_editmesh_from_object(obedit);
if (!EDBM_op_call_and_selectf(
em, op, "verts.out", false,
"create_cone segments=%i diameter1=%f diameter2=%f cap_ends=%b cap_tris=%b depth=%f matrix=%m4",
RNA_int_get(op->ptr, "vertices"), RNA_float_get(op->ptr, "radius1"),
RNA_float_get(op->ptr, "radius2"), cap_end, cap_tri, RNA_float_get(op->ptr, "depth"), mat))
{
return OPERATOR_CANCELLED;
}
make_prim_finish(C, obedit, was_editmode, enter_editmode);
return OPERATOR_FINISHED;
}
示例4: object_rand_verts_exec
static int object_rand_verts_exec(bContext *C, wmOperator *op)
{
const float offset = RNA_float_get(op->ptr, "offset");
const float uniform = RNA_float_get(op->ptr, "uniform");
const float normal_factor = RNA_float_get(op->ptr, "normal");
const unsigned int seed = RNA_int_get(op->ptr, "seed");
TransVertStore tvs = {NULL};
Object *obedit = CTX_data_edit_object(C);
if (obedit) {
int mode = TM_ALL_JOINTS;
if (normal_factor != 0.0f) {
mode |= TX_VERT_USE_NORMAL;
}
ED_transverts_create_from_obedit(&tvs, obedit, mode);
if (tvs.transverts_tot == 0)
return OPERATOR_CANCELLED;
object_rand_transverts(&tvs, offset, uniform, normal_factor, seed);
ED_transverts_update_obedit(&tvs, obedit);
ED_transverts_free(&tvs);
}
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit);
return OPERATOR_FINISHED;
}
示例5: edbm_bevel_update_header
static void edbm_bevel_update_header(bContext *C, wmOperator *op)
{
const char *str = IFACE_("Confirm: (Enter/LMB), Cancel: (Esc/RMB), Mode: %s (M), Clamp Overlap: %s (C), "
"Vertex Only: %s (V), Profile Control: %s (P), Offset: %s, Segments: %d, Profile: %.3f");
char msg[UI_MAX_DRAW_STR];
ScrArea *sa = CTX_wm_area(C);
Scene *sce = CTX_data_scene(C);
if (sa) {
BevelData *opdata = op->customdata;
char offset_str[NUM_STR_REP_LEN];
const char *type_str;
PropertyRNA *prop = RNA_struct_find_property(op->ptr, "offset_type");
if (hasNumInput(&opdata->num_input[OFFSET_VALUE])) {
outputNumInput(&opdata->num_input[OFFSET_VALUE], offset_str, &sce->unit);
}
else {
BLI_snprintf(offset_str, NUM_STR_REP_LEN, "%f", RNA_float_get(op->ptr, "offset"));
}
RNA_property_enum_name_gettexted(C, op->ptr, prop, RNA_property_enum_get(op->ptr, prop), &type_str);
BLI_snprintf(msg, sizeof(msg), str, type_str,
WM_bool_as_string(RNA_boolean_get(op->ptr, "clamp_overlap")),
WM_bool_as_string(RNA_boolean_get(op->ptr, "vertex_only")),
WM_bool_as_string(opdata->value_mode == PROFILE_VALUE),
offset_str, RNA_int_get(op->ptr, "segments"), RNA_float_get(op->ptr, "profile"));
ED_area_headerprint(sa, msg);
}
}
示例6: get_bevel_offset
static float get_bevel_offset(wmOperator *op)
{
float val;
if (RNA_enum_get(op->ptr, "offset_type") == BEVEL_AMT_PERCENT) {
val = RNA_float_get(op->ptr, "offset_pct");
}
else {
val = RNA_float_get(op->ptr, "offset");
}
return val;
}
示例7: edbm_bevel_calc
static bool edbm_bevel_calc(wmOperator *op)
{
BevelData *opdata = op->customdata;
BMEditMesh *em = opdata->em;
BMOperator bmop;
const float offset = RNA_float_get(op->ptr, "offset");
const int offset_type = RNA_enum_get(op->ptr, "offset_type");
const int segments = RNA_int_get(op->ptr, "segments");
const float profile = RNA_float_get(op->ptr, "profile");
const bool vertex_only = RNA_boolean_get(op->ptr, "vertex_only");
const bool clamp_overlap = RNA_boolean_get(op->ptr, "clamp_overlap");
int material = RNA_int_get(op->ptr, "material");
const bool loop_slide = RNA_boolean_get(op->ptr, "loop_slide");
/* revert to original mesh */
if (opdata->is_modal) {
EDBM_redo_state_restore(opdata->mesh_backup, em, false);
}
if (em->ob) {
material = CLAMPIS(material, -1, em->ob->totcol - 1);
}
EDBM_op_init(em, &bmop, op,
"bevel geom=%hev offset=%f segments=%i vertex_only=%b offset_type=%i profile=%f clamp_overlap=%b "
"material=%i loop_slide=%b",
BM_ELEM_SELECT, offset, segments, vertex_only, offset_type, profile,
clamp_overlap, material, loop_slide);
BMO_op_exec(em->bm, &bmop);
if (offset != 0.0f) {
/* not essential, but we may have some loose geometry that
* won't get bevel'd and better not leave it selected */
EDBM_flag_disable_all(em, BM_ELEM_SELECT);
BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, true);
}
/* no need to de-select existing geometry */
if (!EDBM_op_finish(em, &bmop, op, true)) {
return false;
}
EDBM_mesh_normals_update(opdata->em);
EDBM_update_generic(opdata->em, true, true);
return true;
}
示例8: wm_alembic_import_exec
static int wm_alembic_import_exec(bContext *C, wmOperator *op)
{
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
BKE_report(op->reports, RPT_ERROR, "No filename given");
return OPERATOR_CANCELLED;
}
char filename[FILE_MAX];
RNA_string_get(op->ptr, "filepath", filename);
const float scale = RNA_float_get(op->ptr, "scale");
const bool is_sequence = RNA_boolean_get(op->ptr, "is_sequence");
const bool set_frame_range = RNA_boolean_get(op->ptr, "set_frame_range");
const bool validate_meshes = RNA_boolean_get(op->ptr, "validate_meshes");
const bool as_background_job = RNA_boolean_get(op->ptr, "as_background_job");
int offset = 0;
int sequence_len = 1;
if (is_sequence) {
sequence_len = get_sequence_len(filename, &offset);
if (sequence_len < 0) {
BKE_report(op->reports, RPT_ERROR, "Unable to determine ABC sequence length");
return OPERATOR_CANCELLED;
}
}
bool ok = ABC_import(C, filename, scale, is_sequence, set_frame_range,
sequence_len, offset, validate_meshes,
as_background_job);
return as_background_job || ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
示例9: change_frame_apply
/* 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);
}
示例10: actkeys_clean_exec
static int actkeys_clean_exec(bContext *C, wmOperator *op)
{
bAnimContext ac;
float thresh;
bool clean_chan;
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
BKE_report(op->reports, RPT_ERROR, "Not implemented");
return OPERATOR_PASS_THROUGH;
}
/* get cleaning threshold */
thresh = RNA_float_get(op->ptr, "threshold");
clean_chan = RNA_boolean_get(op->ptr, "channels");
/* clean keyframes */
clean_action_keys(&ac, thresh, clean_chan);
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
return OPERATOR_FINISHED;
}
示例11: lattice_select_random_exec
static int lattice_select_random_exec(bContext *C, wmOperator *op)
{
Object *obedit = CTX_data_edit_object(C);
Lattice *lt = ((Lattice *)obedit->data)->editlatt->latt;
const float randfac = RNA_float_get(op->ptr, "percent") / 100.0f;
const int seed = RNA_int_get(op->ptr, "seed");
const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT);
RNG *rng = BLI_rng_new_srandom(seed);
int tot;
BPoint *bp;
tot = lt->pntsu * lt->pntsv * lt->pntsw;
bp = lt->def;
while (tot--) {
if (!bp->hide) {
if (BLI_rng_get_float(rng) < randfac) {
bpoint_select_set(bp, select);
}
}
bp++;
}
if (select == false) {
lt->actbp = LT_ACTBP_NONE;
}
BLI_rng_free(rng);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
return OPERATOR_FINISHED;
}
示例12: create_primitive_from_points
static int create_primitive_from_points(bContext *C, wmOperator *op, const float (*points)[2],
int num_points, char handle_type)
{
ScrArea *sa = CTX_wm_area(C);
Scene *scene = CTX_data_scene(C);
Mask *mask;
MaskLayer *mask_layer;
MaskSpline *new_spline;
float scale, location[2], frame_size[2];
int i, width, height;
int size = RNA_float_get(op->ptr, "size");
ED_mask_get_size(sa, &width, &height);
scale = (float)size / max_ii(width, height);
/* Get location in mask space. */
frame_size[0] = width;
frame_size[1] = height;
RNA_float_get_array(op->ptr, "location", location);
location[0] /= width;
location[1] /= height;
BKE_mask_coord_from_frame(location, location, frame_size);
/* Make it so new primitive is centered to mouse location. */
location[0] -= 0.5f * scale;
location[1] -= 0.5f * scale;
mask_layer = ED_mask_layer_ensure(C);
mask = CTX_data_edit_mask(C);
ED_mask_select_toggle_all(mask, SEL_DESELECT);
new_spline = BKE_mask_spline_add(mask_layer);
new_spline->flag = MASK_SPLINE_CYCLIC | SELECT;
new_spline->tot_point = num_points;
new_spline->points = MEM_recallocN(new_spline->points,
sizeof(MaskSplinePoint) * new_spline->tot_point);
mask_layer->act_spline = new_spline;
mask_layer->act_point = NULL;
for (i = 0; i < num_points; i++) {
MaskSplinePoint *new_point = &new_spline->points[i];
copy_v2_v2(new_point->bezt.vec[1], points[i]);
mul_v2_fl(new_point->bezt.vec[1], scale);
add_v2_v2(new_point->bezt.vec[1], location);
new_point->bezt.h1 = handle_type;
new_point->bezt.h2 = handle_type;
BKE_mask_point_select_set(new_point, true);
}
WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask);
/* TODO: only update this spline */
BKE_mask_update_display(mask, CFRA);
return OPERATOR_FINISHED;
}
示例13: create_subd_mesh
static void create_subd_mesh(Mesh *mesh, BL::Mesh b_mesh, PointerRNA *cmesh, const vector<uint>& used_shaders)
{
/* create subd mesh */
SubdMesh sdmesh;
/* create vertices */
BL::Mesh::vertices_iterator v;
for(b_mesh.vertices.begin(v); v != b_mesh.vertices.end(); ++v)
sdmesh.add_vert(get_float3(v->co()));
/* create faces */
BL::Mesh::faces_iterator f;
for(b_mesh.faces.begin(f); f != b_mesh.faces.end(); ++f) {
int4 vi = get_int4(f->vertices_raw());
int n= (vi[3] == 0)? 3: 4;
//int shader = used_shaders[f->material_index()];
if(n == 4)
sdmesh.add_face(vi[0], vi[1], vi[2], vi[3]);
/*else
sdmesh.add_face(vi[0], vi[1], vi[2]);*/
}
/* finalize subd mesh */
sdmesh.link_boundary();
/* subdivide */
DiagSplit dsplit;
dsplit.camera = NULL;
dsplit.dicing_rate = RNA_float_get(cmesh, "dicing_rate");
sdmesh.tesselate(&dsplit, false, mesh, used_shaders[0], true);
}
示例14: add_primitive_cube_exec
static int add_primitive_cube_exec(bContext *C, wmOperator *op)
{
Object *obedit;
BMEditMesh *em;
float loc[3], rot[3], mat[4][4], dia;
bool enter_editmode;
bool was_editmode;
unsigned int layer;
ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL);
obedit = make_prim_init(C, CTX_DATA_(BLF_I18NCONTEXT_ID_MESH, "Cube"), &dia, mat, &was_editmode, loc, rot, layer);
em = BKE_editmesh_from_object(obedit);
if (!EDBM_op_call_and_selectf(
em, op, "verts.out", false,
"create_cube matrix=%m4 size=%f",
mat, RNA_float_get(op->ptr, "radius") * 2.0f))
{
return OPERATOR_CANCELLED;
}
/* BMESH_TODO make plane side this: M_SQRT2 - plane (diameter of 1.41 makes it unit size) */
make_prim_finish(C, obedit, was_editmode, enter_editmode);
return OPERATOR_FINISHED;
}
示例15: add_primitive_cone_exec
static int add_primitive_cone_exec(bContext *C, wmOperator *op)
{
int enter_editmode;
unsigned int layer;
float loc[3], rot[3];
if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer))
return OPERATOR_CANCELLED;
make_prim_ext(C, loc, rot, enter_editmode, layer,
PRIM_CONE, RNA_int_get(op->ptr, "vertices"), 0, 0,
RNA_float_get(op->ptr,"radius"), RNA_float_get(op->ptr, "depth"),
0, RNA_boolean_get(op->ptr, "cap_end"));
return OPERATOR_FINISHED;
}