File: clothModel.h

package info (click to toggle)
embree 3.13.5%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 27,924 kB
  • sloc: cpp: 180,815; xml: 3,877; ansic: 2,957; python: 1,466; sh: 502; makefile: 229; csh: 42
file content (67 lines) | stat: -rw-r--r-- 1,468 bytes parent folder | download | duplicates (2)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright 2009-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include <vector>
#include "constraints.h"
#include "../common/tutorial/tutorial_device.h"

namespace embree { namespace collide2 {

class Constraint;

struct Mesh {
    
    virtual ~Mesh() {};
    
    std::vector<vec_t>          x_;
    std::vector<Triangle>       tris_;
};

struct ClothModel : public Mesh {

    // particle system
    std::vector<vec_t>          x_0_;
    std::vector<vec_t>          x_old_;
    std::vector<vec_t>          x_last_;
    std::vector<vec_t>          v_;
    std::vector<vec_t>          a_;
    std::vector<float>          m_;
    std::vector<float>          m_inv_;

    // simulation constraints
    std::vector<Constraint*>    m_constraints_;
    std::vector<Constraint*>    c_constraints_;

    // material parameters
    float                       k_stretch_  = 1.f;
    float                       k_damp_     = 1.f;

    void clearMotionConstraints()
    {
      for (auto c : m_constraints_) {
        delete c;
      }
      m_constraints_.clear ();
    }

    void clearCollisionConstraints()
    {
      for (auto c : c_constraints_) {
        delete c;
      }
      c_constraints_.clear ();
    }
      
    virtual ~ClothModel () {
      clearMotionConstraints();
      clearCollisionConstraints();
    }
};

} // namespace collide2

  void initializeClothPositions (collide2::ClothModel & cloth);

} // namespace embree