-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Instance drawing #14
base: master
Are you sure you want to change the base?
Changes from 17 commits
fefe3b0
eb051e1
0eaf212
2c8f513
829c8aa
aeb99ca
6f905fb
b64b2d7
30df4cb
9cf6c1d
c2fe9b2
6a80edd
410fcee
becea96
dead143
e03c9bb
007afe0
ec81927
4801011
784a86e
dd1de73
ee20683
8e3107c
fd7f955
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,5 @@ PublishProfiles | |
plugin | ||
package | ||
.DS_Store | ||
*.user | ||
*.user | ||
/XPNetPluginTestHost/xpnetcfg.json |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace XPNet | ||
{ | ||
public interface IXPlaneInstance | ||
mbrachner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
unsafe IXPInstance Create(IXPSceneryObject inSceneryObject, IEnumerable<string> inDataRefs); | ||
} | ||
|
||
internal class XPlaneInstance : IXPlaneInstance | ||
{ | ||
public IXPInstance Create(IXPSceneryObject inSceneryObject, IEnumerable<string> inDataRefs) | ||
{ | ||
return inSceneryObject.CreateInstance(inDataRefs); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jaurenq what do you think about this solution? Now we we can "redirect" users, who want to create the instance via the instance API, so they can use it in a similar way as they would have done it in the SDK, they can also instantiate directly from the XPSceneryObject via CreateInstance, and we do not need to expose the object reference, keeping it private in the XPSceneryObject. |
||
} | ||
} | ||
|
||
public interface IXPInstance : IDisposable | ||
{ | ||
void SetPosition(XPDrawInfo xPLMDrawInfo_t, float[] v); | ||
} | ||
|
||
internal unsafe class XPInstance : IXPInstance | ||
{ | ||
private readonly void* m_instanceRef; | ||
|
||
public XPInstance(void* instanceRef) | ||
{ | ||
m_instanceRef = instanceRef; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
PluginBridge.ApiFunctions.XPLMDestroyInstance(m_instanceRef); | ||
} | ||
|
||
public void SetPosition(XPDrawInfo xPLMDrawInfo_t, float[] v) | ||
{ | ||
var floatArray = v.ToArray(); | ||
fixed (float* p = &floatArray[0]) | ||
{ | ||
PluginBridge.ApiFunctions.XPLMInstanceSetPosition(m_instanceRef, xPLMDrawInfo_t, p); | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would prefer to have the test harness just store and provide data, without logging to the console. The data can then be verified/asserted/logged either over in the test plugin (C#) or in XPNetPluginTestHost.cpp. If you didn't notice, there were no log messages here in the harness prior to your push last month. One of the directions I want to move with XPNet is to turn the test host into an actual automated unit test suite, which would mean that the places where it currently says, "look for log message XYZ to see if the test succeeded" would turn into tests that are checked for pass/fail. In preparation for that, all of the test output was isolated to XPNetPluginTestHost.cpp, and the harness here just tried/tries to be a simple stand-in for X-Plane. It's OK to do testing by checking logging output currently (that's how the other tests work now as well), but the logging and checking should be done in the test plugin or the test host, not the test harness, to reduce the amount of rework we'll have to do to make those tests automated. (If you're not sure how to do what I'm talking about, or are unfamiliar with automated unit testing, let me know and we'll discuss).