@@ -73,35 +73,50 @@ void Start()
7373 }
7474
7575 int texCpt = 0 ;
76+ bool firstInit = true ;
7677
7778 void Update ( )
7879 {
79- if ( m_carving )
80- {
81- var bData = m_carving . m_dataArchiver . GetBaseData ( "texcoords" ) ;
82- int counter = bData . GetDataCounter ( ) ;
80+ if ( m_carving == null )
81+ return ;
82+
83+ var bData = m_carving . m_dataArchiver . GetBaseData ( "texcoords" ) ;
84+ int counter = bData . GetDataCounter ( ) ;
8385
84- if ( counter == texCpt )
85- return ;
86+ if ( counter == texCpt )
87+ return ;
88+
89+ texCpt = counter ;
8690
87- bool updateSize = false ;
88- if ( m_mesh . vertices . Length != m_nbrV ) // carving in process
91+ if ( firstInit )
92+ {
93+ Debug . Log ( "########## firstInit m_mesh.vertices.Length: " + m_nbrV ) ;
94+ for ( int i = 0 ; i < m_nbrV ; i ++ )
8995 {
90- m_nbrV = m_mesh . vertices . Length ;
91- m_uv2 = new Vector2 [ m_nbrV ] ;
92- updateSize = true ;
96+ m_uv2 [ i ] . x = 0.0f ;
97+ m_uv2 [ i ] . y = 0.0f ;
9398 }
99+ m_mesh . uv2 = m_uv2 ;
100+ firstInit = false ;
101+ return ;
102+ }
94103
95- texCpt = counter ;
96- if ( bData != null )
97- {
98- bool vector = bData . IsVector ( ) ;
99- SofaDataVectorVec2 dataV = ( SofaDataVectorVec2 ) ( bData ) ;
104+ bool updateSize = false ;
105+ Debug . Log ( "########## m_mesh.vertices.Length: " + m_mesh . vertices . Length ) ;
106+ Debug . Log ( "########## m_nbrV: " + m_nbrV ) ;
107+ if ( m_mesh . vertices . Length != m_nbrV ) // carving in process
108+ {
109+ m_nbrV = m_mesh . vertices . Length ;
110+ m_uv2 = new Vector2 [ m_nbrV ] ;
111+ updateSize = true ;
112+ }
100113
101- dataV . GetValues ( m_uv2 , updateSize ) ;
102- m_mesh . uv2 = m_uv2 ;
103- }
104- //vModel.UpdateTexCoords();
114+ if ( bData != null )
115+ {
116+ SofaDataVectorVec2 dataV = ( SofaDataVectorVec2 ) ( bData ) ;
117+
118+ dataV . GetValues ( m_uv2 , updateSize ) ;
119+ m_mesh . uv2 = m_uv2 ;
105120 }
106121 }
107122
@@ -135,14 +150,14 @@ void computeBurnTissus()
135150 m_mesh . uv2 = m_uv2 ;
136151 }
137152
138- // void OnDrawGizmosSelected()
139- // {
140- // if (!m_isReady)
141- // return;
153+ void OnDrawGizmosSelected ( )
154+ {
155+ if ( ! m_isReady )
156+ return ;
142157
143- // Gizmos.color = Color.yellow;
144- // Gizmos.DrawWireSphere(m_burner.transform.position, 0.005f);
145- // Gizmos.DrawLine(firstVertex, m_burner.transform.position);
146- // }
158+ Gizmos . color = Color . yellow ;
159+ Gizmos . DrawWireSphere ( m_burner . transform . position , 0.005f ) ;
160+
161+ }
147162 }
148163}
0 commit comments