mirror of
https://github.com/vlang/v.git
synced 2025-09-14 18:06:48 -04:00
This commit is contained in:
parent
6ba87b948a
commit
2afce42fc7
@ -1563,6 +1563,11 @@ fn (mut g Gen) method_call(node ast.CallExpr) {
|
||||
g.call_args(node)
|
||||
}
|
||||
g.write(')')
|
||||
if !node.return_type.has_option_or_result() {
|
||||
if g.table.final_sym(node.return_type).kind == .array_fixed {
|
||||
g.write('.ret_arr')
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
left_sym := g.table.sym(left_type)
|
||||
|
41
vlib/v/tests/fns/iface_method_fixed_arr_test.v
Normal file
41
vlib/v/tests/fns/iface_method_fixed_arr_test.v
Normal file
@ -0,0 +1,41 @@
|
||||
module main
|
||||
|
||||
pub type Mat4 = [16]f32
|
||||
|
||||
pub fn (a Mat4) * (b Mat4) Mat4 {
|
||||
mut res := Mat4{}
|
||||
for i := 0; i < 4; i++ {
|
||||
for j := 0; j < 4; j++ {
|
||||
res[j * 4 + i] = 0
|
||||
for k := 0; k < 4; k++ {
|
||||
res[j * 4 + i] += a[k * 4 + i] * b[j * 4 + k]
|
||||
}
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
interface IGameObject {
|
||||
parent ?&IGameObject
|
||||
transform Mat4
|
||||
world_transform() Mat4
|
||||
}
|
||||
|
||||
struct GameObject implements IGameObject {
|
||||
mut:
|
||||
transform Mat4
|
||||
parent ?&IGameObject
|
||||
}
|
||||
|
||||
fn (gameobject GameObject) world_transform() Mat4 {
|
||||
if mut p := gameobject.parent {
|
||||
return p.world_transform() * gameobject.transform
|
||||
}
|
||||
return gameobject.transform
|
||||
}
|
||||
|
||||
fn test_main() {
|
||||
t := GameObject{}
|
||||
a := dump(t.world_transform())
|
||||
assert a.len == 16
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user