-
Notifications
You must be signed in to change notification settings - Fork 70
/
sphere.go
40 lines (32 loc) · 849 Bytes
/
sphere.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright (c) 2019, Cogent Core. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package physics
import (
"cogentcore.org/core/math32"
)
// Sphere is a spherical body shape.
type Sphere struct {
BodyBase
// radius
Radius float32
}
func (sp *Sphere) SetBBox() {
sp.BBox.SetBounds(math32.Vec3(-sp.Radius, -sp.Radius, -sp.Radius), math32.Vec3(sp.Radius, sp.Radius, sp.Radius))
sp.BBox.XForm(sp.Abs.Quat, sp.Abs.Pos)
}
func (sp *Sphere) InitAbs(par *NodeBase) {
sp.InitAbsBase(par)
sp.SetBBox()
sp.BBox.VelNilProject()
}
func (sp *Sphere) RelToAbs(par *NodeBase) {
sp.RelToAbsBase(par)
sp.SetBBox()
sp.BBox.VelProject(sp.Abs.LinVel, 1)
}
func (sp *Sphere) Step(step float32) {
sp.StepBase(step)
sp.SetBBox()
sp.BBox.VelProject(sp.Abs.LinVel, step)
}