Free Electron
ChainOp.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __ironworks_ChainOp_h__
8 #define __ironworks_ChainOp_h__
9 
10 namespace fe
11 {
12 namespace ext
13 {
14 
15 /**************************************************************************//**
16  @brief Instantiate links along a curve
17 
18  @ingroup ironworks
19 
20  Based on the Siggraph 2015 Talk 'Rigid Link Chains in "Kung Fu Panda 3"'
21  in the 20150810 3:45pm session "Link and Locks".
22  Specifically reimplemented with permission.
23 
24  http://s2015.siggraph.org/attendees/talks/sessions/links-and-locks
25 *//***************************************************************************/
26 class FE_DL_EXPORT ChainOp:
27  public OperatorSurfaceCommon,
28  public Initialize<ChainOp>
29 {
30  public:
31  ChainOp(void):
32  m_frame(-1),
33  m_clearNextOutput(TRUE) {}
34 virtual ~ChainOp(void) {}
35 
36  void initialize(void);
37 
38  //* As HandlerI
39 virtual void handle(Record& a_rSignal);
40 
41  private:
42  void calcBounds(I32 a_fragmentIndex,SpatialVector& a_center,
43  SpatialVector& a_innermin,SpatialVector& a_innermax,
44  SpatialVector& a_outermin,SpatialVector& a_outermax);
45 
46  void scanInputLinks(void);
47  void removeExcessLinks(void);
48  void addLink(sp<SurfaceAccessibleI> a_spLink,
49  const SpatialTransform& a_transform);
50 
51  sp<SurfaceAccessibleI> m_spResultAccessible;
52  sp<DrawI> m_spOutputDraw;
53 
54  sp<SurfaceAccessibleI> m_spLinkAccessible;
55  sp<SurfaceAccessorI> m_spLinkVertices;
56  sp<SurfaceAccessorI> m_spScanVertices;
57 
58  sp<SurfaceAccessorI> m_spPrimitiveLinkName;
59  sp<SurfaceAccessorI> m_spPointLinkName;
60 
61  class LinkRef {
62  public:
63  void log(char* a_label);
64 
65  Real m_pivotBase;
66  Real m_pivotTip;
67 
68  Real m_pivotGapBase;
69  Real m_pivotGapTip;
70 
71  Real m_pivotYawBase;
72  Real m_pivotYawTip;
73 
74  U32 m_axisForward;
75 
76  // transformation to forward=2 side=0
77  SpatialTransform m_transform;
78  };
79 
80  class LinkState {
81  public:
82  LinkState(void):
83  m_priorSet(FALSE),
84  m_currentSlippage(0.0,0.0,0.0),
85  m_priorSlippage(0.0,0.0,0.0)
86  {
87  setIdentity(m_priorConversion);
88  setIdentity(m_currentConversion);
89  }
90 
91  BWORD m_priorSet;
92  SpatialVector m_currentSlippage;
93  SpatialVector m_priorSlippage;
94  SpatialTransform m_priorConversion;
95  SpatialTransform m_currentConversion;
96  };
97 
98  I32 m_frame;
99  BWORD m_clearNextOutput;
100  I32 m_pointStart;
101  I32 m_primitiveStart;
102  I32 m_fileLinkCount;
103 
104  Array<LinkRef> m_linkRef;
105  Array<LinkState> m_linkState;
106  Array<Real> m_gapCorrection;
107  Array<Real> m_spiralCorrection;
108 
109  Array<String> m_flipTwistPatterns;
110 };
111 
112 } /* namespace ext */
113 } /* namespace fe */
114 
115 #endif /* __ironworks_ChainOp_h__ */
116 
Instantiate links along a curve.
Definition: ChainOp.h:26
kernel
Definition: namespace.dox:3
Per-class participation in the Initialized <> mechanism.
Definition: Initialized.h:117
Partial Generic SurfaceI Implemention.
Definition: OperatorSurfaceCommon.h:20
Reference to an instance of a Layout.
Definition: RecordSB.h:35
Intrusive Smart Pointer.
Definition: src/core/ptr.h:53