mirror of
https://github.com/bloeys/gglm.git
synced 2025-12-29 05:28:20 +00:00
Inlining checks+update readme
This commit is contained in:
@ -22,7 +22,6 @@ gglm currently has the following:
|
||||
## Usage
|
||||
|
||||
```go
|
||||
|
||||
import "github.com/bloeys/gglm/gglm"
|
||||
|
||||
|
||||
@ -43,10 +42,15 @@ func main() {
|
||||
println(v1.Eq(v2))
|
||||
v2.Set(1, 2)
|
||||
println(v1.Eq(v2))
|
||||
|
||||
//This performs: v1 += v2
|
||||
//v1 is returned from the function, so we can chain calls that operate on v1
|
||||
newX := v1.Add(v2).X()
|
||||
println("newX:", newX)
|
||||
}
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
You can check compiler inlining decisions using `go run -gcflags "-m" .`. Some functions look a bit weird compared to similar ones
|
||||
because we are trying to reduce function complexity so the compiler inlines.
|
||||
|
||||
|
||||
7
main.go
7
main.go
@ -64,6 +64,9 @@ func main() {
|
||||
v2.Set(1, 2)
|
||||
println(v1.Eq(v2))
|
||||
|
||||
v1.AddXY(v2.X(), v2.Y())
|
||||
println(v1.String())
|
||||
|
||||
println("V1: " + v1.String())
|
||||
v1.Normalize()
|
||||
println("V1 Normal: " + v1.String())
|
||||
@ -97,6 +100,10 @@ func main() {
|
||||
|
||||
println(gglm.DotVec4(v5, v6))
|
||||
|
||||
v5.Add(v6)
|
||||
v5.AddXYZW(v6.X(), v6.Y(), v6.Z(), v6.W())
|
||||
println(v6.String())
|
||||
|
||||
println("V6: " + v6.String())
|
||||
v6.Normalize()
|
||||
println("V6 Normal: " + v6.String())
|
||||
|
||||
Reference in New Issue
Block a user