// ImpulseToForce converts an impulse to a force over a step duration. func (w World) ImpulseToForce(stepSize float64, impulse Vector3) Vector3 { force := NewVector3() C.dWorldImpulseToForce(w.c(), C.dReal(stepSize), C.dReal(impulse[0]), C.dReal(impulse[1]), C.dReal(impulse[2]), (*C.dReal)(&force[0])) return force }
// SetParams sets the mass parameters. func (m *Mass) SetParams(mass float64, com Vector3, inert Matrix3) { c := &C.dMass{} C.dMassSetParameters(c, C.dReal(mass), C.dReal(com[0]), C.dReal(com[1]), C.dReal(com[2]), C.dReal(inert[0][0]), C.dReal(inert[1][1]), C.dReal(inert[2][2]), C.dReal(inert[0][1]), C.dReal(inert[0][2]), C.dReal(inert[1][3])) m.fromC(c) }
// Build builds a heightfield data set. func (h Heightfield) Build(data HeightfieldData, heightSamples Matrix, width, depth, scale, offset, thickness float64, doWrap bool) { numWidthSamp, numDepthSamp := len(heightSamples), 0 var heightSamplesPtr *C.double if numDepthSamp > 0 { numWidthSamp = len(heightSamples[0]) if numWidthSamp > 0 { heightSamplesPtr = (*C.double)(&heightSamples[0][0]) } } C.dGeomHeightfieldDataBuildDouble(data.c(), heightSamplesPtr, 1, C.dReal(width), C.dReal(depth), C.int(numWidthSamp), C.int(numDepthSamp), C.dReal(scale), C.dReal(offset), C.dReal(thickness), C.int(btoi(doWrap))) }
func (g *ContactGeom) toC(c *C.dContactGeom) { Vector(g.Pos).toC((*C.dReal)(&c.pos[0])) Vector(g.Normal).toC((*C.dReal)(&c.normal[0])) c.depth = C.dReal(g.Depth) c.g1 = g.G1.c() c.g2 = g.G2.c() c.side1 = C.int(g.Side1) c.side2 = C.int(g.Side2) }
func (v Vector) convertC(c *C.dReal, toC bool) { for i := range v { if toC { *c = C.dReal(v[i]) } else { v[i] = float64(*c) } c = (*C.dReal)(unsafe.Pointer(uintptr(unsafe.Pointer(c)) + unsafe.Sizeof(*c))) } }
func (m Matrix) convertC(c *C.dReal, toC bool) { for i := range m { for j := 0; j < cap(m[i]); j++ { if j < len(m[i]) { if toC { *c = C.dReal(m[i][j]) } else { m[i][j] = float64(*c) } } c = (*C.dReal)(unsafe.Pointer(uintptr(unsafe.Pointer(c)) + unsafe.Sizeof(*c))) } } }
// SetContactSurfaceLayer sets the depth of the surface layer around all // geometry objects. func (w World) SetContactSurfaceLayer(depth float64) { C.dWorldSetContactSurfaceLayer(w.c(), C.dReal(depth)) }
// SetContactMaxCorrectingVelocity sets the maximum correcting velocity that // contacts are allowed to generate. func (w World) SetContactMaxCorrectingVelocity(overRelaxation float64) { C.dWorldSetContactMaxCorrectingVel(w.c(), C.dReal(overRelaxation)) }
func (m *Mass) SetTrimesh(density Real, g *Geom) { C.dMassSetTrimesh((*C.dMass)(m), C.dReal(density), (C.dGeomID)((*C.struct_dxGeom)(g))) }
// SetCFM sets the constraint force mixing value. func (w World) SetCFM(cfm float64) { C.dWorldSetCFM(w.c(), C.dReal(cfm)) }
// SetGravity sets the gravity vector. func (w World) SetGravity(grav Vector3) { C.dWorldSetGravity(w.c(), C.dReal(grav[0]), C.dReal(grav[1]), C.dReal(grav[2])) }
// SetAngularDampingThreshold sets the angular damping threshold. func (w World) SetAngularDampingThreshold(threshold float64) { C.dWorldSetAngularDampingThreshold(w.c(), C.dReal(threshold)) }
// SetAutoDisableTime sets the auto disable time. func (w World) SetAutoDisableTime(time float64) { C.dWorldSetAutoDisableTime(w.c(), C.dReal(time)) }
func (s *SurfaceParameters) toC(c *C.dSurfaceParameters) { c.mode = C.int(s.Mode) c.mu = C.dReal(s.Mu) c.mu2 = C.dReal(s.Mu2) c.rho = C.dReal(s.Rho) c.rho2 = C.dReal(s.Rho2) c.rhoN = C.dReal(s.RhoN) c.bounce = C.dReal(s.Bounce) c.bounce_vel = C.dReal(s.BounceVel) c.soft_erp = C.dReal(s.SoftErp) c.soft_cfm = C.dReal(s.SoftCfm) c.motion1 = C.dReal(s.Motion1) c.motion2 = C.dReal(s.Motion2) c.motionN = C.dReal(s.MotionN) c.slip1 = C.dReal(s.Slip1) c.slip2 = C.dReal(s.Slip2) }
func (m *Mass) Translate(v Vector3) { C.dMassTranslate((*C.dMass)(m), C.dReal(v[0]), C.dReal(v[1]), C.dReal(v[2])) }
func (m *Mass) Adjust(newmass Real) { C.dMassAdjust((*C.dMass)(m), C.dReal(newmass)) }
func (m *Mass) SetTrimeshTotal(total_mass Real, g *Geom) { C.dMassSetTrimeshTotal((*C.dMass)(m), C.dReal(total_mass), (C.dGeomID)((*C.struct_dxGeom)(g))) }
// SetAutoDisableLinearThreshold sets the auto disable linear average threshold. func (w World) SetAutoDisableLinearThreshold(linearThreshold float64) { C.dWorldSetAutoDisableLinearThreshold(w.c(), C.dReal(linearThreshold)) }
// SetAutoDisableAngularThreshold sets the auto disable angular average threshold. func (w World) SetAutoDisableAngularThreshold(angularThreshold float64) { C.dWorldSetAutoDisableAngularThreshold(w.c(), C.dReal(angularThreshold)) }
func (m *Matrix6) Random(absmax Real) { C.dMakeRandomMatrix((*C.dReal)(&m[0]), 6, 6, C.dReal(absmax)) }
// SetAngularDamping sets the angular damping scale. func (w World) SetAngularDamping(scale float64) { C.dWorldSetAngularDamping(w.c(), C.dReal(scale)) }
func (v *Vector3) Random(absmax Real) { C.dMakeRandomVector((*C.dReal)(&v[0]), 3, C.dReal(absmax)) }
// SetMaxAngularSpeed sets the maximum angular speed. func (w World) SetMaxAngularSpeed(maxSpeed float64) { C.dWorldSetMaxAngularSpeed(w.c(), C.dReal(maxSpeed)) }
// QuickStep executes a simulation quick step, and returns whether the // operation succeeded. func (w World) QuickStep(stepSize float64) bool { return C.dWorldQuickStep(w.c(), C.dReal(stepSize)) != 0 }
// SetERP sets the error reduction parameter. func (w World) SetERP(erp float64) { C.dWorldSetERP(w.c(), C.dReal(erp)) }
// SetBounds sets the minimum and maximum height. func (h Heightfield) SetBounds(data HeightfieldData, minHeight, maxHeight float64) { C.dGeomHeightfieldDataSetBounds(data.c(), C.dReal(minHeight), C.dReal(maxHeight)) }
func (m *Mass) SetBox(density, lx, ly, lz Real) { C.dMassSetBox((*C.dMass)(m), C.dReal(density), C.dReal(lx), C.dReal(ly), C.dReal(lz)) }
func (m *Mass) SetBoxTotal(total_mass, lx, ly, lz Real) { C.dMassSetBoxTotal((*C.dMass)(m), C.dReal(total_mass), C.dReal(lx), C.dReal(ly), C.dReal(lz)) }
// Point returns a point on the specified triangle at the given barycentric coordinates. func (t TriMesh) Point(index int, u, v float64) Vector3 { pt := NewVector3() C.dGeomTriMeshGetPoint(t.c(), C.int(index), C.dReal(u), C.dReal(v), (*C.dReal)(&pt[0])) return pt }
// SetQuickStepW sets the over-relaxation parameter. func (w World) SetQuickStepW(overRelaxation float64) { C.dWorldSetQuickStepW(w.c(), C.dReal(overRelaxation)) }