Jump to content
  • Advertisement

valenn

Member
  • Content Count

    7
  • Joined

  • Last visited

Community Reputation

0 Neutral

About valenn

  • Rank
    Newbie

Personal Information

  • Role
    Programmer
  • Interests
    Programming
  1. Yep, it works with latest version without any other changes! Thanks!
  2. I'll try with latest version and let you know. "s" in previous example is registered type, "getPosition()" returns vec3 by value and "capturePosition" is a member variable of script class. But that probably won't matter, because now I also reproduced it with: vec3 a = vec3(1.0, 1.0, 1.0); vec3 b = vec3(0.0, 0.0, 0.0); float l = length2(b - a); or float l = length2(vec3(1.0, 1.0, 1.0) - vec3(0.0, 0.0, 0.0));
  3. Null pointer is coming from asBC_COPY (as_context.cpp, in ExecuteNext()). Simply adding copy constructor as suggested by Solokiller solved the issue for me. (thanks!) r = engine->RegisterObjectBehaviour("vec3", asBEHAVE_CONSTRUCT, "void f(const vec3 &in)", asFUNCTION(vec3ConstructorCopy), asCALL_CDECL_OBJLAST); assert( r >= 0 ); void vec3ConstructorCopy(const Vec3Primitive &in, void *memory){ new(memory) Vec3Primitive(in); } Assignment works as expected (making a copy) even without registering copy constructor or assignment operator. If this is indeed bug, and not only missing copy constructor, let me know if I can help somehow Thank you also for other tips!
  4. I thought asOBJ_POD takes care or assignment and copies. Or doesn't it mix with asOBJ_APP_CLASS_CDAK? I'll definitely try adding copy constructor and assign op to see if it helps. Is there a reason why it would work when passing variable to lenght2, but not when passing opSub result directly? length vs length2 - I just me copied wrong line, but they are only differ in function body (sqrt)
  5. Best to describe with some code. This works: vec3 diff = s.getPosition() - capturePosition; float length = length2(diff); And this throws null pointer exception (Null pointer access): float length = length2(s.getPosition() - capturePosition); "vec3" is registered type with overloaded operator "-". Is there any reason why it shouldn't work without storing result in variable? vec3 is registered as (leaving out unrelated stuff) engine->RegisterObjectType("vec3", sizeof(Vec3Primitive), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS_CDAK); engine->RegisterObjectBehaviour("vec3", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(vec3Constructor), asCALL_CDECL_OBJLAST); engine->RegisterObjectBehaviour("vec3", asBEHAVE_CONSTRUCT, "void f(float,float,float)", asFUNCTION(vec3Constructor3), asCALL_CDECL_OBJLAST); engine->RegisterObjectBehaviour("vec3", asBEHAVE_DESTRUCT, "void f()", asFUNCTION(vec3Destructor), asCALL_CDECL_OBJLAST); engine->RegisterObjectMethod("vec3", "vec3 opSub(const vec3)", asMETHOD(Vec3Primitive,opSub), asCALL_THISCALL); engine->RegisterGlobalFunction("float length(const vec3)", asFUNCTION(Vec3Primitive::length), asCALL_CDECL); void vec3Constructor(void *memory){ new(memory) Vec3Primitive(); } void vec3Constructor3(float x, float y, float z, void *memory){ new(memory) Vec3Primitive(x, y, z); } void vec3Destructor(void *memory){ ((Vec3Primitive*)memory)->~Vec3Primitive(); } static float length2(const Vec3Primitive vec3){ return vec3.x * vec3.x + vec3.y * vec3.y + vec3.z * vec3.z; } Vec3Primitive opSub(const Vec3Primitive other){ return Vec3Primitive(x - other.x, y - other.y, z - other.z); } I'm using AngelScript version 2.31.1 I've registered this class some time ago and just now added operator overloading, which brought this error. Maybe I am doing something obviously wrong?
  6. valenn

    Floating point precision (CScriptBuilder?)

    I'm building for win32, and indeed it is changed somewhere in assembler. It changes in CallCDeclFunction in as_callfunc_x86. It happens in first block of assembler inside of #if defined ASM_INTEL. (when reading that assembler part, I vaguely remember seeing CLEAR_FPU_STACK mentioned somewhere before, quite possibly when I was changing that precision. Maybe that is somehow related? EDIT: now I see it is defined in AngelScript, so I probably just visited this part of code some time ago EDIT2: actually, I just checked my older version of AS and found "#define CLEAR_FPU_STACK emms" with commented out "#define CLEAR_FPU_STACK fninit" , which is what is used in newest version. After downloading older version, it seems that I must have changed it and memory of this is getting clearer too ) Call-stack looks like this, along with some argument values if that helps (some are omitted if I see nothing readable): CallCDeclFunction (paramSize = 8, func = StringFactory) CallSystemFunctionNative (descr.name = $str, obj = 0, sysFunc->hostReturnInMemory = false, retQW2 = 0, secondObj = 0) CallSystemFunction CContext::ExecuteNext CContext::Execute CModule::CallInit CModule::ResetGlobalVars CScriptBuilder::Build If there is anything else that could help, let me know
  7. Hi, I've just updated AngelScript in my project from some 2 year old version to newest. Calling CScriptBuilder::BuildModule() now changes floating point precision from one I set in my application. I set this with _controlfp_s to use lower precision. Is there any reason any part of AS or add-on should change it? Does AS require some FP precision to work correctly? Can I set it back to lower precision and not worry? Older version of AS worked with lower precision and didn't change it
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!