Skip to content

Commit 91940aa

Browse files
authored
Merge pull request #146 from Tencent/develop
Develop
2 parents aa1f53d + e346051 commit 91940aa

File tree

12 files changed

+161
-29
lines changed

12 files changed

+161
-29
lines changed

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Generated files
2+
build/cmake_binary/**
3+
lib/**
4+
**/bin/
5+
**/obj/
6+
**/out/**
7+
!**/out/config.xml
8+
*.suo

build/cmake_generate_projects.bat

+15-8
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,6 @@ IF %ERRORLEVEL% NEQ 0 GOTO l_cmake_error
99
mkdir cmake_binary
1010
cd cmake_binary
1111

12-
echo ---------------------------------------------------------------------------------
13-
mkdir vs2013
14-
cd vs2013
15-
REM cmake -G "Visual Studio 12 2013 Win64" --build ../../..
16-
REM cmake -G "Visual Studio 12 2013" -DBEHAVIAC_VERSION_MODE=ForeUseRelease --build ../../..
17-
cmake -G "Visual Studio 12 2013" --build ../../..
18-
cd ..
19-
2012
REM echo ---------------------------------------------------------------------------------
2113
REM mkdir vs2015
2214
REM cd vs2015
@@ -25,6 +17,21 @@ REM cmake -G "Visual Studio 14 2015" -DBEHAVIAC_VERSION_MODE=ForeUseRelease --bu
2517
REM cmake -G "Visual Studio 14 2015" --build ../../..
2618
REM cd ..
2719

20+
REM echo ---------------------------------------------------------------------------------
21+
REM mkdir vs2017
22+
REM cd vs2017
23+
REM cmake -G "Visual Studio 15 2017 Win64" --build ../../..
24+
REM cmake -G "Visual Studio 15 2017" -DBEHAVIAC_VERSION_MODE=ForeUseRelease --build ../../..
25+
REM cmake -G "Visual Studio 15 2017" --build ../../..
26+
REM cd ..
27+
28+
echo ---------------------------------------------------------------------------------
29+
mkdir vs2019
30+
cd vs2019
31+
cmake -G "Visual Studio 16 2019" -A x64 --build ../../..
32+
REM cmake -G "Visual Studio 16 2019" -DBEHAVIAC_VERSION_MODE=ForeUseRelease --build ../../..
33+
REM cmake -G "Visual Studio 16 2019" --build ../../..
34+
cd ..
2835

2936
where make
3037
IF %ERRORLEVEL% NEQ 0 GOTO l_no_make

src/agent/agent.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1166,11 +1166,11 @@ namespace behaviac {
11661166
Agent* Agent::GetParentAgent(const Agent* pAgent, const char* instanceName) {
11671167
Agent* pParent = const_cast<Agent*>(pAgent);
11681168

1169-
if (!StringUtils::IsNullOrEmpty(instanceName) && !StringUtils::Compare(instanceName, "Self")) {
1169+
if (!StringUtils::IsNullOrEmpty(instanceName) && !StringUtils::StringEqual(instanceName, "Self")) {
11701170
pParent = Agent::GetInstance(instanceName, (pParent != NULL) ? pParent->GetContextId() : 0);
11711171

11721172
//if (pAgent != NULL && pParent == NULL && !Utils.IsStaticClass(instanceName))
1173-
if (pAgent != NULL && pParent == NULL /*&& !Utils.IsStaticClass(instanceName)*/) { //TODO how to handle Statice Class
1173+
if (pAgent != NULL && pParent == NULL) { //TODO how to handle Statice Class
11741174
pParent = (Agent*)pAgent->GetVariable<Agent*>(instanceName);
11751175
BEHAVIAC_ASSERT(pParent != NULL);
11761176
}

src/behaviortree/behaviortree_task.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -1152,6 +1152,11 @@ namespace behaviac {
11521152
}
11531153

11541154
void CompositeTask::traverse(bool childFirst, NodeHandler_t handler, Agent* pAgent, void* user_data) {
1155+
if (m_status == BT_INVALID)
1156+
{
1157+
return;
1158+
}
1159+
11551160
if (childFirst) {
11561161
for (BehaviorTasks_t::iterator it = this->m_children.begin();
11571162
it != this->m_children.end(); ++it) {
@@ -1187,7 +1192,12 @@ namespace behaviac {
11871192
}
11881193

11891194
void SingeChildTask::traverse(bool childFirst, NodeHandler_t handler, Agent* pAgent, void* user_data) {
1190-
if (childFirst) {
1195+
if (m_status == BT_INVALID)
1196+
{
1197+
return;
1198+
}
1199+
1200+
if (childFirst) {
11911201
if (this->m_root) {
11921202
this->m_root->traverse(childFirst, handler, pAgent, user_data);
11931203
}

tools/designer/BehaviacDesigner/BehaviorTreeViewDock.cs

+19
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
using System.Drawing;
3939
using System.Text;
4040
using System.Windows.Forms;
41+
using System.IO;
42+
using Behaviac.Design.Nodes;
4143

4244
namespace Behaviac.Design
4345
{
@@ -161,6 +163,23 @@ internal static BehaviorTreeViewDock GetBehaviorTreeViewDock(Nodes.BehaviorNode
161163
return null;
162164
}
163165

166+
internal static BehaviorTreeViewDock GetBehaviorTreeViewDockByName(string behaviorFilename)
167+
{
168+
if (!Path.IsPathRooted(behaviorFilename))
169+
{
170+
behaviorFilename = FileManagers.FileManager.GetFullPath(behaviorFilename);
171+
}
172+
173+
BehaviorTreeViewDock dock = null;
174+
BehaviorNode behaviornode = BehaviorManager.Instance.GetBehavior(behaviorFilename);
175+
if (behaviornode != null)
176+
{
177+
dock = GetBehaviorTreeViewDock(behaviornode);
178+
}
179+
180+
return dock;
181+
}
182+
164183
internal static BehaviorTreeView GetBehaviorTreeView(Nodes.BehaviorNode node)
165184
{
166185
foreach (BehaviorTreeViewDock dock in __instances)

tools/designer/BehaviacDesigner/CallStackDock.Designer.cs

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tools/designer/BehaviacDesigner/CallStackDock.cs

+24
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
using Behaviac.Design.Nodes;
2525
using Behaviac.Design.Properties;
2626

27+
2728
namespace Behaviac.Design
2829
{
2930
internal partial class CallStackDock : WeifenLuo.WinFormsUI.Docking.DockContent
@@ -122,14 +123,18 @@ private void UpdateStackCb(string tree, bool bAdd)
122123
}
123124
}
124125

126+
/*
125127
if (callstackListBox.Items.Count > 0)
126128
{
127129
//callstackListBox.SelectedIndex = -1;
130+
128131
callstackListBox.SelectedIndex = 0;
129132
133+
130134
string currentBt = (string)callstackListBox.Items[0];
131135
UIUtilities.ShowBehaviorTree(currentBt);
132136
}
137+
*/
133138
}
134139

135140
private void copyMenuItem_Click(object sender, EventArgs e)
@@ -184,5 +189,24 @@ private void logListBox_KeyDown(object sender, KeyEventArgs e)
184189
callstackListBox.EndUpdate();
185190
}
186191
}
192+
193+
private void logListBox_MouseDoubleClick(object sender, MouseEventArgs e)
194+
{
195+
if (callstackListBox.SelectedItem != null)
196+
{
197+
String behaviorFilename = callstackListBox.SelectedItem.ToString();
198+
BehaviorTreeView behaviorTreeView = UIUtilities.ShowBehaviorTree(behaviorFilename, true);
199+
if (behaviorTreeView != null)
200+
{
201+
BehaviorTreeViewDock dock = BehaviorTreeViewDock.GetBehaviorTreeViewDockByName(behaviorFilename);
202+
if (dock != null)
203+
{
204+
dock.Focus();
205+
dock.MakeFocused();
206+
}
207+
}
208+
}
209+
}
187210
}
188211
}
212+

tools/designer/BehaviacDesigner/MainWindow.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1129,8 +1129,11 @@ private BehaviorTreeViewDock behaviorTreeList_ShowBehavior(BehaviorNode node)
11291129

11301130
if (dock != null)
11311131
{
1132-
dock.Focus();
1133-
dock.MakeFocused();
1132+
if (Plugin.EditMode == EditModes.Design)
1133+
{
1134+
dock.Focus();
1135+
dock.MakeFocused();
1136+
}
11341137
}
11351138
}
11361139
catch (Exception ex)

tools/designer/BehaviacDesigner/TimelineDock.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ private void updateParameters(AgentType agentType, string agentName, int frame)
281281

282282
if (agentFullname == Plugin.DebugAgentInstance)
283283
{
284-
behavior = UIUtilities.ShowBehavior(behaviorFilename);
284+
behavior = UIUtilities.ShowBehavior(behaviorFilename, false);
285285
}
286286

287287
List<AgentDataPool.ValueMark> values = AgentDataPool.GetValidValues(agentType, agentFullname, frame);

tools/designer/BehaviacDesigner/UIUtilities.cs

+16-7
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ internal class UIUtilities
2828
/// Show the behavior tree view.
2929
/// </summary>
3030
/// <param name="behaviorFilename">The behavior filename in the workspace folder.</param>
31-
public static BehaviorNode ShowBehavior(string behaviorFilename)
31+
public static BehaviorNode ShowBehavior(string behaviorFilename, bool forceshowFlag = true)
3232
{
3333
if (string.IsNullOrEmpty(behaviorFilename))
3434
{
@@ -81,16 +81,19 @@ public static BehaviorNode ShowBehavior(string behaviorFilename)
8181

8282
if (behaviorTreeList != null)
8383
{
84-
behaviorTreeList.ShowNode(behavior as Node);
84+
if (forceshowFlag)
85+
{
86+
behaviorTreeList.ShowNode(behavior as Node);
87+
}
8588
}
8689
}
8790

8891
return behavior;
8992
}
9093

91-
public static BehaviorTreeView ShowBehaviorTree(string behaviorFilename)
94+
public static BehaviorTreeView ShowBehaviorTree(string behaviorFilename, bool forceshowFlag = true)
9295
{
93-
BehaviorNode behavior = ShowBehavior(behaviorFilename);
96+
BehaviorNode behavior = ShowBehavior(behaviorFilename, forceshowFlag);
9497
return BehaviorTreeViewDock.GetBehaviorTreeView(behavior);
9598
}
9699

@@ -105,7 +108,7 @@ public static BehaviorNode ShowBehaviorTree(string agentFullname, int frame, Lis
105108

106109
if (!string.IsNullOrEmpty(behaviorFilename))
107110
{
108-
BehaviorTreeView behaviorTreeView = ShowBehaviorTree(behaviorFilename);
111+
BehaviorTreeView behaviorTreeView = ShowBehaviorTree(behaviorFilename, false);
109112

110113
if (behaviorTreeView != null)
111114
{
@@ -114,8 +117,14 @@ public static BehaviorNode ShowBehaviorTree(string agentFullname, int frame, Lis
114117
profileInfos = null;
115118
}
116119

117-
behaviorTreeView.SetHighlights(highlightedTransitionIds, highlightNodeIds, updatedNodeIds, highlightBreakPoint, profileInfos);
118-
//behaviorTreeView.Focus();
120+
// check if there is a tab for the behaviour, add by j2 server start
121+
BehaviorTreeViewDock dock = BehaviorTreeViewDock.GetBehaviorTreeViewDockByName(behaviorFilename);
122+
if (dock != null && dock == BehaviorTreeViewDock.LastFocused)
123+
{
124+
behaviorTreeView.SetHighlights(highlightedTransitionIds, highlightNodeIds, updatedNodeIds, highlightBreakPoint, profileInfos);
125+
}
126+
127+
// behaviorTreeView.SetHighlights(highlightedTransitionIds, highlightNodeIds, updatedNodeIds, highlightBreakPoint, profileInfos);
119128

120129
return behaviorTreeView.RootNode;
121130
}

tools/designer/BehaviacDesignerBase/Utilities.cs

+55-8
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
using System.Management;
2323
using System.Threading;
2424
using System.Net.NetworkInformation;
25+
using System.Net.Sockets;
26+
using System.Security.Cryptography;
2527

2628
using Behaviac.Design.Properties;
2729

@@ -213,6 +215,7 @@ private static string GetHarddiskID()
213215

214216
private static string _gatwway = "";
215217
private static IPStatus _netWorkStatus = IPStatus.Unknown;
218+
private static UdpClient _udpClient = null;
216219
private static bool CheckNetWork()
217220
{
218221
try
@@ -277,7 +280,7 @@ private static bool ReportToTQOS(int intNum, string intList, int strNum, string
277280
qosData += strList;
278281
qosData += "]}}}]}}}";
279282

280-
using(var client = new WebClient())
283+
using (var client = new WebClient())
281284
{
282285
Uri uri = new Uri(qosData);
283286
client.OpenReadAsync(uri);
@@ -292,6 +295,44 @@ private static bool ReportToTQOS(int intNum, string intList, int strNum, string
292295
return true;
293296
}
294297

298+
private static string _userInfo = "";
299+
private static bool ReportToGStatistic(OperationData operation)
300+
{
301+
try
302+
{
303+
if (_udpClient == null)
304+
{
305+
_udpClient = new UdpClient();
306+
_udpClient.Connect("101.226.141.148", 8080);
307+
Thread.Sleep(2000);
308+
}
309+
310+
string qosDataStr = string.Format("cmd=0&tag=gcloud.behavic.times&event={0}&OperationNum={1}", operation.Type.ToString(), operation.Count);
311+
312+
if (string.IsNullOrEmpty(_userInfo))
313+
{
314+
HashAlgorithm algorithm = MD5.Create();
315+
String EncryptedUserName = BitConverter.ToString(algorithm.ComputeHash(Encoding.UTF8.GetBytes(Dns.GetHostName() + GetLocalMac())));
316+
317+
_userInfo = string.Format("&IP={0}&user_name={1}&version={2}",
318+
GetLocalIP(),
319+
EncryptedUserName,
320+
System.Reflection.Assembly.GetEntryAssembly().GetName().Version);
321+
}
322+
qosDataStr += _userInfo;
323+
324+
byte[] qosData = Encoding.UTF8.GetBytes(qosDataStr);
325+
_udpClient.Send(qosData, qosData.Length);
326+
}
327+
catch (Exception e)
328+
{
329+
Console.WriteLine(e.Message);
330+
return false;
331+
}
332+
333+
return true;
334+
}
335+
295336
[Serializable]
296337
enum OperationTypes
297338
{
@@ -425,13 +466,19 @@ private static bool SendOperations()
425466
{
426467
foreach (OperationData operation in _allOperations)
427468
{
428-
int intNum = 8;
429-
string intList = string.Format("0,0,0,0,0,0,{0},{1}", (int)operation.Type, operation.Count);
430-
431-
int strNum = 8;
432-
string strList = getHeaderString();
433-
434-
if (!ReportToTQOS(intNum, intList, strNum, strList))
469+
//int intNum = 8;
470+
//string intList = string.Format("0,0,0,0,0,0,{0},{1}", (int)operation.Type, operation.Count);
471+
472+
//int strNum = 8;
473+
//string strList = getHeaderString();
474+
475+
//if (!ReportToTQOS(intNum, intList, strNum, strList))
476+
//{
477+
// sendSuccess = false;
478+
// break;
479+
//}
480+
481+
if (!ReportToGStatistic(operation))
435482
{
436483
sendSuccess = false;
437484
break;

tools/designer/Plugins/PluginBehaviac/DataExporters/Cpp/DataCppExporter.cs

+4
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ public static string GetGeneratedDefaultValue(Type type, string typename, string
204204
{
205205
value = "NULL";
206206
}
207+
else if(typename.Equals("BTVector3f"))
208+
{
209+
value = "{0, 0, 0}";
210+
}
207211
else
208212
{
209213
value = null;

0 commit comments

Comments
 (0)