MCPcopy Create free account
hub / github.com/PerroEngine/Perro / viewport_pointer

Function viewport_pointer

perro_editor/res/scripts/scene/editor_viewport.rs:422–460  ·  view source on GitHub ↗
(
    ctx: &mut ScriptContext<'_, API>,
)

Source from the content-addressed store, hash-verified

420 y: point.y,
421 z: point.z,
422 },
423 ) {
424 rebuild_preview(ctx);
425 }
426 refresh_all(ctx);
427 }
428 changed
429}
430
431pub fn snap_vec2(value: Vector2, grid: f32) -> Vector2 {
432 Vector2::new(
433 (value.x / grid).round() * grid,
434 (value.y / grid).round() * grid,
435 )
436}
437
438pub fn snap_vec3(value: Vector3, grid: f32) -> Vector3 {
439 Vector3::new(
440 (value.x / grid).round() * grid,
441 (value.y / grid).round() * grid,
442 (value.z / grid).round() * grid,
443 )
444}
445
446pub fn snap_f32(value: f32, grid: f32) -> f32 {
447 if grid <= 0.0 {
448 value
449 } else {
450 (value / grid).round() * grid
451 }
452}
453
454pub fn ray_ground_point(ray: ViewportRay3D) -> Option<Vector3> {
455 if ray.direction.y.abs() < 0.0001 {
456 return None;
457 }
458 let t = -ray.origin.y / ray.direction.y;
459 if !t.is_finite() || t < 0.0 {
460 return None;
461 }
462 Some(ray.origin + ray.direction * t)
463}

Callers 7

handle_viewport_clickFunction · 0.85
update_preview_pickFunction · 0.85
update_ui_dragFunction · 0.85
editor_cursor_iconFunction · 0.85
pick_preview_uiFunction · 0.85
update_freecam_2dFunction · 0.85
update_ui_canvasFunction · 0.85

Calls 5

stream_half_ndcFunction · 0.85
viewport_sizeMethod · 0.45
maxMethod · 0.45
absMethod · 0.45

Tested by

no test coverage detected