forked from 1b-agent/opencadstudio-upstream
Honor point display geometry and sizing
This commit is contained in:
1 parent
ba9f36adb2
commit
c5fe70627a
10 files changed
+238
-60
No files matched your search
+20
-2
@@ -62,6 +62,9 @@ struct InstanceIn {
|
||||
@location(8) pos_b_low: vec3<f32>,
|
||||
// Per-endpoint world half-width for a tapered band (0 = use the constant).
|
||||
@location(9) taper: vec2<f32>,
|
||||
@location(10) marker_origin_high: vec4<f32>,
|
||||
@location(11) marker_origin_low: vec4<f32>,
|
||||
@location(12) marker_normal_scale: vec4<f32>,
|
||||
}
|
||||
|
||||
// Draw-order depth bias: shifts clip-space z so 2D entities of different
|
||||
@@ -102,6 +105,21 @@ fn resolve_hw(taper: f32, world_hw: f32, px_hw: f32) -> f32 {
|
||||
return select(0.5, px_hw, u.lwdisplay_enable > 0.5);
|
||||
}
|
||||
|
||||
fn marker_relative(position_high: vec3<f32>, position_low: vec3<f32>, instance: InstanceIn) -> vec3<f32> {
|
||||
if instance.marker_normal_scale.w <= 0.0 {
|
||||
return (position_high - u.eye_high) + (position_low - u.eye_low);
|
||||
}
|
||||
let origin_high = instance.marker_origin_high.xyz;
|
||||
let origin_low = instance.marker_origin_low.xyz;
|
||||
let origin_relative = (origin_high - u.eye_high) + (origin_low - u.eye_low);
|
||||
let delta = (position_high - origin_high) + (position_low - origin_low);
|
||||
let normal = normalize(instance.marker_normal_scale.xyz);
|
||||
let axial = normal * dot(delta, normal);
|
||||
let planar = delta - axial;
|
||||
let world_size = instance.marker_normal_scale.w * 0.01 * u.world_per_pixel * u.viewport_size.y;
|
||||
return origin_relative + axial + planar * world_size;
|
||||
}
|
||||
|
||||
@vertex fn vs_main(@builtin(vertex_index) vid: u32, in: InstanceIn) -> VertexOut {
|
||||
// Two-triangle quad corner table:
|
||||
// vid 0,1,2 = (A,-1) (B,-1) (B,+1)
|
||||
@@ -117,8 +135,8 @@ fn resolve_hw(taper: f32, world_hw: f32, px_hw: f32) -> f32 {
|
||||
// operands (Sterbenz); adding (pos_low − eye_low) restores the residual both
|
||||
// the vertex and the eye would otherwise lose — so geometry stays put at
|
||||
// UTM-scale coordinates and after a cross-drawing paste, with no jitter.
|
||||
let rel_a = (in.pos_a - u.eye_high) + (in.pos_a_low - u.eye_low);
|
||||
let rel_b = (in.pos_b - u.eye_high) + (in.pos_b_low - u.eye_low);
|
||||
let rel_a = marker_relative(in.pos_a, in.pos_a_low, in);
|
||||
let rel_b = marker_relative(in.pos_b, in.pos_b_low, in);
|
||||
let clip_a = u.view_rot * vec4<f32>(rel_a, 1.0);
|
||||
let clip_b = u.view_rot * vec4<f32>(rel_b, 1.0);
|
||||
|
||||
|
||||
Reference in new issue
Block a user