Skip to content

Commit 83508e6

Browse files
authored
Merge pull request #103 from ModiaSim/mo_reduce_alloc
Reduce memory allocation for FreeMotion joints
2 parents c0b3795 + daf87b5 commit 83508e6

File tree

4 files changed

+27
-23
lines changed

4 files changed

+27
-23
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Modia3D"
22
uuid = "07f2c1e0-90b0-56cf-bda7-b44b56e34eed"
33
authors = ["Andrea Neumayr <[email protected]>", "Martin Otter <[email protected]>", "Gerhard Hippmann <[email protected]>"]
4-
version = "0.10.0"
4+
version = "0.10.1"
55

66
[deps]
77
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"

docs/src/index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ Modia3D has various *3D animation features*:
6969

7070
## Release Notes
7171

72+
### Version 0.10.1
73+
74+
- Reduce memory allocation, especially in case of collisions and FreeMotion joints.
75+
7276
### Version 0.10.0
7377

7478
**Non-backwards compatible changes**:

src/Composition/joints/joints.jl

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -466,12 +466,12 @@ end
466466

467467

468468
"""
469-
setStatesRevolute!(mbs::MultibodyData{F}, args::Vararg{F,NJOINTS_TIMES_2}) where {F,NJOINTS_TIMES_2}
469+
setStatesRevolute!(mbs::MultibodyData{F}, args::Vararg{F,N}) where {F,N}
470470
471471
Copy states of the revolute joints into the corresponding Object3Ds.
472472
"""
473-
function setStatesRevolute!(mbs::MultibodyData{F,TimeType}, args::Vararg{F})::MultibodyData{F,TimeType} where {F,TimeType}
474-
@assert(length(args) == 2*length(mbs.revoluteObjects))
473+
function setStatesRevolute!(mbs::MultibodyData{F,TimeType}, args::Vararg{F,N})::MultibodyData{F,TimeType} where {F,TimeType,N}
474+
@assert(N == 2*length(mbs.revoluteObjects))
475475
scene = mbs.scene
476476
j = 1
477477
@inbounds for obj in mbs.revoluteObjects
@@ -485,12 +485,12 @@ end
485485

486486

487487
"""
488-
setStatesPrismatic!(mbs::MultibodyData{F}, args::Vararg{F,NJOINTS_TIMES_2}) where {F,NJOINTS_TIMES_2}
488+
setStatesPrismatic!(mbs::MultibodyData{F}, args::Vararg{F,N}) where {F,N}
489489
490490
Copy states of the prismatic joints into the corresponding Object3Ds.
491491
"""
492-
function setStatesPrismatic!(mbs::MultibodyData{F,TimeType}, args::Vararg{F})::MultibodyData{F,TimeType} where {F,TimeType}
493-
@assert(length(args) == 2*length(mbs.prismaticObjects))
492+
function setStatesPrismatic!(mbs::MultibodyData{F,TimeType}, args::Vararg{F,N})::MultibodyData{F,TimeType} where {F,TimeType,N}
493+
@assert(N == 2*length(mbs.prismaticObjects))
494494
scene = mbs.scene
495495
j = 1
496496
@inbounds for obj in mbs.prismaticObjects
@@ -504,12 +504,12 @@ end
504504

505505

506506
"""
507-
setStatesFreeMotion!(mbs::MultibodyData{F}, args::Vararg{SVector{3,F},NJOINTS_TIMES_4}) where {F,NJOINTS_TIMES_4}
507+
setStatesFreeMotion!(mbs::MultibodyData{F}, args::Vararg{SVector{3,F},N}) where {F,N}
508508
509509
Copy states of the free motion joints into the corresponding Object3Ds.
510510
"""
511-
function setStatesFreeMotion!(mbs::MultibodyData{F,TimeType}, args::Vararg{SVector{3,F}})::MultibodyData{F,TimeType} where {F,TimeType}
512-
@assert(length(args) == 4*length(mbs.freeMotionObjects))
511+
function setStatesFreeMotion!(mbs::MultibodyData{F,TimeType}, args::Vararg{SVector{3,F},N})::MultibodyData{F,TimeType} where {F,TimeType,N}
512+
@assert(N== 4*length(mbs.freeMotionObjects))
513513
scene = mbs.scene
514514
j = 1
515515
@inbounds for obj in mbs.freeMotionObjects
@@ -525,12 +525,12 @@ end
525525

526526

527527
"""
528-
setStatesFreeMotion_isrot123!(mbs::MultibodyData{F}, args::Vararg{Bool,NJOINTS})
528+
setStatesFreeMotion_isrot123!(mbs::MultibodyData{F}, args::Vararg{Bool,N})
529529
530530
Copy isrot123 of the free motion joints into the corresponding Object3Ds.
531531
"""
532-
function setStatesFreeMotion_isrot123!(mbs::MultibodyData{F,TimeType}, args::Vararg{Bool})::MultibodyData{F,TimeType} where {F,TimeType}
533-
@assert(length(args) == length(mbs.freeMotionObjects))
532+
function setStatesFreeMotion_isrot123!(mbs::MultibodyData{F,TimeType}, args::Vararg{Bool,N})::MultibodyData{F,TimeType} where {F,TimeType,N}
533+
@assert(N == length(mbs.freeMotionObjects))
534534
scene = mbs.scene
535535
@inbounds for (i,obj) in enumerate(mbs.freeMotionObjects)
536536
scene.freeMotion[obj.jointIndex].isrot123 = args[i]
@@ -540,12 +540,12 @@ end
540540

541541

542542
"""
543-
setAccelerationsRevolute!(mbs::MultibodyData{F}, args::Vararg{F,NJOINTS}) where {F,NJOINTS}
543+
setAccelerationsRevolute!(mbs::MultibodyData{F}, args::Vararg{F,N}) where {F,N}
544544
545545
Copy accelerations of revolute joints into mbs.
546546
"""
547-
function setAccelerationsRevolute!(mbs::MultibodyData{F,TimeType}, args::Vararg{F}) where {F,TimeType}
548-
@assert(length(args) == length(mbs.revoluteObjects))
547+
function setAccelerationsRevolute!(mbs::MultibodyData{F,TimeType}, args::Vararg{F,N}) where {F,TimeType,N}
548+
@assert(N == length(mbs.revoluteObjects))
549549
scene = mbs.scene
550550
@inbounds for (i,obj) in enumerate(mbs.revoluteObjects)
551551
scene.revolute[obj.jointIndex].a = args[i]
@@ -555,12 +555,12 @@ end
555555

556556

557557
"""
558-
setAccelerationsPrismatic!(mbs::MultibodyData{F}, args::Vararg{F,NJOINTS}) where {F,NJOINTS}
558+
setAccelerationsPrismatic!(mbs::MultibodyData{F}, args::Vararg{F,N}) where {F,N}
559559
560560
Copy accelerations of prismatic joints into mbs.
561561
"""
562-
function setAccelerationsPrismatic!(mbs::MultibodyData{F,TimeType}, args::Vararg{F}) where {F,TimeType}
563-
@assert(length(args) == length(mbs.prismaticObjects))
562+
function setAccelerationsPrismatic!(mbs::MultibodyData{F,TimeType}, args::Vararg{F,N}) where {F,TimeType,N}
563+
@assert(N == length(mbs.prismaticObjects))
564564
scene = mbs.scene
565565
@inbounds for (i,obj) in enumerate(mbs.prismaticObjects)
566566
scene.prismatic[obj.jointIndex].a = args[i]
@@ -574,8 +574,8 @@ end
574574
575575
Copy accelerations of free motion joints into mbs
576576
"""
577-
function setAccelerationsFreeMotion!(mbs::MultibodyData{F,TimeType}, args::Vararg{SVector{3,F}}) where {F,TimeType}
578-
@assert(length(args) == 2*length(mbs.freeMotionObjects))
577+
function setAccelerationsFreeMotion!(mbs::MultibodyData{F,TimeType}, args::Vararg{SVector{3,F},N}) where {F,TimeType,N}
578+
@assert(N == 2*length(mbs.freeMotionObjects))
579579
scene = mbs.scene
580580
j = 1
581581
@inbounds for obj in mbs.freeMotionObjects

src/Modia3D.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
module Modia3D
55

66
const path = dirname(dirname(@__FILE__)) # Absolute path of package directory
7-
const Version = "0.10.0"
8-
const Date = "2022-03-01"
7+
const Version = "0.10.1"
8+
const Date = "2022-03-04"
99

1010
println("\nImporting Modia3D Version $Version ($Date)")
1111

0 commit comments

Comments
 (0)